mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-09 08:15:09 +03:00
ComboBox and Spinner: support changing arrow button style (issue #114)
This commit is contained in:
@@ -12,6 +12,10 @@ FlatLaf Change Log
|
||||
- ScrollBar: Support pressed track, thumb and button colors (use UI values
|
||||
`ScrollBar.pressedTrackColor`, `ScrollBar.pressedThumbColor` and
|
||||
`ScrollBar.pressedButtonBackground`). (issue #115)
|
||||
- ComboBox: Support changing arrow button style (set UI value
|
||||
`ComboBox.buttonStyle` to `auto` (default), `button` or `none`). (issue #114)
|
||||
- Spinner: Support changing arrows button style (set UI value
|
||||
`Spinner.buttonStyle` to `button` (default) or `none`).
|
||||
- TableHeader: Support top/bottom/left positioned sort arrow when using
|
||||
[Glazed Lists](https://github.com/glazedlists/glazedlists). (issue #113)
|
||||
|
||||
|
||||
@@ -80,6 +80,7 @@ import com.formdev.flatlaf.util.UIScale;
|
||||
*
|
||||
* @uiDefault ComboBox.minimumWidth int
|
||||
* @uiDefault ComboBox.editorColumns int
|
||||
* @uiDefault ComboBox.buttonStyle String auto (default), button or none
|
||||
* @uiDefault Component.arrowType String triangle (default) or chevron
|
||||
* @uiDefault Component.isIntelliJTheme boolean
|
||||
* @uiDefault Component.borderColor Color
|
||||
@@ -100,6 +101,7 @@ public class FlatComboBoxUI
|
||||
{
|
||||
protected int minimumWidth;
|
||||
protected int editorColumns;
|
||||
protected String buttonStyle;
|
||||
protected String arrowType;
|
||||
protected boolean isIntelliJTheme;
|
||||
protected Color borderColor;
|
||||
@@ -154,6 +156,7 @@ public class FlatComboBoxUI
|
||||
|
||||
minimumWidth = UIManager.getInt( "ComboBox.minimumWidth" );
|
||||
editorColumns = UIManager.getInt( "ComboBox.editorColumns" );
|
||||
buttonStyle = UIManager.getString( "ComboBox.buttonStyle" );
|
||||
arrowType = UIManager.getString( "Component.arrowType" );
|
||||
isIntelliJTheme = UIManager.getBoolean( "Component.isIntelliJTheme" );
|
||||
borderColor = UIManager.getColor( "Component.borderColor" );
|
||||
@@ -350,6 +353,7 @@ public class FlatComboBoxUI
|
||||
int height = c.getHeight();
|
||||
int arrowX = arrowButton.getX();
|
||||
int arrowWidth = arrowButton.getWidth();
|
||||
boolean paintButton = (comboBox.isEditable() || "button".equals( buttonStyle )) && !"none".equals( buttonStyle );
|
||||
boolean enabled = comboBox.isEnabled();
|
||||
boolean isLeftToRight = comboBox.getComponentOrientation().isLeftToRight();
|
||||
|
||||
@@ -361,7 +365,7 @@ public class FlatComboBoxUI
|
||||
|
||||
// paint arrow button background
|
||||
if( enabled ) {
|
||||
g2.setColor( comboBox.isEditable() ? buttonEditableBackground : buttonBackground );
|
||||
g2.setColor( paintButton ? buttonEditableBackground : buttonBackground );
|
||||
Shape oldClip = g2.getClip();
|
||||
if( isLeftToRight )
|
||||
g2.clipRect( arrowX, 0, width - arrowX, height );
|
||||
@@ -372,7 +376,7 @@ public class FlatComboBoxUI
|
||||
}
|
||||
|
||||
// paint vertical line between value and arrow button
|
||||
if( comboBox.isEditable() ) {
|
||||
if( paintButton ) {
|
||||
g2.setColor( enabled ? borderColor : disabledBorderColor );
|
||||
float lw = scale( 1f );
|
||||
float lx = isLeftToRight ? arrowX : arrowX + arrowWidth - lw;
|
||||
|
||||
@@ -58,6 +58,7 @@ import com.formdev.flatlaf.FlatClientProperties;
|
||||
* <!-- FlatSpinnerUI -->
|
||||
*
|
||||
* @uiDefault Component.minimumWidth int
|
||||
* @uiDefault Spinner.buttonStyle String button (default) or none
|
||||
* @uiDefault Component.arrowType String triangle (default) or chevron
|
||||
* @uiDefault Component.isIntelliJTheme boolean
|
||||
* @uiDefault Component.borderColor Color
|
||||
@@ -78,6 +79,7 @@ public class FlatSpinnerUI
|
||||
private Handler handler;
|
||||
|
||||
protected int minimumWidth;
|
||||
protected String buttonStyle;
|
||||
protected String arrowType;
|
||||
protected boolean isIntelliJTheme;
|
||||
protected Color borderColor;
|
||||
@@ -101,6 +103,7 @@ public class FlatSpinnerUI
|
||||
LookAndFeel.installProperty( spinner, "opaque", false );
|
||||
|
||||
minimumWidth = UIManager.getInt( "Component.minimumWidth" );
|
||||
buttonStyle = UIManager.getString( "Spinner.buttonStyle" );
|
||||
arrowType = UIManager.getString( "Component.arrowType" );
|
||||
isIntelliJTheme = UIManager.getBoolean( "Component.isIntelliJTheme" );
|
||||
borderColor = UIManager.getColor( "Component.borderColor" );
|
||||
@@ -258,6 +261,7 @@ public class FlatSpinnerUI
|
||||
Component nextButton = getHandler().nextButton;
|
||||
int arrowX = nextButton.getX();
|
||||
int arrowWidth = nextButton.getWidth();
|
||||
boolean paintButton = !"none".equals( buttonStyle );
|
||||
boolean enabled = spinner.isEnabled();
|
||||
boolean isLeftToRight = spinner.getComponentOrientation().isLeftToRight();
|
||||
|
||||
@@ -268,7 +272,7 @@ public class FlatSpinnerUI
|
||||
FlatUIUtils.paintComponentBackground( g2, 0, 0, width, height, focusWidth, arc );
|
||||
|
||||
// paint arrow buttons background
|
||||
if( enabled ) {
|
||||
if( paintButton && enabled ) {
|
||||
g2.setColor( buttonBackground );
|
||||
Shape oldClip = g2.getClip();
|
||||
if( isLeftToRight )
|
||||
@@ -280,10 +284,12 @@ 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) ) );
|
||||
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) ) );
|
||||
}
|
||||
|
||||
paint( g, c );
|
||||
}
|
||||
|
||||
@@ -181,6 +181,7 @@ ComboBox.padding=2,6,2,6
|
||||
ComboBox.minimumWidth=72
|
||||
ComboBox.editorColumns=0
|
||||
[mac]ComboBox.showPopupOnNavigation=true
|
||||
ComboBox.buttonStyle=auto
|
||||
|
||||
|
||||
#---- Component ----
|
||||
@@ -478,6 +479,7 @@ Spinner.buttonDisabledArrowColor=$ComboBox.buttonDisabledArrowColor
|
||||
Spinner.buttonHoverArrowColor=$ComboBox.buttonHoverArrowColor
|
||||
Spinner.padding=@textComponentMargin
|
||||
Spinner.editorBorderPainted=false
|
||||
Spinner.buttonStyle=button
|
||||
|
||||
|
||||
#---- SplitPane ----
|
||||
|
||||
@@ -189,6 +189,7 @@ ComboBox.buttonEditableBackground #404445 javax.swing.plaf.ColorUIResource [U
|
||||
ComboBox.buttonHighlight #242424 javax.swing.plaf.ColorUIResource [UI]
|
||||
ComboBox.buttonHoverArrowColor #bbbbbb javax.swing.plaf.ColorUIResource [UI]
|
||||
ComboBox.buttonShadow #646464 javax.swing.plaf.ColorUIResource [UI]
|
||||
ComboBox.buttonStyle auto
|
||||
ComboBox.disabledBackground #3c3f41 javax.swing.plaf.ColorUIResource [UI]
|
||||
ComboBox.disabledForeground #777777 javax.swing.plaf.ColorUIResource [UI]
|
||||
ComboBox.editorColumns 0
|
||||
@@ -850,6 +851,7 @@ Spinner.buttonArrowColor #9a9da1 javax.swing.plaf.ColorUIResource [UI]
|
||||
Spinner.buttonBackground #404445 javax.swing.plaf.ColorUIResource [UI]
|
||||
Spinner.buttonDisabledArrowColor #585858 javax.swing.plaf.ColorUIResource [UI]
|
||||
Spinner.buttonHoverArrowColor #bbbbbb javax.swing.plaf.ColorUIResource [UI]
|
||||
Spinner.buttonStyle button
|
||||
Spinner.disabledBackground #3c3f41 javax.swing.plaf.ColorUIResource [UI]
|
||||
Spinner.disabledForeground #777777 javax.swing.plaf.ColorUIResource [UI]
|
||||
Spinner.editorAlignment 11
|
||||
|
||||
@@ -193,6 +193,7 @@ ComboBox.buttonEditableBackground #fafafa javax.swing.plaf.ColorUIResource [U
|
||||
ComboBox.buttonHighlight #ffffff javax.swing.plaf.ColorUIResource [UI]
|
||||
ComboBox.buttonHoverArrowColor #999999 javax.swing.plaf.ColorUIResource [UI]
|
||||
ComboBox.buttonShadow #c4c4c4 javax.swing.plaf.ColorUIResource [UI]
|
||||
ComboBox.buttonStyle auto
|
||||
ComboBox.disabledBackground #f2f2f2 javax.swing.plaf.ColorUIResource [UI]
|
||||
ComboBox.disabledForeground #8c8c8c javax.swing.plaf.ColorUIResource [UI]
|
||||
ComboBox.editorColumns 0
|
||||
@@ -855,6 +856,7 @@ Spinner.buttonArrowColor #666666 javax.swing.plaf.ColorUIResource [UI]
|
||||
Spinner.buttonBackground #fafafa javax.swing.plaf.ColorUIResource [UI]
|
||||
Spinner.buttonDisabledArrowColor #ababab javax.swing.plaf.ColorUIResource [UI]
|
||||
Spinner.buttonHoverArrowColor #999999 javax.swing.plaf.ColorUIResource [UI]
|
||||
Spinner.buttonStyle button
|
||||
Spinner.disabledBackground #f2f2f2 javax.swing.plaf.ColorUIResource [UI]
|
||||
Spinner.disabledForeground #8c8c8c javax.swing.plaf.ColorUIResource [UI]
|
||||
Spinner.editorAlignment 11
|
||||
|
||||
Reference in New Issue
Block a user