ComboBox and Spinner:

- added `buttonSeparatorColor` and `buttonDisabledSeparatorColor`
- fixed styling of `borderColor` and `disabledBorderColor`
This commit is contained in:
Karl Tauber
2021-10-01 13:41:49 +02:00
parent 16920a5b82
commit 3834d93c9d
10 changed files with 64 additions and 33 deletions

View File

@@ -549,6 +549,8 @@ public class IntelliJTheme
uiKeyMapping.put( "ComboBox.ArrowButton.disabledIconColor", "ComboBox.buttonDisabledArrowColor" );
uiKeyMapping.put( "ComboBox.ArrowButton.iconColor", "ComboBox.buttonArrowColor" );
uiKeyMapping.put( "ComboBox.ArrowButton.nonEditableBackground", "ComboBox.buttonBackground" );
uiKeyCopying.put( "ComboBox.buttonSeparatorColor", "Component.borderColor" );
uiKeyCopying.put( "ComboBox.buttonDisabledSeparatorColor", "Component.disabledBorderColor" );
// Component
uiKeyMapping.put( "Component.inactiveErrorFocusColor", "Component.error.borderColor" );
@@ -594,6 +596,10 @@ public class IntelliJTheme
uiKeyCopying.put( "Slider.thumbColor", "ProgressBar.foreground" );
uiKeyCopying.put( "Slider.trackColor", "ProgressBar.background" );
// Spinner
uiKeyCopying.put( "Spinner.buttonSeparatorColor", "Component.borderColor" );
uiKeyCopying.put( "Spinner.buttonDisabledSeparatorColor", "Component.disabledBorderColor" );
// TitlePane
uiKeyCopying.put( "TitlePane.inactiveBackground", "TitlePane.background" );
uiKeyMapping.put( "TitlePane.infoForeground", "TitlePane.foreground" );

View File

