Browse Source

Made selection macOS selection colors available on all platforms.

pull/188/head
weisj 5 years ago
parent
commit
7689be591a
  1. 1
      .gitignore
  2. 70
      core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettingsPanel.java
  3. 4
      core/src/main/resources/com/github/weisj/darklaf/bundles/theme_settings.properties
  4. 4
      core/src/main/resources/com/github/weisj/darklaf/bundles/theme_settings_de.properties
  5. 4
      core/src/main/resources/com/github/weisj/darklaf/bundles/theme_settings_en_GB.properties
  6. 4
      core/src/main/resources/com/github/weisj/darklaf/bundles/theme_settings_en_US.properties
  7. 4
      core/src/main/resources/com/github/weisj/darklaf/bundles/theme_settings_es.properties
  8. 4
      core/src/main/resources/com/github/weisj/darklaf/bundles/theme_settings_fr.properties
  9. 4
      core/src/main/resources/com/github/weisj/darklaf/bundles/theme_settings_ru.properties
  10. 16
      macos/src/main/java/com/github/weisj/darklaf/platform/macos/JNIThemeInfoMacOS.java
  11. 35
      macos/src/main/java/com/github/weisj/darklaf/platform/macos/theme/MacOSColors.java
  12. 2
      macos/src/main/objcpp/ThemeInfo.mm

1
.gitignore vendored

@ -55,6 +55,7 @@ Thumbs.db
/*/bin/ /*/bin/
*.dylib *.dylib
*.dll *.dll
/scratch/
# Eclipse # Eclipse
.classpath .classpath

70
core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettingsPanel.java

