Spinner: reduced gap between up and down arrows, which was increased by previous commit (issue #329)

This commit is contained in:
Karl Tauber
2021-06-30 18:57:54 +02:00
parent 5318d5fa8e
commit 4f9b819f48
6 changed files with 119 additions and 35 deletions

View File

@@ -48,8 +48,8 @@ public class FlatArrowButton
protected final Color pressedBackground;
private int arrowWidth = DEFAULT_ARROW_WIDTH;
private int xOffset = 0;
private int yOffset = 0;
private float xOffset = 0;
private float yOffset = 0;
private boolean hover;
private boolean pressed;
@@ -117,19 +117,19 @@ public class FlatArrowButton
return pressed;
}
public int getXOffset() {
public float getXOffset() {
return xOffset;
}
public void setXOffset( int xOffset ) {
public void setXOffset( float xOffset ) {
this.xOffset = xOffset;
}
public int getYOffset() {
public float getYOffset() {
return yOffset;
}
public void setYOffset( int yOffset ) {
public void setYOffset( float yOffset ) {
this.yOffset = yOffset;
}

View File

@@ -276,7 +276,7 @@ public class FlatSpinnerUI
FlatArrowButton button = new FlatArrowButton( direction, arrowType, buttonArrowColor,
buttonDisabledArrowColor, buttonHoverArrowColor, null, buttonPressedArrowColor, null );
button.setName( name );
button.setYOffset( (direction == SwingConstants.NORTH) ? 1 : -1 );
button.setYOffset( (direction == SwingConstants.NORTH) ? 1.25f : -1.25f );
if( direction == SwingConstants.NORTH )
installNextButtonListeners( button );
else

View File

@@ -660,7 +660,7 @@ public class FlatUIUtils
* @since 1.1
*/
public static void paintArrow( Graphics2D g, int x, int y, int width, int height,
int direction, boolean chevron, int arrowSize, int xOffset, int yOffset )
int direction, boolean chevron, int arrowSize, float xOffset, float yOffset )
{
// compute arrow width/height
int aw = UIScale.scale( arrowSize + (chevron ? 0 : 1) );
@@ -679,8 +679,8 @@ public class FlatUIUtils
int extra = chevron ? 1 : 0;
// compute arrow location
float ox = ((width - (aw + extra)) / 2f) + UIScale.scale( (float) xOffset );
float oy = ((height - (ah + extra)) / 2f) + UIScale.scale( (float) yOffset );
float ox = ((width - (aw + extra)) / 2f) + UIScale.scale( xOffset );
float oy = ((height - (ah + extra)) / 2f) + UIScale.scale( yOffset );
int ax = x + ((direction == SwingConstants.WEST) ? -Math.round( -ox ) : Math.round( ox ));
int ay = y + ((direction == SwingConstants.NORTH) ? -Math.round( -oy ) : Math.round( oy ));