mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-11 06:27:13 -06:00
ToggleButton: button style "tab": added missing foreground colors for hover, focused and selected states (issue #535)
This commit is contained in:
@@ -78,8 +78,11 @@ import com.formdev.flatlaf.util.UIScale;
|
||||
* @uiDefault ToggleButton.tab.underlineColor Color
|
||||
* @uiDefault ToggleButton.tab.disabledUnderlineColor Color
|
||||
* @uiDefault ToggleButton.tab.selectedBackground Color optional
|
||||
* @uiDefault ToggleButton.tab.selectedForeground Color optional
|
||||
* @uiDefault ToggleButton.tab.hoverBackground Color
|
||||
* @uiDefault ToggleButton.tab.hoverForeground Color optional
|
||||
* @uiDefault ToggleButton.tab.focusBackground Color
|
||||
* @uiDefault ToggleButton.tab.focusForeground Color optional
|
||||
*
|
||||
*
|
||||
* @author Karl Tauber
|
||||
@@ -91,8 +94,11 @@ public class FlatToggleButtonUI
|
||||
@Styleable(dot=true) protected Color tabUnderlineColor;
|
||||
@Styleable(dot=true) protected Color tabDisabledUnderlineColor;
|
||||
@Styleable(dot=true) protected Color tabSelectedBackground;
|
||||
/** @since 2.3 */ @Styleable(dot=true) protected Color tabSelectedForeground;
|
||||
@Styleable(dot=true) protected Color tabHoverBackground;
|
||||
/** @since 2.3 */ @Styleable(dot=true) protected Color tabHoverForeground;
|
||||
@Styleable(dot=true) protected Color tabFocusBackground;
|
||||
/** @since 2.3 */ @Styleable(dot=true) protected Color tabFocusForeground;
|
||||
|
||||
private boolean defaults_initialized = false;
|
||||
|
||||
@@ -125,8 +131,11 @@ public class FlatToggleButtonUI
|
||||
tabUnderlineColor = UIManager.getColor( "ToggleButton.tab.underlineColor" );
|
||||
tabDisabledUnderlineColor = UIManager.getColor( "ToggleButton.tab.disabledUnderlineColor" );
|
||||
tabSelectedBackground = UIManager.getColor( "ToggleButton.tab.selectedBackground" );
|
||||
tabSelectedForeground = UIManager.getColor( "ToggleButton.tab.selectedForeground" );
|
||||
tabHoverBackground = UIManager.getColor( "ToggleButton.tab.hoverBackground" );
|
||||
tabHoverForeground = UIManager.getColor( "ToggleButton.tab.hoverForeground" );
|
||||
tabFocusBackground = UIManager.getColor( "ToggleButton.tab.focusBackground" );
|
||||
tabFocusForeground = UIManager.getColor( "ToggleButton.tab.focusForeground" );
|
||||
|
||||
defaults_initialized = true;
|
||||
}
|
||||
@@ -231,4 +240,19 @@ public class FlatToggleButtonUI
|
||||
} else
|
||||
super.paintBackground( g, c );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Color getForeground( JComponent c ) {
|
||||
if( isTabButton( c ) ) {
|
||||
if( !c.isEnabled() )
|
||||
return disabledText;
|
||||
|
||||
if( tabSelectedForeground != null && ((AbstractButton)c).isSelected() )
|
||||
return tabSelectedForeground;
|
||||
|
||||
return buttonStateColor( c, c.getForeground(), disabledText,
|
||||
tabFocusForeground, tabHoverForeground, null );
|
||||
} else
|
||||
return super.getForeground( c );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -829,6 +829,7 @@ ToggleButton.tab.underlineHeight = 2
|
||||
ToggleButton.tab.underlineColor = $TabbedPane.underlineColor
|
||||
ToggleButton.tab.disabledUnderlineColor = $TabbedPane.disabledUnderlineColor
|
||||
ToggleButton.tab.selectedBackground = $?TabbedPane.selectedBackground
|
||||
ToggleButton.tab.selectedForeground = $?TabbedPane.selectedForeground
|
||||
ToggleButton.tab.hoverBackground = $TabbedPane.hoverColor
|
||||
ToggleButton.tab.focusBackground = $TabbedPane.focusColor
|
||||
|
||||
|
||||
@@ -875,8 +875,11 @@ public class TestFlatStyleableInfo
|
||||
"tab.underlineColor", Color.class,
|
||||
"tab.disabledUnderlineColor", Color.class,
|
||||
"tab.selectedBackground", Color.class,
|
||||
"tab.selectedForeground", Color.class,
|
||||
"tab.hoverBackground", Color.class,
|
||||
"tab.focusBackground", Color.class
|
||||
"tab.hoverForeground", Color.class,
|
||||
"tab.focusBackground", Color.class,
|
||||
"tab.focusForeground", Color.class
|
||||
);
|
||||
|
||||
// FlatToggleButtonUI extends FlatButtonUI
|
||||
|
||||
@@ -1085,8 +1085,11 @@ public class TestFlatStyling
|
||||
ui.applyStyle( b, "tab.underlineColor: #fff" );
|
||||
ui.applyStyle( b, "tab.disabledUnderlineColor: #fff" );
|
||||
ui.applyStyle( b, "tab.selectedBackground: #fff" );
|
||||
ui.applyStyle( b, "tab.selectedForeground: #fff" );
|
||||
ui.applyStyle( b, "tab.hoverBackground: #fff" );
|
||||
ui.applyStyle( b, "tab.hoverForeground: #fff" );
|
||||
ui.applyStyle( b, "tab.focusBackground: #fff" );
|
||||
ui.applyStyle( b, "tab.focusForeground: #fff" );
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1314,8 +1314,11 @@ ToggleButton.selectedForeground #000000 HSL 0 0 0 javax.swing.plaf.Col
|
||||
ToggleButton.shadow #a0a0a0 HSL 0 0 63 javax.swing.plaf.ColorUIResource [UI]
|
||||
ToggleButton.tab.disabledUnderlineColor #7a7a7a HSL 0 0 48 javax.swing.plaf.ColorUIResource [UI]
|
||||
ToggleButton.tab.focusBackground #dddddd HSL 0 0 87 javax.swing.plaf.ColorUIResource [UI]
|
||||
ToggleButton.tab.focusForeground #ffffff HSL 0 0 100 javax.swing.plaf.ColorUIResource [UI]
|
||||
ToggleButton.tab.hoverBackground #eeeeee HSL 0 0 93 javax.swing.plaf.ColorUIResource [UI]
|
||||
ToggleButton.tab.selectedBackground #00ff00 HSL 120 100 50 javax.swing.plaf.ColorUIResource [UI]
|
||||
ToggleButton.tab.hoverForeground #00ff00 HSL 120 100 50 javax.swing.plaf.ColorUIResource [UI]
|
||||
ToggleButton.tab.selectedBackground #ffff00 HSL 60 100 50 javax.swing.plaf.ColorUIResource [UI]
|
||||
ToggleButton.tab.selectedForeground #00aaff HSL 200 100 50 javax.swing.plaf.ColorUIResource [UI]
|
||||
ToggleButton.tab.underlineColor #ffff00 HSL 60 100 50 javax.swing.plaf.ColorUIResource [UI]
|
||||
ToggleButton.tab.underlineHeight 2
|
||||
ToggleButton.textIconGap 4
|
||||
|
||||
@@ -454,6 +454,11 @@ ToggleButton.toolbar.selectedForeground = #800
|
||||
ToggleButton.toolbar.disabledSelectedBackground = #ccc
|
||||
ToggleButton.toolbar.disabledSelectedForeground = #866
|
||||
|
||||
ToggleButton.tab.selectedBackground = #080
|
||||
ToggleButton.tab.selectedForeground = #fff
|
||||
ToggleButton.tab.hoverForeground = #00f
|
||||
ToggleButton.tab.focusForeground = #080
|
||||
|
||||
|
||||
#---- ToolBar ----
|
||||
|
||||
|
||||
@@ -1034,8 +1034,11 @@ ToggleButton.selectedForeground
|
||||
ToggleButton.shadow
|
||||
ToggleButton.tab.disabledUnderlineColor
|
||||
ToggleButton.tab.focusBackground
|
||||
ToggleButton.tab.focusForeground
|
||||
ToggleButton.tab.hoverBackground
|
||||
ToggleButton.tab.hoverForeground
|
||||
ToggleButton.tab.selectedBackground
|
||||
ToggleButton.tab.selectedForeground
|
||||
ToggleButton.tab.underlineColor
|
||||
ToggleButton.tab.underlineHeight
|
||||
ToggleButton.textIconGap
|
||||
|
||||
Reference in New Issue
Block a user