Browse Source

REPORT-107972 【UI翻新】翻新东区属性面板侧边栏

newui
Levy.Xie-解安森 7 months ago
parent
commit
b71d6f55a6
  1. 39
      designer-base/src/main/java/com/fine/theme/light/ui/PropertiesItemUI.java
  2. 45
      designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java
  3. 55
      designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java

39
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();
}
}
}

45
designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java

@ -1,23 +1,27 @@
package com.fr.design.gui.icontainer; package com.fr.design.gui.icontainer;
import com.fine.theme.icon.LazyIcon;
import com.fr.design.base.mode.DesignModeContext; import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.layout.VerticalFlowLayout;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.utils.SvgDrawUtils;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.BorderFactory;
import javax.swing.UIManager;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.Icon;
import javax.swing.border.Border;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component; import java.awt.Component;
import java.awt.Container; import java.awt.Container;
import java.awt.Cursor; import java.awt.Cursor;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Image;
import java.awt.LayoutManager; import java.awt.LayoutManager;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
@ -34,20 +38,18 @@ public class UIEastResizableContainer extends JPanel {
private int containerWidth = 240; private int containerWidth = 240;
private int preferredWidth = 240; private int preferredWidth = 240;
private int topToolPaneHeight = 25; private int topToolPaneHeight = 40;
private int leftPaneWidth = 42; private int leftPaneWidth = 42;
private JComponent leftPane; private JComponent leftPane;
private JComponent rightPane; private JComponent rightPane;
// private HorizotalToolPane horizontToolPane;
private TopToolPane topToolPane; private TopToolPane topToolPane;
private static final int ARROW_MARGIN = 15; private static final int ARROW_MARGIN = 15;
private static final int ARROW_RANGE = 35; private static final int ARROW_RANGE = 35;
// private boolean isRightPaneVisible = true;
public UIEastResizableContainer() { public UIEastResizableContainer() {
this(new JPanel(), new JPanel()); 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) { private void setPreferredWidth(int width) {
this.preferredWidth = width; this.preferredWidth = width;
} }
public UIEastResizableContainer(JComponent leftPane, JComponent rightPane) { public UIEastResizableContainer(JComponent leftPane, JComponent rightPane) {
// setBackground(UIConstants.PROPERTY_PANE_BACKGROUND);
this.leftPane = leftPane; this.leftPane = leftPane;
this.rightPane = rightPane; this.rightPane = rightPane;
this.topToolPane = new TopToolPane(); 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); setLayout(containerLayout);
add(topToolPane); add(topToolPane);
@ -176,12 +174,8 @@ public class UIEastResizableContainer extends JPanel {
if (topToolPane == null || rightPane == null) { if (topToolPane == null || rightPane == null) {
return; return;
} }
// topToolPane.setBounds(0, 0, containerWidth, topToolPaneHeight);//0,0,10,462
topToolPane.setBounds(0, 0, leftPaneWidth, topToolPaneHeight);//0,0,10,462 topToolPane.setBounds(0, 0, leftPaneWidth, topToolPaneHeight);//0,0,10,462
leftPane.setBounds(0, topToolPaneHeight, leftPaneWidth, getHeight() - topToolPaneHeight); 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 rightPane.setBounds(leftPaneWidth, 0, containerWidth - leftPaneWidth, getHeight());//20,0,230,0
} }
@ -322,21 +316,18 @@ public class UIEastResizableContainer extends JPanel {
@Override @Override
public void paint(Graphics g) { 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 (containerWidth == leftPaneWidth) {
if (model == UIConstants.MODEL_NORMAL) { button = new LazyIcon("drag_left");
button = UIConstants.DRAG_LEFT_NORMAL;
} else {
button = UIConstants.DRAG_LEFT_PRESS;
}
} else { } else {
if (model == UIConstants.MODEL_NORMAL) { button = new LazyIcon("drag_right");
button = UIConstants.DRAG_RIGHT_NORMAL;
} else {
button = UIConstants.DRAG_RIGHT_PRESS;
}
} }
SvgDrawUtils.doDrawSVG(g, () -> SvgDrawUtils.drawImage(g, button, 10, 7, null)); button.paintIcon(this, g, 12, 12);
} }
} }
} }

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

