diff --git a/designer-base/src/main/java/com/fine/theme/light/ui/FineRoundBorder.java b/designer-base/src/main/java/com/fine/theme/light/ui/FineRoundBorder.java new file mode 100644 index 0000000000..280f3ca746 --- /dev/null +++ b/designer-base/src/main/java/com/fine/theme/light/ui/FineRoundBorder.java @@ -0,0 +1,59 @@ +package com.fine.theme.light.ui; + +import com.formdev.flatlaf.ui.FlatRoundBorder; +import com.formdev.flatlaf.ui.FlatStylingSupport.Styleable; +import com.fr.design.event.HoverAware; + +import javax.swing.UIManager; +import java.awt.Color; +import java.awt.Component; +import java.awt.Paint; + + +/** + * 通用的Border类,具备hover、click、禁用等多种状态 + * + * @author Levy.Xie + * @since 11.0 + * Created on 2023/12/06 + */ +public class FineRoundBorder extends FlatRoundBorder { + + @Styleable(dot = true) + protected Color borderColor = UIManager.getColor("defaultBorderColor"); + @Styleable(dot = true) + protected Color disabledBorderColor = UIManager.getColor("defaultBorderColor"); + @Styleable(dot = true) + protected Color highlightBorderColor = UIManager.getColor("defaultHighlightBorderColor"); + @Styleable(dot = true) + protected Color focusColor = UIManager.getColor("defaultBorderFocusShadow"); + @Styleable(dot = true) + protected int focusWidth = UIManager.getInt("defaultBorderFocusWidth"); + + @Override + protected Paint getBorderColor(Component c) { + if (isEnabled(c)) { + if (c instanceof HoverAware && ((HoverAware) c).isHovered()) { + return getHoverBorderColor(); + } else { + return isFocused(c) ? focusedBorderColor : borderColor; + } + } + return disabledBorderColor; + } + + @Override + protected Color getFocusColor(Component c) { + return focusColor; + } + + @Override + protected int getFocusWidth(Component c) { + return focusWidth; + } + + protected Color getHoverBorderColor() { + return highlightBorderColor; + } + +}