@@ -95,8 +95,6 @@ import com.formdev.flatlaf.util.SystemInfo;
* @uiDefault ComboBox.buttonStyle String auto (default), button or none
* @uiDefault Component.arrowType String chevron (default) or triangle
* @uiDefault Component.isIntelliJTheme boolean
* @uiDefault Component.borderColor Color
* @uiDefault Component.disabledBorderColor Color
* @uiDefault ComboBox.editableBackground Color optional; defaults to ComboBox.background
* @uiDefault ComboBox.focusedBackground Color optional
* @uiDefault ComboBox.disabledBackground Color
@@ -104,6 +102,8 @@ import com.formdev.flatlaf.util.SystemInfo;
* @uiDefault ComboBox.buttonBackground Color
* @uiDefault ComboBox.buttonEditableBackground Color
* @uiDefault ComboBox.buttonFocusedBackground Color optional; defaults to ComboBox.focusedBackground
* @uiDefault ComboBox.buttonSeparatorColor Color optional
* @uiDefault ComboBox.buttonDisabledSeparatorColor Color optional
* @uiDefault ComboBox.buttonArrowColor Color
* @uiDefault ComboBox.buttonDisabledArrowColor Color
* @uiDefault ComboBox.buttonHoverArrowColor Color
@@ -121,8 +121,6 @@ public class FlatComboBoxUI
@Styleable protected String buttonStyle;
@Styleable protected String arrowType;
protected boolean isIntelliJTheme;
@Styleable protected Color borderColor;
@Styleable protected Color disabledBorderColor;
@Styleable protected Color editableBackground;
@Styleable protected Color focusedBackground;
@@ -132,6 +130,8 @@ public class FlatComboBoxUI
@Styleable protected Color buttonBackground;
@Styleable protected Color buttonEditableBackground;
@Styleable protected Color buttonFocusedBackground;
/** @since 2 */ @Styleable protected Color buttonSeparatorColor;
/** @since 2 */ @Styleable protected Color buttonDisabledSeparatorColor;
@Styleable protected Color buttonArrowColor;
@Styleable protected Color buttonDisabledArrowColor;
@Styleable protected Color buttonHoverArrowColor;
@@ -215,8 +215,6 @@ public class FlatComboBoxUI
buttonStyle = UIManager.getString( "ComboBox.buttonStyle" );
arrowType = UIManager.getString( "Component.arrowType" );
isIntelliJTheme = UIManager.getBoolean( "Component.isIntelliJTheme" );
borderColor = UIManager.getColor( "Component.borderColor" );
disabledBorderColor = UIManager.getColor( "Component.disabledBorderColor" );
editableBackground = UIManager.getColor( "ComboBox.editableBackground" );
focusedBackground = UIManager.getColor( "ComboBox.focusedBackground" );
@@ -226,6 +224,8 @@ public class FlatComboBoxUI
buttonBackground = UIManager.getColor( "ComboBox.buttonBackground" );
buttonFocusedBackground = UIManager.getColor( "ComboBox.buttonFocusedBackground" );
buttonEditableBackground = UIManager.getColor( "ComboBox.buttonEditableBackground" );
buttonSeparatorColor = UIManager.getColor( "ComboBox.buttonSeparatorColor" );
buttonDisabledSeparatorColor = UIManager.getColor( "ComboBox.buttonDisabledSeparatorColor" );
buttonArrowColor = UIManager.getColor( "ComboBox.buttonArrowColor" );
buttonDisabledArrowColor = UIManager.getColor( "ComboBox.buttonDisabledArrowColor" );
buttonHoverArrowColor = UIManager.getColor( "ComboBox.buttonHoverArrowColor" );
@@ -247,9 +247,6 @@ public class FlatComboBoxUI
protected void uninstallDefaults() {
super.uninstallDefaults();
borderColor = null;
disabledBorderColor = null;
editableBackground = null;
focusedBackground = null;
disabledBackground = null;
@@ -258,6 +255,8 @@ public class FlatComboBoxUI
buttonBackground = null;
buttonEditableBackground = null;
buttonFocusedBackground = null;
buttonSeparatorColor = null;
buttonDisabledSeparatorColor = null;
buttonArrowColor = null;
buttonDisabledArrowColor = null;
buttonHoverArrowColor = null;
@@ -555,10 +554,13 @@ public class FlatComboBoxUI
// paint vertical line between value and arrow button
if( paintButton ) {
g2.setColor( enabled ? borderColor : disabledBorderColor );
float lw = scale( 1f );
float lx = isLeftToRight ? arrowX : arrowX + arrowWidth - lw;
g2.fill( new Rectangle2D.Float( lx, focusWidth, lw, height - 1 - (focusWidth * 2)) );
Color separatorColor = enabled ? buttonSeparatorColor : buttonDisabledSeparatorColor;
if( separatorColor != null ) {
g2.setColor( separatorColor );
float lw = scale( 1f );
float lx = isLeftToRight ? arrowX : arrowX + arrowWidth - lw;
g2.fill( new Rectangle2D.Float( lx, focusWidth, lw, height - 1 - (focusWidth * 2)) );
}
}
}

View File