@ -1,9 +1,10 @@
package com.fr.design.mainframe; 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.FlatDarkLaf;
import com.formdev.flatlaf.ui.FlatLineBorder; import com.formdev.flatlaf.ui.FlatLineBorder;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.svg.IconUtils;
import com.fr.base.vcs.DesignerMode; import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager; 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 CONTAINER_WIDTH = containerWidth();
private static final int TAB_WIDTH = 42; private static final int TAB_WIDTH = 42;
private static final int TAB_BUTTON_WIDTH = 40; 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 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 ARROW_RANGE_START = CONTENT_WIDTH - 30;
// 弹出对话框高度 // 弹出对话框高度
private static final int POPUP_MIN_HEIGHT = 145; private static final int POPUP_MIN_HEIGHT = 145;
@ -416,7 +417,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
// 左侧按钮面板 // 左侧按钮面板
private void initLeftPane() { private void initLeftPane() {
leftPane = new JPanel(); leftPane = new JPanel();
leftPane.setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 1, 4)); leftPane.setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 1, 0));
for (PropertyItem item : propertyItemMap.values()) { for (PropertyItem item : propertyItemMap.values()) {
if (item.isPoppedOut() || !item.isVisible()) { if (item.isPoppedOut() || !item.isVisible()) {
continue; continue;
@ -767,16 +768,15 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
// 完整icon路径为 ICON_BASE_DIR + btnIconName + iconSuffix // 完整icon路径为 ICON_BASE_DIR + btnIconName + iconSuffix
private static final String ICON_BASE_DIR = "/com/fr/design/standard/propertiestab/"; 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_NORMAL = StringUtils.EMPTY;
private static final String ICON_SUFFIX_DISABLED = "_disabled.svg"; private static final String ICON_SUFFIX_DISABLED = "_disabled";
private static final String ICON_SUFFIX_SELECTED = "_selected.svg"; private static final String ICON_SUFFIX_SELECTED = "_selected";
private static final int ICON_WIDTH = 18; private static final int ICON_WIDTH = 18;
private static final int ICON_HEIGHT = 18; private static final int ICON_HEIGHT = 18;
private String btnIconName; private String btnIconName;
private String iconBaseDir; private String iconBaseDir;
private String iconSuffix = ICON_SUFFIX_NORMAL; // normal, diabled, selected, 三者之一 private String iconSuffix = ICON_SUFFIX_NORMAL; // normal, diabled, selected, 三者之一
private final Color selectedBtnBackground = new Color(0xF5F5F7); private final Color selectedBtnBackground = UIManager.getColor("East.TabSelectedColor");
private Color originBtnBackground;
private ActionListener actionListener; private ActionListener actionListener;
@ -967,15 +967,18 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
} }
private String getBtnIconUrl() { private String getBtnIconUrl() {
return getIconBaseDir() + btnIconName + iconSuffix; return getIconBaseDir() + btnIconName + iconSuffix;
} }
private String getBtnIconId() {
return btnIconName + iconSuffix;
}
public void resetButtonIcon() { public void resetButtonIcon() {
button.setBackground(null);
if (iconSuffix.equals(ICON_SUFFIX_SELECTED)) { if (iconSuffix.equals(ICON_SUFFIX_SELECTED)) {
iconSuffix = ICON_SUFFIX_NORMAL; iconSuffix = ICON_SUFFIX_NORMAL;
button.setIcon(IconUtils.readIcon(getBtnIconUrl())); button.setIcon(new LazyIcon(getBtnIconId()));
// button.setBackground(originBtnBackground);
button.setOpaque(false); button.setOpaque(false);
} }
} }
@ -983,8 +986,8 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
public void setTabButtonSelected() { public void setTabButtonSelected() {
resetPropertyIcons(); resetPropertyIcons();
iconSuffix = ICON_SUFFIX_SELECTED; iconSuffix = ICON_SUFFIX_SELECTED;
button.setIcon(IconUtils.readIcon(getBtnIconUrl())); button.setIcon(new LazyIcon(getBtnIconId()));
// button.setBackground(selectedBtnBackground); button.setBackground(selectedBtnBackground);
button.setOpaque(true); button.setOpaque(true);
selectedItem = this; selectedItem = this;
} }
@ -994,28 +997,14 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
} }
private void initButton() { private void initButton() {
button = new UIButton(IconUtils.readIcon(getBtnIconUrl())) { button = new UIButton(new LazyIcon(getBtnIconId())) {
public Dimension getPreferredSize() { public Dimension getPreferredSize() {
return new Dimension(TAB_BUTTON_WIDTH, TAB_BUTTON_HEIGHT); 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.set4LargeToolbarButton();
// button.setUI(new UIButtonUI() { button.setUI(new PropertiesItemUI(false));
// @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.addActionListener(new ActionListener() { button.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -1284,9 +1273,9 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
this.propertyItem = propertyItem; this.propertyItem = propertyItem;
this.title = propertyItem.getTitle(); this.title = propertyItem.getTitle();
originColor = UIConstants.UI_TOOLBAR_COLOR; originColor = UIConstants.UI_TOOLBAR_COLOR;
this.setForeground(UIManager.getColor("DarkenedFontColor"));
contentPane = new JPanel(); contentPane = new JPanel();
// contentPane.setBackground(originColor);
contentPane.setLayout(new BorderLayout()); contentPane.setLayout(new BorderLayout());
UILabel label = new UILabel(title); UILabel label = new UILabel(title);
contentPane.add(label, BorderLayout.WEST); contentPane.add(label, BorderLayout.WEST);
@ -1294,7 +1283,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
setLayout(new BorderLayout()); setLayout(new BorderLayout());
add(contentPane, BorderLayout.CENTER); 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); initToolButton(buttonType);
} }

Loading…
Cancel
Save