mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-08 15:00:54 +03:00
ToggleButton renamed toggle button type "underline" to "tab" (value of client property JButton.buttonType is now tab)
This commit is contained in:
@@ -12,7 +12,9 @@ FlatLaf Change Log
|
||||
property `JComponent.minimumHeight` to an integer). (issue #44)
|
||||
- Button and ToggleButton: Do not apply minimum width if button border was
|
||||
changed (is no longer an instance of `FlatButtonBorder`).
|
||||
- ToggleButton: No longer use focus width for underline style toggle buttons to
|
||||
- ToggleButton: Renamed toggle button type "underline" to "tab" (value of client
|
||||
property `JButton.buttonType` is now `tab`).
|
||||
- ToggleButton: No longer use focus width for tab-style toggle buttons to
|
||||
compute component size, which reduces/fixes component size in "Flat IntelliJ"
|
||||
and "Flat Darcula" themes.
|
||||
|
||||
|
||||
@@ -43,13 +43,13 @@ public interface FlatClientProperties
|
||||
String BUTTON_TYPE_SQUARE = "square";
|
||||
|
||||
/**
|
||||
* Paint the toggle button in underline style.
|
||||
* Paint the toggle button in tab style.
|
||||
* <p>
|
||||
* <strong>Components</strong> {@link javax.swing.JToggleButton}
|
||||
*
|
||||
* @see #TOGGLE_BUTTON_TYPE
|
||||
*/
|
||||
String BUTTON_TYPE_UNDERLINE = "underline";
|
||||
String BUTTON_TYPE_TAB = "tab";
|
||||
|
||||
/**
|
||||
* Paint a help button (circle with question mark).
|
||||
|
||||
@@ -445,11 +445,11 @@ public class IntelliJTheme
|
||||
for( Map.Entry<String, String> e : uiKeyMapping.entrySet() )
|
||||
uiKeyInverseMapping.put( e.getValue(), e.getKey() );
|
||||
|
||||
uiKeyCopying.put( "ToggleButton.underline.underlineColor", "TabbedPane.underlineColor" );
|
||||
uiKeyCopying.put( "ToggleButton.underline.disabledUnderlineColor", "TabbedPane.disabledUnderlineColor" );
|
||||
uiKeyCopying.put( "ToggleButton.underline.selectedBackground", "TabbedPane.selectedBackground" );
|
||||
uiKeyCopying.put( "ToggleButton.underline.hoverBackground", "TabbedPane.hoverColor" );
|
||||
uiKeyCopying.put( "ToggleButton.underline.focusBackground", "TabbedPane.focusColor" );
|
||||
uiKeyCopying.put( "ToggleButton.tab.underlineColor", "TabbedPane.underlineColor" );
|
||||
uiKeyCopying.put( "ToggleButton.tab.disabledUnderlineColor", "TabbedPane.disabledUnderlineColor" );
|
||||
uiKeyCopying.put( "ToggleButton.tab.selectedBackground", "TabbedPane.selectedBackground" );
|
||||
uiKeyCopying.put( "ToggleButton.tab.hoverBackground", "TabbedPane.hoverColor" );
|
||||
uiKeyCopying.put( "ToggleButton.tab.focusBackground", "TabbedPane.focusColor" );
|
||||
|
||||
checkboxKeyMapping.put( "Checkbox.Background.Default", "CheckBox.icon.background" );
|
||||
checkboxKeyMapping.put( "Checkbox.Background.Disabled", "CheckBox.icon.disabledBackground" );
|
||||
|
||||
@@ -65,7 +65,7 @@ public class FlatButtonBorder
|
||||
|
||||
@Override
|
||||
public void paintBorder( Component c, Graphics g, int x, int y, int width, int height ) {
|
||||
if( FlatButtonUI.isContentAreaFilled( c ) && !FlatButtonUI.isHelpButton( c ) && !FlatToggleButtonUI.isUnderlineButton( c ) )
|
||||
if( FlatButtonUI.isContentAreaFilled( c ) && !FlatButtonUI.isHelpButton( c ) && !FlatToggleButtonUI.isTabButton( c ) )
|
||||
super.paintBorder( c, g, x, y, width, height );
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public class FlatButtonBorder
|
||||
|
||||
@Override
|
||||
protected float getFocusWidth( Component c ) {
|
||||
return FlatToggleButtonUI.isUnderlineButton( c ) ? 0 : super.getFocusWidth(c );
|
||||
return FlatToggleButtonUI.isTabButton( c ) ? 0 : super.getFocusWidth(c );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -61,12 +61,12 @@ import com.formdev.flatlaf.util.UIScale;
|
||||
* @uiDefault ToggleButton.disabledSelectedBackground Color
|
||||
* @uiDefault ToggleButton.toolbar.selectedBackground Color
|
||||
*
|
||||
* @uiDefault ToggleButton.underline.underlineHeight int
|
||||
* @uiDefault ToggleButton.underline.underlineColor Color
|
||||
* @uiDefault ToggleButton.underline.disabledUnderlineColor Color
|
||||
* @uiDefault ToggleButton.underline.selectedBackground Color optional
|
||||
* @uiDefault ToggleButton.underline.hoverBackground Color
|
||||
* @uiDefault ToggleButton.underline.focusBackground Color
|
||||
* @uiDefault ToggleButton.tab.underlineHeight int
|
||||
* @uiDefault ToggleButton.tab.underlineColor Color
|
||||
* @uiDefault ToggleButton.tab.disabledUnderlineColor Color
|
||||
* @uiDefault ToggleButton.tab.selectedBackground Color optional
|
||||
* @uiDefault ToggleButton.tab.hoverBackground Color
|
||||
* @uiDefault ToggleButton.tab.focusBackground Color
|
||||
*
|
||||
*
|
||||
* @author Karl Tauber
|
||||
@@ -80,12 +80,12 @@ public class FlatToggleButtonUI
|
||||
|
||||
protected Color toolbarSelectedBackground;
|
||||
|
||||
protected int underlineHeight;
|
||||
protected Color underlineColor;
|
||||
protected Color disabledUnderlineColor;
|
||||
protected Color underlineSelectedBackground;
|
||||
protected Color underlineHoverBackground;
|
||||
protected Color underlineFocusBackground;
|
||||
protected int tabUnderlineHeight;
|
||||
protected Color tabUnderlineColor;
|
||||
protected Color tabDisabledUnderlineColor;
|
||||
protected Color tabSelectedBackground;
|
||||
protected Color tabHoverBackground;
|
||||
protected Color tabFocusBackground;
|
||||
|
||||
private boolean defaults_initialized = false;
|
||||
|
||||
@@ -113,12 +113,12 @@ public class FlatToggleButtonUI
|
||||
|
||||
toolbarSelectedBackground = UIManager.getColor( "ToggleButton.toolbar.selectedBackground" );
|
||||
|
||||
underlineHeight = UIManager.getInt( "ToggleButton.underline.underlineHeight" );
|
||||
underlineColor = UIManager.getColor( "ToggleButton.underline.underlineColor" );
|
||||
disabledUnderlineColor = UIManager.getColor( "ToggleButton.underline.disabledUnderlineColor" );
|
||||
underlineSelectedBackground = UIManager.getColor( "ToggleButton.underline.selectedBackground" );
|
||||
underlineHoverBackground = UIManager.getColor( "ToggleButton.underline.hoverBackground" );
|
||||
underlineFocusBackground = UIManager.getColor( "ToggleButton.underline.focusBackground" );
|
||||
tabUnderlineHeight = UIManager.getInt( "ToggleButton.tab.underlineHeight" );
|
||||
tabUnderlineColor = UIManager.getColor( "ToggleButton.tab.underlineColor" );
|
||||
tabDisabledUnderlineColor = UIManager.getColor( "ToggleButton.tab.disabledUnderlineColor" );
|
||||
tabSelectedBackground = UIManager.getColor( "ToggleButton.tab.selectedBackground" );
|
||||
tabHoverBackground = UIManager.getColor( "ToggleButton.tab.hoverBackground" );
|
||||
tabFocusBackground = UIManager.getColor( "ToggleButton.tab.focusBackground" );
|
||||
|
||||
defaults_initialized = true;
|
||||
}
|
||||
@@ -136,7 +136,7 @@ public class FlatToggleButtonUI
|
||||
|
||||
switch( e.getPropertyName() ) {
|
||||
case BUTTON_TYPE:
|
||||
if( BUTTON_TYPE_UNDERLINE.equals( e.getOldValue() ) || BUTTON_TYPE_UNDERLINE.equals( e.getNewValue() ) ) {
|
||||
if( BUTTON_TYPE_TAB.equals( e.getOldValue() ) || BUTTON_TYPE_TAB.equals( e.getNewValue() ) ) {
|
||||
MigLayoutVisualPadding.uninstall( b );
|
||||
MigLayoutVisualPadding.install( b, getFocusWidth( b ) );
|
||||
b.revalidate();
|
||||
@@ -147,21 +147,21 @@ public class FlatToggleButtonUI
|
||||
}
|
||||
}
|
||||
|
||||
static boolean isUnderlineButton( Component c ) {
|
||||
return c instanceof JToggleButton && clientPropertyEquals( (JToggleButton) c, BUTTON_TYPE, BUTTON_TYPE_UNDERLINE );
|
||||
static boolean isTabButton( Component c ) {
|
||||
return c instanceof JToggleButton && clientPropertyEquals( (JToggleButton) c, BUTTON_TYPE, BUTTON_TYPE_TAB );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintBackground( Graphics g, JComponent c ) {
|
||||
if( isUnderlineButton( c ) ) {
|
||||
if( isTabButton( c ) ) {
|
||||
int height = c.getHeight();
|
||||
int width = c.getWidth();
|
||||
boolean selected = ((AbstractButton)c).isSelected();
|
||||
|
||||
// paint background
|
||||
Color background = buttonStateColor( c,
|
||||
selected ? underlineSelectedBackground : null,
|
||||
null, underlineFocusBackground, underlineHoverBackground, null );
|
||||
selected ? tabSelectedBackground : null,
|
||||
null, tabFocusBackground, tabHoverBackground, null );
|
||||
if( background != null ) {
|
||||
g.setColor( background );
|
||||
g.fillRect( 0, 0, width, height );
|
||||
@@ -169,8 +169,8 @@ public class FlatToggleButtonUI
|
||||
|
||||
// paint underline if selected
|
||||
if( selected ) {
|
||||
int underlineHeight = UIScale.scale( this.underlineHeight );
|
||||
g.setColor( c.isEnabled() ? underlineColor : disabledUnderlineColor );
|
||||
int underlineHeight = UIScale.scale( tabUnderlineHeight );
|
||||
g.setColor( c.isEnabled() ? tabUnderlineColor : tabDisabledUnderlineColor );
|
||||
g.fillRect( 0, height - underlineHeight, width, underlineHeight );
|
||||
}
|
||||
} else
|
||||
@@ -207,6 +207,6 @@ public class FlatToggleButtonUI
|
||||
|
||||
@Override
|
||||
protected int getFocusWidth( JComponent c ) {
|
||||
return isUnderlineButton( c ) ? 0 : super.getFocusWidth( c );
|
||||
return isTabButton( c ) ? 0 : super.getFocusWidth( c );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -439,13 +439,13 @@ ToggleButton.pressedBackground=$Button.pressedBackground
|
||||
ToggleButton.toolbar.hoverBackground=$Button.toolbar.hoverBackground
|
||||
ToggleButton.toolbar.pressedBackground=$Button.toolbar.pressedBackground
|
||||
|
||||
# button type "underline"
|
||||
ToggleButton.underline.underlineHeight=2
|
||||
ToggleButton.underline.underlineColor=$TabbedPane.underlineColor
|
||||
ToggleButton.underline.disabledUnderlineColor=$TabbedPane.disabledUnderlineColor
|
||||
ToggleButton.underline.selectedBackground=$?TabbedPane.selectedBackground
|
||||
ToggleButton.underline.hoverBackground=$TabbedPane.hoverColor
|
||||
ToggleButton.underline.focusBackground=$TabbedPane.focusColor
|
||||
# button type "tab"
|
||||
ToggleButton.tab.underlineHeight=2
|
||||
ToggleButton.tab.underlineColor=$TabbedPane.underlineColor
|
||||
ToggleButton.tab.disabledUnderlineColor=$TabbedPane.disabledUnderlineColor
|
||||
ToggleButton.tab.selectedBackground=$?TabbedPane.selectedBackground
|
||||
ToggleButton.tab.hoverBackground=$TabbedPane.hoverColor
|
||||
ToggleButton.tab.focusBackground=$TabbedPane.focusColor
|
||||
|
||||
|
||||
#---- ToolBar ----
|
||||
|
||||
@@ -344,14 +344,14 @@ public class FlatComponentsTest
|
||||
add(toggleButton4, "cell 4 2");
|
||||
|
||||
//---- toggleButton5 ----
|
||||
toggleButton5.setText("underline");
|
||||
toggleButton5.putClientProperty("JButton.buttonType", "underline");
|
||||
toggleButton5.setText("tab");
|
||||
toggleButton5.putClientProperty("JButton.buttonType", "tab");
|
||||
toggleButton5.setSelected(true);
|
||||
add(toggleButton5, "cell 5 2");
|
||||
|
||||
//---- toggleButton8 ----
|
||||
toggleButton8.setText("underline");
|
||||
toggleButton8.putClientProperty("JButton.buttonType", "underline");
|
||||
toggleButton8.setText("tab");
|
||||
toggleButton8.putClientProperty("JButton.buttonType", "tab");
|
||||
toggleButton8.setEnabled(false);
|
||||
toggleButton8.setSelected(true);
|
||||
add(toggleButton8, "cell 5 2");
|
||||
|
||||
@@ -171,16 +171,16 @@ new FormModel {
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JToggleButton" ) {
|
||||
name: "toggleButton5"
|
||||
"text": "underline"
|
||||
"$client.JButton.buttonType": "underline"
|
||||
"text": "tab"
|
||||
"$client.JButton.buttonType": "tab"
|
||||
"selected": true
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 5 2"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JToggleButton" ) {
|
||||
name: "toggleButton8"
|
||||
"text": "underline"
|
||||
"$client.JButton.buttonType": "underline"
|
||||
"text": "tab"
|
||||
"$client.JButton.buttonType": "tab"
|
||||
"enabled": false
|
||||
"selected": true
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
|
||||
Reference in New Issue
Block a user