mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-09 16:25:10 +03:00
Styling:
- support ComboBox.padding - fixed updating of Spinner.padding
This commit is contained in:
@@ -447,10 +447,15 @@ public class FlatComboBoxUI
|
||||
* @since TODO
|
||||
*/
|
||||
protected void applyStyle( Object style ) {
|
||||
Insets oldPadding = padding;
|
||||
int oldEditorColumns = editorColumns;
|
||||
|
||||
oldStyleValues = FlatStyleSupport.parseAndApply( oldStyleValues, style, this::applyStyleProperty );
|
||||
|
||||
if( !padding.equals( oldPadding ) ) {
|
||||
paddingBorder.padding = padding;
|
||||
updateEditorPadding();
|
||||
}
|
||||
if( arrowButton instanceof FlatComboBoxButton )
|
||||
((FlatComboBoxButton)arrowButton).updateStyle();
|
||||
if( popup instanceof FlatComboPopup )
|
||||
@@ -463,6 +468,13 @@ public class FlatComboBoxUI
|
||||
* @since TODO
|
||||
*/
|
||||
protected Object applyStyleProperty( String key, Object value ) {
|
||||
// BasicComboBoxUI
|
||||
if( key.equals( "padding" ) ) {
|
||||
Object oldValue = padding;
|
||||
padding = (Insets) value;
|
||||
return oldValue;
|
||||
}
|
||||
|
||||
if( borderShared == null )
|
||||
borderShared = new AtomicBoolean( true );
|
||||
return FlatStyleSupport.applyToAnnotatedObjectOrBorder( this, key, value, comboBox, borderShared );
|
||||
@@ -834,7 +846,7 @@ public class FlatComboBoxUI
|
||||
private static class CellPaddingBorder
|
||||
extends AbstractBorder
|
||||
{
|
||||
private final Insets padding;
|
||||
private Insets padding;
|
||||
private JComponent rendererComponent;
|
||||
private Border rendererBorder;
|
||||
|
||||
|
||||
@@ -192,6 +192,7 @@ public class FlatSpinnerUI
|
||||
*/
|
||||
protected void applyStyle( Object style ) {
|
||||
oldStyleValues = FlatStyleSupport.parseAndApply( oldStyleValues, style, this::applyStyleProperty );
|
||||
updateEditorPadding();
|
||||
updateArrowButtonsStyle();
|
||||
}
|
||||
|
||||
@@ -442,7 +443,6 @@ public class FlatSpinnerUI
|
||||
public void layoutContainer( Container parent ) {
|
||||
Dimension size = parent.getSize();
|
||||
Insets insets = parent.getInsets();
|
||||
Insets padding = scale( FlatSpinnerUI.this.padding );
|
||||
Rectangle r = FlatUIUtils.subtractInsets( new Rectangle( size ), insets );
|
||||
|
||||
if( nextButton == null && previousButton == null ) {
|
||||
|
||||
@@ -149,6 +149,8 @@ public class TestFlatStyling
|
||||
JComboBox<Object> c = new JComboBox<>();
|
||||
FlatComboBoxUI ui = (FlatComboBoxUI) c.getUI();
|
||||
|
||||
ui.applyStyle( "padding: 1,2,3,4" );
|
||||
|
||||
ui.applyStyle( "minimumWidth: 100" );
|
||||
ui.applyStyle( "editorColumns: 10" );
|
||||
ui.applyStyle( "buttonStyle: auto" );
|
||||
|
||||
Reference in New Issue
Block a user