mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-08 23:08:42 +03:00
SplitPane: scale one-touch buttons
This commit is contained in:
@@ -285,15 +285,15 @@ public abstract class FlatLaf
|
||||
key.endsWith( "Margins" ) || key.endsWith( "Insets" ) )
|
||||
return parseInsets( value );
|
||||
|
||||
// size
|
||||
if( key.endsWith( "Size" ) && !key.equals( "SplitPane.dividerSize" ))
|
||||
return parseSize( value );
|
||||
|
||||
// scaled number
|
||||
ScaledNumber scaledNumber = parseScaledNumber( key, value );
|
||||
if( scaledNumber != null )
|
||||
return scaledNumber;
|
||||
|
||||
// size
|
||||
if( key.endsWith( "Size" ) && !key.equals( "SplitPane.dividerSize" ))
|
||||
return parseSize( value );
|
||||
|
||||
// width, height
|
||||
if( key.endsWith( "Width" ) || key.endsWith( "Height" ) )
|
||||
return parseInteger( value, true );
|
||||
@@ -400,8 +400,10 @@ public abstract class FlatLaf
|
||||
}
|
||||
|
||||
private ScaledNumber parseScaledNumber( String key, String value ) {
|
||||
if( !key.equals( "OptionPane.buttonMinimumWidth" ) )
|
||||
return null; // not supported
|
||||
if( !key.equals( "OptionPane.buttonMinimumWidth" ) &&
|
||||
!key.equals( "SplitPane.oneTouchButtonSize" ) &&
|
||||
!key.equals( "SplitPane.oneTouchButtonOffset" ) )
|
||||
return null; // not supported
|
||||
|
||||
try {
|
||||
return new ScaledNumber( Integer.parseInt( value ) );
|
||||
|
||||
@@ -126,8 +126,16 @@ public class FlatArrowButton
|
||||
|
||||
int w = scale( chevron ? 8 : 9 );
|
||||
int h = scale( chevron ? 4 : 5 );
|
||||
int x = Math.round( (width - (vert ? w : h)) / 2f + scale( (float) xOffset ) );
|
||||
int y = Math.round( (height - (vert ? h : w)) / 2f + scale( (float) yOffset ) );
|
||||
int rw = vert ? w : h;
|
||||
int rh = vert ? h : w;
|
||||
int x = Math.round( (width - rw) / 2f + scale( (float) xOffset ) );
|
||||
int y = Math.round( (height - rh) / 2f + scale( (float) yOffset ) );
|
||||
|
||||
// optimization for small chevron arrows (e.g. OneTouchButtons in SplitPane)
|
||||
if( x + rw >= width && x > 0 )
|
||||
x--;
|
||||
if( y + rh >= height && y > 0 )
|
||||
y--;
|
||||
|
||||
// paint arrow
|
||||
g.setColor( enabled
|
||||
|
||||
@@ -307,6 +307,8 @@ SplitPane.dividerSize=5
|
||||
SplitPane.continuousLayout=true
|
||||
SplitPane.border=null
|
||||
SplitPane.centerOneTouchButtons=true
|
||||
SplitPane.oneTouchButtonSize=6
|
||||
SplitPane.oneTouchButtonOffset=2
|
||||
|
||||
SplitPaneDivider.border=null
|
||||
SplitPaneDivider.oneTouchArrowColor=@@ComboBox.buttonArrowColor
|
||||
|
||||
Reference in New Issue
Block a user