@@ -68,12 +68,12 @@ import com.formdev.flatlaf.util.LoggingFacade;
* @uiDefault Spinner.buttonStyle String button (default) or none
* @uiDefault Component.arrowType String chevron (default) or triangle
* @uiDefault Component.isIntelliJTheme boolean
* @uiDefault Component.borderColor Color
* @uiDefault Component.disabledBorderColor Color
* @uiDefault Spinner.disabledBackground Color
* @uiDefault Spinner.disabledForeground Color
* @uiDefault Spinner.focusedBackground Color optional
* @uiDefault Spinner.buttonBackground Color
* @uiDefault Spinner.buttonSeparatorColor Color optional
* @uiDefault Spinner.buttonDisabledSeparatorColor Color optional
* @uiDefault Spinner.buttonArrowColor Color
* @uiDefault Spinner.buttonDisabledArrowColor Color
* @uiDefault Spinner.buttonHoverArrowColor Color
@@ -92,12 +92,12 @@ public class FlatSpinnerUI
@Styleable protected String buttonStyle;
@Styleable protected String arrowType;
protected boolean isIntelliJTheme;
@Styleable protected Color borderColor;
@Styleable protected Color disabledBorderColor;
@Styleable protected Color disabledBackground;
@Styleable protected Color disabledForeground;
@Styleable protected Color focusedBackground;
@Styleable protected Color buttonBackground;
/** @since 2 */ @Styleable protected Color buttonSeparatorColor;
/** @since 2 */ @Styleable protected Color buttonDisabledSeparatorColor;
@Styleable protected Color buttonArrowColor;
@Styleable protected Color buttonDisabledArrowColor;
@Styleable protected Color buttonHoverArrowColor;
@@ -128,12 +128,12 @@ public class FlatSpinnerUI
buttonStyle = UIManager.getString( "Spinner.buttonStyle" );
arrowType = UIManager.getString( "Component.arrowType" );
isIntelliJTheme = UIManager.getBoolean( "Component.isIntelliJTheme" );
borderColor = UIManager.getColor( "Component.borderColor" );
disabledBorderColor = UIManager.getColor( "Component.disabledBorderColor" );
disabledBackground = UIManager.getColor( "Spinner.disabledBackground" );
disabledForeground = UIManager.getColor( "Spinner.disabledForeground" );
focusedBackground = UIManager.getColor( "Spinner.focusedBackground" );
buttonBackground = UIManager.getColor( "Spinner.buttonBackground" );
buttonSeparatorColor = UIManager.getColor( "Spinner.buttonSeparatorColor" );
buttonDisabledSeparatorColor = UIManager.getColor( "Spinner.buttonDisabledSeparatorColor" );
buttonArrowColor = UIManager.getColor( "Spinner.buttonArrowColor" );
buttonDisabledArrowColor = UIManager.getColor( "Spinner.buttonDisabledArrowColor" );
buttonHoverArrowColor = UIManager.getColor( "Spinner.buttonHoverArrowColor" );
@@ -147,12 +147,12 @@ public class FlatSpinnerUI
protected void uninstallDefaults() {
super.uninstallDefaults();
borderColor = null;
disabledBorderColor = null;
disabledBackground = null;
disabledForeground = null;
focusedBackground = null;
buttonBackground = null;
buttonSeparatorColor = null;
buttonDisabledSeparatorColor = null;
buttonArrowColor = null;
buttonDisabledArrowColor = null;
buttonHoverArrowColor = null;
@@ -394,10 +394,13 @@ public class FlatSpinnerUI
}
// paint vertical line between value and arrow buttons
g2.setColor( enabled ? borderColor : disabledBorderColor );
float lw = scale( 1f );
float lx = isLeftToRight ? arrowX : arrowX + arrowWidth - lw;
g2.fill( new Rectangle2D.Float( lx, focusWidth, lw, height - 1 - (focusWidth * 2) ) );
Color separatorColor = enabled ? buttonSeparatorColor : buttonDisabledSeparatorColor;
if( separatorColor != null ) {
g2.setColor( separatorColor );
float lw = scale( 1f );
float lx = isLeftToRight ? arrowX : arrowX + arrowWidth - lw;
g2.fill( new Rectangle2D.Float( lx, focusWidth, lw, height - 1 - (focusWidth * 2) ) );
}
}
paint( g, c );

View File

@@ -214,6 +214,8 @@ ComboBox.maximumRowCount = 15
ComboBox.buttonStyle = auto
ComboBox.background = @textComponentBackground
ComboBox.buttonBackground = @textComponentBackground
ComboBox.buttonSeparatorColor = $Component.borderColor
ComboBox.buttonDisabledSeparatorColor = $Component.disabledBorderColor
ComboBox.buttonArrowColor = @buttonArrowColor
ComboBox.buttonDisabledArrowColor = @buttonDisabledArrowColor
ComboBox.buttonHoverArrowColor = @buttonHoverArrowColor
@@ -547,6 +549,8 @@ Slider.focusWidth = 4
Spinner.border = com.formdev.flatlaf.ui.FlatRoundBorder
Spinner.background = @textComponentBackground
Spinner.buttonBackground = $ComboBox.buttonEditableBackground
Spinner.buttonSeparatorColor = $Component.borderColor
Spinner.buttonDisabledSeparatorColor = $Component.disabledBorderColor
Spinner.buttonArrowColor = @buttonArrowColor
Spinner.buttonDisabledArrowColor = @buttonDisabledArrowColor
Spinner.buttonHoverArrowColor = @buttonHoverArrowColor

