diff --git a/designer-base/src/main/java/com/fine/theme/light/ui/FineColorButtonUI.java b/designer-base/src/main/java/com/fine/theme/light/ui/FineColorButtonUI.java new file mode 100644 index 0000000000..9f23998a66 --- /dev/null +++ b/designer-base/src/main/java/com/fine/theme/light/ui/FineColorButtonUI.java @@ -0,0 +1,66 @@ +package com.fine.theme.light.ui; + +import com.formdev.flatlaf.ui.FlatUIUtils; +import com.fr.base.Utils; +import com.fr.design.gui.ibutton.UIColorButton; + +import javax.swing.ButtonModel; +import javax.swing.JComponent; +import javax.swing.plaf.ComponentUI; +import java.awt.Color; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Rectangle; +import java.awt.geom.RoundRectangle2D; + +import static com.fine.theme.utils.FineUIScale.scale; + +/** + * 颜色按钮 + * + * @author vito + * @since 11.0 + * Created on 2024/1/3 + */ +public class FineColorButtonUI extends FineButtonUI { + + public static final float HEIGHT = 1.5f; + public static final float WIDTH = 13; + public static final float Y = 13.5f; + + /** + * @param shared + * @since 2 + */ + protected FineColorButtonUI(boolean shared) { + super(shared); + } + + /** + * 创建UI + */ + public static ComponentUI createUI(JComponent c) { + return new FineColorButtonUI(false); + } + + @Override + protected void paintIcon(Graphics g, JComponent c, Rectangle iconRect) { + super.paintIcon(g, c, iconRect); + UIColorButton b = (UIColorButton) c; + ButtonModel model = b.getModel(); + if (model.isEnabled()) { + g.setColor(b.getColor()); + } else { + g.setColor(new Color(Utils.filterRGB(b.getColor().getRGB(), 50))); + } + FlatUIUtils.setRenderingHints(g); + Graphics2D g2d = (Graphics2D) g; + float height = scale(HEIGHT); + float width = scale(WIDTH); + // 计算实际大小与icon区域大小的偏移,用于居中调整 + float offsetX = (iconRect.width - width) / 2.0f; + RoundRectangle2D.Float colorRect = new RoundRectangle2D.Float( + iconRect.x + offsetX, iconRect.y + scale(Y), width, height, height, height); + g2d.fill(colorRect); + } +} diff --git a/designer-base/src/main/java/com/fine/theme/light/ui/FineCombinationButtonUI.java b/designer-base/src/main/java/com/fine/theme/light/ui/FineCombinationButtonUI.java index 6e61a1f79b..e243f47e07 100644 --- a/designer-base/src/main/java/com/fine/theme/light/ui/FineCombinationButtonUI.java +++ b/designer-base/src/main/java/com/fine/theme/light/ui/FineCombinationButtonUI.java @@ -28,8 +28,6 @@ public class FineCombinationButtonUI extends FlatPanelUI { @Styleable(dot = true) protected int arc; - @Styleable(dot = true) - protected Color borderColor; /** * @param shared @@ -53,7 +51,6 @@ public class FineCombinationButtonUI extends FlatPanelUI { public void installUI(JComponent c) { super.installUI(c); background = FineUIUtils.getUIColor("CombinationButton.background", "desktop"); - borderColor = FineUIUtils.getUIColor("CombinationButton.borderColor", "CombinationButton.secondary.background"); arc = FineUIUtils.getUIInt("CombinationButton.arc", "Component.arc"); } @@ -80,7 +77,9 @@ public class FineCombinationButtonUI extends FlatPanelUI { switch (e.getPropertyName()) { case FineClientProperties.STYLE_CLASS: UICombinationButton b = (UICombinationButton) e.getSource(); - b.setPrimary(); + if (FineClientProperties.STYLE_PRIMARY.equals(e.getNewValue())) { + b.setPrimary(); + } b.repaint(); break; default: diff --git a/designer-base/src/main/java/com/fine/theme/utils/FineClientProperties.java b/designer-base/src/main/java/com/fine/theme/utils/FineClientProperties.java index 5015dd9d9d..7f2f501a7d 100644 --- a/designer-base/src/main/java/com/fine/theme/utils/FineClientProperties.java +++ b/designer-base/src/main/java/com/fine/theme/utils/FineClientProperties.java @@ -19,8 +19,8 @@ public interface FineClientProperties extends FlatClientProperties { String STYLE_PRIMARY = "primary"; String STYLE_SECONDARY = "secondary"; - String STYLE_SIZE_MEDIUM = "medium"; - String STYLE_SIZE_SMALL = "small"; + String STYLE_SIZE_MEDIUM = "mediumSize"; + String STYLE_SIZE_SMALL = "smallSize"; String BUTTON_TYPE_LEFT_ROUND_RECT = "leftRoundRect"; String BUTTON_TYPE_RIGHT_ROUND_RECT = "rightRoundRect"; diff --git a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java index 8659bcd95b..e6e6155759 100644 --- a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java +++ b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java @@ -486,7 +486,7 @@ public class MultiTemplateTabPane extends JPanel { startX = new int[maxPaintIndex - minPaintIndex + 1]; double templateStartX = scale(LEADING_WIDTH); for (int i = getViewRange().getFirst(); i <= getViewRange().getSecond(); i++) { - int closePosition = (int) templateStartX + getTabWidth() - clodeIcon.getIconWidth() - GAP; + int closePosition = (int) templateStartX + getTabWidth() - clodeIcon.getIconWidth() - GAP; startX[i - minPaintIndex] = closePosition; templateStartX += getTabWidth(); } @@ -922,7 +922,9 @@ public class MultiTemplateTabPane extends JPanel { public void mouseMoved(MouseEvent e) { int evtX = e.getX(); mouseOveredIndex = getTemplateIndex(evtX); - setToolTipText(openedTemplate.get(mouseOveredIndex).getEditingFILE().getName()); + if (mouseOveredIndex > -1) { + setToolTipText(openedTemplate.get(mouseOveredIndex).getEditingFILE().getName()); + } hoverMoreAction = isOverListDown(evtX); closeIconIndex = isOverCloseIcon(evtX) ? mouseOveredIndex : -1; MultiTemplateTabPane.this.repaint(); diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIButton.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIButton.java index f01c52cb7b..9b89a90419 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIButton.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIButton.java @@ -1,32 +1,24 @@ package com.fr.design.gui.ibutton; -import com.fanruan.gui.UiInspector; import com.fine.theme.icon.LazyIcon; -import com.fine.theme.light.ui.laf.FineLightLaf; -import com.fr.base.BaseUtils; +import com.fine.theme.utils.FineClientProperties; import com.fr.base.CellBorderStyle; import com.fr.base.svg.IconUtils; import com.fr.design.constants.UIConstants; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; import com.fr.design.gui.core.UITextComponent; -import com.fr.design.utils.gui.GUICoreUtils; import com.fr.stable.Constants; import com.fr.stable.StringUtils; import javax.swing.Action; import javax.swing.Icon; import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JPanel; import javax.swing.ToolTipManager; -import javax.swing.UIManager; -import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; -import java.awt.Insets; import java.awt.Shape; import java.awt.Stroke; import java.awt.event.ActionEvent; @@ -163,8 +155,6 @@ public class UIButton extends JButton implements UIObserver, UITextComponent { private void init() { - setOpaque(false); - setBackground(null); setRolloverEnabled(true); initListener(); ToolTipManager.sharedInstance().setInitialDelay(TOOLTIP_INIT_DELAY); @@ -290,8 +280,8 @@ public class UIButton extends JButton implements UIObserver, UITextComponent { */ public void setNormalPainted(boolean isNormalPressed) { this.isNormalPainted = isNormalPressed; - if (!isNormalPressed) { - setBackground(null); + boolean primary = FineClientProperties.hasStyle(this, FineClientProperties.STYLE_PRIMARY); + if (!isNormalPainted() && !primary) { setOpaque(false); } } @@ -303,40 +293,6 @@ public class UIButton extends JButton implements UIObserver, UITextComponent { this.isBorderPaintedOnlyWhenPressed = value; } - /** - * 主函数 - * @param args 入口参数 - */ - public static void main(String... args) { - try { - UIManager.setLookAndFeel( new FineLightLaf() ); - } catch( Exception ex ) { - System.err.println( "Failed to initialize LaF" ); - } - JFrame jf = new JFrame("test"); - jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - JPanel content = (JPanel) jf.getContentPane(); -// content.setLayout(new BorderLayout()); - - UIButton bb = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png")); - bb.setEnabled(true); - // bb.setBounds(20, 20,content.getSize().width, bb.getPreferredSize().height); -// bb.setPreferredSize(new Dimension(100, 30)); - bb.setBounds(0, 0, bb.getPreferredSize().width, bb.getPreferredSize().height); - bb.setMargin(new Insets(10,10,10,10)); - UIButton cc = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png")); - cc.setEnabled(true); -// cc.setPreferredSize(new Dimension(100, 30)); - cc.setBounds(0, 0, cc.getPreferredSize().width, cc.getPreferredSize().height); - cc.setMargin(new Insets(20,20,20,20)); - content.add(bb, BorderLayout.SOUTH); - content.add(cc,BorderLayout.NORTH); - GUICoreUtils.centerWindow(jf); - jf.setSize(400, 400); - new UiInspector(); - jf.setVisible(true); - } - /** * 给组件登记一个观察者监听事件 * @@ -355,7 +311,4 @@ public class UIButton extends JButton implements UIObserver, UITextComponent { return true; } - - - } diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButton.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButton.java index 31a6d963d9..0129909b08 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButton.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButton.java @@ -1,7 +1,6 @@ package com.fr.design.gui.ibutton; -import com.fr.base.Utils; -import com.fr.design.constants.UIConstants; +import com.fine.theme.icon.LazyIcon; import com.fr.design.event.GlobalNameListener; import com.fr.design.event.GlobalNameObserver; import com.fr.design.event.UIObserver; @@ -11,39 +10,38 @@ import com.fr.design.style.color.ColorControlWindow; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; -import javax.swing.AbstractButton; -import javax.swing.ButtonModel; import javax.swing.Icon; -import javax.swing.JComponent; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.EventListenerList; import java.awt.Color; -import java.awt.Graphics; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; public class UIColorButton extends UIButton implements PopupHider, UIObserver, GlobalNameObserver { - public static final int SIZE = 16; - public static final int SIZE_2 = 2; - public static final int SIZE_4 = 4; - public static final int SIZE_6 = 6; + + private static final String UI_CLASS_ID = "ColorButtonUI"; + private static final int POPUP_MENU_SHIFT = -70; private Color color = Color.BLACK; private ColorControlWindow popupWin; - private EventListenerList colorChangeListenerList = new EventListenerList(); + private final EventListenerList colorChangeListenerList = new EventListenerList(); private boolean isEventBanned = false; private String colorButtonName = ""; private UIObserverListener uiObserverListener; private GlobalNameListener globalNameListener = null; + @Override + public String getUIClassID() { + return UI_CLASS_ID; + } + public UIColorButton() { - this(UIConstants.FONT_ICON); + this(new LazyIcon("foreground")); } public UIColorButton(Icon icon) { super(icon); - setUI(getButtonUI()); addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { @@ -63,38 +61,18 @@ public class UIColorButton extends UIButton implements PopupHider, UIObserver, G private void iniListener() { if (shouldResponseChangeListener()) { - this.addColorChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - if (uiObserverListener == null) { - return; - } - if (globalNameListener != null && shouldResponseNameListener()) { - globalNameListener.setGlobalName(colorButtonName); - } - uiObserverListener.doChange(); + this.addColorChangeListener(e -> { + if (uiObserverListener == null) { + return; + } + if (globalNameListener != null && shouldResponseNameListener()) { + globalNameListener.setGlobalName(colorButtonName); } + uiObserverListener.doChange(); }); } } - private UIButtonUI getButtonUI() { - return new UIButtonUI() { - @Override - protected void paintIcon(Graphics g, JComponent c) { - super.paintIcon(g, c); - AbstractButton b = (AbstractButton) c; - ButtonModel model = b.getModel(); - if (model.isEnabled()) { - g.setColor(UIColorButton.this.getColor()); - } else { - g.setColor(new Color(Utils.filterRGB(UIColorButton.this.getColor().getRGB(), 50))); - } - g.fillRect((b.getWidth() - SIZE) / SIZE_2, b.getHeight() - SIZE_6, SIZE, SIZE_4); - } - }; - } - public void setEventBanned(boolean isEventBanned) { this.isEventBanned = isEventBanned; } diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButtonWithAuto.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButtonWithAuto.java index a7dcad008a..b10b1d91f8 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButtonWithAuto.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButtonWithAuto.java @@ -1,5 +1,6 @@ package com.fr.design.gui.ibutton; +import com.fine.theme.icon.LazyIcon; import com.fr.chart.base.ChartConstants; import com.fr.design.constants.UIConstants; import com.fr.design.style.color.ColorControlWindow; @@ -12,7 +13,7 @@ public class UIColorButtonWithAuto extends UIColorButton { protected void checkColorChange(Color oldColor, Color newColor) { if (ComparatorUtils.equals(oldColor, ChartConstants.AUTO_FONT_COLOR) && !ComparatorUtils.equals(newColor, ChartConstants.AUTO_FONT_COLOR)) { - setIcon(UIConstants.FONT_ICON); + setIcon(new LazyIcon("foreground")); } if (!ComparatorUtils.equals(oldColor, ChartConstants.AUTO_FONT_COLOR) && ComparatorUtils.equals(newColor, ChartConstants.AUTO_FONT_COLOR)) { diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UICombinationButton.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UICombinationButton.java index ff3398077d..0cb7d6af15 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UICombinationButton.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UICombinationButton.java @@ -25,6 +25,7 @@ import static com.formdev.flatlaf.FlatClientProperties.BUTTON_TYPE; * created by vito on 2023/12/28 **/ public class UICombinationButton extends JPanel { + private static final String UI_CLASS_ID = "CombinationButtonUI"; protected UIButton leftButton; @@ -129,24 +130,15 @@ public class UICombinationButton extends JPanel { return leftButton; } - public void setExtraPainted(boolean isExtraPainted) { -// if (!isExtraPainted) { -// leftButton.setBackground(null); -// rightButton.setBackground(null); -// leftButton.setOpaque(false); -// rightButton.setOpaque(false); -// } - } - public UIButton getRightButton() { return rightButton; } public void set4Toolbar() { - leftButton.setNormalPainted(false); - rightButton.setNormalPainted(false); - leftButton.setBorderPaintedOnlyWhenPressed(true); - rightButton.setBorderPaintedOnlyWhenPressed(true); + leftButton.setBorderPainted(false); + setStyle(leftButton, "inToolbarLeft"); + rightButton.setBorderPainted(false); + setStyle(rightButton, "inToolbarRight"); } protected void showPopWindow(JPopupMenu menu) { diff --git a/designer-base/src/main/java/com/fr/design/style/color/UIToolbarColorButton.java b/designer-base/src/main/java/com/fr/design/style/color/UIToolbarColorButton.java index 5c27bc58cb..d3f3600dfb 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/UIToolbarColorButton.java +++ b/designer-base/src/main/java/com/fr/design/style/color/UIToolbarColorButton.java @@ -37,6 +37,12 @@ public class UIToolbarColorButton extends UICombinationButton implements PopupHi public UIToolbarColorButton(Icon icon) { super(new UIColorButton(icon), new UIButton(new LazyIcon("popup"))); getLeftButton().setEventBanned(true); + set4Toolbar(); + + initListener(); + } + + private void initListener() { getRightButton().addFocusListener(new FocusListener() { @Override @@ -48,19 +54,12 @@ public class UIToolbarColorButton extends UICombinationButton implements PopupHi hidePopupMenu(); } }); - iniListener(); - } - - private void iniListener() { if (shouldResponseChangeListener()) { - this.addColorChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - if (uiObserverListener == null) { - return; - } - uiObserverListener.doChange(); + this.addColorChangeListener(e -> { + if (uiObserverListener == null) { + return; } + uiObserverListener.doChange(); }); } } diff --git a/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLaf.properties b/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLaf.properties index 41d855e279..ce1aaba19a 100644 --- a/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLaf.properties +++ b/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLaf.properties @@ -49,4 +49,5 @@ SelectBoxUI=com.fine.theme.light.ui.FineSelectBoxUI CombinationButtonUI=com.fine.theme.light.ui.FineCombinationButtonUI InputUI=com.fine.theme.light.ui.FineInputUI GradientBarUI=com.fine.theme.light.ui.FineGradientBarUI -TemplateTabPaneUI=com.fine.theme.light.ui.FineTemplateTabPaneUI \ No newline at end of file +TemplateTabPaneUI=com.fine.theme.light.ui.FineTemplateTabPaneUI +ColorButtonUI=com.fine.theme.light.ui.FineColorButtonUI diff --git a/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties b/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties index b67d4b1087..7a7a852246 100644 --- a/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties +++ b/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties @@ -147,7 +147,7 @@ Button.margin = 2,12,2,12 Button.iconTextGap = 4 Button.rollover = true Button.defaultButtonFollowsFocus = false -Button.borderWidth = 2 +Button.borderWidth = 1 Button.medium.margin = 2,12,2,12 Button.small.margin = 0,10,0,10 @@ -155,7 +155,7 @@ Button.background = @buttonBackground Button.focusedBackground = @buttonBackground Button.hoverBackground = $fill.hover Button.pressedBackground = $fill.click -Button.selectedBackground = darken($Button.background,20%,derived) +Button.selectedBackground = $fill.click Button.selectedForeground = $Button.foreground Button.disabledSelectedBackground = darken($Button.background,13%,derived) Button.disabledBackground = $fill.disabled @@ -189,13 +189,15 @@ Button.default.borderColor = @accentButtonDefaultBorderColor Button.default.hoverBorderColor = $Button.hoverBorderColor Button.default.focusedBorderColor = $Button.focusedBorderColor Button.default.focusColor = $Component.focusColor -Button.default.borderWidth = 2 +Button.default.borderWidth = 1 -Button.toolbar.hoverBackground = darken($Button.background,12%,derived) -Button.toolbar.pressedBackground = darken($Button.background,15%,derived) -Button.toolbar.selectedBackground = $Button.selectedBackground -Button.toolbar.margin = 3,3,3,3 -Button.toolbar.spacingInsets = 1,2,1,2 +Button.toolbar.background = #fff +Button.toolbar.hoverBackground = $fill.hover +Button.toolbar.pressedBackground = $fill.click +Button.toolbar.selectedBackground = $fill.click +Button.toolbar.margin = 4,4,4,4 +Button.toolbar.borderWidth = 0 +Button.toolbar.spacingInsets = 0,0,0,0 Button.group.background = #FFF Button.group.selectedBackground = #2576EF @@ -413,48 +415,6 @@ HelpButton.pressedBackground = $?Button.pressedBackground HelpButton.borderWidth = $?Button.borderWidth HelpButton.innerFocusWidth = $?Button.innerFocusWidth - -#---- InternalFrame ---- - -InternalFrame.border = com.formdev.flatlaf.ui.FlatInternalFrameUI$FlatInternalFrameBorder -InternalFrame.borderLineWidth = 1 -InternalFrame.borderMargins = 6,6,6,6 -InternalFrame.buttonSize = 24,24 -InternalFrame.closeIcon = com.formdev.flatlaf.icons.FlatInternalFrameCloseIcon -InternalFrame.iconifyIcon = com.formdev.flatlaf.icons.FlatInternalFrameIconifyIcon -InternalFrame.maximizeIcon = com.formdev.flatlaf.icons.FlatInternalFrameMaximizeIcon -InternalFrame.minimizeIcon = com.formdev.flatlaf.icons.FlatInternalFrameRestoreIcon -InternalFrame.windowBindings = null - -# drop shadow -InternalFrame.dropShadowPainted = true -InternalFrame.activeDropShadowColor = null -InternalFrame.activeDropShadowInsets = 5,5,6,6 -InternalFrame.inactiveDropShadowColor = null -InternalFrame.inactiveDropShadowInsets = 3,3,4,4 - -InternalFrame.activeTitleBackground = #fff -InternalFrame.activeTitleForeground = @foreground -InternalFrame.inactiveTitleBackground = darken($InternalFrame.activeTitleBackground,2%) -InternalFrame.inactiveTitleForeground = @disabledForeground - -InternalFrame.activeBorderColor = shade(@background,40%) -InternalFrame.inactiveBorderColor = shade(@background,20%) - -InternalFrame.buttonHoverBackground = darken($InternalFrame.activeTitleBackground,10%,derived) -InternalFrame.buttonPressedBackground = darken($InternalFrame.activeTitleBackground,20%,derived) -InternalFrame.closeHoverBackground = lazy(Actions.Red) -InternalFrame.closePressedBackground = darken(Actions.Red,10%,lazy) -InternalFrame.closeHoverForeground = #fff -InternalFrame.closePressedForeground = #fff - -InternalFrame.activeDropShadowOpacity = 0.25 -InternalFrame.inactiveDropShadowOpacity = 0.5 - -#---- InternalFrameTitlePane ---- - -InternalFrameTitlePane.border = 0,8,0,0 - #---- List ---- List.border = 0,0,0,0 @@ -1059,7 +1019,7 @@ ToggleButton.disabledSelectedBackground = darken($ToggleButton.background,13%,de ToggleButton.toolbar.hoverBackground = $Button.toolbar.hoverBackground ToggleButton.toolbar.pressedBackground = $Button.toolbar.pressedBackground -ToggleButton.toolbar.selectedBackground = $ToggleButton.selectedBackground +ToggleButton.toolbar.selectedBackground = $Button.toolbar.selectedBackground # button type "tab" ToggleButton.tab.underlineHeight = 0 @@ -1241,7 +1201,7 @@ CellOtherSetPane.height=$Component.defaultHeight disabledSelectedBackground : #F2F4F8; \ borderWidth : 0 -[style]Button.small = margin : 0,10,0,10; +[style]Button.abc = margin : 0,8,0,8 [style]Button.secondary = \ background : $Button.background; \ @@ -1253,14 +1213,23 @@ CellOtherSetPane.height=$Component.defaultHeight hoverBorderColor : $Button.hoverBorderColor; \ focusedBorderColor : $Button.focusedBorderColor; \ focusColor : $Component.focusColor; \ - borderWidth : 2 + borderWidth : 1 [style]CombinationButton.primary = \ - background : @BrandColor; \ - arc : 3 + background : @BrandColor; \ + arc : 3 + +[style]CombinationButton.toolbar = \ + background : #fff + +[style]Button.inToolbarLeft = \ + margin : 4,4,4,0 + +[style]Button.inToolbarRight = \ + margin : 1,1,1,1 [style]ToolBar.topTools = \ - background: #fff + background: #fff #---- clearButton ---- # for clear/cancel button in text fields diff --git a/designer-base/src/test/java/com/fr/design/gui/storybook/components/ButtonStoryBoard.java b/designer-base/src/test/java/com/fr/design/gui/storybook/components/ButtonStoryBoard.java index e0d0dad170..2dad573779 100644 --- a/designer-base/src/test/java/com/fr/design/gui/storybook/components/ButtonStoryBoard.java +++ b/designer-base/src/test/java/com/fr/design/gui/storybook/components/ButtonStoryBoard.java @@ -6,8 +6,11 @@ import com.fr.design.gui.ibutton.UICombinationButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.storybook.Story; import com.fr.design.gui.storybook.StoryBoard; +import com.fr.design.style.color.UIToolbarColorButton; import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JToolBar; import static com.fine.swing.ui.layout.Layouts.cell; import static com.fine.swing.ui.layout.Layouts.column; @@ -145,7 +148,7 @@ public class ButtonStoryBoard extends StoryBoard { cell(new UICombinationButton("按钮", new LazyIcon("triangle_down"))) .with(it -> { setStyle(it, STYLE_PRIMARY); - it.setExtraPainted(false); +// it.setExtraPainted(false); }), cell(new UICombinationButton("按钮", new LazyIcon("triangle_down"))) .with(it -> setStyle(it, STYLE_PRIMARY)), @@ -153,7 +156,21 @@ public class ButtonStoryBoard extends StoryBoard { cell(new JButton("按钮", new LazyIcon("add"))), cell(new JButton(new LazyIcon("multi"))) ), + row(20, + cell(new UIToolbarColorButton(new LazyIcon("foreground"))), + cell(toolbar()) + .with(it -> { + }) + ), flex() ); } + + public JComponent toolbar(){ + JToolBar bar = new JToolBar(); + UIToolbarColorButton foreground = new UIToolbarColorButton(new LazyIcon("foreground")); + bar.add(foreground); + setStyle(bar, "topTools"); + return bar; + } } diff --git a/designer-realize/src/main/java/com/fr/design/actions/cell/UIToolbarBorderButton.java b/designer-realize/src/main/java/com/fr/design/actions/cell/UIToolbarBorderButton.java index a5c2c123b1..e6f940ea03 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/cell/UIToolbarBorderButton.java +++ b/designer-realize/src/main/java/com/fr/design/actions/cell/UIToolbarBorderButton.java @@ -47,6 +47,7 @@ public class UIToolbarBorderButton extends UICombinationButton implements PopupH public UIToolbarBorderButton(Icon icon, ElementCasePane reportPane) { super(new UIButton(icon), new UIButton(new LazyIcon("popup"))); + set4Toolbar(); this.reportPane = reportPane; } diff --git a/designer-realize/src/main/java/com/fr/start/MainDesigner.java b/designer-realize/src/main/java/com/fr/start/MainDesigner.java index 8ab1ea9eb2..e054956ea8 100644 --- a/designer-realize/src/main/java/com/fr/start/MainDesigner.java +++ b/designer-realize/src/main/java/com/fr/start/MainDesigner.java @@ -51,7 +51,6 @@ import com.fr.design.ui.util.UIUtil; import com.fr.design.utils.DesignUtils; import com.fr.design.utils.DesignerPort; import com.fr.design.utils.concurrent.ThreadFactoryBuilder; -import com.fr.design.utils.gui.GUICoreUtils; import com.fr.env.utils.DesignerInteractionHistory; import com.fr.event.Event; import com.fr.event.EventDispatcher; @@ -358,11 +357,9 @@ public class MainDesigner extends BaseDesigner { for (UIMenuItem item : items) { menu.add(item); } - GUICoreUtils.showPopupMenu(menu, run, run.getX(), run.getY() - 1 + run.getHeight()); + menu.show(run, 0, run.getHeight() + 1); }); run.setPrimary(); - run.setExtraPainted(false); - run.set4Toolbar(); run.getLeftButton().setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview")); run.getRightButton().setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Dropdown_More_Preview")); return run;