diff --git a/designer-base/src/main/java/com/fine/theme/light/ui/FineMenuItemUI.java b/designer-base/src/main/java/com/fine/theme/light/ui/FineMenuItemUI.java new file mode 100644 index 0000000000..58237f59d9 --- /dev/null +++ b/designer-base/src/main/java/com/fine/theme/light/ui/FineMenuItemUI.java @@ -0,0 +1,41 @@ +package com.fine.theme.light.ui; + +import com.fine.theme.utils.FineClientProperties; +import com.formdev.flatlaf.ui.FlatMenuItemUI; +import com.fr.design.editlock.EditLockUtils; + +import javax.swing.JComponent; +import javax.swing.plaf.ComponentUI; +import java.awt.Graphics; + +/** + * menuItem UI类 + * + * @author Leo.Qin + * @since 11.0 + * Created on 2024/1/8 + */ +public class FineMenuItemUI extends FlatMenuItemUI { + int iconSize = 16; + int rightMargin = 10; + + /** + * 创建UI + * + * @param c + * @return + */ + public static ComponentUI createUI(JComponent c) { + return new FineMenuItemUI(); + } + + @Override + public void paint(Graphics g, JComponent c) { + super.paint(g, c); + + Object itemType = c.getClientProperty(FineClientProperties.MENU_ITEM_TYPE); + if (FineClientProperties.MENU_ITEM_TYPE_LOCK.equals(itemType)) { + g.drawImage(EditLockUtils.LOCKED_IMAGE, c.getWidth() - rightMargin - iconSize, (c.getHeight() - iconSize) / 2, iconSize, iconSize, null); + } + } +} diff --git a/designer-base/src/main/java/com/fine/theme/light/ui/FineMenuUI.java b/designer-base/src/main/java/com/fine/theme/light/ui/FineMenuUI.java new file mode 100644 index 0000000000..b71b816a07 --- /dev/null +++ b/designer-base/src/main/java/com/fine/theme/light/ui/FineMenuUI.java @@ -0,0 +1,40 @@ +package com.fine.theme.light.ui; + +import com.fine.theme.icon.LazyIcon; +import com.formdev.flatlaf.ui.FlatMenuUI; + +import javax.swing.JComponent; +import javax.swing.plaf.ComponentUI; +import java.awt.Graphics; + +/** + * 弹窗菜单UI + * + * @author Leo.Qin + * @since 11.0 + * Created on 2024/1/8 + */ +public class FineMenuUI extends FlatMenuUI { + + + /** + * 创建UI + * + * @param c + * @return + */ + public static ComponentUI createUI(JComponent c) { + return new FineMenuUI(); + } + + @Override + protected void installDefaults() { + arrowIcon = new LazyIcon("triangle_right"); + super.installDefaults(); + } + + @Override + public void paint(Graphics g, JComponent c) { + super.paint(g, c); + } +} diff --git a/designer-base/src/main/java/com/fine/theme/light/ui/FinePopupMenuSeparatorUI.java b/designer-base/src/main/java/com/fine/theme/light/ui/FinePopupMenuSeparatorUI.java new file mode 100644 index 0000000000..f5708005d6 --- /dev/null +++ b/designer-base/src/main/java/com/fine/theme/light/ui/FinePopupMenuSeparatorUI.java @@ -0,0 +1,70 @@ +package com.fine.theme.light.ui; + +import com.fine.theme.utils.FineUIUtils; +import com.formdev.flatlaf.ui.FlatPopupMenuSeparatorUI; +import com.formdev.flatlaf.ui.FlatUIUtils; + +import javax.swing.JComponent; +import javax.swing.JSeparator; +import javax.swing.plaf.ComponentUI; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Insets; +import java.awt.geom.Rectangle2D; + +import static com.formdev.flatlaf.util.UIScale.scale; + +/** + * popup弹窗分割线UI + * + * @author Leo.Qin + * @since 11.0 + * Created on 2024/1/8 + */ +public class FinePopupMenuSeparatorUI extends FlatPopupMenuSeparatorUI { + protected Insets insets; + + /** + * @param shared + * @since 2 + */ + protected FinePopupMenuSeparatorUI(boolean shared) { + super(shared); + } + + /** + * 创建UI类 + * + * @param c + * @return + */ + public static ComponentUI createUI(JComponent c) { + return new FinePopupMenuSeparatorUI(false); + } + + @Override + protected void installDefaults(JSeparator s) { + super.installDefaults(s); + insets = FineUIUtils.getAndScaleUIInsets("PopupMenuSeparator.Insets", new Insets(0, 10, 0, 10)); + } + + @Override + public void paint(Graphics g, JComponent c) { + Graphics2D g2 = (Graphics2D) g.create(); + try { + FlatUIUtils.setRenderingHints(g2); + g2.setColor(c.getForeground()); + + float width = scale((float) stripeWidth); + float indent = scale((float) stripeIndent); + + if (((JSeparator) c).getOrientation() == JSeparator.VERTICAL) { + g2.fill(new Rectangle2D.Float(indent, insets.left, width - (insets.left + insets.right), c.getHeight())); + } else { + g2.fill(new Rectangle2D.Float(insets.left, indent, c.getWidth() - (insets.left + insets.right), width)); + } + } finally { + g2.dispose(); + } + } +} diff --git a/designer-base/src/main/java/com/fine/theme/light/ui/FinePopupMenuUI.java b/designer-base/src/main/java/com/fine/theme/light/ui/FinePopupMenuUI.java index 402734a77a..58a37da791 100644 --- a/designer-base/src/main/java/com/fine/theme/light/ui/FinePopupMenuUI.java +++ b/designer-base/src/main/java/com/fine/theme/light/ui/FinePopupMenuUI.java @@ -19,7 +19,7 @@ import java.awt.geom.RoundRectangle2D; */ public class FinePopupMenuUI extends FlatPopupMenuUI { private int arc; - private final int DEFAULT_ARC = 5; + private final int DEFAULT_ARC = 10; /** * 创建UI @@ -39,6 +39,7 @@ public class FinePopupMenuUI extends FlatPopupMenuUI { @Override public void paint(Graphics g, JComponent c) { + // 绘制圆角矩形作为弹窗背景 Graphics2D g2d = (Graphics2D) g; g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 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 aa50ebae8c..8883f88da4 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 @@ -17,6 +17,10 @@ public interface FineClientProperties extends FlatClientProperties { String BUTTON_TYPE_LEFT_ROUND_RECT = "leftRoundRect"; String BUTTON_TYPE_RIGHT_ROUND_RECT = "rightRoundRect"; + //--------------------------- PopupMenu ----------------------- + String MENU_ITEM_TYPE = "MenuItemType"; + String MENU_ITEM_TYPE_LOCK = "lock"; + String BUTTON_GROUP_POSITION = "group_position"; int GROUP_BUTTON_POSITION_INNER = 0; diff --git a/designer-base/src/main/java/com/fine/theme/utils/FineUIStyle.java b/designer-base/src/main/java/com/fine/theme/utils/FineUIStyle.java index 1e029ed551..82172be6f7 100644 --- a/designer-base/src/main/java/com/fine/theme/utils/FineUIStyle.java +++ b/designer-base/src/main/java/com/fine/theme/utils/FineUIStyle.java @@ -27,6 +27,10 @@ public interface FineUIStyle { String BRAND_COLOR_LABEL = "brandColorLabel"; String BUTTON_TAB_ACTION = "tabAction"; + String MENU_TOOL_BAR = "menuToolBar"; + String MENU_ITEM_TOOL_BAR = "menuItemToolBar"; + String POPUP_MENU_TOOL_BAR = "popupMenuToolBar"; + /** * 添加组件的样式类,类似css,该方法会接在原样式后方 diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java index 2f385d8a47..faf4de9e34 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java @@ -182,7 +182,6 @@ public class TableDataTreePane extends BasicTableDataTreePane { popupMenu.add(copyAction.createMenuItem()); popupMenu.add(pasteAction.createMenuItem()); popupMenu.add(removeAction.createMenuItem()); - popupMenu.addSeparator(); // 监听 tableDataTree.addMouseListener(new MouseAdapter() { @Override diff --git a/designer-base/src/main/java/com/fr/design/gui/imenu/UILockMenuItem.java b/designer-base/src/main/java/com/fr/design/gui/imenu/UILockMenuItem.java index c609e5d5c7..4127b3eec8 100644 --- a/designer-base/src/main/java/com/fr/design/gui/imenu/UILockMenuItem.java +++ b/designer-base/src/main/java/com/fr/design/gui/imenu/UILockMenuItem.java @@ -1,5 +1,6 @@ package com.fr.design.gui.imenu; +import com.fine.theme.utils.FineClientProperties; import com.fr.design.editlock.EditLockChangeEvent; import com.fr.design.editlock.EditLockChangeListener; import com.fr.report.LockItem; @@ -32,7 +33,7 @@ public class UILockMenuItem extends UIMenuItem implements EditLockChangeListener this.lockedTooltips = lockedTooltips; this.normalTooltips = normalTooltips; this.lockItem = lockItem; - setUI(new UILockMenuItemUI()); + this.putClientProperty(FineClientProperties.MENU_ITEM_TYPE, FineClientProperties.MENU_ITEM_TYPE_LOCK); } public LockItem getLockItem() { diff --git a/designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuItem.java b/designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuItem.java index 3d7a0b85ba..337799dca3 100644 --- a/designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuItem.java +++ b/designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuItem.java @@ -8,7 +8,7 @@ import javax.swing.JMenuItem; public class UIMenuItem extends JMenuItem{ public UIMenuItem() { - this(StringUtils.BLANK); + this(StringUtils.EMPTY); } public UIMenuItem(String string) { diff --git a/designer-base/src/main/java/com/fr/design/menu/DottedSeparator.java b/designer-base/src/main/java/com/fr/design/menu/DottedSeparator.java index 7d1ec7b261..65dd153b6e 100644 --- a/designer-base/src/main/java/com/fr/design/menu/DottedSeparator.java +++ b/designer-base/src/main/java/com/fr/design/menu/DottedSeparator.java @@ -1,12 +1,15 @@ package com.fr.design.menu; +import com.fine.theme.utils.FineUIUtils; import com.fr.design.actions.UpdateAction; import com.fr.design.gui.imenu.UIMenuItem; +import javax.swing.UIManager; import java.awt.BasicStroke; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; +import java.awt.Insets; import java.awt.Stroke; import java.awt.event.ActionEvent; @@ -42,31 +45,32 @@ public class DottedSeparator extends UpdateAction { } private class MenuItem extends UIMenuItem { + + + private final Insets insets; + private final int height; + public MenuItem() { - this.setUI(null); + this.setEnabled(false); this.removeAll(); + insets = FineUIUtils.getAndScaleUIInsets("PopupMenuSeparator.Insets", new Insets(0, 10, 0, 10)); + height = FineUIUtils.getAndScaleInt("PopupMenuSeparator.height", 5); } public void paint(Graphics g) { int w = this.getWidth(); int h = this.getHeight(); Graphics2D g2d = (Graphics2D)g; - g2d.setColor(getBackground()); - g2d.fillRect(0, 0, w, h); - g2d.setColor(getForeground()); + g2d.setColor(UIManager.getColor("Separator.background")); + Stroke bs = new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 2f, new float[] { 3, 1 }, 0); g2d.setStroke(bs); - g2d.drawLine(30, h / 2+1, w-4, h / 2+1); - this.setForeground(getForeground()); - super.paint(g); - } - - public Dimension getSize() { - return new Dimension(super.getSize().width, 8); + g2d.drawLine(insets.left, h / 2 + 1, w - insets.right, h / 2 + 1); } + @Override public Dimension getPreferredSize() { - return new Dimension(super.getPreferredSize().width, 8); + return new Dimension(super.getPreferredSize().width, height); } } diff --git a/designer-base/src/main/java/com/fr/design/menu/LineSeparator.java b/designer-base/src/main/java/com/fr/design/menu/LineSeparator.java index 1419d31d88..bfba89052a 100644 --- a/designer-base/src/main/java/com/fr/design/menu/LineSeparator.java +++ b/designer-base/src/main/java/com/fr/design/menu/LineSeparator.java @@ -4,9 +4,6 @@ import com.fr.design.actions.UpdateAction; import com.fr.design.gui.imenu.UIMenuItem; import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; import java.awt.event.ActionEvent; /** @@ -47,28 +44,7 @@ public class LineSeparator extends UpdateAction{ private class MenuItem extends UIMenuItem { public MenuItem() { - this.setUI(null); this.removeAll(); } - - public void paint(Graphics g) { - int w = this.getWidth(); - int h = this.getHeight(); - Graphics2D g2d = (Graphics2D)g; - g2d.setColor(getBackground()); - g2d.fillRect(0, 0, w, h); - g2d.setColor(getForeground()); - g2d.drawLine(4, h / 2+1, w-4, h / 2+1); -// this.setForeground(color); - super.paint(g); - } - - public Dimension getSize() { - return new Dimension(super.getSize().width, 8); - } - - public Dimension getPreferredSize() { - return new Dimension(super.getPreferredSize().width, 8); - } } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/menu/MenuDef.java b/designer-base/src/main/java/com/fr/design/menu/MenuDef.java index c46adb7997..5b82786abd 100644 --- a/designer-base/src/main/java/com/fr/design/menu/MenuDef.java +++ b/designer-base/src/main/java/com/fr/design/menu/MenuDef.java @@ -1,6 +1,7 @@ package com.fr.design.menu; import com.fine.theme.icon.LazyIcon; +import com.fine.theme.utils.FineUIStyle; import com.fr.base.svg.IconUtils; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.gui.ibutton.UIButton; @@ -17,8 +18,10 @@ import com.fr.stable.StringUtils; import javax.swing.Icon; import javax.swing.JMenu; +import javax.swing.JMenuItem; import javax.swing.JPopupMenu; import javax.swing.JToolBar; +import javax.swing.MenuElement; import javax.swing.event.MenuEvent; import javax.swing.event.MenuListener; import java.awt.Component; @@ -32,6 +35,8 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import static com.fine.theme.utils.FineUIStyle.setStyle; + /** * Define Menu. */ @@ -311,7 +316,13 @@ public class MenuDef extends ShortCut { */ public void updateMenu() { //peter:这个方法用来产生JMenu的孩子控件,但是不update,action. - this.updatePopupMenu(this.createJMenu().getPopupMenu()); + UIMenu jMenu = this.createJMenu(); + JPopupMenu jPopupMenu = jMenu.getPopupMenu(); + this.updatePopupMenu(jPopupMenu); + + if (jMenu instanceof UIHeadMenu) { + setToolBarClientProperty(jPopupMenu); + } //peter:需要设置JMenu的enabled属性. if (createdJMenu != null) { @@ -320,6 +331,26 @@ public class MenuDef extends ShortCut { } } + private void setToolBarClientProperty(JPopupMenu jPopupMenu) { + setStyle(jPopupMenu, FineUIStyle.POPUP_MENU_TOOL_BAR); + + MenuElement[] subElements = jPopupMenu.getSubElements(); + for (MenuElement subElement : subElements) { + if (subElement instanceof JMenu) { + JMenu jMenu = (JMenu) subElement; + setStyle(jMenu, FineUIStyle.MENU_TOOL_BAR); + JPopupMenu childPopupMenu = jMenu.getPopupMenu(); + setToolBarClientProperty(childPopupMenu); + } else if (subElement instanceof JMenuItem) { + JMenuItem jMenuItem = (JMenuItem) subElement; + setStyle(jMenuItem, FineUIStyle.MENU_ITEM_TOOL_BAR); + } + } + } + + + + public void updateEnable() { setEnabled(checkEnable()); } @@ -350,8 +381,11 @@ public class MenuDef extends ShortCut { } nec_seperator = false; } - - shortcut.intoJPopupMenu(popupMenu); + if (shortcut instanceof LineSeparator) { + popupMenu.addSeparator(); + } else { + shortcut.intoJPopupMenu(popupMenu); + } isFirstItem = false; } diff --git a/designer-base/src/main/java/com/fr/design/menu/NameSeparator.java b/designer-base/src/main/java/com/fr/design/menu/NameSeparator.java index b22184eb8f..f5a0a1a756 100644 --- a/designer-base/src/main/java/com/fr/design/menu/NameSeparator.java +++ b/designer-base/src/main/java/com/fr/design/menu/NameSeparator.java @@ -5,6 +5,7 @@ import com.fr.design.actions.UpdateAction; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.imenu.UIMenuItem; +import javax.swing.UIManager; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.FontMetrics; @@ -44,21 +45,12 @@ public class NameSeparator extends UpdateAction { private class MenuItem extends UIMenuItem { public MenuItem(String text) { - this.setUI(null); + this.setEnabled(false); this.removeAll(); this.setLayout(new BorderLayout()); this.add(new CustomerLable(text, UILabel.LEFT), BorderLayout.CENTER); } - public void paint(Graphics g) { - int w = this.getWidth(); - int h = this.getHeight(); - Graphics2D g2d = (Graphics2D)g; - g2d.setColor(getBackground()); - g2d.fillRect(0, 0, w, h); - super.paint(g); - } - public Dimension getSize() { return new Dimension(super.getSize().width, 20); } @@ -85,6 +77,7 @@ public class NameSeparator extends UpdateAction { for (int i = 0; i < str.length(); i++) { strwidth = strwidth + fm.charWidth(str.charAt(i)); } + g2d.setColor(UIManager.getColor("Separator.background")); g2d.drawLine(strwidth + 4, h / 2+2, w, h / 2+2); super.paint(g); } diff --git a/designer-base/src/main/java/com/fr/design/menu/SnapChatUpdateAction.java b/designer-base/src/main/java/com/fr/design/menu/SnapChatUpdateAction.java index 8cc0734371..d35972989c 100644 --- a/designer-base/src/main/java/com/fr/design/menu/SnapChatUpdateAction.java +++ b/designer-base/src/main/java/com/fr/design/menu/SnapChatUpdateAction.java @@ -57,7 +57,6 @@ public abstract class SnapChatUpdateAction extends UpdateAction implements SnapC UIMenuItem menuItem = new UIMenuItem(this); // 设置名字用作单元测 menuItem.setName(getName()); - menuItem.setUI(new SnapChatMenuItemUI(this)); object = menuItem; this.putValue(UIMenuItem.class.getName(), object); 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 55596987fe..8985e99dd0 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 @@ -13,14 +13,14 @@ FormattedTextFieldUI=com.formdev.flatlaf.ui.FlatFormattedTextFieldUI InternalFrameUI=com.formdev.flatlaf.ui.FlatInternalFrameUI LabelUI=com.formdev.flatlaf.ui.FlatLabelUI ListUI=com.formdev.flatlaf.ui.FlatListUI -MenuUI=com.formdev.flatlaf.ui.FlatMenuUI +MenuUI=com.fine.theme.light.ui.FineMenuUI MenuBarUI=com.formdev.flatlaf.ui.FlatMenuBarUI -MenuItemUI=com.formdev.flatlaf.ui.FlatMenuItemUI +MenuItemUI=com.fine.theme.light.ui.FineMenuItemUI OptionPaneUI=com.formdev.flatlaf.ui.FlatOptionPaneUI PanelUI=com.formdev.flatlaf.ui.FlatPanelUI PasswordFieldUI=com.formdev.flatlaf.ui.FlatPasswordFieldUI PopupMenuUI=com.fine.theme.light.ui.FinePopupMenuUI -PopupMenuSeparatorUI=com.formdev.flatlaf.ui.FlatPopupMenuSeparatorUI +PopupMenuSeparatorUI=com.fine.theme.light.ui.FinePopupMenuSeparatorUI ProgressBarUI=com.formdev.flatlaf.ui.FlatProgressBarUI RadioButtonUI=com.formdev.flatlaf.ui.FlatRadioButtonUI RadioButtonMenuItemUI=com.formdev.flatlaf.ui.FlatRadioButtonMenuItemUI 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 8f204787a6..d6994d04cf 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 @@ -135,6 +135,7 @@ text.highlight=fade(@foreground, 90%) fill.hover=#E6E9EF fill.click=#DADEE7 fill.normal=#FFFFFF +fill.gray=#F2F4F8 fill.disabled=#F2F4F8 border.divider=#DADEE7 tooltip.normal=#3F506A @@ -447,13 +448,16 @@ Menu.icon.disabledArrowColor = @buttonDisabledArrowColor Menu.border = com.formdev.flatlaf.ui.FlatMenuItemBorder Menu.arrowIcon = com.formdev.flatlaf.icons.FlatMenuArrowIcon Menu.checkIcon = null -Menu.margin = @menuItemMargin +Menu.margin=3,10,3,10 Menu.submenuPopupOffsetX = {scaledInteger}-4 Menu.submenuPopupOffsetY = {scaledInteger}-4 Menu.opaque = false Menu.borderPainted = true Menu.background = @menuBackground - +Menu.selectionBackground=$fill.hover +#Menu.selectionForeground=$text.white +#Menu.acceleratorForeground=@foreground +#Menu.acceleratorSelectionForeground=$text.white #---- MenuBar ---- @@ -471,25 +475,27 @@ MenuBar.selectionArc = $MenuItem.selectionArc MenuItem.border = com.formdev.flatlaf.ui.FlatMenuItemBorder MenuItem.arrowIcon = com.formdev.flatlaf.icons.FlatMenuItemArrowIcon MenuItem.checkIcon = null -MenuItem.margin=0,10,0,10 +MenuItem.margin=3,10,3,10 MenuItem.opaque = false MenuItem.borderPainted = true MenuItem.verticallyAlignText = true MenuItem.background = @menuBackground MenuItem.checkBackground = @menuCheckBackground MenuItem.checkMargins = 2,2,2,2 -MenuItem.minimumWidth = 72 +MenuItem.minimumWidth=150 MenuItem.minimumIconSize = 16,16 MenuItem.iconTextGap = 6 MenuItem.textAcceleratorGap = 24 MenuItem.textNoAcceleratorGap = 6 MenuItem.acceleratorArrowGap=4 MenuItem.acceleratorDelimiter = "+" +MenuItem.acceleratorForeground=@foreground +MenuItem.acceleratorSelectionForeground=@foreground [mac]MenuItem.acceleratorDelimiter = "" -MenuItem.selectionInsets = 0,0,0,0 -MenuItem.selectionArc = 0 -MenuItem.selectionBackground=$brand.normal -MenuItem.selectionForeground=$text.white +MenuItem.selectionInsets=0,4,0,4 +MenuItem.selectionArc=4 +MenuItem.selectionBackground=$fill.hover +MenuItem.selectionForeground=@foreground MenuItem.disabledForeground=fade(@foreground,29%) # for MenuItem.selectionType = underline @@ -497,6 +503,8 @@ MenuItem.underlineSelectionBackground = @menuHoverBackground MenuItem.underlineSelectionCheckBackground = @menuCheckBackground MenuItem.underlineSelectionColor = @accentUnderlineColor MenuItem.underlineSelectionHeight = 3 +#---- Separator ---- +Separator.background=$border.divider #---- OptionPane ---- @@ -560,13 +568,13 @@ PopupMenu.background=$background.normal PopupMenu.scrollArrowColor = @buttonArrowColor PopupMenu.borderColor=$border.divider PopupMenu.hoverScrollArrowBackground = darken(@background,5%) -PopupMenu.arc=$Component.arc +PopupMenu.arc=10 #---- PopupMenuSeparator ---- - -PopupMenuSeparator.height = 9 +PopupMenuSeparator.height=5 PopupMenuSeparator.stripeWidth = 1 PopupMenuSeparator.stripeIndent=2 +PopupMenuSeparator.Insets=0,10,0,10 #---- ProgressBar ---- @@ -1257,6 +1265,18 @@ CellOtherSetPane.height=$Component.defaultHeight [style]ToggleButton.inToolbarGroup = \ margin : 4,4,4,4; \ background : #fff +[style]Menu.menuToolBar=\ + selectionBackground : $brand.normal; \ + selectionForeground : $text.white; \ + acceleratorForeground : @foreground; \ + acceleratorSelectionForeground : $text.white +[style]MenuItem.menuItemToolBar=\ + selectionBackground : $brand.normal; \ + selectionForeground : $text.white; \ + acceleratorForeground : @foreground; \ + acceleratorSelectionForeground : $text.white +[style]PopupMenu.popupMenuToolBar=\ + background: $fill.gray #---- clearButton ---- # for clear/cancel button in text fields diff --git a/designer-base/src/test/java/com/fr/design/gui/storybook/components/PopupMenuStoryBoard.java b/designer-base/src/test/java/com/fr/design/gui/storybook/components/PopupMenuStoryBoard.java new file mode 100644 index 0000000000..fb4354d3df --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/gui/storybook/components/PopupMenuStoryBoard.java @@ -0,0 +1,103 @@ +package com.fr.design.gui.storybook.components; + +import com.fine.theme.icon.LazyIcon; +import com.fine.theme.utils.FineUIStyle; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.imenu.UIMenuItem; +import com.fr.design.gui.imenu.UIPopupMenu; +import com.fr.design.gui.storybook.Story; +import com.fr.design.gui.storybook.StoryBoard; +import com.fr.design.menu.DottedSeparator; +import com.fr.design.menu.NameSeparator; + +import javax.swing.JMenu; +import javax.swing.JMenuItem; +import javax.swing.JPopupMenu; +import javax.swing.MenuElement; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +import static com.fine.swing.ui.layout.Layouts.cell; +import static com.fine.swing.ui.layout.Layouts.column; +import static com.fine.theme.utils.FineUIStyle.setStyle; + +/** + * 弹窗组件 + * + * @author Leo.Qin + * @since 11.0 + * Created on 2024/1/8 + */ +@Story +public class PopupMenuStoryBoard extends StoryBoard { + public PopupMenuStoryBoard() { + super("弹窗"); + add( + column(70, + cell(new UIButton("点击展示弹窗")).with(it -> { + UIPopupMenu popupMenu = new UIPopupMenu(); + popupMenu.add(new UIMenuItem("test1", new LazyIcon("edit"))); + popupMenu.add(new UIMenuItem("test2", new LazyIcon("cellHyperLinkAttr"))); + popupMenu.addSeparator(); + popupMenu.add(new UIMenuItem("test3", new LazyIcon("cellClear"))); + popupMenu.add(new NameSeparator("分割线").createMenuItem()); + popupMenu.add(new UIMenuItem("test4", new LazyIcon("cellOtherAttr"))); + popupMenu.add(new DottedSeparator().createMenuItem()); + popupMenu.add(new UIMenuItem("test5", new LazyIcon("cellExpandAttr"))); + + it.addMouseListener(new MouseAdapter() { + + + @Override + public void mouseClicked(MouseEvent e) { + popupMenu.show(it, e.getX(), e.getY()); + } + }); + }), + + cell(new UIButton("点击展示菜单栏弹窗")).with(it -> { + UIPopupMenu popupMenu = new UIPopupMenu(); + popupMenu.add(new UIMenuItem("test1", new LazyIcon("edit"))); + popupMenu.add(new UIMenuItem("test2", new LazyIcon("cellHyperLinkAttr"))); + popupMenu.addSeparator(); + popupMenu.add(new UIMenuItem("test3", new LazyIcon("cellClear"))); + popupMenu.add(new NameSeparator("分割线").createMenuItem()); + popupMenu.add(new UIMenuItem("test4", new LazyIcon("cellOtherAttr"))); + popupMenu.add(new DottedSeparator().createMenuItem()); + popupMenu.add(new UIMenuItem("test5", new LazyIcon("cellExpandAttr"))); + + it.addMouseListener(new MouseAdapter() { + + + @Override + public void mouseClicked(MouseEvent e) { + popupMenu.show(it, e.getX(), e.getY()); + } + }); + + setToolBarClientProperty(popupMenu); + }) + ) + ); + + } + + + private void setToolBarClientProperty(JPopupMenu jPopupMenu) { + setStyle(jPopupMenu, FineUIStyle.POPUP_MENU_TOOL_BAR); + + MenuElement[] subElements = jPopupMenu.getSubElements(); + for (MenuElement subElement : subElements) { + if (subElement instanceof JMenu) { + JMenu jMenu = (JMenu) subElement; + JPopupMenu childPopupMenu = jMenu.getPopupMenu(); + setStyle(jMenu, FineUIStyle.MENU_TOOL_BAR); + setToolBarClientProperty(childPopupMenu); + } else if (subElement instanceof JMenuItem) { + JMenuItem jMenuItem = (JMenuItem) subElement; + setStyle(jMenuItem, FineUIStyle.MENU_ITEM_TOOL_BAR); + } + } + } + +} diff --git a/designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java b/designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java index 4d5fe8a62b..c5ec43463f 100644 --- a/designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java +++ b/designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java @@ -506,8 +506,6 @@ public class CellSelection extends Selection { popup.add(DeprecatedActionManager.getDeleteMenu(ePane)); popup.add(DeprecatedActionManager.getClearMenu(ePane)); - popup.addSeparator(); - addExtraMenu(ePane, popup); return popup; } diff --git a/designer-realize/src/main/java/com/fr/grid/selection/Selection.java b/designer-realize/src/main/java/com/fr/grid/selection/Selection.java index 1ddc54d432..d51707fb60 100644 --- a/designer-realize/src/main/java/com/fr/grid/selection/Selection.java +++ b/designer-realize/src/main/java/com/fr/grid/selection/Selection.java @@ -70,12 +70,17 @@ public abstract class Selection implements FCloneable, Serializable , Selectable * @param popupMenu */ public void addExtraMenu(ElementCasePane ePane, UIPopupMenu popupMenu) { + boolean existExtraMenu = false; Set selectionHandlerProviders = ExtraDesignClassManager.getInstance().getArray(RightSelectionHandlerProvider.XML_TAG); for (RightSelectionHandlerProvider handler : selectionHandlerProviders) { if (handler.accept(this)) { + existExtraMenu = true; handler.dmlMenu(ePane, popupMenu); } } + if (existExtraMenu) { + popupMenu.addSeparator(); + } } public abstract boolean clear(ElementCasePane.Clear type, ElementCasePane ePane);