InternalFrame: made buttons larger and square (issue #39)

This commit is contained in:
Karl Tauber
2020-02-02 17:12:34 +01:00
parent 10695ff51b
commit 5853bd4a96
8 changed files with 23 additions and 18 deletions

View File

@@ -18,6 +18,7 @@ package com.formdev.flatlaf.icons;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics2D;
import javax.swing.UIManager;
import com.formdev.flatlaf.ui.FlatButtonUI;
@@ -28,7 +29,6 @@ import com.formdev.flatlaf.ui.FlatUIUtils;
*
* @uiDefault InternalFrame.buttonHoverBackground Color
* @uiDefault InternalFrame.buttonPressedBackground Color
* @uiDefault Button.arc int
*
* @author Karl Tauber
*/
@@ -37,15 +37,15 @@ public abstract class FlatInternalFrameAbstractIcon
{
private final Color hoverBackground;
private final Color pressedBackground;
private final int arc = UIManager.getInt( "Button.arc" );
public FlatInternalFrameAbstractIcon() {
this( UIManager.getColor( "InternalFrame.buttonHoverBackground" ),
this( UIManager.getDimension( "InternalFrame.buttonSize" ),
UIManager.getColor( "InternalFrame.buttonHoverBackground" ),
UIManager.getColor( "InternalFrame.buttonPressedBackground" ) );
}
public FlatInternalFrameAbstractIcon( Color hoverBackground, Color pressedBackground ) {
super( 16, 16, null );
public FlatInternalFrameAbstractIcon( Dimension size, Color hoverBackground, Color pressedBackground ) {
super( size.width, size.height, null );
this.hoverBackground = hoverBackground;
this.pressedBackground = pressedBackground;
}
@@ -54,7 +54,7 @@ public abstract class FlatInternalFrameAbstractIcon
Color background = FlatButtonUI.buttonStateColor( c, null, null, null, hoverBackground, pressedBackground );
if( background != null ) {
FlatUIUtils.setColor( g, background, c.getBackground() );
g.fillRoundRect( 0, 0, width, height, arc, arc );
g.fillRect( 0, 0, width, height );
}
}
}

View File

@@ -40,7 +40,8 @@ public class FlatInternalFrameCloseIcon
private final Color pressedForeground = UIManager.getColor( "InternalFrame.closePressedForeground" );
public FlatInternalFrameCloseIcon() {
super( UIManager.getColor( "InternalFrame.closeHoverBackground" ),
super( UIManager.getDimension( "InternalFrame.buttonSize" ),
UIManager.getColor( "InternalFrame.closeHoverBackground" ),
UIManager.getColor( "InternalFrame.closePressedBackground" ) );
}
@@ -50,8 +51,8 @@ public class FlatInternalFrameCloseIcon
g.setColor( FlatButtonUI.buttonStateColor( c, null, null, null, hoverForeground, pressedForeground ) );
float mx = 8;
float my = 8;
float mx = width / 2;
float my = height / 2;
float r = 3.25f;
Path2D path = new Path2D.Float( Path2D.WIND_EVEN_ODD );

View File

@@ -35,6 +35,6 @@ public class FlatInternalFrameIconifyIcon
paintBackground( c, g );
g.setColor( c.getForeground() );
g.fillRect( 4, 8, 8, 1 );
g.fillRect( (width / 2) - 4, height / 2, 8, 1 );
}
}

View File

@@ -36,6 +36,6 @@ public class FlatInternalFrameMaximizeIcon
paintBackground( c, g );
g.setColor( c.getForeground() );
g.fill( FlatUIUtils.createRectangle( 4, 4, 8, 8, 1 ) );
g.fill( FlatUIUtils.createRectangle( (width / 2) - 4, (height / 2) - 4, 8, 8, 1 ) );
}
}

View File

@@ -40,11 +40,13 @@ public class FlatInternalFrameMinimizeIcon
g.setColor( c.getForeground() );
Path2D r1 = FlatUIUtils.createRectangle( 5, 3, 8, 8, 1 );
Path2D r2 = FlatUIUtils.createRectangle( 3, 5, 8, 8, 1 );
int x = (width / 2) - 4;
int y = (height / 2) - 4;
Path2D r1 = FlatUIUtils.createRectangle( x + 1, y - 1, 8, 8, 1 );
Path2D r2 = FlatUIUtils.createRectangle( x - 1, y + 1, 8, 8, 1 );
Area area = new Area( r1 );
area.subtract( new Area( new Rectangle2D.Float( 3, 5, 8, 8 ) ) );
area.subtract( new Area( new Rectangle2D.Float( x - 1, y + 1, 8, 8 ) ) );
g.fill( area );
g.fill( r2 );

View File

@@ -50,9 +50,10 @@ public class FlatEmptyBorder
@Override
public Insets getBorderInsets( Component c, Insets insets ) {
insets.left = scale( left );
boolean leftToRight = left == right || c.getComponentOrientation().isLeftToRight();
insets.left = scale( leftToRight ? left : right );
insets.top = scale( top );
insets.right = scale( right );
insets.right = scale( leftToRight ? right : left );
insets.bottom = scale( bottom );
return insets;
}

View File

@@ -205,6 +205,7 @@ HelpButton.disabledQuestionMarkColor=$CheckBox.icon.disabledCheckmarkColor
InternalFrame.border=com.formdev.flatlaf.ui.FlatInternalFrameUI$FlatInternalFrameBorder
InternalFrame.borderLineWidth=1
InternalFrame.borderMargins=6,6,6,6
InternalFrame.buttonSize=24,24
InternalFrame.closeIcon=com.formdev.flatlaf.icons.FlatInternalFrameCloseIcon
InternalFrame.iconifyIcon=com.formdev.flatlaf.icons.FlatInternalFrameIconifyIcon
InternalFrame.maximizeIcon=com.formdev.flatlaf.icons.FlatInternalFrameMaximizeIcon
@@ -213,7 +214,7 @@ InternalFrame.minimizeIcon=com.formdev.flatlaf.icons.FlatInternalFrameMinimizeIc
#---- InternalFrameTitlePane ----
InternalFrameTitlePane.border=4,8,4,4
InternalFrameTitlePane.border=0,8,0,0
#---- List ----

View File

@@ -150,7 +150,7 @@ InternalFrame.inactiveTitleForeground=#afa
InternalFrame.activeBorderColor=#f00
InternalFrame.inactiveBorderColor=#0f0
InternalFrame.buttonHoverBackground=#080
InternalFrame.buttonHoverBackground=#060
InternalFrame.buttonPressedBackground=#0a0
InternalFrame.closeHoverBackground=#008
InternalFrame.closePressedBackground=#00f