mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 14:00:55 +03:00
CheckBox and RadioButton: added RadioButton.icon.style (similar to CheckBox.icon.style) to support different styles for checkbox and radiobutton
(e.g. Material design uses filled checkboxes, but outlined radiobuttons)
This commit is contained in:
@@ -86,7 +86,7 @@ import com.formdev.flatlaf.ui.FlatUIUtils;
|
||||
public class FlatCheckBoxIcon
|
||||
extends FlatAbstractIcon
|
||||
{
|
||||
protected final String style = UIManager.getString( "CheckBox.icon.style" );
|
||||
protected final String style = UIManager.getString( getPropertyPrefix() + "icon.style" );
|
||||
@Styleable protected float focusWidth = getUIFloat( "CheckBox.icon.focusWidth", UIManager.getInt( "Component.focusWidth" ), style );
|
||||
@Styleable protected Color focusColor = FlatUIUtils.getUIColor( "CheckBox.icon.focusColor", UIManager.getColor( "Component.focusColor" ) );
|
||||
/** @since 2 */ @Styleable protected float borderWidth = getUIFloat( "CheckBox.icon.borderWidth", FlatUIUtils.getUIFloat( "Component.borderWidth", 1 ), style );
|
||||
@@ -129,6 +129,10 @@ public class FlatCheckBoxIcon
|
||||
/** @since 2 */ @Styleable protected Color pressedSelectedBackground = getUIColor( "CheckBox.icon.pressedSelectedBackground", style );
|
||||
/** @since 2 */ @Styleable protected Color pressedCheckmarkColor = getUIColor( "CheckBox.icon.pressedCheckmarkColor", style );
|
||||
|
||||
protected String getPropertyPrefix() {
|
||||
return "CheckBox.";
|
||||
}
|
||||
|
||||
protected static Color getUIColor( String key, String style ) {
|
||||
if( style != null ) {
|
||||
Color color = UIManager.getColor( styleKey( key, style ) );
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.formdev.flatlaf.ui.FlatStylingSupport.Styleable;
|
||||
* is painted outside of the icon bounds. Make sure that the radiobutton
|
||||
* has margins, which are equal or greater than focusWidth.
|
||||
*
|
||||
* @uiDefault RadioButton.icon.style String optional; "outlined"/null (default) or "filled"
|
||||
* @uiDefault RadioButton.icon.centerDiameter int or float
|
||||
*
|
||||
* @author Karl Tauber
|
||||
@@ -38,6 +39,11 @@ public class FlatRadioButtonIcon
|
||||
{
|
||||
@Styleable protected float centerDiameter = getUIFloat( "RadioButton.icon.centerDiameter", 8, style );
|
||||
|
||||
@Override
|
||||
protected String getPropertyPrefix() {
|
||||
return "RadioButton.";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintFocusBorder( Component c, Graphics2D g ) {
|
||||
// the outer focus border is painted outside of the icon
|
||||
|
||||
@@ -155,7 +155,7 @@ CheckBox.icon.pressedBorderColor = $CheckBox.icon.focusedBorderColor
|
||||
CheckBox.icon.pressedBackground = lighten($CheckBox.icon.background,6%,derived)
|
||||
|
||||
|
||||
# used if CheckBox.icon.style = filled
|
||||
# used if CheckBox.icon.style or RadioButton.icon.style = filled
|
||||
# enabled
|
||||
CheckBox.icon[filled].selectedBorderColor = $CheckBox.icon.checkmarkColor
|
||||
CheckBox.icon[filled].selectedBackground = $CheckBox.icon.checkmarkColor
|
||||
|
||||
@@ -64,3 +64,8 @@ Component.focusWidth = 2
|
||||
Component.innerFocusWidth = 0
|
||||
Component.innerOutlineWidth = 0
|
||||
Component.arrowType = triangle
|
||||
|
||||
|
||||
#---- RadioButton ----
|
||||
|
||||
RadioButton.icon.style = filled
|
||||
|
||||
@@ -158,7 +158,7 @@ CheckBox.icon.pressedBorderColor = $CheckBox.icon.focusedBorderColor
|
||||
CheckBox.icon.pressedBackground = darken($CheckBox.icon.background,10%,derived)
|
||||
|
||||
|
||||
# used if CheckBox.icon.style = filled
|
||||
# used if CheckBox.icon.style or RadioButton.icon.style = filled
|
||||
# enabled
|
||||
CheckBox.icon[filled].selectedBorderColor = shade($CheckBox.icon[filled].selectedBackground,5%)
|
||||
CheckBox.icon[filled].selectedBackground = @accentCheckmarkColor
|
||||
|
||||
@@ -100,6 +100,11 @@
|
||||
+ PasswordField.border [lazy] 3,3,3,3 false com.formdev.flatlaf.ui.FlatTextBorder [UI]
|
||||
|
||||
|
||||
#---- RadioButton ----
|
||||
|
||||
+ RadioButton.icon.style filled
|
||||
|
||||
|
||||
#---- ScrollPane ----
|
||||
|
||||
- ScrollPane.border [lazy] 1,1,1,1 false com.formdev.flatlaf.ui.FlatBorder [UI]
|
||||
|
||||
@@ -601,6 +601,7 @@ RadioButton.foreground
|
||||
RadioButton.highlight
|
||||
RadioButton.icon
|
||||
RadioButton.icon.centerDiameter
|
||||
RadioButton.icon.style
|
||||
RadioButton.iconTextGap
|
||||
RadioButton.icon[filled].centerDiameter
|
||||
RadioButton.light
|
||||
|
||||
Reference in New Issue
Block a user