Browse Source

REPORT-111995 按钮组圆角

newui
Levy.Xie-解安森 11 months ago
parent
commit
0b185b6e09
  1. 53
      designer-base/src/main/java/com/fine/theme/light/ui/FineToggleButtonUI.java

53
designer-base/src/main/java/com/fine/theme/light/ui/FineToggleButtonUI.java

@ -6,6 +6,7 @@ import com.formdev.flatlaf.ui.FlatStylingSupport.Styleable;
import com.formdev.flatlaf.ui.FlatToggleButtonUI; import com.formdev.flatlaf.ui.FlatToggleButtonUI;
import com.formdev.flatlaf.ui.FlatUIUtils; import com.formdev.flatlaf.ui.FlatUIUtils;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import javax.swing.AbstractButton; import javax.swing.AbstractButton;
@ -156,29 +157,7 @@ public class FineToggleButtonUI extends FlatToggleButtonUI {
FlatUIUtils.paintComponentBackground(g2, 0, 0, c.getWidth(), c.getHeight(), focusWidth, 0); FlatUIUtils.paintComponentBackground(g2, 0, 0, c.getWidth(), c.getHeight(), focusWidth, 0);
} else { } else {
float arc = FlatUIUtils.getBorderArc( c ) / 2; float arc = FlatUIUtils.getBorderArc( c ) / 2;
Shape path2D; Shape path2D = getGroupButtonPath2D(c, position, arc);
switch (position) {
case GROUP_BUTTON_POSITION_LEFT:
path2D = FineUIUtils.createLeftRoundRectangle(0, 0, c.getWidth(), c.getHeight(), arc);
break;
case GROUP_BUTTON_POSITION_RIGHT:
path2D = FineUIUtils.createRightRoundRectangle(0, 0, c.getWidth(), c.getHeight(), arc);
break;
case GROUP_BUTTON_POSITION_LEFT_TOP:
path2D = FineUIUtils.createTopLeftRoundRectangle(0, 0, c.getWidth(), c.getHeight(), arc);
break;
case GROUP_BUTTON_POSITION_LEFT_BOTTOM:
path2D = FineUIUtils.createBottomLeftRoundRectangle(0, 0, c.getWidth(), c.getHeight(), arc);
break;
case GROUP_BUTTON_POSITION_RIGHT_TOP:
path2D = FineUIUtils.createTopRightRoundRectangle(0, 0, c.getWidth(), c.getHeight(), arc);
break;
case GROUP_BUTTON_POSITION_RIGHT_BOTTOM:
path2D = FineUIUtils.createBottomRightRoundRectangle(0, 0, c.getWidth(), c.getHeight(), arc);
break;
default:
path2D = new Rectangle();
}
g2.fill(path2D); g2.fill(path2D);
} }
} finally { } finally {
@ -186,6 +165,34 @@ public class FineToggleButtonUI extends FlatToggleButtonUI {
} }
} }
@NotNull
private static Shape getGroupButtonPath2D(JComponent c, int position, float arc) {
Shape path2D;
switch (position) {
case GROUP_BUTTON_POSITION_LEFT:
path2D = FineUIUtils.createLeftRoundRectangle(0, 0, c.getWidth(), c.getHeight(), arc);
break;
case GROUP_BUTTON_POSITION_RIGHT:
path2D = FineUIUtils.createRightRoundRectangle(0, 0, c.getWidth(), c.getHeight(), arc);
break;
case GROUP_BUTTON_POSITION_LEFT_TOP:
path2D = FineUIUtils.createTopLeftRoundRectangle(0, 0, c.getWidth(), c.getHeight(), arc);
break;
case GROUP_BUTTON_POSITION_LEFT_BOTTOM:
path2D = FineUIUtils.createBottomLeftRoundRectangle(0, 0, c.getWidth(), c.getHeight(), arc);
break;
case GROUP_BUTTON_POSITION_RIGHT_TOP:
path2D = FineUIUtils.createTopRightRoundRectangle(0, 0, c.getWidth(), c.getHeight(), arc);
break;
case GROUP_BUTTON_POSITION_RIGHT_BOTTOM:
path2D = FineUIUtils.createBottomRightRoundRectangle(0, 0, c.getWidth(), c.getHeight(), arc);
break;
default:
path2D = new Rectangle();
}
return path2D;
}
@Override @Override
protected Color getForeground(JComponent c) { protected Color getForeground(JComponent c) {
if (isGroupButton(c) && ((AbstractButton)c).isSelected()) { if (isGroupButton(c) && ((AbstractButton)c).isSelected()) {

Loading…
Cancel
Save