From 3b86f775bbfc2e869f90dd6dd696272d8922163f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Levy=2EXie-=E8=A7=A3=E5=AE=89=E6=A3=AE?= Date: Thu, 4 Jan 2024 19:54:27 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-111995=20=E3=80=90UI=E7=BF=BB=E6=96=B0?= =?UTF-8?q?=E3=80=91=E8=A5=BF=E5=8C=BA=E6=8B=96=E6=8B=BD=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E5=A4=84=E7=90=86/=E7=BD=91=E6=A0=BC=E8=89=B2=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/icontainer/UIResizableContainer.java | 143 +++++------------- .../fr/design/mainframe/ElementCasePane.java | 2 +- 2 files changed, 41 insertions(+), 104 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java index 535ba582ab..6cd8e8df4f 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java +++ b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java @@ -1,24 +1,23 @@ package com.fr.design.gui.icontainer; -import com.fr.base.vcs.DesignerMode; -import com.fr.design.constants.UIConstants; +import com.fine.theme.utils.FineUIScale; +import com.fr.design.base.mode.DesignModeContext; import com.fr.design.mainframe.DesignerContext; -import com.fr.design.utils.SvgDrawUtils; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.stable.Constants; +import javax.swing.BorderFactory; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.UIManager; +import javax.swing.border.Border; import java.awt.BorderLayout; import java.awt.Color; 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; @@ -26,31 +25,28 @@ import java.awt.event.MouseMotionListener; public class UIResizableContainer extends JPanel { private static final long serialVersionUID = 1854340560790476907L; - private static final int MAX_PARA_HEIGHT = 240; - private int containerWidth = 240; - private int preferredWidth = 240; - private int toolPaneY = 300; - private int toolPaneHeight = 10; - private int bottomHeight = 30; + private int maxParaHeight = FineUIScale.scale(240); + private int containerWidth = FineUIScale.scale(240); + private int preferredWidth = FineUIScale.scale(240); + private int toolPaneY = FineUIScale.scale(300); + private int toolPaneHeight = FineUIScale.scale(5); + private int bottomHeight = FineUIScale.scale(30); private JComponent upPane; private JComponent downPane; //放参数面板 private JComponent parameterPane = new JPanel(); - private HorizotalToolPane horizontToolPane; + private HorizontalToolPane horizontalToolPane; private VerticalToolPane verticalToolPane; private int direction; private boolean hasParameterPane; - private static final int MAX_WIDTH = 300; - private static final int MIN_WIDTH = 165; + private static final int MAX_WIDTH = FineUIScale.scale(300); - private static final int ARROW_MARGIN = 15; - private static final int ARROW_MARGIN_VERTICAL = 7; - private static final int ARROW_RANGE = 35; - private static final int ARROW_RANGE_VERTICAL = 25; + private static final int ARROW_RANGE = FineUIScale.scale(35); + private static final int ARROW_RANGE_VERTICAL = FineUIScale.scale(25); private boolean isLeftRightDragEnabled = true; private boolean isDownPaneVisible = true ; @@ -95,12 +91,12 @@ public class UIResizableContainer extends JPanel { this.direction = direction; this.downPane = downPane; - this.horizontToolPane = new HorizotalToolPane(); + this.horizontalToolPane = new HorizontalToolPane(); this.verticalToolPane = new VerticalToolPane(); setLayout(containerLayout); add(upPane); - add(horizontToolPane); + add(horizontalToolPane); add(downPane); add(verticalToolPane); } @@ -110,10 +106,10 @@ public class UIResizableContainer extends JPanel { this.upPane = upPane; this.direction = direction; - this.horizontToolPane = new HorizotalToolPane(); + this.horizontalToolPane = new HorizontalToolPane(); setLayout(containerLayout); add(upPane); - add(horizontToolPane); + add(horizontalToolPane); } @@ -152,7 +148,7 @@ public class UIResizableContainer extends JPanel { * @param height */ public void setParameterHeight(int height) { - paraHeight = hasParameterPane? Math.min(height, MAX_PARA_HEIGHT) : 0; + paraHeight = hasParameterPane? Math.min(height, maxParaHeight) : 0; refreshContainer(); } @@ -220,7 +216,7 @@ public class UIResizableContainer extends JPanel { if (direction == Constants.RIGHT) { if(isDownPaneVisible){ upPane.setBounds(0, 0, containerWidth - toolPaneHeight, toolPaneY); - horizontToolPane.setBounds(0, toolPaneY, containerWidth - toolPaneHeight, toolPaneHeight); + horizontalToolPane.setBounds(0, toolPaneY, containerWidth, toolPaneHeight); downPane.setBounds(0, toolPaneY + toolPaneHeight, containerWidth - toolPaneHeight, parent.getHeight() - toolPaneY - toolPaneHeight - bottomHeight); verticalToolPane.setBounds(containerWidth - toolPaneHeight, 0, toolPaneHeight, getHeight()); }else{ @@ -232,13 +228,13 @@ public class UIResizableContainer extends JPanel { if (toolPaneY > getHeight() - toolPaneHeight - getParameterPaneHeight()) { toolPaneY = getHeight() - toolPaneHeight - getParameterPaneHeight(); } - parameterPane.setBounds(20, 0, 230, getParameterPaneHeight()); + parameterPane.setBounds(FineUIScale.scale(20), 0, FineUIScale.scale(230), getParameterPaneHeight()); upPane.setBounds(toolPaneHeight, getParameterPaneHeight(), containerWidth - toolPaneHeight, toolPaneY); - horizontToolPane.setBounds(toolPaneHeight, toolPaneY + getParameterPaneHeight(), containerWidth - toolPaneHeight, toolPaneHeight); + horizontalToolPane.setBounds(toolPaneHeight, toolPaneY + getParameterPaneHeight(), containerWidth, toolPaneHeight); downPane.setBounds(toolPaneHeight, toolPaneY + toolPaneHeight + getParameterPaneHeight(), containerWidth - toolPaneHeight, parent.getHeight() - toolPaneY - toolPaneHeight - getParameterPaneHeight()); verticalToolPane.setBounds(0, 0, toolPaneHeight, getHeight()); } else { - parameterPane.setBounds(20, 0, 230, getParameterPaneHeight()); + parameterPane.setBounds(FineUIScale.scale(20), 0, FineUIScale.scale(230), getParameterPaneHeight()); upPane.setBounds(toolPaneHeight, getParameterPaneHeight(), containerWidth - toolPaneHeight, getHeight() - getParameterPaneHeight()); verticalToolPane.setBounds(0, 0, toolPaneHeight, getHeight()); } @@ -251,7 +247,7 @@ public class UIResizableContainer extends JPanel { parentHeight = parent.getHeight(); } if (parentHeight != parent.getHeight() && (parent.getHeight() - toolPaneHeight) >= 0) { - // 调整toolPaneY,保证至少水平的拖拽条horizontToolPane不丢失 + // 调整toolPaneY,保证至少水平的拖拽条horizontalToolPane不丢失 toolPaneY = Math.min(toolPaneY, parent.getHeight() - toolPaneHeight); parentHeight = parent.getHeight(); } @@ -267,7 +263,7 @@ public class UIResizableContainer extends JPanel { * 得到最佳大小 */ public Dimension getPreferredSize() { - return new Dimension(containerWidth, 400); + return new Dimension(containerWidth, FineUIScale.scale(400)); } /** @@ -350,24 +346,24 @@ public class UIResizableContainer extends JPanel { } - private class HorizotalToolPane extends JPanel { - private int upModel = UIConstants.MODEL_NORMAL; - private int downModel = UIConstants.MODEL_NORMAL; + private class HorizontalToolPane extends JPanel { - public HorizotalToolPane() { + private Border paneBorder = BorderFactory.createMatteBorder(1, 0, 0, 1, UIManager.getColor("East.border")); + private Border hideBorder = BorderFactory.createMatteBorder(0, 0, 0, 1, UIManager.getColor("East.border")); + private final JPanel toolPane = this; + + public HorizontalToolPane() { super(); + this.setBorder(paneBorder); addMouseMotionListener(new MouseMotionListener() { @Override public void mouseMoved(MouseEvent e) { if (e.getX() <= ARROW_RANGE) { setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); - upModel = UIConstants.MODEL_PRESS; } else if (e.getX() >= getWidth() - ARROW_RANGE) { setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); - downModel = UIConstants.MODEL_PRESS; } else { - resetModel(); setCursor(Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR)); } repaint(); @@ -376,8 +372,9 @@ public class UIResizableContainer extends JPanel { @Override public void mouseDragged(MouseEvent e) { toolPaneY = e.getYOnScreen() - UIResizableContainer.this.getLocationOnScreen().y; - toolPaneY = toolPaneY < 0 ? 0 : toolPaneY; + toolPaneY = Math.max(toolPaneY, 0); toolPaneY = toolPaneY > UIResizableContainer.this.getHeight() - toolPaneHeight ? UIResizableContainer.this.getHeight() - toolPaneHeight - getParameterPaneHeight() : toolPaneY - getParameterPaneHeight(); + toolPane.setBorder(toolPaneY == 0 ? hideBorder : paneBorder); refreshContainer(); } }); @@ -391,7 +388,6 @@ public class UIResizableContainer extends JPanel { @Override public void mouseExited(MouseEvent e) { setCursor(Cursor.getDefaultCursor()); - resetModel(); repaint(); } @@ -409,36 +405,20 @@ public class UIResizableContainer extends JPanel { }); } - private void resetModel() { - upModel = UIConstants.MODEL_NORMAL; - downModel = UIConstants.MODEL_NORMAL; - } - - @Override - public void paint(Graphics g) { - - Image upButton = (upModel == UIConstants.MODEL_NORMAL ? UIConstants.DRAG_UP_NORMAL : UIConstants.DRAG_UP_PRESS); - Image downButton = (downModel == UIConstants.MODEL_NORMAL ? UIConstants.DRAG_DOWN_NORMAL : UIConstants.DRAG_DOWN_PRESS); - g.setColor(UIManager.getColor("SplitPane.background")); - g.fillRect(0, 0, getWidth(), getHeight()); - SvgDrawUtils.doDrawSVG(g, () -> SvgDrawUtils.drawImage(g, UIConstants.DRAG_LINE, (getWidth() - toolPaneHeight) / 2, 3, null)); - SvgDrawUtils.doDrawSVG(g, () -> SvgDrawUtils.drawImage(g, upButton, ARROW_MARGIN, 0, null)); - SvgDrawUtils.doDrawSVG(g, () -> SvgDrawUtils.drawImage(g, downButton, (getWidth() - toolPaneHeight - ARROW_MARGIN), 0, null)); - } } private class VerticalToolPane extends JPanel { - private int model = UIConstants.MODEL_NORMAL; public VerticalToolPane() { super(); + this.setOpaque(false); + this.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, UIManager.getColor("East.border"))); addMouseMotionListener(new MouseMotionListener() { @Override public void mouseMoved(MouseEvent e) { if (e.getY() <= ARROW_RANGE_VERTICAL) { setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); - model = UIConstants.MODEL_PRESS; } else if (isLeftRightDragEnabled) { setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR)); } @@ -458,10 +438,10 @@ public class UIResizableContainer extends JPanel { containerWidth = UIResizableContainer.this.getWidth() + (UIResizableContainer.this.getLocationOnScreen().x - e.getXOnScreen()); } - containerWidth = containerWidth > MAX_WIDTH ? MAX_WIDTH : containerWidth; - containerWidth = containerWidth < MIN_WIDTH ? MIN_WIDTH : containerWidth; + containerWidth = Math.min(containerWidth, MAX_WIDTH); + containerWidth = Math.max(containerWidth, toolPaneHeight); refreshContainer(); - if (DesignerMode.isAuthorityEditing()) { + if (DesignModeContext.isAuthorityEditing()) { DesignerContext.getDesignerFrame().doResize(); } @@ -480,7 +460,6 @@ public class UIResizableContainer extends JPanel { @Override public void mouseExited(MouseEvent e) { setCursor(Cursor.getDefaultCursor()); - model = UIConstants.MODEL_NORMAL; repaint(); } @@ -494,7 +473,7 @@ public class UIResizableContainer extends JPanel { containerWidth = toolPaneHeight; } refreshContainer(); - if (DesignerMode.isAuthorityEditing()) { + if (DesignModeContext.isAuthorityEditing()) { DesignerContext.getDesignerFrame().doResize(); } } @@ -502,48 +481,6 @@ public class UIResizableContainer extends JPanel { }); } - @Override - public void paint(Graphics g) { - Image button; - g.setColor(UIManager.getColor("SplitPane.background")); - g.fillRect(0, 0, toolPaneHeight, getHeight()); - if (direction == Constants.RIGHT) { -// g.drawImage(UIConstants.DRAG_BAR_LIGHT, 0, 0, toolPaneHeight, getHeight(), null); - if (containerWidth == toolPaneHeight) { - if (model == UIConstants.MODEL_NORMAL) { - button = UIConstants.DRAG_RIGHT_NORMAL; - } else { - button = UIConstants.DRAG_RIGHT_PRESS; - } - } else { - if (model == UIConstants.MODEL_NORMAL) { - button = UIConstants.DRAG_LEFT_NORMAL; - } else { - button = UIConstants.DRAG_LEFT_PRESS; - } - } - SvgDrawUtils.doDrawSVG(g, () -> SvgDrawUtils.drawImage(g, button, -6, ARROW_MARGIN_VERTICAL, VerticalToolPane.this)); - } else { -// g.drawImage(UIConstants.DRAG_BAR_LIGHT, 0, 0, toolPaneHeight, getHeight(), null); - if (containerWidth == toolPaneHeight) { - if (model == UIConstants.MODEL_NORMAL) { - button = UIConstants.DRAG_LEFT_NORMAL; - } else { - button = UIConstants.DRAG_LEFT_PRESS; - } - } else { - if (model == UIConstants.MODEL_NORMAL) { - button = UIConstants.DRAG_RIGHT_NORMAL; - } else { - button = UIConstants.DRAG_RIGHT_PRESS; - } - } - SvgDrawUtils.doDrawSVG(g, () -> SvgDrawUtils.drawImage(g, button, 10, ARROW_MARGIN_VERTICAL, VerticalToolPane.this)); - } - if (isLeftRightDragEnabled) { - g.drawImage(UIConstants.DRAG_DOT_VERTICAL, 2, getHeight() / 2, 5, toolPaneHeight, null); - } - } } /** diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java b/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java index 0defeadfcd..2e8b0d5faa 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java @@ -3,6 +3,7 @@ */ package com.fr.design.mainframe; +import com.formdev.flatlaf.ui.FlatUIUtils; import com.fr.base.BaseFormula; import com.fr.base.DynamicUnitList; import com.fr.base.Formula; @@ -404,7 +405,6 @@ public abstract class ElementCasePane extends Tar grid.setDefaultFloatEditor(chartClass, new ChartFloatEditor()); } - addExtraCellEditor(grid); grid.setDefaultFloatEditor(Formula.class, new FormulaFloatEditor());