From 818f651fe4b102369a0978f357bd8f2d69449846 Mon Sep 17 00:00:00 2001 From: weisj Date: Mon, 25 May 2020 22:02:49 +0200 Subject: [PATCH] Improved slider thumb shape. --- .../darklaf/task/ThemeDefaultsInitTask.java | 5 +- .../weisj/darklaf/ui/slider/DarkSliderUI.java | 252 +++++++++--------- .../weisj/darklaf/icons/control/slider.svg | 17 ++ .../darklaf/icons/control/sliderDisabled.svg | 17 ++ .../darklaf/icons/control/sliderFocused.svg | 23 ++ .../darklaf/icons/control/volumeSlider.svg | 17 ++ .../icons/control/volumeSliderDisabled.svg | 18 ++ .../icons/control/volumeSliderFocused.svg | 23 ++ .../properties/icons/slider.properties | 48 ++++ .../darklaf/properties/ui/slider.properties | 13 +- 10 files changed, 298 insertions(+), 135 deletions(-) create mode 100644 core/src/main/resources/com/github/weisj/darklaf/icons/control/slider.svg create mode 100644 core/src/main/resources/com/github/weisj/darklaf/icons/control/sliderDisabled.svg create mode 100644 core/src/main/resources/com/github/weisj/darklaf/icons/control/sliderFocused.svg create mode 100644 core/src/main/resources/com/github/weisj/darklaf/icons/control/volumeSlider.svg create mode 100644 core/src/main/resources/com/github/weisj/darklaf/icons/control/volumeSliderDisabled.svg create mode 100644 core/src/main/resources/com/github/weisj/darklaf/icons/control/volumeSliderFocused.svg create mode 100644 core/src/main/resources/com/github/weisj/darklaf/properties/icons/slider.properties diff --git a/core/src/main/java/com/github/weisj/darklaf/task/ThemeDefaultsInitTask.java b/core/src/main/java/com/github/weisj/darklaf/task/ThemeDefaultsInitTask.java index dd76d6e0..a5227033 100644 --- a/core/src/main/java/com/github/weisj/darklaf/task/ThemeDefaultsInitTask.java +++ b/core/src/main/java/com/github/weisj/darklaf/task/ThemeDefaultsInitTask.java @@ -24,7 +24,6 @@ */ package com.github.weisj.darklaf.task; -import java.awt.*; import java.util.HashMap; import java.util.Properties; @@ -49,8 +48,8 @@ public class ThemeDefaultsInitTask implements DefaultsInitTask { "slider", "spinner", "splitPane", "statusBar", "tabbedPane", "tabFrame", "table", "taskPane", "text", "toggleButton", "toolBar", "toolTip", "tree", "misc"}; - private static final String[] ICON_PROPERTIES = new String[]{"checkBox", "radioButton", "dialog", "files", "frame", - "indicator", "menu", "misc", "navigation"}; + private static final String[] ICON_PROPERTIES = new String[]{"checkBox", "radioButton", "slider", "dialog", "files", + "frame", "indicator", "menu", "misc", "navigation"}; private final DefaultsAdjustmentTask userPreferenceAdjustment = new UserDefaultsAdjustmentTask(); private final DefaultsAdjustmentTask accentColorAdjustment = new AccentColorAdjustmentTask(); private final DefaultsAdjustmentTask foregroundGeneration = new ForegroundColorGenerationTask(); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/slider/DarkSliderUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/slider/DarkSliderUI.java index e386ae64..f12479c8 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/slider/DarkSliderUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/slider/DarkSliderUI.java @@ -27,11 +27,11 @@ package com.github.weisj.darklaf.ui.slider; import java.awt.*; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; -import java.awt.geom.Path2D; import java.awt.geom.RoundRectangle2D; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.Dictionary; +import java.util.Enumeration; import javax.swing.*; import javax.swing.plaf.ComponentUI; @@ -40,7 +40,10 @@ import javax.swing.plaf.basic.BasicSliderUI; import com.github.weisj.darklaf.graphics.GraphicsContext; import com.github.weisj.darklaf.graphics.GraphicsUtil; import com.github.weisj.darklaf.graphics.PaintUtil; +import com.github.weisj.darklaf.icons.RotatableIcon; import com.github.weisj.darklaf.listener.MouseClickListener; +import com.github.weisj.darklaf.util.Alignment; +import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.PropertyKey; import com.github.weisj.darklaf.util.PropertyUtil; @@ -54,12 +57,9 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene public static final String KEY_SHOW_VOLUME_ICON = KEY_PREFIX + "volume.showIcon"; public static final String KEY_VARIANT = KEY_PREFIX + "variant"; public static final String KEY_INSTANT_SCROLL = KEY_PREFIX + "instantScrollEnabled"; - public static final String KEY_SHOW_FOCUS_GLOW = KEY_PREFIX + "paintFocusGlow"; public static final String KEY_MANUAL_LABEL_ALIGN = KEY_PREFIX + "manualLabelAlign"; public static final String VARIANT_VOLUME = "volume"; - private static final int ICON_BAR_EXT = 5; - private static final int ICON_PAD = 10; private final Rectangle iconRect = new Rectangle(0, 0, 0, 0); private final MouseListener mouseListener = new MouseClickListener() { private boolean muted = false; @@ -82,6 +82,7 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene protected int plainThumbRadius; protected int arcSize; protected int trackSize; + protected int iconPad; protected Dimension thumbSize; protected Color inactiveTickForeground; protected Color trackBackground; @@ -94,8 +95,19 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene protected Color volumeThumbBackground; protected Color volumeThumbInactiveBackground; protected Color thumbBorderColor; + protected Color thumbFocusBorderColor; protected Color thumbInactiveBorderColor; + protected RotatableIcon rotatableIcon; + + protected Icon thumb; + protected Icon thumbDisabled; + protected Icon thumbFocused; + + protected Icon volumeThumb; + protected Icon volumeThumbDisabled; + protected Icon volumeThumbFocused; + protected Icon volume0; protected Icon volume1; protected Icon volume2; @@ -108,6 +120,7 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene protected Icon volume4Inactive; protected int focusBorderSize; + protected boolean paintFocus; protected RoundRectangle2D trackShape = new RoundRectangle2D.Double(); public DarkSliderUI(final JSlider b) { @@ -119,7 +132,7 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene } private static boolean showVolumeIcon(final JComponent c) { - return isVolumeSlider(c) && PropertyUtil.getBooleanProperty(c, KEY_SHOW_VOLUME_ICON); + return PropertyUtil.getBooleanProperty(c, KEY_SHOW_VOLUME_ICON); } private static boolean isVolumeSlider(final JComponent c) { @@ -155,36 +168,44 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene } } + @Override + protected void calculateFocusRect() { + focusRect.setRect(0, 0, slider.getWidth(), slider.getHeight()); + DarkUIUtil.applyInsets(focusRect, focusInsets); + } + @Override protected void calculateContentRect() { - super.calculateContentRect(); + contentRect.setRect(focusRect); + boolean horizontal = slider.getOrientation() == JSlider.HORIZONTAL; if (showVolumeIcon(slider)) { - if (isHorizontal()) { - contentRect.width -= getVolumeIcon().getIconWidth() + ICON_PAD; + if (horizontal) { + contentRect.width -= getVolumeIcon().getIconWidth() + iconPad; if (!slider.getComponentOrientation().isLeftToRight()) { - contentRect.x += getVolumeIcon().getIconWidth() + ICON_PAD; + contentRect.x += getVolumeIcon().getIconWidth() + iconPad; } } else { - contentRect.height -= getVolumeIcon().getIconHeight() + ICON_PAD; + contentRect.height -= getVolumeIcon().getIconHeight() + iconPad; if (!slider.getComponentOrientation().isLeftToRight()) { - contentRect.y += getVolumeIcon().getIconHeight() + ICON_PAD; + contentRect.y += getVolumeIcon().getIconHeight() + iconPad; } } } - } - - @Override - protected void calculateTrackBuffer() { - super.calculateTrackBuffer(); - if (slider.getOrientation() == JSlider.HORIZONTAL) { - trackBuffer = 0; + if (horizontal) { + int thumbWidth = getThumbWidth(); + contentRect.x += thumbWidth / 2; + contentRect.width -= thumbWidth; + } else { + int thumbHeight = getThumbHeight(); + contentRect.y += thumbHeight / 2; + contentRect.height -= thumbHeight; } + adjustRect(contentRect); } @Override - protected void calculateTrackRect() { - super.calculateTrackRect(); - adjustRect(trackRect); + protected void calculateTrackBuffer() { + trackBuffer = 0; } @Override @@ -293,29 +314,13 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene protected void adjustRect(final Rectangle rectangle, final boolean outwards) { boolean horizontal = slider.getOrientation() == JSlider.HORIZONTAL; - - if (horizontal) { - boolean ltr = slider.getComponentOrientation().isLeftToRight(); - int left = ltr ? focusInsets.left : focusInsets.right; - int right = ltr ? focusInsets.right : focusInsets.left; - rectangle.x += left; - rectangle.width -= left + right; - } else { - rectangle.y += focusInsets.top; - rectangle.height -= focusInsets.top + focusInsets.bottom; - } - Dictionary dict = slider.getLabelTable(); if (!slider.getPaintLabels() || dict == null || dict.isEmpty() || !horizontal) { return; } - int extra = getLowerHorizontalExtend(); int extend = getUpperHorizontalExtend(); - int thumbWidth = getThumbWidth() / 2; int factor = outwards ? 1 : -1; - extra -= thumbWidth; - extend -= thumbWidth; rectangle.x -= factor * extra; rectangle.width += factor * (extra + extend); } @@ -327,7 +332,7 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene boolean adjustMin = PropertyUtil.getBooleanProperty(minLabel, KEY_MANUAL_LABEL_ALIGN); int minPrefWidth = minLabel.getPreferredSize().width; float adj = (adjustMin ? minLabel.getAlignmentX() : Component.CENTER_ALIGNMENT); - return (int) (minPrefWidth * adj) + (ltr ? focusInsets.left : focusInsets.right); + return (int) (minPrefWidth * adj); } protected int getUpperHorizontalExtend() { @@ -337,23 +342,35 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene boolean adjustMax = PropertyUtil.getBooleanProperty(maxLabel, KEY_MANUAL_LABEL_ALIGN); int maxPrefWidth = maxLabel.getPreferredSize().width; float adj = (adjustMax ? maxLabel.getAlignmentX() : Component.CENTER_ALIGNMENT); - return (int) (maxPrefWidth * (1f - adj)) + (ltr ? focusInsets.right : focusInsets.left); + return (int) (maxPrefWidth * (1f - adj)); } - @Override public Dimension getPreferredHorizontalSize() { Dimension dim = super.getPreferredHorizontalSize(); Rectangle rect = new Rectangle(0, 0, 0, 0); rect.setSize(dim); adjustRect(rect, true); + Dictionary dict = slider.getLabelTable(); + if (dict != null && !dict.isEmpty()) { + int totalLabelWidth = 0; + Enumeration labels = dict.elements(); + while (labels.hasMoreElements()) { + Object obj = labels.nextElement(); + if (obj instanceof Component) { + totalLabelWidth += ((Component) obj).getPreferredSize().width; + } + } + totalLabelWidth += getThumbWidth(); + rect.width = Math.max(rect.width, totalLabelWidth); + } return rect.getSize(); } @Override public Dimension getThumbSize() { if (isPlainThumb()) { - return new Dimension(plainThumbRadius + 2 * focusBorderSize, - plainThumbRadius + 2 * focusBorderSize); + int bw = 2 * getFocusBorderSize(); + return new Dimension(plainThumbRadius + bw, plainThumbRadius + bw); } return isHorizontal() ? new Dimension(thumbSize.width, thumbSize.height) @@ -455,15 +472,12 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene public void paintThumb(final Graphics g2) { Graphics2D g = (Graphics2D) g2; GraphicsContext context = GraphicsUtil.setupStrokePainting(g); - g.translate(thumbRect.x, thumbRect.y); if (isPlainThumb()) { paintPlainSliderThumb(g); } else { paintSliderThumb(g); } - - g.translate(-thumbRect.x, -thumbRect.y); context.restore(); } @@ -493,12 +507,6 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene return inactiveTickForeground; } - @Override - public void installUI(final JComponent c) { - super.installUI(c); - slider.putClientProperty(KEY_SHOW_FOCUS_GLOW, UIManager.getBoolean("Slider.paintFocusGlow")); - } - @Override protected void installDefaults(final JSlider slider) { super.installDefaults(slider); @@ -507,6 +515,7 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene trackSize = UIManager.getInt("Slider.trackThickness"); plainThumbRadius = UIManager.getInt("Slider.plainThumbRadius"); thumbSize = UIManager.getDimension("Slider.thumbSize"); + iconPad = UIManager.getInt("Slider.iconPad"); inactiveTickForeground = UIManager.getColor("Slider.disabledTickColor"); trackBackground = UIManager.getColor("Slider.trackBackground"); selectedTrackBackground = UIManager.getColor("Slider.selectedTrackColor"); @@ -518,8 +527,18 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene volumeThumbBackground = UIManager.getColor("Slider.volume.activeThumbFill"); volumeThumbInactiveBackground = UIManager.getColor("Slider.volume.inactiveThumbFill"); thumbBorderColor = UIManager.getColor("Slider.thumbBorderColor"); + thumbFocusBorderColor = UIManager.getColor("Slider.thumbFocusBorderColor"); thumbInactiveBorderColor = UIManager.getColor("Slider.thumbBorderColorDisabled"); focusBorderSize = UIManager.getInt("Slider.focusBorderSize"); + paintFocus = UIManager.getBoolean("Slider.paintFocusGlow"); + + thumb = UIManager.getIcon("Slider.enabledThumb.icon"); + thumbDisabled = UIManager.getIcon("Slider.disabledThumb.icon"); + thumbFocused = UIManager.getIcon("Slider.focusedThumb.icon"); + + volumeThumb = UIManager.getIcon("Slider.volume.enabledThumb.icon"); + volumeThumbDisabled = UIManager.getIcon("Slider.volume.disabledThumb.icon"); + volumeThumbFocused = UIManager.getIcon("Slider.volume.focusedThumb.icon"); volume0 = UIManager.getIcon("Slider.volume.enabled_level_0.icon"); volume1 = UIManager.getIcon("Slider.volume.enabled_level_1.icon"); @@ -531,26 +550,34 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene volume2Inactive = UIManager.getIcon("Slider.volume.disabled_level_2.icon"); volume3Inactive = UIManager.getIcon("Slider.volume.disabled_level_3.icon"); volume4Inactive = UIManager.getIcon("Slider.volume.disabled_level_4.icon"); + + rotatableIcon = new RotatableIcon(); + } + + public int getFocusBorderSize() { + return paintFocus ? focusBorderSize : 0; } protected void calculateIconRect() { iconRect.width = getVolumeIcon().getIconWidth(); iconRect.height = getVolumeIcon().getIconHeight(); if (isHorizontal()) { + int extraSpace = iconPad + getThumbWidth() / 2; if (slider.getComponentOrientation().isLeftToRight()) { - iconRect.x = trackRect.x + trackRect.width + ICON_PAD; + iconRect.x = trackRect.x + trackRect.width + extraSpace; iconRect.y = trackRect.y + (trackRect.height - iconRect.height) / 2; } else { - iconRect.x = trackRect.x - iconRect.width - ICON_PAD; + iconRect.x = trackRect.x - iconRect.width - extraSpace; iconRect.y = trackRect.y + (trackRect.height - iconRect.height) / 2; } } else { + int extraSpace = iconPad + getThumbHeight() / 2; if (slider.getComponentOrientation().isLeftToRight()) { iconRect.x = trackRect.x + (trackRect.width - iconRect.width) / 2; - iconRect.y = trackRect.y + trackRect.height + ICON_PAD; + iconRect.y = trackRect.y + trackRect.height + extraSpace; } else { iconRect.x = trackRect.x + (trackRect.width - iconRect.width) / 2; - iconRect.y = trackRect.y - iconRect.height - ICON_PAD; + iconRect.y = trackRect.y - iconRect.height - extraSpace; } } } @@ -591,11 +618,11 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene private Shape getHorizontalTrackShape(final RoundRectangle2D trackShape) { int arc = arcSize; int yOff = (trackRect.height / 2) - trackSize / 2; - int w = showVolumeIcon(slider) ? trackRect.width + getIconBarExt() : trackRect.width; + int w = trackRect.width; if (slider.getComponentOrientation().isLeftToRight()) { trackShape.setRoundRect(trackRect.x, trackRect.y + yOff, w, trackSize, arc, arc); } else { - trackShape.setRoundRect(trackRect.x - getIconBarExt(), trackRect.y + yOff, w, trackSize, arc, arc); + trackShape.setRoundRect(trackRect.x, trackRect.y + yOff, w, trackSize, arc, arc); } return trackShape; } @@ -612,22 +639,19 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene private Shape getVerticalTrackShape(final RoundRectangle2D trackShape) { int arc = arcSize; int xOff = (trackRect.width / 2) - trackSize / 2; - int h = showVolumeIcon(slider) ? trackRect.height + getIconBarExt() : trackRect.height; + int h = trackRect.height; if (slider.getComponentOrientation().isLeftToRight()) { trackShape.setRoundRect(trackRect.x + xOff, trackRect.y, trackSize, h, arc, arc); } else { - trackShape.setRoundRect(trackRect.x + xOff, trackRect.y - getIconBarExt(), trackSize, h, arc, arc); + trackShape.setRoundRect(trackRect.x + xOff, trackRect.y, trackSize, h, arc, arc); } return trackShape; } - private int getIconBarExt() { - return isPlainThumb() && showVolumeIcon(slider) ? ICON_BAR_EXT : 0; - } - private void paintPlainSliderThumb(final Graphics2D g) { + g.translate(thumbRect.x, thumbRect.y); int r = plainThumbRadius; - int bw = focusBorderSize; + int bw = getFocusBorderSize(); g.setColor(getThumbColor()); PaintUtil.fillRoundRect(g, bw, bw, r, r, r); if (!isVolumeSlider(slider)) { @@ -637,30 +661,50 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene if (paintFocus()) { PaintUtil.paintFocusBorder(g, r + 2 * bw, r + 2 * bw, r + 2 * bw, bw); } + g.translate(-thumbRect.x, -thumbRect.y); } protected boolean isPlainThumb() { return !slider.getPaintTicks() || !PropertyUtil.getBooleanProperty(slider, KEY_THUMB_ARROW_SHAPE, true); } + protected Icon getThumbIcon() { + boolean enabled = slider.isEnabled(); + boolean focused = slider.hasFocus(); + boolean volume = isVolumeSlider(slider); + Icon icon; + if (volume) { + icon = enabled ? focused ? volumeThumbFocused : volumeThumb : volumeThumbDisabled; + } else { + icon = enabled ? focused ? thumbFocused : thumb : thumbDisabled; + } + rotatableIcon.setIcon(icon); + if (isHorizontal()) { + rotatableIcon.setOrientation(Alignment.NORTH); + } else { + if (slider.getComponentOrientation().isLeftToRight()) { + rotatableIcon.setOrientation(Alignment.WEST); + } else { + rotatableIcon.setOrientation(Alignment.EAST); + } + } + return rotatableIcon; + } + private void paintSliderThumb(final Graphics2D g) { - Path2D thumb = getThumbShape(); - if (paintFocus()) { - GraphicsContext config = new GraphicsContext(g); - g.setComposite(PaintUtil.getGlowComposite()); - g.setStroke(new BasicStroke(4f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 8)); - PaintUtil.Outline.focus.setGraphicsColor(g, true); - g.draw(thumb); - config.restore(); + if (isHorizontal()) { + getThumbIcon().paintIcon(slider, g, thumbRect.x, thumbRect.y); + } else { + int cx = thumbRect.x + thumbRect.width / 2; + int cy = thumbRect.y + thumbRect.height / 2; + int x = cx - thumbRect.height / 2; + int y = cy - thumbRect.width / 2; + getThumbIcon().paintIcon(slider, g, x, y); } - g.setColor(getThumbColor()); - g.fill(thumb); - g.setColor(getThumbBorderColor()); - g.draw(thumb); } private boolean paintFocus() { - return slider.hasFocus() && PropertyUtil.getBooleanProperty(slider, KEY_SHOW_FOCUS_GLOW); + return slider.hasFocus() && paintFocus; } protected int getThumbWidth() { @@ -671,58 +715,6 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene return thumbRect.height; } - private Path2D getThumbShape() { - if (isHorizontal()) { - return getHorizontalThumbShape(); - } else if (slider.getComponentOrientation().isLeftToRight()) { - return getVerticalThumbShapeLR(); - } else { - return getVerticalThumbShapeRL(); - } - } - - private Path2D getHorizontalThumbShape() { - int w = thumbRect.width; - int h = thumbRect.height; - int cw = w / 2; - Path2D shape = new Path2D.Float(Path2D.WIND_EVEN_ODD); - shape.moveTo(1, 1); - shape.lineTo(w - 2, 1); - shape.lineTo(w - 2, h - cw - 1); - shape.lineTo(cw, h - 2); - shape.lineTo(1, h - cw - 1); - shape.closePath(); - return shape; - } - - private Path2D getVerticalThumbShapeLR() { - int w = thumbRect.width; - int h = thumbRect.height; - int cw = h / 2; - Path2D shape = new Path2D.Float(Path2D.WIND_EVEN_ODD); - shape.moveTo(2, 1); - shape.lineTo(w - cw - 1, 1); - shape.lineTo(w - 1, h - cw); - shape.lineTo(w - cw - 1, h - 2); - shape.lineTo(2, h - 2); - shape.closePath(); - return shape; - } - - private Path2D getVerticalThumbShapeRL() { - int w = thumbRect.width; - int h = thumbRect.height; - int cw = h / 2; - Path2D shape = new Path2D.Float(Path2D.WIND_EVEN_ODD); - shape.moveTo(w - 2, 1); - shape.lineTo(cw + 1, 1); - shape.lineTo(1, h - cw); - shape.lineTo(cw + 1, h - 2); - shape.lineTo(w - 2, h - 2); - shape.closePath(); - return shape; - } - protected Color getThumbColor() { if (isVolumeSlider(slider)) { return slider.isEnabled() ? volumeThumbBackground : volumeThumbInactiveBackground; @@ -732,7 +724,7 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene } protected Color getThumbBorderColor() { - return slider.isEnabled() ? thumbBorderColor : thumbInactiveBorderColor; + return slider.isEnabled() ? paintFocus() ? thumbFocusBorderColor : thumbBorderColor : thumbInactiveBorderColor; } protected Color getTrackBackground() { diff --git a/core/src/main/resources/com/github/weisj/darklaf/icons/control/slider.svg b/core/src/main/resources/com/github/weisj/darklaf/icons/control/slider.svg new file mode 100644 index 00000000..1a7ee942 --- /dev/null +++ b/core/src/main/resources/com/github/weisj/darklaf/icons/control/slider.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + diff --git a/core/src/main/resources/com/github/weisj/darklaf/icons/control/sliderDisabled.svg b/core/src/main/resources/com/github/weisj/darklaf/icons/control/sliderDisabled.svg new file mode 100644 index 00000000..97744ecf --- /dev/null +++ b/core/src/main/resources/com/github/weisj/darklaf/icons/control/sliderDisabled.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + diff --git a/core/src/main/resources/com/github/weisj/darklaf/icons/control/sliderFocused.svg b/core/src/main/resources/com/github/weisj/darklaf/icons/control/sliderFocused.svg new file mode 100644 index 00000000..590b2a73 --- /dev/null +++ b/core/src/main/resources/com/github/weisj/darklaf/icons/control/sliderFocused.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/core/src/main/resources/com/github/weisj/darklaf/icons/control/volumeSlider.svg b/core/src/main/resources/com/github/weisj/darklaf/icons/control/volumeSlider.svg new file mode 100644 index 00000000..edc75350 --- /dev/null +++ b/core/src/main/resources/com/github/weisj/darklaf/icons/control/volumeSlider.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + diff --git a/core/src/main/resources/com/github/weisj/darklaf/icons/control/volumeSliderDisabled.svg b/core/src/main/resources/com/github/weisj/darklaf/icons/control/volumeSliderDisabled.svg new file mode 100644 index 00000000..2aaea7b2 --- /dev/null +++ b/core/src/main/resources/com/github/weisj/darklaf/icons/control/volumeSliderDisabled.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + diff --git a/core/src/main/resources/com/github/weisj/darklaf/icons/control/volumeSliderFocused.svg b/core/src/main/resources/com/github/weisj/darklaf/icons/control/volumeSliderFocused.svg new file mode 100644 index 00000000..9ffc8705 --- /dev/null +++ b/core/src/main/resources/com/github/weisj/darklaf/icons/control/volumeSliderFocused.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/icons/slider.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/icons/slider.properties new file mode 100644 index 00000000..6016bcac --- /dev/null +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/icons/slider.properties @@ -0,0 +1,48 @@ +# +# MIT License +# +# Copyright (c) 2020 Jannis Weis +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# +# suppress inspection "UnusedProperty" for whole file +# +Icons.Slider.activeFillColor = %Slider.activeThumbFill +Icons.Slider.borderColor = %Slider.thumbBorderColor + +Icons.SliderDisabled.inactiveFillColor = %Slider.inactiveThumbFill +Icons.SliderDisabled.inactiveBorderColor = %Slider.thumbBorderColorDisabled + +Icons.SliderFocused.activeFillColor = %Slider.activeThumbFill +Icons.SliderFocused.focusBorderColor = %Slider.thumbFocusBorderColor +Icons.SliderFocused.glowFocus = %glowFocus +Icons.SliderFocused.glowOpacity = %glowOpacity + +Icons.VolumeSlider.activeFillColor = %Slider.volume.activeThumbFill +Icons.VolumeSlider.borderColor = %Slider.thumbBorderColor + +Icons.VolumeSliderDisabled.inactiveFillColor = %Slider.volume.inactiveThumbFill +Icons.VolumeSliderDisabled.inactiveBorderColor = %Slider.thumbBorderColorDisabled + +Icons.VolumeSliderFocused.activeFillColor = %Slider.volume.activeThumbFill +Icons.VolumeSliderFocused.focusBorderColor = %Slider.thumbFocusBorderColor +Icons.VolumeSliderFocused.glowFocus = %glowFocus +Icons.VolumeSliderFocused.glowOpacity = %glowOpacity + diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/slider.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/slider.properties index b8e6e6c1..496733f6 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/slider.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/slider.properties @@ -31,6 +31,7 @@ Slider.selectedTrackColor = %controlFillSecondary Slider.disabledTrackColor = %controlFillDisabled Slider.trackBackground = %controlBackground Slider.thumbBorderColor = %controlBorder +Slider.thumbFocusBorderColor = %controlBorderFocus Slider.thumbBorderColorDisabled = %controlBorderDisabled Slider.inactiveThumbFill = %controlFillDisabled Slider.activeThumbFill = %widgetFill @@ -44,8 +45,9 @@ Slider.focusBorderSize = 2 Slider.arc = 4 Slider.trackThickness = 4 Slider.plainThumbRadius = 12 -Slider.thumbSize = 10,18 -Slider.focusInsets = 4,4,4,4 +Slider.thumbSize = 20,23 +Slider.focusInsets = 1,1,1,1 +Slider.iconPad = 2 Slider.horizontalSize = 200,21 Slider.verticalSize = 21,200 @@ -55,6 +57,13 @@ Slider.minimumVerticalSize = 21,36 #Icons Slider.horizontalThumbIcon = empty(0,0) Slider.verticalThumbIcon = empty(0,0) +Slider.enabledThumb.icon = control/slider.svg[themed](20,23) +Slider.disabledThumb.icon = control/sliderDisabled.svg[themed](20,23) +Slider.focusedThumb.icon = control/sliderFocused.svg[themed](20,23) +Slider.volume.enabledThumb.icon = control/volumeSlider.svg[themed](20,23) +Slider.volume.disabledThumb.icon = control/volumeSliderDisabled.svg[themed](20,23) +Slider.volume.focusedThumb.icon = control/volumeSliderFocused.svg[themed](20,23) + Slider.volume.enabled_level_0.icon = indicator/speaker_0.svg[themed] Slider.volume.enabled_level_1.icon = indicator/speaker_1.svg[themed] Slider.volume.enabled_level_2.icon = indicator/speaker_2.svg[themed]