Browse Source

Settings: Replace smaller/larger text with icons

In some languages the labels would overlap. Using icons solves this issue as only
the default font size is marked with the text.
Fixes #269
pull/284/head
weisj 3 years ago
parent
commit
c6a36374ab
No known key found for this signature in database
GPG Key ID: 31124CB75461DA2A
  1. 13
      core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettingsUI.java
  2. 2
      iconset/iconAccessorSpec.properties
  3. 16
      iconset/src/main/resources/com/github/weisj/darklaf/iconset/misc/decreaseFontSize.svg
  4. 16
      iconset/src/main/resources/com/github/weisj/darklaf/iconset/misc/increaseFontSize.svg

13
core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettingsUI.java

@ -48,6 +48,7 @@ import com.github.weisj.darklaf.components.tooltip.ToolTipContext;
import com.github.weisj.darklaf.components.tristate.TristateCheckBox;
import com.github.weisj.darklaf.components.tristate.TristateState;
import com.github.weisj.darklaf.graphics.ThemedColor;
import com.github.weisj.darklaf.iconset.AllIcons;
import com.github.weisj.darklaf.listener.UIUpdater;
import com.github.weisj.darklaf.platform.ThemePreferencesHandler;
import com.github.weisj.darklaf.platform.macos.theme.MacOSColors;
@ -338,9 +339,9 @@ public class ThemeSettingsUI {
Dictionary<Integer, JComponent> dict = fontSlider.createStandardLabels(tickSpacing);
JLabel min = (JLabel) dict.get(fontSlider.getMinimum());
UIUpdater.registerComponent(min);
DynamicUI.withDynamic(min,
c -> c.setText(UIManager.getString("settings.label_font_smaller", fontSlider.getLocale())));
min.setAlignmentX(JComponent.LEFT_ALIGNMENT);
min.setText("");
min.setIcon(AllIcons.Action.DecreaseFontSize.get());
min.setAlignmentX(JComponent.CENTER_ALIGNMENT);
min.putClientProperty(DarkSliderUI.KEY_MANUAL_LABEL_ALIGN, true);
JLabel mid = (JLabel) dict.get(fontSlider.getMinimum() + tickSpacing);
@ -355,9 +356,9 @@ public class ThemeSettingsUI {
JLabel max = (JLabel) dict.get(fontSlider.getMaximum());
max.putClientProperty(DarkSliderUI.KEY_MANUAL_LABEL_ALIGN, true);
DynamicUI.withDynamic(max,
c -> c.setText(UIManager.getString("settings.label_font_bigger", fontSlider.getLocale())));
max.setAlignmentX(JComponent.RIGHT_ALIGNMENT);
max.setText("");
max.setIcon(AllIcons.Action.IncreaseFontSize.get());
max.setAlignmentX(JComponent.CENTER_ALIGNMENT);
max.putClientProperty(DarkSliderUI.KEY_MANUAL_LABEL_ALIGN, true);
UIUpdater.registerComponent(max);

2
iconset/iconAccessorSpec.properties

@ -82,6 +82,8 @@ Action.Plus|disabled = misc/plusDisabled.svg
Action.Minus = misc/minus.svg
Action.Minus|selected = misc/minusSelected.svg
Action.Minus|disabled = misc/minusDisabled.svg
Action.IncreaseFontSize = misc/increaseFontSize.svg
Action.DecreaseFontSize = misc/decreaseFontSize.svg
Arrow.Thick.Down = navigation/arrow/thick/arrowDown.svg
Arrow.Thick.Down|disabled = navigation/arrow/thick/arrowDownDisabled.svg

16
iconset/src/main/resources/com/github/weisj/darklaf/iconset/misc/decreaseFontSize.svg

@ -0,0 +1,16 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 1000 1000">
<defs id="colors">
<linearGradient id="menuIconEnabled" fallback="Label.foreground">
<stop offset="0" stop-color="#AFB1B3"/>
<stop offset="1" stop-color="#AFB1B3"/>
</linearGradient>
</defs>
<g transform="translate(25 0)" fill="url(#menuIconEnabled)">
<path d="M233,574 l106,-343 l107,343 H233
M411,80 H267 L10,920 h120 L198,702 h286 L553,920 h119 L411,80"/>
<path d="M714,708 l66 -182 l56,182 H714
M822,438 H738 L658,665 l35,118 h164 l46,138 H973 L822,438"
transform="translate(-31)"/>
<path d="M590,200 l159,159 l159,-159 z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 749 B

16
iconset/src/main/resources/com/github/weisj/darklaf/iconset/misc/increaseFontSize.svg

@ -0,0 +1,16 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 1000 1000">
<defs id="colors">
<linearGradient id="menuIconEnabled" fallback="Label.foreground">
<stop offset="0" stop-color="#AFB1B3"/>
<stop offset="1" stop-color="#AFB1B3"/>
</linearGradient>
</defs>
<g transform="scale(-1, 1) translate(-1000 0) translate(25 0)" fill="url(#menuIconEnabled)">
<path d="M233,574 l106,-343 l107,343 H233
M411,80 H267 L10,920 h120 L198,702 h286 L553,920 h119 L411,80"/>
<path d="M714,708 l66 -182 l56,182 H714
M822,438 H738 L658,665 l35,118 h164 l46,138 H973 L822,438"
transform="translate(-31)"/>
<path d="M590,359 l159,-159 l159,159 z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 797 B

Loading…
Cancel
Save