Browse Source

REPORT-107973 工具栏反白图标绘制

newui
Leo.Qin 11 months ago
parent
commit
b818ebb5d9
  1. 40
      designer-base/src/main/java/com/fine/theme/light/ui/FineMenuUI.java
  2. 2
      designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java
  3. 8
      designer-base/src/main/java/com/fr/design/menu/MenuDef.java
  4. 2
      designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLaf.properties
  5. 3
      designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties
  6. 33
      designer-base/src/test/java/com/fr/design/gui/storybook/components/PopupMenuStoryBoard.java

40
designer-base/src/main/java/com/fine/theme/light/ui/FineMenuUI.java

@ -1,40 +0,0 @@
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);
}
}

2
designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java

@ -1,6 +1,7 @@
package com.fr.design.mainframe;
import com.fine.theme.icon.LazyIcon;
import com.fine.theme.light.ui.RectangleButtonUI;
import com.fine.theme.utils.FineUIScale;
import com.fine.theme.utils.FineUIUtils;
import com.formdev.flatlaf.FlatDarkLaf;
@ -1004,6 +1005,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
};
button.setDisabledIcon(new LazyIcon(btnIconName + ICON_SUFFIX_DISABLED));
button.set4LargeToolbarButton();
button.setUI(new RectangleButtonUI(false));
setStyle(button, STYLE_TEXT);
button.addActionListener(new ActionListener() {
@Override

8
designer-base/src/main/java/com/fr/design/menu/MenuDef.java

@ -361,11 +361,19 @@ public class MenuDef extends ShortCut {
for (MenuElement subElement : subElements) {
if (subElement instanceof JMenu) {
JMenu jMenu = (JMenu) subElement;
Icon icon = jMenu.getIcon();
if (icon instanceof LazyIcon && jMenu.getSelectedIcon() == null) {
jMenu.setSelectedIcon(((LazyIcon) icon).white());
}
setStyle(jMenu, FineUIStyle.MENU_TOOL_BAR);
JPopupMenu childPopupMenu = jMenu.getPopupMenu();
setToolBarClientProperty(childPopupMenu);
} else if (subElement instanceof JMenuItem) {
JMenuItem jMenuItem = (JMenuItem) subElement;
Icon icon = jMenuItem.getIcon();
if (icon instanceof LazyIcon && jMenuItem.getSelectedIcon() == null) {
jMenuItem.setSelectedIcon(((LazyIcon) icon).white());
}
setStyle(jMenuItem, FineUIStyle.MENU_ITEM_TOOL_BAR);
}
}

2
designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLaf.properties

@ -13,7 +13,7 @@ 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.fine.theme.light.ui.FineMenuUI
MenuUI=com.formdev.flatlaf.ui.FlatMenuUI
MenuBarUI=com.formdev.flatlaf.ui.FlatMenuBarUI
MenuItemUI=com.fine.theme.light.ui.FineMenuItemUI
OptionPaneUI=com.formdev.flatlaf.ui.FlatOptionPaneUI

3
designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties

@ -1274,7 +1274,8 @@ CellOtherSetPane.height=$Component.defaultHeight
selectionBackground : $brand.normal; \
selectionForeground : $text.white; \
acceleratorForeground : @foreground; \
acceleratorSelectionForeground : $text.white
acceleratorSelectionForeground : $text.white; \
icon.arrowType : triangle;
[style]MenuItem.menuItemToolBar=\
selectionBackground : $brand.normal; \
selectionForeground : $text.white; \

33
designer-base/src/test/java/com/fr/design/gui/storybook/components/PopupMenuStoryBoard.java

@ -10,16 +10,20 @@ import com.fr.design.gui.storybook.StoryBoard;
import com.fr.design.menu.DottedSeparator;
import com.fr.design.menu.NameSeparator;
import javax.swing.Icon;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.KeyStroke;
import javax.swing.MenuElement;
import java.awt.event.KeyEvent;
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;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
/**
* 弹窗组件
@ -36,14 +40,19 @@ public class PopupMenuStoryBoard extends StoryBoard {
column(70,
cell(new UIButton("点击展示弹窗")).with(it -> {
UIPopupMenu popupMenu = new UIPopupMenu();
popupMenu.add(new UIMenuItem("test1", new LazyIcon("edit")));
popupMenu.add(new UIMenuItem("test1"));
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")));
UIMenuItem menuItem = new UIMenuItem("test4", new LazyIcon("cellOtherAttr"));
menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, DEFAULT_MODIFIER));
popupMenu.add(menuItem);
popupMenu.add(new DottedSeparator().createMenuItem());
popupMenu.add(new UIMenuItem("test5", new LazyIcon("cellExpandAttr")));
JMenu test5 = new JMenu("test5");
test5.setIcon(new LazyIcon("cellExpandAttr"));
popupMenu.add(test5);
it.addMouseListener(new MouseAdapter() {
@ -57,14 +66,18 @@ public class PopupMenuStoryBoard extends StoryBoard {
cell(new UIButton("点击展示菜单栏弹窗")).with(it -> {
UIPopupMenu popupMenu = new UIPopupMenu();
popupMenu.add(new UIMenuItem("test1", new LazyIcon("edit")));
popupMenu.add(new UIMenuItem("test1"));
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")));
UIMenuItem menuItem = new UIMenuItem("test4", new LazyIcon("cellOtherAttr"));
menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, DEFAULT_MODIFIER));
popupMenu.add(menuItem);
popupMenu.add(new DottedSeparator().createMenuItem());
popupMenu.add(new UIMenuItem("test5", new LazyIcon("cellExpandAttr")));
JMenu test5 = new JMenu("test5");
test5.setIcon(new LazyIcon("cellExpandAttr"));
popupMenu.add(test5);
it.addMouseListener(new MouseAdapter() {
@ -90,11 +103,19 @@ public class PopupMenuStoryBoard extends StoryBoard {
for (MenuElement subElement : subElements) {
if (subElement instanceof JMenu) {
JMenu jMenu = (JMenu) subElement;
Icon icon = jMenu.getIcon();
if (icon instanceof LazyIcon && jMenu.getSelectedIcon() == null) {
jMenu.setSelectedIcon(((LazyIcon) icon).white());
}
JPopupMenu childPopupMenu = jMenu.getPopupMenu();
setStyle(jMenu, FineUIStyle.MENU_TOOL_BAR);
setToolBarClientProperty(childPopupMenu);
} else if (subElement instanceof JMenuItem) {
JMenuItem jMenuItem = (JMenuItem) subElement;
Icon icon = jMenuItem.getIcon();
if (icon instanceof LazyIcon && jMenuItem.getSelectedIcon() == null) {
jMenuItem.setSelectedIcon(((LazyIcon) icon).white());
}
setStyle(jMenuItem, FineUIStyle.MENU_ITEM_TOOL_BAR);
}
}

Loading…
Cancel
Save