Button and ToggleButton: paint disabled background by default (issue #112)

This commit is contained in:
Karl Tauber
2020-06-18 11:10:59 +02:00
parent fe15f44e96
commit 5c7378cf94
4 changed files with 13 additions and 2 deletions

View File

@@ -284,6 +284,7 @@ public abstract class FlatLaf
// initialize some defaults (for overriding) that are used in UI delegates, // initialize some defaults (for overriding) that are used in UI delegates,
// but are not set in BasicLookAndFeel // but are not set in BasicLookAndFeel
putDefaults( defaults, defaults.getColor( "control" ), putDefaults( defaults, defaults.getColor( "control" ),
"Button.disabledBackground",
"EditorPane.disabledBackground", "EditorPane.disabledBackground",
"EditorPane.inactiveBackground", "EditorPane.inactiveBackground",
"FormattedTextField.disabledBackground", "FormattedTextField.disabledBackground",
@@ -293,7 +294,8 @@ public abstract class FlatLaf
"TextArea.inactiveBackground", "TextArea.inactiveBackground",
"TextField.disabledBackground", "TextField.disabledBackground",
"TextPane.disabledBackground", "TextPane.disabledBackground",
"TextPane.inactiveBackground" ); "TextPane.inactiveBackground",
"ToggleButton.disabledBackground" );
putDefaults( defaults, defaults.getColor( "textInactiveText" ), putDefaults( defaults, defaults.getColor( "textInactiveText" ),
"Button.disabledText", "Button.disabledText",
"CheckBox.disabledText", "CheckBox.disabledText",

View File

@@ -147,6 +147,11 @@ public class IntelliJTheme
applyColorPalette( defaults ); applyColorPalette( defaults );
applyCheckBoxColors( defaults ); applyCheckBoxColors( defaults );
// IDEA does not paint button background if disabled, but FlatLaf does
Object panelBackground = defaults.get( "Panel.background" );
defaults.put( "Button.disabledBackground", panelBackground );
defaults.put( "ToggleButton.disabledBackground", panelBackground );
// IDEA uses a SVG icon for the help button, but paints the background with Button.startBackground and Button.endBackground // IDEA uses a SVG icon for the help button, but paints the background with Button.startBackground and Button.endBackground
Object helpButtonBackground = defaults.get( "Button.startBackground" ); Object helpButtonBackground = defaults.get( "Button.startBackground" );
Object helpButtonBorderColor = defaults.get( "Button.startBorderColor" ); Object helpButtonBorderColor = defaults.get( "Button.startBorderColor" );
@@ -156,7 +161,7 @@ public class IntelliJTheme
helpButtonBorderColor = defaults.get( "Button.borderColor" ); helpButtonBorderColor = defaults.get( "Button.borderColor" );
defaults.put( "HelpButton.background", helpButtonBackground ); defaults.put( "HelpButton.background", helpButtonBackground );
defaults.put( "HelpButton.borderColor", helpButtonBorderColor ); defaults.put( "HelpButton.borderColor", helpButtonBorderColor );
defaults.put( "HelpButton.disabledBackground", defaults.get( "Panel.background" ) ); defaults.put( "HelpButton.disabledBackground", panelBackground );
defaults.put( "HelpButton.disabledBorderColor", defaults.get( "Button.disabledBorderColor" ) ); defaults.put( "HelpButton.disabledBorderColor", defaults.get( "Button.disabledBorderColor" ) );
defaults.put( "HelpButton.focusedBorderColor", defaults.get( "Button.focusedBorderColor" ) ); defaults.put( "HelpButton.focusedBorderColor", defaults.get( "Button.focusedBorderColor" ) );
defaults.put( "HelpButton.focusedBackground", defaults.get( "Button.focusedBackground" ) ); defaults.put( "HelpButton.focusedBackground", defaults.get( "Button.focusedBackground" ) );

View File

@@ -77,6 +77,7 @@ Button.default.hoverBackground #3b5f8b com.formdev.flatlaf.util.DerivedColor
Button.default.hoverBorderColor #537699 javax.swing.plaf.ColorUIResource [UI] Button.default.hoverBorderColor #537699 javax.swing.plaf.ColorUIResource [UI]
Button.default.pressedBackground #3f6796 com.formdev.flatlaf.util.DerivedColor [UI] lighten(6% autoInverse) Button.default.pressedBackground #3f6796 com.formdev.flatlaf.util.DerivedColor [UI] lighten(6% autoInverse)
Button.defaultButtonFollowsFocus true Button.defaultButtonFollowsFocus true
Button.disabledBackground #3c3f41 javax.swing.plaf.ColorUIResource [UI]
Button.disabledBorderColor #5e6060 javax.swing.plaf.ColorUIResource [UI] Button.disabledBorderColor #5e6060 javax.swing.plaf.ColorUIResource [UI]
Button.disabledText #777777 javax.swing.plaf.ColorUIResource [UI] Button.disabledText #777777 javax.swing.plaf.ColorUIResource [UI]
Button.focusedBorderColor #466d94 javax.swing.plaf.ColorUIResource [UI] Button.focusedBorderColor #466d94 javax.swing.plaf.ColorUIResource [UI]
@@ -1059,6 +1060,7 @@ TitledPanelUI com.formdev.flatlaf.swingx.ui.FlatTitledPanelUI
ToggleButton.background #4c5052 javax.swing.plaf.ColorUIResource [UI] ToggleButton.background #4c5052 javax.swing.plaf.ColorUIResource [UI]
ToggleButton.border [lazy] 1,1,1,1 false com.formdev.flatlaf.ui.FlatButtonBorder [UI] ToggleButton.border [lazy] 1,1,1,1 false com.formdev.flatlaf.ui.FlatButtonBorder [UI]
ToggleButton.darkShadow #7e7e7e javax.swing.plaf.ColorUIResource [UI] ToggleButton.darkShadow #7e7e7e javax.swing.plaf.ColorUIResource [UI]
ToggleButton.disabledBackground #3c3f41 javax.swing.plaf.ColorUIResource [UI]
ToggleButton.disabledSelectedBackground #53585a com.formdev.flatlaf.util.DerivedColor [UI] lighten(3% autoInverse) ToggleButton.disabledSelectedBackground #53585a com.formdev.flatlaf.util.DerivedColor [UI] lighten(3% autoInverse)
ToggleButton.disabledText #777777 javax.swing.plaf.ColorUIResource [UI] ToggleButton.disabledText #777777 javax.swing.plaf.ColorUIResource [UI]
ToggleButton.font [active] $defaultFont [UI] ToggleButton.font [active] $defaultFont [UI]

View File

@@ -77,6 +77,7 @@ Button.default.hoverBackground #f7f7f7 com.formdev.flatlaf.util.DerivedColor
Button.default.hoverBorderColor #87afda javax.swing.plaf.ColorUIResource [UI] Button.default.hoverBorderColor #87afda javax.swing.plaf.ColorUIResource [UI]
Button.default.pressedBackground #e6e6e6 com.formdev.flatlaf.util.DerivedColor [UI] darken(10% autoInverse) Button.default.pressedBackground #e6e6e6 com.formdev.flatlaf.util.DerivedColor [UI] darken(10% autoInverse)
Button.defaultButtonFollowsFocus true Button.defaultButtonFollowsFocus true
Button.disabledBackground #f2f2f2 javax.swing.plaf.ColorUIResource [UI]
Button.disabledBorderColor #cfcfcf javax.swing.plaf.ColorUIResource [UI] Button.disabledBorderColor #cfcfcf javax.swing.plaf.ColorUIResource [UI]
Button.disabledText #8c8c8c javax.swing.plaf.ColorUIResource [UI] Button.disabledText #8c8c8c javax.swing.plaf.ColorUIResource [UI]
Button.focusedBackground #e3f1fa javax.swing.plaf.ColorUIResource [UI] Button.focusedBackground #e3f1fa javax.swing.plaf.ColorUIResource [UI]
@@ -1061,6 +1062,7 @@ TitledPanelUI com.formdev.flatlaf.swingx.ui.FlatTitledPanelUI
ToggleButton.background #ffffff javax.swing.plaf.ColorUIResource [UI] ToggleButton.background #ffffff javax.swing.plaf.ColorUIResource [UI]
ToggleButton.border [lazy] 1,1,1,1 false com.formdev.flatlaf.ui.FlatButtonBorder [UI] ToggleButton.border [lazy] 1,1,1,1 false com.formdev.flatlaf.ui.FlatButtonBorder [UI]
ToggleButton.darkShadow #9e9e9e javax.swing.plaf.ColorUIResource [UI] ToggleButton.darkShadow #9e9e9e javax.swing.plaf.ColorUIResource [UI]
ToggleButton.disabledBackground #f2f2f2 javax.swing.plaf.ColorUIResource [UI]
ToggleButton.disabledSelectedBackground #dedede com.formdev.flatlaf.util.DerivedColor [UI] darken(13% autoInverse) ToggleButton.disabledSelectedBackground #dedede com.formdev.flatlaf.util.DerivedColor [UI] darken(13% autoInverse)
ToggleButton.disabledText #8c8c8c javax.swing.plaf.ColorUIResource [UI] ToggleButton.disabledText #8c8c8c javax.swing.plaf.ColorUIResource [UI]
ToggleButton.font [active] $defaultFont [UI] ToggleButton.font [active] $defaultFont [UI]