diff --git a/CHANGELOG.md b/CHANGELOG.md index 299185f3..ece9cf5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,13 +7,13 @@ FlatLaf Change Log - macOS: Re-enabled rounded popup border (see PR #772) on macOS 14.4+ (was disabled in 3.5.x). -- Increased contrast of text for better readability: (issue #762) - - In **FlatLaf Dark**, **FlatLaf Darcula** and many dark IntelliJ themes made +- Increased contrast of text for better readability: (PR #972; issue #762) + - In **FlatLaf Dark**, **FlatLaf Darcula** and many dark IntelliJ themes, made all text colors brighter. - - In **FlatLaf Light**, **FlatLaf IntelliJ** and many light IntelliJ themes + - In **FlatLaf Light**, **FlatLaf IntelliJ** and many light IntelliJ themes, made disabled text colors slightly darker. - - In **FlatLaf macOS Light** made disabled text colors darker. - - In **FlatLaf macOS Dark** made text colors of "default" button and selected + - In **FlatLaf macOS Light**, made disabled text colors darker. + - In **FlatLaf macOS Dark**, made text colors of "default" button and selected ToggleButton lighter. - CheckBox: Support styling indeterminate state of [tri-state check boxes](https://www.javadoc.io/doc/com.formdev/flatlaf-extras/latest/com/formdev/flatlaf/extras/components/FlatTriStateCheckBox.html). diff --git a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatDarkLaf.properties b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatDarkLaf.properties index ff4e2bfa..e804b603 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatDarkLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatDarkLaf.properties @@ -284,7 +284,7 @@ ScrollBar.pressedButtonBackground = lighten(@background,10%,derived noAutoInvers #---- Separator ---- -Separator.foreground = tint(@background,10%) +Separator.foreground = tint(@background,15%) #---- Slider ---- diff --git a/flatlaf-testing/dumps/uidefaults/FlatDarculaLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatDarculaLaf_1.8.0.txt index 2e9e00e2..66b6a9df 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatDarculaLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatDarculaLaf_1.8.0.txt @@ -117,5 +117,8 @@ #---- contrast ratio: ProgressBar ---- +- contrast ratio: ProgressBar.foreground #4c87c8 #3c3f41 2.8 !!!!! ++ contrast ratio: ProgressBar.foreground #c4c4c4 #3c3f41 6.1 ! + - contrast ratio: ProgressBar.selectionForeground #eeeeee #4c87c8 3.2 !!!! + contrast ratio: ProgressBar.selectionForeground #3c3f41 #c4c4c4 6.1 ! diff --git a/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0.txt index fcdffa9d..9b7f11b0 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0.txt @@ -598,7 +598,7 @@ Menu.submenuPopupOffsetY [active] -4 MenuBar.background #303234 HSL 210 4 20 javax.swing.plaf.ColorUIResource [UI] MenuBar.border [lazy] 0,0,1,0 false com.formdev.flatlaf.ui.FlatMenuBarBorder [UI] -MenuBar.borderColor #505254 HSL 210 2 32 javax.swing.plaf.ColorUIResource [UI] +MenuBar.borderColor #595c5e HSL 204 3 36 javax.swing.plaf.ColorUIResource [UI] MenuBar.font [active] $defaultFont [UI] MenuBar.foreground #dddddd HSL 0 0 87 javax.swing.plaf.ColorUIResource [UI] MenuBar.highlight #232324 HSL 240 1 14 javax.swing.plaf.ColorUIResource [UI] @@ -938,7 +938,7 @@ SearchField.searchIconPressedColor [lazy] #7f8b9180 50% HSLA 200 8 53 50 #---- Separator ---- Separator.background #3c3f41 HSL 204 4 25 javax.swing.plaf.ColorUIResource [UI] -Separator.foreground #505254 HSL 210 2 32 javax.swing.plaf.ColorUIResource [UI] +Separator.foreground #595c5e HSL 204 3 36 javax.swing.plaf.ColorUIResource [UI] Separator.height 3 Separator.highlight #232324 HSL 240 1 14 javax.swing.plaf.ColorUIResource [UI] Separator.shadow #616365 HSL 210 2 39 javax.swing.plaf.ColorUIResource [UI] @@ -1289,7 +1289,7 @@ TitlePane.useWindowDecorations true #---- TitledBorder ---- -TitledBorder.border [lazy] 1,1,1,1 false com.formdev.flatlaf.ui.FlatLineBorder [UI] lineColor=#505254 HSL 210 2 32 javax.swing.plaf.ColorUIResource [UI] lineThickness=1.000000 +TitledBorder.border [lazy] 1,1,1,1 false com.formdev.flatlaf.ui.FlatLineBorder [UI] lineColor=#595c5e HSL 204 3 36 javax.swing.plaf.ColorUIResource [UI] lineThickness=1.000000 TitledBorder.font [active] $defaultFont [UI] TitledBorder.titleColor #dddddd HSL 0 0 87 javax.swing.plaf.ColorUIResource [UI] @@ -1352,7 +1352,7 @@ ToolBar.hoverButtonGroupArc 8 ToolBar.hoverButtonGroupBackground #434749 HSL 200 4 27 com.formdev.flatlaf.util.DerivedColor [UI] lighten(3% autoInverse) ToolBar.isRollover true ToolBar.light #2f3031 HSL 210 2 19 javax.swing.plaf.ColorUIResource [UI] -ToolBar.separatorColor #505254 HSL 210 2 32 javax.swing.plaf.ColorUIResource [UI] +ToolBar.separatorColor #595c5e HSL 204 3 36 javax.swing.plaf.ColorUIResource [UI] ToolBar.separatorWidth 7 ToolBar.shadow #616365 HSL 210 2 39 javax.swing.plaf.ColorUIResource [UI] ToolBar.spacingBorder [lazy] 1,2,1,2 false com.formdev.flatlaf.ui.FlatEmptyBorder [UI] @@ -1750,3 +1750,17 @@ Tree.textForeground #dddddd #46494b 6.7 ! #-- titleForeground -- JXTitledPanel.titleForeground #dddddd #4c5052 6.0 ! + +#-- non-text -- +CheckBoxMenuItem.icon.checkmarkColor #b7b7b7 #3c3f41 5.3 !! +CheckBoxMenuItem.icon.disabledCheckmarkColor #777777 #3c3f41 2.4 !!!!! +Menu.icon.arrowColor #b7b7b7 #3c3f41 5.3 !! +Menu.icon.disabledArrowColor #777777 #3c3f41 2.4 !!!!! +ProgressBar.background #505456 #3c3f41 1.4 !!!!!! +ProgressBar.foreground #4c87c8 #3c3f41 2.8 !!!!! +Separator.foreground #595c5e #3c3f41 1.6 !!!!!! +Slider.disabledTrackColor #54595c #3c3f41 1.5 !!!!!! +Slider.trackColor #616669 #3c3f41 1.8 !!!!!! +Slider.trackValueColor #4c87c8 #3c3f41 2.8 !!!!! +TabbedPane.contentAreaColor #616365 #3c3f41 1.8 !!!!!! +ToolBar.separatorColor #595c5e #3c3f41 1.6 !!!!!! diff --git a/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0.txt index ff24fe83..a0953d46 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0.txt @@ -1755,3 +1755,17 @@ Tree.textForeground #000000 #ffffff 21.0 #-- titleForeground -- JXTitledPanel.titleForeground #222222 #dfdfdf 11.9 + +#-- non-text -- +CheckBoxMenuItem.icon.checkmarkColor #4e9de7 #f2f2f2 2.6 !!!!! +CheckBoxMenuItem.icon.disabledCheckmarkColor #a6a6a6 #f2f2f2 2.2 !!!!! +Menu.icon.arrowColor #666666 #f2f2f2 5.1 !! +Menu.icon.disabledArrowColor #a6a6a6 #f2f2f2 2.2 !!!!! +ProgressBar.background #d1d1d1 #f2f2f2 1.4 !!!!!! +ProgressBar.foreground #2285e1 #f2f2f2 3.4 !!!! +Separator.foreground #cecece #f2f2f2 1.4 !!!!!! +Slider.disabledTrackColor #d1d1d1 #f2f2f2 1.4 !!!!!! +Slider.trackColor #c4c4c4 #f2f2f2 1.6 !!!!!! +Slider.trackValueColor #2285e1 #f2f2f2 3.4 !!!! +TabbedPane.contentAreaColor #c2c2c2 #f2f2f2 1.6 !!!!!! +ToolBar.separatorColor #cecece #f2f2f2 1.4 !!!!!! diff --git a/flatlaf-testing/dumps/uidefaults/FlatMacDarkLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatMacDarkLaf_1.8.0.txt index 352a5d70..8ef3492d 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatMacDarkLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatMacDarkLaf_1.8.0.txt @@ -1761,3 +1761,17 @@ Tree.textForeground #dddddd #282828 10.9 #-- titleForeground -- JXTitledPanel.titleForeground #dddddd #4c5052 6.0 ! + +#-- non-text -- +CheckBoxMenuItem.icon.checkmarkColor #b7b7b7 #1e1e1e 8.3 +CheckBoxMenuItem.icon.disabledCheckmarkColor #777777 #1e1e1e 3.7 !!!! +Menu.icon.arrowColor #b7b7b7 #1e1e1e 8.3 +Menu.icon.disabledArrowColor #777777 #1e1e1e 3.7 !!!! +ProgressBar.background #323232 #1e1e1e 1.3 !!!!!! +ProgressBar.foreground #007aff #1e1e1e 4.2 !!! +Separator.foreground #343434 #1e1e1e 1.3 !!!!!! #ffffff19 10% +Slider.disabledTrackColor #282828 #1e1e1e 1.1 !!!!!! +Slider.trackColor #323232 #1e1e1e 1.3 !!!!!! +Slider.trackValueColor #007aff #1e1e1e 4.2 !!! +TabbedPane.contentAreaColor #343434 #1e1e1e 1.3 !!!!!! #ffffff19 10% +ToolBar.separatorColor #343434 #1e1e1e 1.3 !!!!!! #ffffff19 10% diff --git a/flatlaf-testing/dumps/uidefaults/FlatMacLightLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatMacLightLaf_1.8.0.txt index 5016b3b5..96795586 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatMacLightLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatMacLightLaf_1.8.0.txt @@ -1765,3 +1765,17 @@ Tree.textForeground #262626 #ffffff 15.1 #-- titleForeground -- JXTitledPanel.titleForeground #222222 #dfdfdf 11.9 + +#-- non-text -- +CheckBoxMenuItem.icon.checkmarkColor #007aff #f6f6f6 3.7 !!!! +CheckBoxMenuItem.icon.disabledCheckmarkColor #bdbdbd #f6f6f6 1.7 !!!!!! +Menu.icon.arrowColor #7d7d7d #f6f6f6 3.8 !!!! +Menu.icon.disabledArrowColor #bdbdbd #f6f6f6 1.7 !!!!!! +ProgressBar.background #e9e9e9 #f6f6f6 1.1 !!!!!! +ProgressBar.foreground #007aff #f6f6f6 3.7 !!!! +Separator.foreground #dedede #f6f6f6 1.2 !!!!!! #00000019 10% +Slider.disabledTrackColor #ececec #f6f6f6 1.1 !!!!!! +Slider.trackColor #e4e4e4 #f6f6f6 1.2 !!!!!! +Slider.trackValueColor #007aff #f6f6f6 3.7 !!!! +TabbedPane.contentAreaColor #d1d1d1 #f6f6f6 1.4 !!!!!! #00000026 15% +ToolBar.separatorColor #dedede #f6f6f6 1.2 !!!!!! #00000019 10% diff --git a/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0.txt index 82b7c47e..ffe6bff2 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0.txt @@ -1844,3 +1844,16 @@ Tree.textForeground #ff0000 #fff0ff 3.6 !! #-- titleForeground -- JXTitledPanel.titleForeground #ff00ff #ffff00 2.9 !!!!! + +#-- non-text -- +CheckBoxMenuItem.icon.checkmarkColor #4d89c9 #ccffcc 3.3 !!!! +CheckBoxMenuItem.icon.disabledCheckmarkColor #ababab #ccffcc 2.0 !!!!! +Menu.icon.arrowColor #4d89c9 #ccffcc 3.3 !!!! +Menu.icon.disabledArrowColor #ababab #ccffcc 2.0 !!!!! +ProgressBar.background #88ff88 #ccffcc 1.1 !!!!!! +ProgressBar.foreground #bae3ba #ccffcc 1.3 !!!!!! #73737333 20% +Separator.foreground #00bb00 #ccffcc 2.3 !!!!! +Slider.disabledTrackColor #ffff88 #ccffcc 1.1 !!!!!! +Slider.trackColor #88ff88 #ccffcc 1.1 !!!!!! +TabbedPane.contentAreaColor #ff0000 #ccffcc 3.6 !!!! +ToolBar.separatorColor #00bb00 #ccffcc 2.3 !!!!! diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/uidefaults/UIDefaultsDump.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/uidefaults/UIDefaultsDump.java index b0ac8641..a5cf5878 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/uidefaults/UIDefaultsDump.java +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/uidefaults/UIDefaultsDump.java @@ -901,6 +901,22 @@ public class UIDefaultsDump fg2bgMap.remove( "TitlePane.closeHoverForeground" ); fg2bgMap.remove( "TitlePane.closePressedForeground" ); + // non-text + HashMap nonTextMap = new HashMap<>(); + nonTextMap.put( "Menu.icon.arrowColor", "Panel.background" ); + nonTextMap.put( "Menu.icon.disabledArrowColor", "Panel.background" ); + nonTextMap.put( "CheckBoxMenuItem.icon.checkmarkColor", "Panel.background" ); + nonTextMap.put( "CheckBoxMenuItem.icon.disabledCheckmarkColor", "Panel.background" ); + nonTextMap.put( "ProgressBar.foreground", "Panel.background" ); + nonTextMap.put( "ProgressBar.background", "Panel.background" ); + nonTextMap.put( "Separator.foreground", "Separator.background" ); + nonTextMap.put( "Slider.trackColor", "Panel.background" ); + nonTextMap.put( "Slider.trackValueColor", "Panel.background" ); + nonTextMap.put( "Slider.disabledTrackColor", "Panel.background" ); + nonTextMap.put( "TabbedPane.contentAreaColor", "Panel.background" ); + nonTextMap.put( "ToolBar.separatorColor", "ToolBar.background" ); + + // out.println(); // fg2bgMap.entrySet().stream() // .sorted( (e1, e2) -> e1.getKey().compareTo( e2.getKey() ) ) @@ -925,37 +941,58 @@ public class UIDefaultsDump return key1.substring( 0, dot1 ).compareTo( key2.substring( 0, dot2 ) ); } ) .forEach( e -> { - String fgKey = e.getKey(); - String bgKey = e.getValue(); - Color background = defaults.getColor( bgKey ); - Color foreground = defaults.getColor( fgKey ); - if( background != null && foreground != null ) { - float luma1 = ColorFunctions.luma( background ); - float luma2 = ColorFunctions.luma( foreground ); - float contrastRatio = (luma1 > luma2) - ? (luma1 + 0.05f) / (luma2 + 0.05f) - : (luma2 + 0.05f) / (luma1 + 0.05f); - String rateing = - contrastRatio < 1.95f ? " !!!!!!" : - contrastRatio < 2.95f ? " !!!!!" : - contrastRatio < 3.95f ? " !!!!" : - contrastRatio < 4.95f ? " !!!" : - contrastRatio < 5.95f ? " !!" : - contrastRatio < 6.95f ? " !" : - ""; - - String subkey = fgKey.substring( fgKey.lastIndexOf( '.' ) + 1 ); - if( !subkey.equals( lastSubkey.get() ) ) { - lastSubkey.set( subkey ); - out.println(); - out.println( "#-- " + subkey + " --" ); - } - - out.printf( "%-50s #%06x #%06x %4.1f%s%n", fgKey, - foreground.getRGB() & 0xffffff, background.getRGB() & 0xffffff, - contrastRatio, rateing ); - } + dumpContrastRatio( out, e.getKey(), e.getValue(), lastSubkey ); } ); + + out.println(); + out.println( "#-- non-text --" ); + nonTextMap.entrySet().stream() + .sorted( (e1, e2) -> { + return e1.getKey().compareTo( e2.getKey() ); + } ) + .forEach( e -> { + dumpContrastRatio( out, e.getKey(), e.getValue(), null ); + } ); + } + + private void dumpContrastRatio( PrintWriter out, String fgKey, String bgKey, AtomicReference lastSubkey ) { + Color background = defaults.getColor( bgKey ); + Color foreground = defaults.getColor( fgKey ); + if( background == null || foreground == null ) + return; + + String subkey = fgKey.substring( fgKey.lastIndexOf( '.' ) + 1 ); + if( lastSubkey != null && !subkey.equals( lastSubkey.get() ) ) { + lastSubkey.set( subkey ); + out.println(); + out.println( "#-- " + subkey + " --" ); + } + + Color translucentForeground = null; + if( foreground.getAlpha() != 255 ) { + translucentForeground = foreground; + float weight = foreground.getAlpha() / 255f; + foreground = ColorFunctions.mix( new Color( foreground.getRGB() ), background, weight ); + } + + float luma1 = ColorFunctions.luma( background ); + float luma2 = ColorFunctions.luma( foreground ); + float contrastRatio = (luma1 > luma2) + ? (luma1 + 0.05f) / (luma2 + 0.05f) + : (luma2 + 0.05f) / (luma1 + 0.05f); + String rateing = + contrastRatio < 1.95f ? " !!!!!!" : + contrastRatio < 2.95f ? " !!!!!" : + contrastRatio < 3.95f ? " !!!!" : + contrastRatio < 4.95f ? " !!!" : + contrastRatio < 5.95f ? " !!" : + contrastRatio < 6.95f ? " !" : + ""; + + out.printf( "%-50s #%06x #%06x %4.1f%s%s%n", fgKey, + foreground.getRGB() & 0xffffff, background.getRGB() & 0xffffff, + contrastRatio, rateing, + translucentForeground != null ? " " + dumpColorHex( translucentForeground ) : "" ); } //---- class MyBasicLookAndFeel -------------------------------------------