From b71d6f55a6bdc8e16e43d4142380eb93a80f9368 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Levy=2EXie-=E8=A7=A3=E5=AE=89=E6=A3=AE?= Date: Mon, 4 Dec 2023 16:36:52 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-107972=20=E3=80=90UI=E7=BF=BB=E6=96=B0?= =?UTF-8?q?=E3=80=91=E7=BF=BB=E6=96=B0=E4=B8=9C=E5=8C=BA=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E9=9D=A2=E6=9D=BF=E4=BE=A7=E8=BE=B9=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fine/theme/light/ui/PropertiesItemUI.java | 39 +++++++++++++ .../icontainer/UIEastResizableContainer.java | 45 ++++++--------- .../mainframe/EastRegionContainerPane.java | 55 ++++++++----------- 3 files changed, 79 insertions(+), 60 deletions(-) create mode 100644 designer-base/src/main/java/com/fine/theme/light/ui/PropertiesItemUI.java diff --git a/designer-base/src/main/java/com/fine/theme/light/ui/PropertiesItemUI.java b/designer-base/src/main/java/com/fine/theme/light/ui/PropertiesItemUI.java new file mode 100644 index 0000000000..45ce82d352 --- /dev/null +++ b/designer-base/src/main/java/com/fine/theme/light/ui/PropertiesItemUI.java @@ -0,0 +1,39 @@ +package com.fine.theme.light.ui; + +import com.formdev.flatlaf.ui.FlatButtonUI; +import com.formdev.flatlaf.ui.FlatUIUtils; + +import javax.swing.JComponent; +import java.awt.*; + +/** + * 东区属性面板,属性按钮UI + * + * @author Levy.Xie + * @since 11.0 + * Created on 2023/11/30 + */ +public class PropertiesItemUI extends FlatButtonUI { + + + public PropertiesItemUI(boolean shared) { + super(shared); + } + + @Override + protected void paintBackground(Graphics g, JComponent c) { + Color background = getBackground( c ); + if( background == null ) { + return; + } + Graphics2D g2 = (Graphics2D) g.create(); + try { + FlatUIUtils.setRenderingHints( g2 ); + g2.setColor(FlatUIUtils.deriveColor(background, getBackgroundBase(c, true))); + float focusWidth = FlatUIUtils.getBorderFocusWidth( c ); + FlatUIUtils.paintComponentBackground( g2, 0, 0, c.getWidth(), c.getHeight(), focusWidth, 0 ); + } finally { + g2.dispose(); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java index 6c35310fa4..a366626153 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java +++ b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java @@ -1,23 +1,27 @@ package com.fr.design.gui.icontainer; +import com.fine.theme.icon.LazyIcon; import com.fr.design.base.mode.DesignModeContext; import com.fr.design.constants.UIConstants; import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.layout.VerticalFlowLayout; import com.fr.design.mainframe.DesignerContext; -import com.fr.design.utils.SvgDrawUtils; import com.fr.design.utils.gui.GUICoreUtils; +import javax.swing.BorderFactory; +import javax.swing.UIManager; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JPanel; +import javax.swing.Icon; +import javax.swing.border.Border; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Container; import java.awt.Cursor; import java.awt.Dimension; import java.awt.Graphics; -import java.awt.Image; import java.awt.LayoutManager; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -34,20 +38,18 @@ public class UIEastResizableContainer extends JPanel { private int containerWidth = 240; private int preferredWidth = 240; - private int topToolPaneHeight = 25; + private int topToolPaneHeight = 40; private int leftPaneWidth = 42; private JComponent leftPane; private JComponent rightPane; - // private HorizotalToolPane horizontToolPane; private TopToolPane topToolPane; private static final int ARROW_MARGIN = 15; private static final int ARROW_RANGE = 35; -// private boolean isRightPaneVisible = true; public UIEastResizableContainer() { this(new JPanel(), new JPanel()); @@ -68,21 +70,17 @@ public class UIEastResizableContainer extends JPanel { } -// public void setRightPaneVisible(boolean isVisible){ -// this.isRightPaneVisible = isVisible; -// } private void setPreferredWidth(int width) { this.preferredWidth = width; } public UIEastResizableContainer(JComponent leftPane, JComponent rightPane) { -// setBackground(UIConstants.PROPERTY_PANE_BACKGROUND); this.leftPane = leftPane; this.rightPane = rightPane; - this.topToolPane = new TopToolPane(); -// topToolPane.setBackground(UIConstants.PROPERTY_PANE_BACKGROUND); + topToolPane.setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 1, 0)); + topToolPane.setBorder(BorderFactory.createMatteBorder(1 ,1, 0, 1, UIManager.getColor("East.border"))); setLayout(containerLayout); add(topToolPane); @@ -176,12 +174,8 @@ public class UIEastResizableContainer extends JPanel { if (topToolPane == null || rightPane == null) { return; } - -// topToolPane.setBounds(0, 0, containerWidth, topToolPaneHeight);//0,0,10,462 topToolPane.setBounds(0, 0, leftPaneWidth, topToolPaneHeight);//0,0,10,462 leftPane.setBounds(0, topToolPaneHeight, leftPaneWidth, getHeight() - topToolPaneHeight); - -// parameterPane.setBounds(20, 0, 230, getParameterPaneHeight());//10,0,230,462 rightPane.setBounds(leftPaneWidth, 0, containerWidth - leftPaneWidth, getHeight());//20,0,230,0 } @@ -322,21 +316,18 @@ public class UIEastResizableContainer extends JPanel { @Override public void paint(Graphics g) { - Image button; + // 绘制边框 + Border border = getBorder(); + if (border != null) { + border.paintBorder(this, g, 0, 0, getWidth(), getHeight()); + } + Icon button; if (containerWidth == leftPaneWidth) { - if (model == UIConstants.MODEL_NORMAL) { - button = UIConstants.DRAG_LEFT_NORMAL; - } else { - button = UIConstants.DRAG_LEFT_PRESS; - } + button = new LazyIcon("drag_left"); } else { - if (model == UIConstants.MODEL_NORMAL) { - button = UIConstants.DRAG_RIGHT_NORMAL; - } else { - button = UIConstants.DRAG_RIGHT_PRESS; - } + button = new LazyIcon("drag_right"); } - SvgDrawUtils.doDrawSVG(g, () -> SvgDrawUtils.drawImage(g, button, 10, 7, null)); + button.paintIcon(this, g, 12, 12); } } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java index 9898d606ff..73b37acd6c 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java @@ -1,9 +1,10 @@ package com.fr.design.mainframe; +import com.fine.theme.icon.LazyIcon; +import com.fine.theme.light.ui.PropertiesItemUI; import com.formdev.flatlaf.FlatDarkLaf; import com.formdev.flatlaf.ui.FlatLineBorder; import com.fr.base.FRContext; -import com.fr.base.svg.IconUtils; import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; @@ -80,9 +81,9 @@ public class EastRegionContainerPane extends UIEastResizableContainer { private static final int CONTAINER_WIDTH = containerWidth(); private static final int TAB_WIDTH = 42; private static final int TAB_BUTTON_WIDTH = 40; - private static final int TAB_BUTTON_HEIGHT = 34; + private static final int TAB_BUTTON_HEIGHT = 40; private static final int CONTENT_WIDTH = CONTAINER_WIDTH - TAB_WIDTH; - private static final int POPUP_TOOLPANE_HEIGHT = 27; + private static final int POPUP_TOOLPANE_HEIGHT = 40; private static final int ARROW_RANGE_START = CONTENT_WIDTH - 30; // 弹出对话框高度 private static final int POPUP_MIN_HEIGHT = 145; @@ -416,7 +417,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer { // 左侧按钮面板 private void initLeftPane() { leftPane = new JPanel(); - leftPane.setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 1, 4)); + leftPane.setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 1, 0)); for (PropertyItem item : propertyItemMap.values()) { if (item.isPoppedOut() || !item.isVisible()) { continue; @@ -767,16 +768,15 @@ public class EastRegionContainerPane extends UIEastResizableContainer { // 完整icon路径为 ICON_BASE_DIR + btnIconName + iconSuffix private static final String ICON_BASE_DIR = "/com/fr/design/standard/propertiestab/"; - private static final String ICON_SUFFIX_NORMAL = "_normal.svg"; - private static final String ICON_SUFFIX_DISABLED = "_disabled.svg"; - private static final String ICON_SUFFIX_SELECTED = "_selected.svg"; + private static final String ICON_SUFFIX_NORMAL = StringUtils.EMPTY; + private static final String ICON_SUFFIX_DISABLED = "_disabled"; + private static final String ICON_SUFFIX_SELECTED = "_selected"; private static final int ICON_WIDTH = 18; private static final int ICON_HEIGHT = 18; private String btnIconName; private String iconBaseDir; private String iconSuffix = ICON_SUFFIX_NORMAL; // normal, diabled, selected, 三者之一 - private final Color selectedBtnBackground = new Color(0xF5F5F7); - private Color originBtnBackground; + private final Color selectedBtnBackground = UIManager.getColor("East.TabSelectedColor"); private ActionListener actionListener; @@ -967,15 +967,18 @@ public class EastRegionContainerPane extends UIEastResizableContainer { } private String getBtnIconUrl() { - return getIconBaseDir() + btnIconName + iconSuffix; } + private String getBtnIconId() { + return btnIconName + iconSuffix; + } + public void resetButtonIcon() { + button.setBackground(null); if (iconSuffix.equals(ICON_SUFFIX_SELECTED)) { iconSuffix = ICON_SUFFIX_NORMAL; - button.setIcon(IconUtils.readIcon(getBtnIconUrl())); -// button.setBackground(originBtnBackground); + button.setIcon(new LazyIcon(getBtnIconId())); button.setOpaque(false); } } @@ -983,8 +986,8 @@ public class EastRegionContainerPane extends UIEastResizableContainer { public void setTabButtonSelected() { resetPropertyIcons(); iconSuffix = ICON_SUFFIX_SELECTED; - button.setIcon(IconUtils.readIcon(getBtnIconUrl())); -// button.setBackground(selectedBtnBackground); + button.setIcon(new LazyIcon(getBtnIconId())); + button.setBackground(selectedBtnBackground); button.setOpaque(true); selectedItem = this; } @@ -994,28 +997,14 @@ public class EastRegionContainerPane extends UIEastResizableContainer { } private void initButton() { - button = new UIButton(IconUtils.readIcon(getBtnIconUrl())) { + button = new UIButton(new LazyIcon(getBtnIconId())) { public Dimension getPreferredSize() { return new Dimension(TAB_BUTTON_WIDTH, TAB_BUTTON_HEIGHT); } }; - button.setDisabledIcon(IconUtils.readIcon(getIconBaseDir() + btnIconName + ICON_SUFFIX_DISABLED)); + button.setDisabledIcon(new LazyIcon(btnIconName + ICON_SUFFIX_DISABLED)); button.set4LargeToolbarButton(); -// button.setUI(new UIButtonUI() { -// @Override -// protected void doExtraPainting(UIButton b, Graphics2D g2d, int w, int h, String selectedRoles) { -// if (isPressed(b) && b.isPressedPainted()) { -// Color pressColor = isTabButtonSelected() ? UIConstants.TAB_BUTTON_PRESS_SELECTED : UIConstants.TAB_BUTTON_PRESS; -// GUIPaintUtils.fillPressed(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), pressColor); -// } else if (isRollOver(b)) { -// Color hoverColor = isTabButtonSelected() ? UIConstants.TAB_BUTTON_HOVER_SELECTED : UIConstants.TAB_BUTTON_HOVER; -// GUIPaintUtils.fillRollOver(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted(), hoverColor); -// } else if (b.isNormalPainted()) { -// GUIPaintUtils.fillNormal(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted()); -// } -// } -// }); - originBtnBackground = button.getBackground(); + button.setUI(new PropertiesItemUI(false)); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -1284,9 +1273,9 @@ public class EastRegionContainerPane extends UIEastResizableContainer { this.propertyItem = propertyItem; this.title = propertyItem.getTitle(); originColor = UIConstants.UI_TOOLBAR_COLOR; + this.setForeground(UIManager.getColor("DarkenedFontColor")); contentPane = new JPanel(); -// contentPane.setBackground(originColor); contentPane.setLayout(new BorderLayout()); UILabel label = new UILabel(title); contentPane.add(label, BorderLayout.WEST); @@ -1294,7 +1283,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer { setLayout(new BorderLayout()); add(contentPane, BorderLayout.CENTER); - setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIConstants.TOOLBAR_BORDER_COLOR)); + setBorder(BorderFactory.createMatteBorder(1, 0, 1, 0, UIManager.getColor("East.border"))); initToolButton(buttonType); }