View File

@@ -151,8 +151,6 @@ public class TestFlatStyleableInfo
"editorColumns", int.class,
"buttonStyle", String.class,
"arrowType", String.class,
"borderColor", Color.class,
"disabledBorderColor", Color.class,
"editableBackground", Color.class,
"focusedBackground", Color.class,
@@ -162,6 +160,8 @@ public class TestFlatStyleableInfo
"buttonBackground", Color.class,
"buttonFocusedBackground", Color.class,
"buttonEditableBackground", Color.class,
"buttonSeparatorColor", Color.class,
"buttonDisabledSeparatorColor", Color.class,
"buttonArrowColor", Color.class,
"buttonDisabledArrowColor", Color.class,
"buttonHoverArrowColor", Color.class,
@@ -598,12 +598,12 @@ public class TestFlatStyleableInfo
"minimumWidth", int.class,
"buttonStyle", String.class,
"arrowType", String.class,
"borderColor", Color.class,
"disabledBorderColor", Color.class,
"disabledBackground", Color.class,
"disabledForeground", Color.class,
"focusedBackground", Color.class,
"buttonBackground", Color.class,
"buttonSeparatorColor", Color.class,
"buttonDisabledSeparatorColor", Color.class,
"buttonArrowColor", Color.class,
"buttonDisabledArrowColor", Color.class,
"buttonHoverArrowColor", Color.class,

View File

@@ -236,8 +236,6 @@ public class TestFlatStyling
ui.applyStyle( "editorColumns: 10" );
ui.applyStyle( "buttonStyle: auto" );
ui.applyStyle( "arrowType: chevron" );
ui.applyStyle( "borderColor: #fff" );
ui.applyStyle( "disabledBorderColor: #fff" );
ui.applyStyle( "editableBackground: #fff" );
ui.applyStyle( "focusedBackground: #fff" );
@@ -247,6 +245,8 @@ public class TestFlatStyling
ui.applyStyle( "buttonBackground: #fff" );
ui.applyStyle( "buttonFocusedBackground: #fff" );
ui.applyStyle( "buttonEditableBackground: #fff" );
ui.applyStyle( "buttonSeparatorColor: #fff" );
ui.applyStyle( "buttonDisabledSeparatorColor: #fff" );
ui.applyStyle( "buttonArrowColor: #fff" );
ui.applyStyle( "buttonDisabledArrowColor: #fff" );
ui.applyStyle( "buttonHoverArrowColor: #fff" );
@@ -702,12 +702,12 @@ public class TestFlatStyling
ui.applyStyle( "minimumWidth: 100" );
ui.applyStyle( "buttonStyle: button" );
ui.applyStyle( "arrowType: chevron" );
ui.applyStyle( "borderColor: #fff" );
ui.applyStyle( "disabledBorderColor: #fff" );
ui.applyStyle( "disabledBackground: #fff" );
ui.applyStyle( "disabledForeground: #fff" );
ui.applyStyle( "focusedBackground: #fff" );
ui.applyStyle( "buttonBackground: #fff" );
ui.applyStyle( "buttonSeparatorColor: #fff" );
ui.applyStyle( "buttonDisabledSeparatorColor: #fff" );
ui.applyStyle( "buttonArrowColor: #fff" );
ui.applyStyle( "buttonDisabledArrowColor: #fff" );
ui.applyStyle( "buttonHoverArrowColor: #fff" );