mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-11 06:27:13 -06:00
ToolBar: added styling properties separatorWidth and separatorColor
This commit is contained in:
@@ -3,6 +3,10 @@ FlatLaf Change Log
|
|||||||
|
|
||||||
## 3.3-SNAPSHOT
|
## 3.3-SNAPSHOT
|
||||||
|
|
||||||
|
#### New features and improvements
|
||||||
|
|
||||||
|
- ToolBar: Added styling properties `separatorWidth` and `separatorColor`.
|
||||||
|
|
||||||
#### Fixed bugs
|
#### Fixed bugs
|
||||||
|
|
||||||
- Button and ToggleButton: Selected buttons did not use explicitly set
|
- Button and ToggleButton: Selected buttons did not use explicitly set
|
||||||
@@ -188,7 +192,6 @@ FlatLaf Change Log
|
|||||||
- Windows DLLs are now digitally signed with FormDev Software GmbH
|
- Windows DLLs are now digitally signed with FormDev Software GmbH
|
||||||
certificate.
|
certificate.
|
||||||
|
|
||||||
|
|
||||||
#### Fixed bugs
|
#### Fixed bugs
|
||||||
|
|
||||||
- FlatLaf window decorations:
|
- FlatLaf window decorations:
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package com.formdev.flatlaf.ui;
|
|||||||
|
|
||||||
import static com.formdev.flatlaf.util.UIScale.scale;
|
import static com.formdev.flatlaf.util.UIScale.scale;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
import java.awt.Container;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
@@ -173,6 +174,12 @@ public class FlatToolBarSeparatorUI
|
|||||||
if( size != null )
|
if( size != null )
|
||||||
return scale( size );
|
return scale( size );
|
||||||
|
|
||||||
|
// get separator width
|
||||||
|
int separatorWidth = this.separatorWidth;
|
||||||
|
FlatToolBarUI toolBarUI = getToolBarUI( c );
|
||||||
|
if( toolBarUI != null && toolBarUI.separatorWidth != null )
|
||||||
|
separatorWidth = toolBarUI.separatorWidth;
|
||||||
|
|
||||||
// make sure that gap on left and right side of line have same size
|
// make sure that gap on left and right side of line have same size
|
||||||
int sepWidth = (scale( (separatorWidth - LINE_WIDTH) / 2 ) * 2) + scale( LINE_WIDTH );
|
int sepWidth = (scale( (separatorWidth - LINE_WIDTH) / 2 ) * 2) + scale( LINE_WIDTH );
|
||||||
|
|
||||||
@@ -196,6 +203,12 @@ public class FlatToolBarSeparatorUI
|
|||||||
float lineWidth = scale( 1f );
|
float lineWidth = scale( 1f );
|
||||||
float offset = scale( 2f );
|
float offset = scale( 2f );
|
||||||
|
|
||||||
|
// get separator color
|
||||||
|
Color separatorColor = this.separatorColor;
|
||||||
|
FlatToolBarUI toolBarUI = getToolBarUI( c );
|
||||||
|
if( toolBarUI != null && toolBarUI.separatorColor != null )
|
||||||
|
separatorColor = toolBarUI.separatorColor;
|
||||||
|
|
||||||
Object[] oldRenderingHints = FlatUIUtils.setRenderingHints( g );
|
Object[] oldRenderingHints = FlatUIUtils.setRenderingHints( g );
|
||||||
g.setColor( separatorColor );
|
g.setColor( separatorColor );
|
||||||
|
|
||||||
@@ -210,4 +223,11 @@ public class FlatToolBarSeparatorUI
|
|||||||
private boolean isVertical( JComponent c ) {
|
private boolean isVertical( JComponent c ) {
|
||||||
return ((JToolBar.Separator)c).getOrientation() == SwingConstants.VERTICAL;
|
return ((JToolBar.Separator)c).getOrientation() == SwingConstants.VERTICAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private FlatToolBarUI getToolBarUI( JComponent c ) {
|
||||||
|
Container parent = c.getParent();
|
||||||
|
return (parent instanceof JToolBar && ((JToolBar)parent).getUI() instanceof FlatToolBarUI)
|
||||||
|
? (FlatToolBarUI) ((JToolBar)parent).getUI()
|
||||||
|
: null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,6 +93,10 @@ public class FlatToolBarUI
|
|||||||
@Styleable protected Insets borderMargins;
|
@Styleable protected Insets borderMargins;
|
||||||
@Styleable protected Color gripColor;
|
@Styleable protected Color gripColor;
|
||||||
|
|
||||||
|
// for FlatToolBarSeparatorUI
|
||||||
|
/** @since 3.3 */ @Styleable protected Integer separatorWidth;
|
||||||
|
/** @since 3.3 */ @Styleable protected Color separatorColor;
|
||||||
|
|
||||||
private FocusTraversalPolicy focusTraversalPolicy;
|
private FocusTraversalPolicy focusTraversalPolicy;
|
||||||
private Boolean oldFloatable;
|
private Boolean oldFloatable;
|
||||||
private Map<String, Object> oldStyleValues;
|
private Map<String, Object> oldStyleValues;
|
||||||
|
|||||||
@@ -925,7 +925,10 @@ public class TestFlatStyleableInfo
|
|||||||
"hoverButtonGroupBackground", Color.class,
|
"hoverButtonGroupBackground", Color.class,
|
||||||
|
|
||||||
"borderMargins", Insets.class,
|
"borderMargins", Insets.class,
|
||||||
"gripColor", Color.class
|
"gripColor", Color.class,
|
||||||
|
|
||||||
|
"separatorWidth", Integer.class,
|
||||||
|
"separatorColor", Color.class
|
||||||
);
|
);
|
||||||
|
|
||||||
assertMapEquals( expected, ui.getStyleableInfos( c ) );
|
assertMapEquals( expected, ui.getStyleableInfos( c ) );
|
||||||
|
|||||||
@@ -902,6 +902,9 @@ public class TestFlatStyleableValue
|
|||||||
|
|
||||||
testInsets( c, ui, "borderMargins", 1,2,3,4 );
|
testInsets( c, ui, "borderMargins", 1,2,3,4 );
|
||||||
testColor( c, ui, "gripColor", 0x123456 );
|
testColor( c, ui, "gripColor", 0x123456 );
|
||||||
|
|
||||||
|
testInteger( c, ui, "separatorWidth", 123 );
|
||||||
|
testColor( c, ui, "separatorColor", 0x123456 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -1146,6 +1146,9 @@ public class TestFlatStyling
|
|||||||
ui.applyStyle( "borderMargins: 1,2,3,4" );
|
ui.applyStyle( "borderMargins: 1,2,3,4" );
|
||||||
ui.applyStyle( "gripColor: #fff" );
|
ui.applyStyle( "gripColor: #fff" );
|
||||||
|
|
||||||
|
ui.applyStyle( "separatorWidth: 6" );
|
||||||
|
ui.applyStyle( "separatorColor: #fff" );
|
||||||
|
|
||||||
// JComponent properties
|
// JComponent properties
|
||||||
ui.applyStyle( "background: #fff" );
|
ui.applyStyle( "background: #fff" );
|
||||||
ui.applyStyle( "foreground: #fff" );
|
ui.applyStyle( "foreground: #fff" );
|
||||||
|
|||||||
Reference in New Issue
Block a user