SplitPane: scale one-touch buttons

This commit is contained in:
Karl Tauber
2019-10-02 23:28:05 +02:00
parent 144f79f0f9
commit 2d26b6fa94
3 changed files with 20 additions and 8 deletions

View File

@@ -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 ) );

View File

@@ -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

View File

@@ -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