mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-07 06:20:53 +03:00
ComboBox: support rounded selection
This commit is contained in:
@@ -114,6 +114,9 @@ import com.formdev.flatlaf.util.SystemInfo;
|
|||||||
* @uiDefault ComboBox.buttonHoverArrowColor Color
|
* @uiDefault ComboBox.buttonHoverArrowColor Color
|
||||||
* @uiDefault ComboBox.buttonPressedArrowColor Color
|
* @uiDefault ComboBox.buttonPressedArrowColor Color
|
||||||
* @uiDefault ComboBox.popupBackground Color optional
|
* @uiDefault ComboBox.popupBackground Color optional
|
||||||
|
* @uiDefault ComboBox.popupInsets Insets
|
||||||
|
* @uiDefault ComboBox.selectionInsets Insets
|
||||||
|
* @uiDefault ComboBox.selectionArc int
|
||||||
*
|
*
|
||||||
* @author Karl Tauber
|
* @author Karl Tauber
|
||||||
*/
|
*/
|
||||||
@@ -144,6 +147,9 @@ public class FlatComboBoxUI
|
|||||||
@Styleable protected Color buttonPressedArrowColor;
|
@Styleable protected Color buttonPressedArrowColor;
|
||||||
|
|
||||||
@Styleable protected Color popupBackground;
|
@Styleable protected Color popupBackground;
|
||||||
|
/** @since 3 */ @Styleable protected Insets popupInsets;
|
||||||
|
/** @since 3 */ @Styleable protected Insets selectionInsets;
|
||||||
|
/** @since 3 */ @Styleable protected int selectionArc;
|
||||||
|
|
||||||
private MouseListener hoverListener;
|
private MouseListener hoverListener;
|
||||||
protected boolean hover;
|
protected boolean hover;
|
||||||
@@ -239,6 +245,9 @@ public class FlatComboBoxUI
|
|||||||
buttonPressedArrowColor = UIManager.getColor( "ComboBox.buttonPressedArrowColor" );
|
buttonPressedArrowColor = UIManager.getColor( "ComboBox.buttonPressedArrowColor" );
|
||||||
|
|
||||||
popupBackground = UIManager.getColor( "ComboBox.popupBackground" );
|
popupBackground = UIManager.getColor( "ComboBox.popupBackground" );
|
||||||
|
popupInsets = UIManager.getInsets( "ComboBox.popupInsets" );
|
||||||
|
selectionInsets = UIManager.getInsets( "ComboBox.selectionInsets" );
|
||||||
|
selectionArc = UIManager.getInt( "ComboBox.selectionArc" );
|
||||||
|
|
||||||
// set maximumRowCount
|
// set maximumRowCount
|
||||||
int maximumRowCount = UIManager.getInt( "ComboBox.maximumRowCount" );
|
int maximumRowCount = UIManager.getInt( "ComboBox.maximumRowCount" );
|
||||||
@@ -824,11 +833,6 @@ public class FlatComboBoxUI
|
|||||||
Border border = UIManager.getBorder( "PopupMenu.border" );
|
Border border = UIManager.getBorder( "PopupMenu.border" );
|
||||||
if( border != null )
|
if( border != null )
|
||||||
setBorder( FlatUIUtils.nonUIResource( border ) );
|
setBorder( FlatUIUtils.nonUIResource( border ) );
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void configureList() {
|
|
||||||
super.configureList();
|
|
||||||
|
|
||||||
list.setCellRenderer( new PopupListCellRenderer() );
|
list.setCellRenderer( new PopupListCellRenderer() );
|
||||||
updateStyle();
|
updateStyle();
|
||||||
@@ -842,6 +846,15 @@ public class FlatComboBoxUI
|
|||||||
// use non-UIResource to avoid that it is overwritten when making
|
// use non-UIResource to avoid that it is overwritten when making
|
||||||
// popup visible (see JPopupMenu.setInvoker()) in theme editor preview
|
// popup visible (see JPopupMenu.setInvoker()) in theme editor preview
|
||||||
setBackground( FlatUIUtils.nonUIResource( list.getBackground() ) );
|
setBackground( FlatUIUtils.nonUIResource( list.getBackground() ) );
|
||||||
|
|
||||||
|
scroller.setViewportBorder( (popupInsets != null) ? new FlatEmptyBorder( popupInsets ) : null );
|
||||||
|
scroller.setOpaque( false );
|
||||||
|
|
||||||
|
if( list.getUI() instanceof FlatListUI ) {
|
||||||
|
FlatListUI ui = (FlatListUI) list.getUI();
|
||||||
|
ui.selectionInsets = selectionInsets;
|
||||||
|
ui.selectionArc = selectionArc;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import javax.swing.ListSelectionModel;
|
|||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.event.ListSelectionListener;
|
import javax.swing.event.ListSelectionListener;
|
||||||
import javax.swing.plaf.ComponentUI;
|
import javax.swing.plaf.ComponentUI;
|
||||||
|
import javax.swing.plaf.basic.BasicComboBoxRenderer;
|
||||||
import javax.swing.plaf.basic.BasicListUI;
|
import javax.swing.plaf.basic.BasicListUI;
|
||||||
import com.formdev.flatlaf.FlatClientProperties;
|
import com.formdev.flatlaf.FlatClientProperties;
|
||||||
import com.formdev.flatlaf.ui.FlatStylingSupport.Styleable;
|
import com.formdev.flatlaf.ui.FlatStylingSupport.Styleable;
|
||||||
@@ -306,7 +307,8 @@ public class FlatListUI
|
|||||||
// rounded selection or selection insets
|
// rounded selection or selection insets
|
||||||
if( isSelected &&
|
if( isSelected &&
|
||||||
!isFileList && // rounded selection is not supported for file list
|
!isFileList && // rounded selection is not supported for file list
|
||||||
rendererComponent instanceof DefaultListCellRenderer &&
|
(rendererComponent instanceof DefaultListCellRenderer ||
|
||||||
|
rendererComponent instanceof BasicComboBoxRenderer) &&
|
||||||
(selectionArc > 0 ||
|
(selectionArc > 0 ||
|
||||||
(selectionInsets != null &&
|
(selectionInsets != null &&
|
||||||
(selectionInsets.top != 0 || selectionInsets.left != 0 || selectionInsets.bottom != 0 || selectionInsets.right != 0))) )
|
(selectionInsets.top != 0 || selectionInsets.left != 0 || selectionInsets.bottom != 0 || selectionInsets.right != 0))) )
|
||||||
|
|||||||
@@ -285,6 +285,10 @@ ComboBox.buttonDisabledArrowColor = @buttonDisabledArrowColor
|
|||||||
ComboBox.buttonHoverArrowColor = @buttonHoverArrowColor
|
ComboBox.buttonHoverArrowColor = @buttonHoverArrowColor
|
||||||
ComboBox.buttonPressedArrowColor = @buttonPressedArrowColor
|
ComboBox.buttonPressedArrowColor = @buttonPressedArrowColor
|
||||||
|
|
||||||
|
ComboBox.popupInsets = 0,0,0,0
|
||||||
|
ComboBox.selectionInsets = 0,0,0,0
|
||||||
|
ComboBox.selectionArc = 0
|
||||||
|
|
||||||
|
|
||||||
#---- Component ----
|
#---- Component ----
|
||||||
|
|
||||||
|
|||||||
@@ -173,7 +173,10 @@ public class TestFlatStyleableInfo
|
|||||||
"buttonHoverArrowColor", Color.class,
|
"buttonHoverArrowColor", Color.class,
|
||||||
"buttonPressedArrowColor", Color.class,
|
"buttonPressedArrowColor", Color.class,
|
||||||
|
|
||||||
"popupBackground", Color.class
|
"popupBackground", Color.class,
|
||||||
|
"popupInsets", Insets.class,
|
||||||
|
"selectionInsets", Insets.class,
|
||||||
|
"selectionArc", int.class
|
||||||
);
|
);
|
||||||
|
|
||||||
// border
|
// border
|
||||||
|
|||||||
@@ -304,6 +304,9 @@ public class TestFlatStyling
|
|||||||
ui.applyStyle( "buttonPressedArrowColor: #fff" );
|
ui.applyStyle( "buttonPressedArrowColor: #fff" );
|
||||||
|
|
||||||
ui.applyStyle( "popupBackground: #fff" );
|
ui.applyStyle( "popupBackground: #fff" );
|
||||||
|
ui.applyStyle( "popupInsets: 1,2,3,4" );
|
||||||
|
ui.applyStyle( "selectionInsets: 1,2,3,4" );
|
||||||
|
ui.applyStyle( "selectionArc: 8" );
|
||||||
|
|
||||||
// border
|
// border
|
||||||
flatRoundBorder( style -> ui.applyStyle( style ) );
|
flatRoundBorder( style -> ui.applyStyle( style ) );
|
||||||
|
|||||||
@@ -220,8 +220,11 @@ ComboBox.maximumRowCount 15
|
|||||||
ComboBox.minimumWidth 72
|
ComboBox.minimumWidth 72
|
||||||
ComboBox.noActionOnKeyNavigation false
|
ComboBox.noActionOnKeyNavigation false
|
||||||
ComboBox.padding 2,6,2,6 javax.swing.plaf.InsetsUIResource [UI]
|
ComboBox.padding 2,6,2,6 javax.swing.plaf.InsetsUIResource [UI]
|
||||||
|
ComboBox.popupInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI]
|
||||||
|
ComboBox.selectionArc 0
|
||||||
ComboBox.selectionBackground #4b6eaf HSL 219 40 49 javax.swing.plaf.ColorUIResource [UI]
|
ComboBox.selectionBackground #4b6eaf HSL 219 40 49 javax.swing.plaf.ColorUIResource [UI]
|
||||||
ComboBox.selectionForeground #bbbbbb HSL 0 0 73 javax.swing.plaf.ColorUIResource [UI]
|
ComboBox.selectionForeground #bbbbbb HSL 0 0 73 javax.swing.plaf.ColorUIResource [UI]
|
||||||
|
ComboBox.selectionInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI]
|
||||||
ComboBox.timeFactor 1000
|
ComboBox.timeFactor 1000
|
||||||
ComboBoxUI com.formdev.flatlaf.ui.FlatComboBoxUI
|
ComboBoxUI com.formdev.flatlaf.ui.FlatComboBoxUI
|
||||||
|
|
||||||
|
|||||||
@@ -224,8 +224,11 @@ ComboBox.maximumRowCount 15
|
|||||||
ComboBox.minimumWidth 72
|
ComboBox.minimumWidth 72
|
||||||
ComboBox.noActionOnKeyNavigation false
|
ComboBox.noActionOnKeyNavigation false
|
||||||
ComboBox.padding 2,6,2,6 javax.swing.plaf.InsetsUIResource [UI]
|
ComboBox.padding 2,6,2,6 javax.swing.plaf.InsetsUIResource [UI]
|
||||||
|
ComboBox.popupInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI]
|
||||||
|
ComboBox.selectionArc 0
|
||||||
ComboBox.selectionBackground #2675bf HSL 209 67 45 javax.swing.plaf.ColorUIResource [UI]
|
ComboBox.selectionBackground #2675bf HSL 209 67 45 javax.swing.plaf.ColorUIResource [UI]
|
||||||
ComboBox.selectionForeground #ffffff HSL 0 0 100 javax.swing.plaf.ColorUIResource [UI]
|
ComboBox.selectionForeground #ffffff HSL 0 0 100 javax.swing.plaf.ColorUIResource [UI]
|
||||||
|
ComboBox.selectionInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI]
|
||||||
ComboBox.timeFactor 1000
|
ComboBox.timeFactor 1000
|
||||||
ComboBoxUI com.formdev.flatlaf.ui.FlatComboBoxUI
|
ComboBoxUI com.formdev.flatlaf.ui.FlatComboBoxUI
|
||||||
|
|
||||||
|
|||||||
@@ -231,8 +231,11 @@ ComboBox.minimumWidth 72
|
|||||||
ComboBox.noActionOnKeyNavigation false
|
ComboBox.noActionOnKeyNavigation false
|
||||||
ComboBox.padding 2,6,2,6 javax.swing.plaf.InsetsUIResource [UI]
|
ComboBox.padding 2,6,2,6 javax.swing.plaf.InsetsUIResource [UI]
|
||||||
ComboBox.popupBackground #ffffcc HSL 60 100 90 javax.swing.plaf.ColorUIResource [UI]
|
ComboBox.popupBackground #ffffcc HSL 60 100 90 javax.swing.plaf.ColorUIResource [UI]
|
||||||
|
ComboBox.popupInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI]
|
||||||
|
ComboBox.selectionArc 0
|
||||||
ComboBox.selectionBackground #00aa00 HSL 120 100 33 javax.swing.plaf.ColorUIResource [UI]
|
ComboBox.selectionBackground #00aa00 HSL 120 100 33 javax.swing.plaf.ColorUIResource [UI]
|
||||||
ComboBox.selectionForeground #ffff00 HSL 60 100 50 javax.swing.plaf.ColorUIResource [UI]
|
ComboBox.selectionForeground #ffff00 HSL 60 100 50 javax.swing.plaf.ColorUIResource [UI]
|
||||||
|
ComboBox.selectionInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI]
|
||||||
ComboBox.timeFactor 1000
|
ComboBox.timeFactor 1000
|
||||||
ComboBoxUI com.formdev.flatlaf.ui.FlatComboBoxUI
|
ComboBoxUI com.formdev.flatlaf.ui.FlatComboBoxUI
|
||||||
|
|
||||||
|
|||||||
@@ -196,8 +196,11 @@ ComboBox.minimumWidth
|
|||||||
ComboBox.noActionOnKeyNavigation
|
ComboBox.noActionOnKeyNavigation
|
||||||
ComboBox.padding
|
ComboBox.padding
|
||||||
ComboBox.popupBackground
|
ComboBox.popupBackground
|
||||||
|
ComboBox.popupInsets
|
||||||
|
ComboBox.selectionArc
|
||||||
ComboBox.selectionBackground
|
ComboBox.selectionBackground
|
||||||
ComboBox.selectionForeground
|
ComboBox.selectionForeground
|
||||||
|
ComboBox.selectionInsets
|
||||||
ComboBox.timeFactor
|
ComboBox.timeFactor
|
||||||
ComboBoxUI
|
ComboBoxUI
|
||||||
Component.accentColor
|
Component.accentColor
|
||||||
|
|||||||
Reference in New Issue
Block a user