Accent color:

- added `Component.accentColor`
- dark themes: changed threshold for contrast() from 39% down to 25% for better readability of text
- Demo: added "Default" accent color and changed "Blue" to lighter color

(issue #233)
This commit is contained in:
Karl Tauber
2021-09-28 11:12:17 +02:00
parent e31e4dfe3a
commit bb5c2eea10
8 changed files with 19 additions and 6 deletions

View File

@@ -336,9 +336,12 @@ class DemoFrame
// flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/FlatLightLaf.properties and
// flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/FlatDarkLaf.properties
private static String[] accentColorKeys = {
"Demo.accent.blue", "Demo.accent.purple", "Demo.accent.red",
"Demo.accent.default", "Demo.accent.blue", "Demo.accent.purple", "Demo.accent.red",
"Demo.accent.orange", "Demo.accent.yellow", "Demo.accent.green",
};
private static String[] accentColorNames = {
"Default", "Blue", "Purple", "Red", "Orange", "Yellow", "Green",
};
private final JToggleButton[] accentColorButtons = new JToggleButton[accentColorKeys.length];
private JLabel accentColorLabel;
@@ -351,6 +354,7 @@ class DemoFrame
ButtonGroup group = new ButtonGroup();
for( int i = 0; i < accentColorButtons.length; i++ ) {
accentColorButtons[i] = new JToggleButton( new AccentColorIcon( accentColorKeys[i] ) );
accentColorButtons[i].setToolTipText( accentColorNames[i] );
accentColorButtons[i].addActionListener( this::accentColorChanged );
toolBar.add( accentColorButtons[i] );
group.add( accentColorButtons[i] );

View File

@@ -16,9 +16,11 @@
#---- Demo.accent ----
Demo.accent.blue = #4B6EAF
# accent colors from https://github.com/89netraM/SystemColors/blob/master/src/net/asberg/macos/AccentColor.java
Demo.accent.default = #4B6EAF
Demo.accent.blue = #0A84FF
Demo.accent.purple = #BF5AF2
Demo.accent.red = #e81123
Demo.accent.red = #FF453A
Demo.accent.orange = #FF9F0A
Demo.accent.yellow = #FFCC00
Demo.accent.green = #32D74B

View File

@@ -16,7 +16,9 @@
#---- Demo.accent ----
Demo.accent.blue = #2675BF
# accent colors from https://github.com/89netraM/SystemColors/blob/master/src/net/asberg/macos/AccentColor.java
Demo.accent.default = #2675BF
Demo.accent.blue = #007AFF
Demo.accent.purple = #BF5AF2
Demo.accent.red = #FF3B30
Demo.accent.orange = #FF9500