Browse Source

REPORT-132283 feat: NewUI支持东区面板拖拽大小

fbp/release
Levy.Xie-解安森 3 months ago
parent
commit
ad297d2c00
  1. 13
      designer-base/src/main/java/com/fine/theme/utils/FineUIUtils.java
  2. 122
      designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java
  3. 9
      designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java
  4. 3
      designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties
  5. 3
      designer-base/src/main/resources/com/fr/design/i18n/dimension_ja_JP.properties
  6. 3
      designer-base/src/main/resources/com/fr/design/i18n/dimension_ko_KR.properties
  7. 3
      designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties
  8. 3
      designer-base/src/main/resources/com/fr/design/i18n/dimension_zh_TW.properties

13
designer-base/src/main/java/com/fine/theme/utils/FineUIUtils.java

@ -6,6 +6,7 @@ import com.fr.design.border.FineBorderFactory;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.DesignSizeI18nManager;
import com.fr.stable.os.OperatingSystem;
import com.fr.value.AtomicClearableLazyValue;
@ -16,6 +17,7 @@ import javax.swing.UIManager;
import java.awt.Color;
import java.awt.Component;
import java.awt.Composite;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
@ -435,4 +437,15 @@ public class FineUIUtils {
Font newSizeFont = font.deriveFont(font.getStyle(), scale(size));
c.setFont(newSizeFont);
}
/**
* 获取缩放后的国际化尺寸
*
* @param i18nDimensionKey 国际化key值
* @return 缩放后的国际化尺寸
*/
public static Dimension getScaledI18nDimension(String i18nDimensionKey) {
return FineUIScale.scale(DesignSizeI18nManager.getInstance().i18nDimension(i18nDimensionKey));
}
}

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