@ -236,44 +236,60 @@ public class ThemeSettingsPanel extends JPanel {
Color currentAccentColor = LafManager.getTheme().getAccentColorRule().getAccentColor(); Color currentAccentColor = LafManager.getTheme().getAccentColorRule().getAccentColor();
Color currentSelectionColor = LafManager.getTheme().getAccentColorRule().getSelectionColor(); Color currentSelectionColor = LafManager.getTheme().getAccentColorRule().getSelectionColor();
JComponent selectionBox = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
JLabel selectionColorLabel = new JLabel(resourceBundle.getString("label_selection_color"));
selectionColorLabel.setLabelFor(selectionBox);
bgSelection = new ButtonGroup();
defaultSelectionColor = createDefaultColor("textCompSelectionBackground");
defaultSelection = addColoredButton(bgSelection, selectionBox, defaultSelectionColor,
resourceBundle.getString("color_default"));
AbstractButton selectionBlue = addColoredButton(bgSelection, selectionBox, MacOSColors.SELECTION_BLUE,
resourceBundle.getString("color_blue"));
AbstractButton selectionPurple = addColoredButton(bgSelection, selectionBox, MacOSColors.SELECTION_PURPLE,
resourceBundle.getString("color_purple"));
AbstractButton selectionPink = addColoredButton(bgSelection, selectionBox, MacOSColors.SELECTION_PINK,
resourceBundle.getString("color_pink"));
AbstractButton selectionRed = addColoredButton(bgSelection, selectionBox, MacOSColors.SELECTION_RED,
resourceBundle.getString("color_red"));
AbstractButton selectionOrange = addColoredButton(bgSelection, selectionBox, MacOSColors.SELECTION_ORANGE,
resourceBundle.getString("color_orange"));
AbstractButton selectionYellow = addColoredButton(bgSelection, selectionBox, MacOSColors.SELECTION_YELLOW,
resourceBundle.getString("color_yellow"));
AbstractButton selectionGreen = addColoredButton(bgSelection, selectionBox, MacOSColors.SELECTION_GREEN,
resourceBundle.getString("color_green"));
AbstractButton selectionGraphite = addColoredButton(bgSelection, selectionBox, MacOSColors.SELECTION_GRAPHITE,
resourceBundle.getString("color_gray"));
customSelection = addCustomButton(bgSelection, selectionBox, currentSelectionColor, defaultSelectionColor,
resourceBundle.getString("color_custom"));
JComponent accentBox = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); JComponent accentBox = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
JLabel accentColorLabel = new JLabel(resourceBundle.getString("label_accent_color")); JLabel accentColorLabel = new JLabel(resourceBundle.getString("label_accent_color"));
accentColorLabel.setLabelFor(accentBox); accentColorLabel.setLabelFor(accentBox);
defaultAccentColor = createDefaultColor("widgetFillDefault"); defaultAccentColor = createDefaultColor("widgetFillDefault");
bgAccent = new ButtonGroup(); bgAccent = new ButtonGroup();
defaultAccent = addColoredButton(bgAccent, accentBox, ColoredRadioButton.DEFAULT_FILLED, defaultAccent = addColoredButton(bgAccent, accentBox, ColoredRadioButton.DEFAULT_FILLED, defaultSelection,
resourceBundle.getString("color_default")); resourceBundle.getString("color_default"));
addColoredButton(bgAccent, accentBox, MacOSColors.BLUE, addColoredButton(bgAccent, accentBox, MacOSColors.ACCENT_BLUE, selectionBlue,
resourceBundle.getString("color_Blue")); resourceBundle.getString("color_blue"));
addColoredButton(bgAccent, accentBox, MacOSColors.LILAC, addColoredButton(bgAccent, accentBox, MacOSColors.ACCENT_LILAC, selectionPurple,
resourceBundle.getString("color_lilac")); resourceBundle.getString("color_lilac"));
addColoredButton(bgAccent, accentBox, MacOSColors.ROSE, addColoredButton(bgAccent, accentBox, MacOSColors.ACCENT_ROSE, selectionPink,
resourceBundle.getString("color_rose")); resourceBundle.getString("color_rose"));
addColoredButton(bgAccent, accentBox, MacOSColors.RED, addColoredButton(bgAccent, accentBox, MacOSColors.ACCENT_RED, selectionRed,
resourceBundle.getString("color_red")); resourceBundle.getString("color_red"));
addColoredButton(bgAccent, accentBox, MacOSColors.ORANGE, addColoredButton(bgAccent, accentBox, MacOSColors.ACCENT_ORANGE, selectionOrange,
resourceBundle.getString("color_orange")); resourceBundle.getString("color_orange"));
addColoredButton(bgAccent, accentBox, MacOSColors.YELLOW, addColoredButton(bgAccent, accentBox, MacOSColors.ACCENT_YELLOW, selectionYellow,
resourceBundle.getString("color_yellow")); resourceBundle.getString("color_yellow"));
addColoredButton(bgAccent, accentBox, MacOSColors.GREEN, addColoredButton(bgAccent, accentBox, MacOSColors.ACCENT_GREEN, selectionGreen,
resourceBundle.getString("color_green")); resourceBundle.getString("color_green"));
addColoredButton(bgAccent, accentBox, MacOSColors.GRAY, addColoredButton(bgAccent, accentBox, MacOSColors.ACCENT_GRAPHITE, selectionGraphite,
resourceBundle.getString("color_gray")); resourceBundle.getString("color_gray"));
customAccent = addCustomButton(bgAccent, accentBox, currentAccentColor, defaultAccentColor, customAccent = addCustomButton(bgAccent, accentBox, currentAccentColor, defaultAccentColor,
resourceBundle.getString("color_custom")); resourceBundle.getString("color_custom"));
JComponent selectionBox = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
JLabel selectionColorLabel = new JLabel(resourceBundle.getString("label_selection_color"));
selectionColorLabel.setLabelFor(selectionBox);
bgSelection = new ButtonGroup();
defaultSelectionColor = createDefaultColor("textCompSelectionBackground");
defaultSelection = addColoredButton(bgSelection, selectionBox, defaultSelectionColor,
resourceBundle.getString("color_default"));
customSelection = addCustomButton(bgSelection, selectionBox, currentSelectionColor, defaultSelectionColor,
resourceBundle.getString("color_custom"));
fontSlider = createFontSlider(); fontSlider = createFontSlider();
JLabel fontSizeLabel = new JLabel(resourceBundle.getString("label_font_size")); JLabel fontSizeLabel = new JLabel(resourceBundle.getString("label_font_size"));
fontSizeLabel.setLabelFor(fontSlider); fontSizeLabel.setLabelFor(fontSlider);
@ -661,6 +677,18 @@ public class ThemeSettingsPanel extends JPanel {
return button; return button;
} }
public ColoredRadioButton addColoredButton(final ButtonGroup bg, final JComponent parent,
final Color color, final AbstractButton peer,
final String tipText) {
ColoredRadioButton button = addColoredButton(new ColoredRadioButton(null, color), bg, parent, tipText);
button.addActionListener(e -> {
if (button.isSelected()) {
peer.setSelected(true);
}
});
return button;
}
public ColoredRadioButton addColoredButton(final ButtonGroup bg, final JComponent parent, public ColoredRadioButton addColoredButton(final ButtonGroup bg, final JComponent parent,
final Color color, final String tipText) { final Color color, final String tipText) {
return addColoredButton(new ColoredRadioButton(null, color), bg, parent, tipText); return addColoredButton(new ColoredRadioButton(null, color), bg, parent, tipText);

4
core/src/main/resources/com/github/weisj/darklaf/bundles/theme_settings.properties

@ -26,7 +26,7 @@
# #
title = Theme Settings title = Theme Settings
color_default = Default color_default = Default
color_Blue = Blue color_blue = Blue
color_lilac = Lilac color_lilac = Lilac
color_rose = Rose color_rose = Rose
color_red = Red color_red = Red
@ -35,6 +35,8 @@ color_yellow = Yellow
color_green = Green color_green = Green
color_gray = Graphite color_gray = Graphite
color_custom = Custom color_custom = Custom
color_purple = Purple
color_pink = Pink
label_theme = Theme: label_theme = Theme:

4
core/src/main/resources/com/github/weisj/darklaf/bundles/theme_settings_de.properties

@ -26,7 +26,7 @@
# #
title = Thema Einstellungen title = Thema Einstellungen
color_default = Standard color_default = Standard
color_Blue = Blau color_blue = Blau
color_lilac = Lila color_lilac = Lila
color_rose = Rosa color_rose = Rosa
color_red = Rot color_red = Rot
@ -35,6 +35,8 @@ color_yellow = Gelb
color_green = Grün color_green = Grün
color_gray = Graphit color_gray = Graphit
color_custom = Benutzerdefiniert color_custom = Benutzerdefiniert
color_purple = Lila
color_pink = Pink
label_theme = Thema: label_theme = Thema:

4
core/src/main/resources/com/github/weisj/darklaf/bundles/theme_settings_en_GB.properties

@ -26,7 +26,7 @@
# #
title = Theme Settings title = Theme Settings
color_default = Default color_default = Default
color_Blue = Blue color_blue = Blue
color_lilac = Lilac color_lilac = Lilac
color_rose = Rose color_rose = Rose
color_red = Red color_red = Red
@ -35,6 +35,8 @@ color_yellow = Yellow
color_green = Green color_green = Green
color_gray = Graphite color_gray = Graphite
color_custom = Custom color_custom = Custom
color_purple = Purple
color_pink = Pink
label_theme = Theme: label_theme = Theme:

4
core/src/main/resources/com/github/weisj/darklaf/bundles/theme_settings_en_US.properties

@ -26,7 +26,7 @@
# #
title = Theme Settings title = Theme Settings
color_default = Default color_default = Default
color_Blue = Blue color_blue = Blue
color_lilac = Lilac color_lilac = Lilac
color_rose = Rose color_rose = Rose
color_red = Red color_red = Red
@ -35,6 +35,8 @@ color_yellow = Yellow
color_green = Green color_green = Green
color_gray = Graphite color_gray = Graphite
color_custom = Custom color_custom = Custom
color_purple = Purple
color_pink = Pink
label_theme = Theme: label_theme = Theme:

4
core/src/main/resources/com/github/weisj/darklaf/bundles/theme_settings_es.properties

@ -26,7 +26,7 @@
# #
title = Configuración de Temas title = Configuración de Temas
color_default = Defecto color_default = Defecto
color_Blue = Azul color_blue = Azul
color_lilac = Lila color_lilac = Lila
color_rose = Rosa color_rose = Rosa
color_red = Rojo color_red = Rojo
@ -35,6 +35,8 @@ color_yellow = Amarillo
color_green = Verde color_green = Verde
color_gray = Grafito color_gray = Grafito
color_custom = Personalizado color_custom = Personalizado
color_purple = Lila
color_pink = Rosa
label_theme = Tema: label_theme = Tema:

4
core/src/main/resources/com/github/weisj/darklaf/bundles/theme_settings_fr.properties

@ -26,7 +26,7 @@
# #
title = Réglage des Thèmes title = Réglage des Thèmes
color_default = Défaut color_default = Défaut
color_Blue = Bleu color_blue = Bleu
color_lilac = Lilas color_lilac = Lilas
color_rose = Rose color_rose = Rose
color_red = Rouge color_red = Rouge
@ -35,6 +35,8 @@ color_yellow = Jaune
color_green = Vert color_green = Vert
color_gray = Graphite color_gray = Graphite
color_custom = Personnalisé color_custom = Personnalisé
color_purple = Lilas
color_pink = Rose
label_theme = Thème: label_theme = Thème:

4
core/src/main/resources/com/github/weisj/darklaf/bundles/theme_settings_ru.properties

@ -26,7 +26,7 @@
# #
title = Настройки Темы title = Настройки Темы
color_default = По умолчанию color_default = По умолчанию
color_Blue = Синий color_blue = Синий
color_lilac = Сирень color_lilac = Сирень
color_rose = Розовый color_rose = Розовый
color_red = Красный color_red = Красный
@ -35,6 +35,8 @@ color_yellow = Жёлтый
color_green = Зелёный color_green = Зелёный
color_gray = Графит color_gray = Графит
color_custom = Другой color_custom = Другой
color_purple = Сирень
color_pink = Розовый
label_theme = Тема: label_theme = Тема:

16
macos/src/main/java/com/github/weisj/darklaf/platform/macos/JNIThemeInfoMacOS.java

@ -58,21 +58,21 @@ public class JNIThemeInfoMacOS {
int index = nativeGetAccentColor(); int index = nativeGetAccentColor();
switch (index) { switch (index) {
case -2 : case -2 :
return MacOSColors.BLUE; return MacOSColors.ACCENT_BLUE;
case -1 : case -1 :
return MacOSColors.GRAY; return MacOSColors.ACCENT_GRAPHITE;
case 0 : case 0 :
return MacOSColors.RED; return MacOSColors.ACCENT_RED;
case 1 : case 1 :
return MacOSColors.ORANGE; return MacOSColors.ACCENT_ORANGE;
case 2 : case 2 :
return MacOSColors.YELLOW; return MacOSColors.ACCENT_YELLOW;
case 3 : case 3 :
return MacOSColors.GREEN; return MacOSColors.ACCENT_GREEN;
case 5 : case 5 :
return MacOSColors.LILAC; return MacOSColors.ACCENT_LILAC;
case 6 : case 6 :
return MacOSColors.ROSE; return MacOSColors.ACCENT_ROSE;
default : default :
return null; return null;
} }

35
macos/src/main/java/com/github/weisj/darklaf/platform/macos/theme/MacOSColors.java

@ -29,19 +29,36 @@ import java.awt.*;
public class MacOSColors { public class MacOSColors {
// 0.000000 0.478431 1.000000 // 0.000000 0.478431 1.000000
public static final Color BLUE = new Color(0, 122, 255); public static final Color ACCENT_BLUE = new Color(0.000000f, 0.478431f, 1.000000f);
// 0.584314 0.239216 0.588235 // 0.584314 0.239216 0.588235
public static final Color LILAC = new Color(149, 61, 149); public static final Color ACCENT_LILAC = new Color(0.584314f, 0.239216f, 0.588235f);
// 0.968627 0.309804 0.619608 // 0.968627 0.309804 0.619608
public static final Color ROSE = new Color(247, 79, 158); public static final Color ACCENT_ROSE = new Color(0.968627f, 0.309804f, 0.619608f);
// 0.878431 0.219608 0.243137 // 0.878431 0.219608 0.243137
public static final Color RED = new Color(224, 56, 62); public static final Color ACCENT_RED = new Color(0.878431f, 0.219608f, 0.243137f);
// 0.968627 0.509804 0.105882 // 0.968627 0.509804 0.105882
public static final Color ORANGE = new Color(247, 130, 27); public static final Color ACCENT_ORANGE = new Color(0.968627f, 0.509804f, 0.105882f);
// 0.988235 0.721569 0.152941 // 0.988235 0.721569 0.152941
public static final Color YELLOW = new Color(252, 184, 39); public static final Color ACCENT_YELLOW = new Color(0.988235f, 0.721569f, 0.152941f);
// 0.384314 0.729412 0.27451 // 0.384314 0.729412 0.274510
public static final Color GREEN = new Color(98, 186, 70); public static final Color ACCENT_GREEN = new Color(0.384314f, 0.729412f, 0.274510f);
// 0.596078 0.596078 0.596078 // 0.596078 0.596078 0.596078
public static final Color GRAY = new Color(152, 152, 152); public static final Color ACCENT_GRAPHITE = new Color(0.596078f, 0.596078f, 0.596078f);
// 0.701961 0.843137 1.000000
public static final Color SELECTION_BLUE = new Color(0.701961f, 0.843137f, 1.000000f);
// 0.874510 0.772549 0.874510
public static final Color SELECTION_PURPLE = new Color(0.874510f, 0.772549f, 0.874510f);
// 0.988235 0.792157 0.886275
public static final Color SELECTION_PINK = new Color(0.988235f, 0.792157f, 0.886275f);
// 0.960784 0.764706 0.772549
public static final Color SELECTION_RED = new Color(0.960784f, 0.764706f, 0.772549f);
// 0.988235 0.850980 0.733333
public static final Color SELECTION_ORANGE = new Color(0.988235f, 0.850980f, 0.733333f);
// 0.996078 0.913725 0.745098
public static final Color SELECTION_YELLOW = new Color(0.996078f, 0.913725f, 0.745098f);
// 0.815686 0.917647 0.780392
public static final Color SELECTION_GREEN = new Color(0.815686f, 0.917647f, 0.780392f);
// 0.878431 0.878431 0.878431
public static final Color SELECTION_GRAPHITE = new Color(0.878431f, 0.878431f, 0.878431f);
} }

2
macos/src/main/objcpp/ThemeInfo.mm

@ -173,7 +173,7 @@ JNF_COCOA_EXIT(env);
JNIEXPORT jint JNICALL JNIEXPORT jint JNICALL
Java_com_github_weisj_darklaf_platform_macos_JNIThemeInfoMacOS_nativeGetSelectionColor(JNIEnv *env, jclass obj) { Java_com_github_weisj_darklaf_platform_macos_JNIThemeInfoMacOS_nativeGetSelectionColor(JNIEnv *env, jclass obj) {
JNF_COCOA_ENTER(env); JNF_COCOA_ENTER(env);
NSColorSpace *rgbSpace = [NSColorSpace genericRGBColorSpace]; NSColorSpace *rgbSpace = [NSColorSpace sRGBColorSpace];
NSColor *accentColor = [[[NSColorList colorListNamed: KEY_SYSTEM_COLOR_LIST] colorWithKey:KEY_SELECTION_COLOR] colorUsingColorSpace:rgbSpace]; NSColor *accentColor = [[[NSColorList colorListNamed: KEY_SYSTEM_COLOR_LIST] colorWithKey:KEY_SELECTION_COLOR] colorUsingColorSpace:rgbSpace];
NSInteger r = (NSInteger) (255 * [accentColor redComponent]); NSInteger r = (NSInteger) (255 * [accentColor redComponent]);
NSInteger g = (NSInteger) (255 * [accentColor greenComponent]); NSInteger g = (NSInteger) (255 * [accentColor greenComponent]);

Loading…
Cancel
Save