From c478d28b71cfb2cd161df079661f588a263dd9af Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Sun, 13 Mar 2022 18:39:12 +0100 Subject: [PATCH] PasswordField: fixed reveal button appearance in IntelliJ themes (issue #494) --- CHANGELOG.md | 1 + .../java/com/formdev/flatlaf/IntelliJTheme.java | 14 +++++++++++++- .../com/formdev/flatlaf/FlatDarkLaf.properties | 7 ++++--- .../com/formdev/flatlaf/FlatLaf.properties | 1 - .../com/formdev/flatlaf/FlatLightLaf.properties | 7 ++++--- .../flatlaf/IntelliJTheme$ThemeLaf.properties | 5 +++++ .../dumps/uidefaults/FlatDarkLaf_1.8.0.txt | 6 +++--- .../dumps/uidefaults/FlatLightLaf_1.8.0.txt | 6 +++--- .../dumps/uidefaults/FlatTestLaf_1.8.0.txt | 2 +- .../formdev/flatlaf/testing/FlatTestLaf.properties | 1 + 10 files changed, 35 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 914cbd03..c53ad431 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ FlatLaf Change Log #### Fixed bugs +- PasswordField: Fixed reveal button appearance in IntelliJ themes. (issue #494) - ScrollBar: Center and scale arrows in scroll up/down buttons (if shown). (issue #493) diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/IntelliJTheme.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/IntelliJTheme.java index a5b40196..8e2c4876 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/IntelliJTheme.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/IntelliJTheme.java @@ -242,7 +242,19 @@ public class IntelliJTheme defaults.put( "Tree.rowHeight", 22 ); // apply theme specific UI defaults at the end to allow overwriting - defaults.putAll( themeSpecificDefaults ); + for( Map.Entry e : themeSpecificDefaults.entrySet() ) { + Object key = e.getKey(); + Object value = e.getValue(); + + // append styles to existing styles + if( key instanceof String && ((String)key).startsWith( "[style]" ) ) { + Object oldValue = defaults.get( key ); + if( oldValue != null ) + value = oldValue + "; " + value; + } + + defaults.put( key, value ); + } } private Map removeThemeSpecificDefaults( UIDefaults defaults ) { 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 5512f857..895f5888 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatDarkLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatDarkLaf.properties @@ -240,6 +240,7 @@ MenuBar.borderColor = $Separator.foreground #---- PasswordField ---- PasswordField.capsLockIconColor = #ffffff64 +PasswordField.revealIconColor = @foreground #---- Popup ---- @@ -367,6 +368,6 @@ Tree.hash = lighten($Tree.background,5%) focusable: false; \ toolbar.margin: 1,1,1,1; \ toolbar.spacingInsets: 1,1,1,1; \ - toolbar.hoverBackground: fade(Actions.GreyInline,30%,lazy); \ - toolbar.pressedBackground: fade(Actions.GreyInline,40%,lazy); \ - toolbar.selectedBackground: fade(Actions.GreyInline,50%,lazy) + toolbar.hoverBackground: lighten($TextField.background,5%); \ + toolbar.pressedBackground: lighten($TextField.background,10%); \ + toolbar.selectedBackground: lighten($TextField.background,15%) diff --git a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties index e242a1eb..766bf944 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties @@ -487,7 +487,6 @@ PasswordField.showCapsLock = true PasswordField.showRevealButton = false PasswordField.capsLockIcon = com.formdev.flatlaf.icons.FlatCapsLockIcon PasswordField.revealIcon = com.formdev.flatlaf.icons.FlatRevealIcon -PasswordField.revealIconColor = lazy(Actions.Grey) #---- Popup ---- diff --git a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLightLaf.properties b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLightLaf.properties index f1aeafb3..6473b89a 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLightLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLightLaf.properties @@ -247,6 +247,7 @@ MenuBar.borderColor = $Separator.foreground #---- PasswordField ---- PasswordField.capsLockIconColor = #00000064 +PasswordField.revealIconColor = tint(@foreground,40%) #---- Popup ---- @@ -374,6 +375,6 @@ Tree.hash = darken($Tree.background,10%) focusable: false; \ toolbar.margin: 1,1,1,1; \ toolbar.spacingInsets: 1,1,1,1; \ - toolbar.hoverBackground: fade(Actions.GreyInline,10%,lazy); \ - toolbar.pressedBackground: fade(Actions.GreyInline,20%,lazy); \ - toolbar.selectedBackground: fade(Actions.GreyInline,30%,lazy) + toolbar.hoverBackground: darken($TextField.background,4%); \ + toolbar.pressedBackground: darken($TextField.background,8%); \ + toolbar.selectedBackground: darken($TextField.background,12%) diff --git a/flatlaf-core/src/main/resources/com/formdev/flatlaf/IntelliJTheme$ThemeLaf.properties b/flatlaf-core/src/main/resources/com/formdev/flatlaf/IntelliJTheme$ThemeLaf.properties index c14c0921..306ba14a 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/IntelliJTheme$ThemeLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/IntelliJTheme$ThemeLaf.properties @@ -158,6 +158,11 @@ ToggleButton.endBackground = $ToggleButton.background [High_contrast]ToggleButton.selectedForeground = #000 [High_contrast]ToggleButton.disabledSelectedBackground = #444 [High_contrast]ToggleButton.toolbar.selectedBackground = #fff +[High_contrast][style]Button.inTextField = \ + toolbar.hoverBackground: #444; \ + toolbar.pressedBackground: #666; \ + toolbar.selectedBackground: #fff +[High_contrast][style]ToggleButton.inTextField = $[High_contrast][style]Button.inTextField [Light_Flat]TableHeader.background = #E5E5E9 diff --git a/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0.txt index 78fa7538..700e8f6a 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0.txt @@ -712,7 +712,7 @@ PasswordField.inactiveForeground #8c8c8c HSL 0 0 55 javax.swing.plaf.Co PasswordField.margin 2,6,2,6 javax.swing.plaf.InsetsUIResource [UI] PasswordField.placeholderForeground #8c8c8c HSL 0 0 55 javax.swing.plaf.ColorUIResource [UI] PasswordField.revealIcon [lazy] 16,16 com.formdev.flatlaf.icons.FlatRevealIcon [UI] -PasswordField.revealIconColor [lazy] #afb1b3 HSL 210 3 69 javax.swing.plaf.ColorUIResource [UI] +PasswordField.revealIconColor #bbbbbb HSL 0 0 73 javax.swing.plaf.ColorUIResource [UI] PasswordField.selectionBackground #4b6eaf HSL 219 40 49 javax.swing.plaf.ColorUIResource [UI] PasswordField.selectionForeground #bbbbbb HSL 0 0 73 javax.swing.plaf.ColorUIResource [UI] PasswordField.showCapsLock true @@ -1426,12 +1426,12 @@ ViewportUI com.formdev.flatlaf.ui.FlatViewportUI #---- [style]Button ---- [style]Button.clearButton icon: com.formdev.flatlaf.icons.FlatClearIcon; focusable: false; toolbar.margin: 1,1,1,1; toolbar.spacingInsets: 1,1,1,1; toolbar.hoverBackground: null; toolbar.pressedBackground: null -[style]Button.inTextField focusable: false; toolbar.margin: 1,1,1,1; toolbar.spacingInsets: 1,1,1,1; toolbar.hoverBackground: fade(Actions.GreyInline,30%,lazy); toolbar.pressedBackground: fade(Actions.GreyInline,40%,lazy); toolbar.selectedBackground: fade(Actions.GreyInline,50%,lazy) +[style]Button.inTextField focusable: false; toolbar.margin: 1,1,1,1; toolbar.spacingInsets: 1,1,1,1; toolbar.hoverBackground: lighten($TextField.background,5%); toolbar.pressedBackground: lighten($TextField.background,10%); toolbar.selectedBackground: lighten($TextField.background,15%) #---- [style]ToggleButton ---- -[style]ToggleButton.inTextField focusable: false; toolbar.margin: 1,1,1,1; toolbar.spacingInsets: 1,1,1,1; toolbar.hoverBackground: fade(Actions.GreyInline,30%,lazy); toolbar.pressedBackground: fade(Actions.GreyInline,40%,lazy); toolbar.selectedBackground: fade(Actions.GreyInline,50%,lazy) +[style]ToggleButton.inTextField focusable: false; toolbar.margin: 1,1,1,1; toolbar.spacingInsets: 1,1,1,1; toolbar.hoverBackground: lighten($TextField.background,5%); toolbar.pressedBackground: lighten($TextField.background,10%); toolbar.selectedBackground: lighten($TextField.background,15%) #---- [style]ToolBar ---- diff --git a/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0.txt index 40cce209..69c1f517 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0.txt @@ -717,7 +717,7 @@ PasswordField.inactiveForeground #8c8c8c HSL 0 0 55 javax.swing.plaf.Co PasswordField.margin 2,6,2,6 javax.swing.plaf.InsetsUIResource [UI] PasswordField.placeholderForeground #8c8c8c HSL 0 0 55 javax.swing.plaf.ColorUIResource [UI] PasswordField.revealIcon [lazy] 16,16 com.formdev.flatlaf.icons.FlatRevealIcon [UI] -PasswordField.revealIconColor [lazy] #6e6e6e HSL 0 0 43 javax.swing.plaf.ColorUIResource [UI] +PasswordField.revealIconColor #666666 HSL 0 0 40 javax.swing.plaf.ColorUIResource [UI] PasswordField.selectionBackground #2675bf HSL 209 67 45 javax.swing.plaf.ColorUIResource [UI] PasswordField.selectionForeground #ffffff HSL 0 0 100 javax.swing.plaf.ColorUIResource [UI] PasswordField.showCapsLock true @@ -1431,12 +1431,12 @@ ViewportUI com.formdev.flatlaf.ui.FlatViewportUI #---- [style]Button ---- [style]Button.clearButton icon: com.formdev.flatlaf.icons.FlatClearIcon; focusable: false; toolbar.margin: 1,1,1,1; toolbar.spacingInsets: 1,1,1,1; toolbar.hoverBackground: null; toolbar.pressedBackground: null -[style]Button.inTextField focusable: false; toolbar.margin: 1,1,1,1; toolbar.spacingInsets: 1,1,1,1; toolbar.hoverBackground: fade(Actions.GreyInline,10%,lazy); toolbar.pressedBackground: fade(Actions.GreyInline,20%,lazy); toolbar.selectedBackground: fade(Actions.GreyInline,30%,lazy) +[style]Button.inTextField focusable: false; toolbar.margin: 1,1,1,1; toolbar.spacingInsets: 1,1,1,1; toolbar.hoverBackground: darken($TextField.background,4%); toolbar.pressedBackground: darken($TextField.background,8%); toolbar.selectedBackground: darken($TextField.background,12%) #---- [style]ToggleButton ---- -[style]ToggleButton.inTextField focusable: false; toolbar.margin: 1,1,1,1; toolbar.spacingInsets: 1,1,1,1; toolbar.hoverBackground: fade(Actions.GreyInline,10%,lazy); toolbar.pressedBackground: fade(Actions.GreyInline,20%,lazy); toolbar.selectedBackground: fade(Actions.GreyInline,30%,lazy) +[style]ToggleButton.inTextField focusable: false; toolbar.margin: 1,1,1,1; toolbar.spacingInsets: 1,1,1,1; toolbar.hoverBackground: darken($TextField.background,4%); toolbar.pressedBackground: darken($TextField.background,8%); toolbar.selectedBackground: darken($TextField.background,12%) #---- [style]ToolBar ---- diff --git a/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0.txt index 429e7366..1ccc3ef4 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0.txt @@ -727,7 +727,7 @@ PasswordField.inactiveForeground #000088 HSL 240 100 27 javax.swing.plaf.Co PasswordField.margin 2,6,2,6 javax.swing.plaf.InsetsUIResource [UI] PasswordField.placeholderForeground #000088 HSL 240 100 27 javax.swing.plaf.ColorUIResource [UI] PasswordField.revealIcon [lazy] 16,16 com.formdev.flatlaf.icons.FlatRevealIcon [UI] -PasswordField.revealIconColor [lazy] #6e6e6e HSL 0 0 43 javax.swing.plaf.ColorUIResource [UI] +PasswordField.revealIconColor #0000ff HSL 240 100 50 javax.swing.plaf.ColorUIResource [UI] PasswordField.selectionBackground #00aa00 HSL 120 100 33 javax.swing.plaf.ColorUIResource [UI] PasswordField.selectionForeground #ffff00 HSL 60 100 50 javax.swing.plaf.ColorUIResource [UI] PasswordField.showCapsLock true diff --git a/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/FlatTestLaf.properties b/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/FlatTestLaf.properties index 98fd7fdb..77bd40a8 100644 --- a/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/FlatTestLaf.properties +++ b/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/FlatTestLaf.properties @@ -263,6 +263,7 @@ OptionPane.icon.foreground = #fff #---- PasswordField ---- PasswordField.focusedBackground = #ff8 +PasswordField.revealIconColor = #00f #---- Popup ----