@ -3,27 +3,26 @@ package com.fr.design.gui.icontainer;
import com.fine.theme.icon.LazyIcon;
import com.fine.theme.utils.FineUIScale;
import com.fine.theme.utils.FineUIUtils;
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.gui.GUICoreUtils;
import javax.swing.BorderFactory;
import javax.swing.UIManager;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.Icon;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
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.LayoutManager;
import java.awt.Point;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
@ -34,32 +33,84 @@ import java.awt.event.MouseMotionListener;
public class UIEastResizableContainer extends JPanel {
private static final long serialVersionUID = 1854340560790476907L;
public static final int MAX_CONTAINER_WIDTH = FineUIScale.scale(340);
public static final int MIN_CONTAINER_WIDTH = FineUIScale.scale(286);
public static final int MAX_CONTAINER_WIDTH = FineUIUtils.getScaledI18nDimension(
"com.fr.design.mainframe.EastRegionContainerPane.maximum").width;
public static final int MIN_CONTAINER_WIDTH = FineUIUtils.getScaledI18nDimension(
"com.fr.design.mainframe.EastRegionContainerPane.minimum").width;
public static final int STD_CONTAINER_WIDTH = FineUIUtils.getScaledI18nDimension(
"com.fr.design.mainframe.EastRegionContainerPane.standard").width;
private int containerWidth = STD_CONTAINER_WIDTH;
private int preferredWidth = STD_CONTAINER_WIDTH;
protected final int leftPaneWidth = FineUIScale.scale(42);
protected final int topToolPaneHeight = FineUIScale.scale(40);
private int containerWidth = FineUIScale.scale(240);
private int preferredWidth = FineUIScale.scale(240);
private int topToolPaneHeight = FineUIScale.scale(40);
private int leftPaneWidth = FineUIScale.scale(42);
private static final int ARROW_RANGE = FineUIScale.scale(35);
private JComponent leftPane;
private JComponent rightPane;
private TopToolPane topToolPane;
private static final int ARROW_MARGIN = FineUIScale.scale(15);
private static final int ARROW_RANGE = FineUIScale.scale(35);
private static final int DRAG_GAP_SIZE = 10;
private Point dragPoint;
public UIEastResizableContainer() {
this(new JPanel(), new JPanel());
initMouseListener();
}
private void initMouseListener() {
MouseAdapter mouseAdapter = new MouseAdapter() {
@Override
public void mouseMoved(MouseEvent e) {
updateCursor(e);
}
@Override
public void mousePressed(MouseEvent e) {
if (isEnableDrag(e)) {
dragPoint = e.getPoint();
}
}
@Override
public void mouseDragged(MouseEvent e) {
resizePanel(e);
}
};
addMouseListener(mouseAdapter);
addMouseMotionListener(mouseAdapter);
}
private void updateCursor(MouseEvent e) {
if (isEnableDrag(e)) {
setCursor(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR));
} else {
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
}
protected boolean isEnableDrag(MouseEvent e) {
return e.getX() <= DRAG_GAP_SIZE && isRightPaneVisible();
}
protected void resizePanel(MouseEvent e) {
int dx = e.getX() - dragPoint.x;
Dimension size = getSize();
int newWidth = size.width - dx;
// 限制container大小为指定范围
containerWidth = Math.max(MIN_CONTAINER_WIDTH, Math.min(newWidth, MAX_CONTAINER_WIDTH));
SwingUtilities.invokeLater(this::revalidate);
}
/**
* 设置面板宽度
*
* @param width
* @param width 宽度
*/
public void setContainerWidth(int width) {
this.containerWidth = width;
@ -70,8 +121,6 @@ public class UIEastResizableContainer extends JPanel {
return containerWidth > leftPaneWidth;
}
private void setPreferredWidth(int width) {
this.preferredWidth = width;
}
@ -89,38 +138,6 @@ public class UIEastResizableContainer extends JPanel {
add(rightPane);
}
public static void main(String... args) {
JFrame jf = new JFrame("test");
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel content = (JPanel) jf.getContentPane();
content.setLayout(new BorderLayout());
JPanel leftPane = new JPanel();
// leftPane.setBackground(Color.yellow);
JPanel rightPane = new JPanel();
// rightPane.setBackground(Color.green);
UIButton b1, b2;
b1 = new UIButton("b1");
b2 = new UIButton("b2");
b1.setPreferredSize(new Dimension(40, 40));
b2.setPreferredSize(new Dimension(40, 40));
leftPane.add(b1);
leftPane.add(b2);
UIEastResizableContainer bb = new UIEastResizableContainer(leftPane, rightPane);
JPanel cc = new JPanel();
// cc.setBackground(Color.WHITE);
content.add(bb, BorderLayout.EAST);
content.add(cc, BorderLayout.CENTER);
GUICoreUtils.centerWindow(jf);
jf.setSize(500, 500);
jf.setVisible(true);
}
/**
* 将面板设置成最佳的宽度
*/
@ -156,7 +173,6 @@ public class UIEastResizableContainer extends JPanel {
@Override
public void removeLayoutComponent(Component comp) {
// TODO Auto-generated method stub
}
@ -182,7 +198,7 @@ public class UIEastResizableContainer extends JPanel {
@Override
public void addLayoutComponent(String name, Component comp) {
// do nothing
}
};

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

@ -142,10 +142,13 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
private static int containerWidth() {
if (FRContext.isChineseEnv()) {
return UIEastResizableContainer.MIN_CONTAINER_WIDTH;
return UIEastResizableContainer.STD_CONTAINER_WIDTH;
}
return UIEastResizableContainer.MAX_CONTAINER_WIDTH;
@Override
protected boolean isEnableDrag(MouseEvent e) {
return super.isEnableDrag(e)
&& e.getY() > topToolPaneHeight + leftPane.getPreferredSize().height;
}
/**

3
designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties

@ -30,3 +30,6 @@ com.fr.design.formula.FormulaPaneWhenReserveFormula=1200*600
com.fr.design.mainframe.mobile.ui.MobileStyleDefinePane.configLabel=130*20
com.fr.design.mainframe.mobile.utils.DesignerUtils.configLabel=140*20
com.fr.design.update.ui.dialog.UpdateMainDialog.updateButton=100*24
com.fr.design.mainframe.EastRegionContainerPane.maximum=600*400
com.fr.design.mainframe.EastRegionContainerPane.minimum=340*400
com.fr.design.mainframe.EastRegionContainerPane.standard=480*400

3
designer-base/src/main/resources/com/fr/design/i18n/dimension_ja_JP.properties

@ -29,3 +29,6 @@ com.fr.design.formula.FormulaPaneWhenReserveFormula=900*600
com.fr.design.mainframe.mobile.ui.MobileStyleDefinePane.configLabel=100*20
com.fr.design.mainframe.mobile.utils.DesignerUtils.configLabel=130*20
com.fr.design.update.ui.dialog.UpdateMainDialog.updateButton=160*24
com.fr.design.mainframe.EastRegionContainerPane.maximum=600*400
com.fr.design.mainframe.EastRegionContainerPane.minimum=340*400
com.fr.design.mainframe.EastRegionContainerPane.standard=480*400

3
designer-base/src/main/resources/com/fr/design/i18n/dimension_ko_KR.properties

@ -29,3 +29,6 @@ com.fr.design.formula.FormulaPaneWhenReserveFormula=900*600
com.fr.design.mainframe.mobile.ui.MobileStyleDefinePane.configLabel=75*20
com.fr.design.mainframe.mobile.utils.DesignerUtils.configLabel=100*20
com.fr.design.update.ui.dialog.UpdateMainDialog.updateButton=80*24
com.fr.design.mainframe.EastRegionContainerPane.maximum=500*400
com.fr.design.mainframe.EastRegionContainerPane.minimum=340*400
com.fr.design.mainframe.EastRegionContainerPane.standard=340*400

3
designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties

@ -29,3 +29,6 @@ com.fr.design.formula.FormulaPaneWhenReserveFormula=900*600
com.fr.design.mainframe.mobile.ui.MobileStyleDefinePane.configLabel=75*20
com.fr.design.mainframe.mobile.utils.DesignerUtils.configLabel=100*20
com.fr.design.update.ui.dialog.UpdateMainDialog.updateButton=80*24
com.fr.design.mainframe.EastRegionContainerPane.maximum=400*400
com.fr.design.mainframe.EastRegionContainerPane.minimum=286*400
com.fr.design.mainframe.EastRegionContainerPane.standard=286*400

3
designer-base/src/main/resources/com/fr/design/i18n/dimension_zh_TW.properties

@ -28,3 +28,6 @@ com.fr.design.formula.FormulaPaneWhenReserveFormula=900*600
com.fr.design.mainframe.mobile.ui.MobileStyleDefinePane.configLabel=75*20
com.fr.design.mainframe.mobile.utils.DesignerUtils.configLabel=100*20
com.fr.design.update.ui.dialog.UpdateMainDialog.updateButton=80*24
com.fr.design.mainframe.EastRegionContainerPane.maximum=400*400
com.fr.design.mainframe.EastRegionContainerPane.minimum=286*400
com.fr.design.mainframe.EastRegionContainerPane.standard=286*400

Loading…
Cancel
Save