|
|
|
@ -1,12 +1,10 @@
|
|
|
|
|
package com.fr.design.gui.icontainer; |
|
|
|
|
|
|
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
|
import com.fr.base.vcs.DesignerMode; |
|
|
|
|
import com.fr.design.constants.UIConstants; |
|
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
|
|
import com.fr.stable.Constants; |
|
|
|
|
import com.fr.design.utils.gui.GUICoreUtils; |
|
|
|
|
import com.fr.stable.collections.utils.MathUtils; |
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
|
import java.awt.*; |
|
|
|
@ -46,6 +44,7 @@ public class UIResizableContainer extends JPanel {
|
|
|
|
|
private boolean isDownPaneVisible = true ; |
|
|
|
|
private int paraHeight; |
|
|
|
|
private int parentHeight = -1; |
|
|
|
|
private double toolPaneYRate; |
|
|
|
|
|
|
|
|
|
public UIResizableContainer(int direction) { |
|
|
|
|
this(new JPanel(), new JPanel(), direction); |
|
|
|
@ -159,12 +158,19 @@ public class UIResizableContainer extends JPanel {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 设置关闭设计器前最后一次上下子面板的高度 |
|
|
|
|
* |
|
|
|
|
* @param toolPaneY |
|
|
|
|
* 获取上子面板高度占容器总高度的比例 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public double getToolPaneYRate() { |
|
|
|
|
return toolPaneYRate; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 设置关闭设计器前最新的上子面板的高度比例 |
|
|
|
|
* @param toolPaneYRate |
|
|
|
|
*/ |
|
|
|
|
public void setLastToolPaneY(int toolPaneY) { |
|
|
|
|
this.toolPaneY = toolPaneY; |
|
|
|
|
public void setLastToolPaneYRate(double toolPaneYRate) { |
|
|
|
|
this.toolPaneYRate = toolPaneYRate; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -242,12 +248,12 @@ public class UIResizableContainer extends JPanel {
|
|
|
|
|
if (parentHeight == -1) { |
|
|
|
|
// 初始化下parentheight,存一下当前的父容器height
|
|
|
|
|
parentHeight = parent.getHeight(); |
|
|
|
|
} else if (parentHeight != parent.getHeight()) { |
|
|
|
|
// parentHeight与父容器height不等时,代表用户调整分辨率或者dpi了,此时调整toolPaneY
|
|
|
|
|
toolPaneY = toolPaneY * parent.getHeight() / parentHeight; |
|
|
|
|
toolPaneY = Math.min(toolPaneY, (parent.getHeight() - toolPaneHeight)); |
|
|
|
|
} else if (parentHeight != parent.getHeight() && parent.getHeight() > 0) { |
|
|
|
|
// parentHeight与父容器height不等时,代表用户调整分辨率或者dpi或者容器高度发生变化了,此时调整toolPaneY
|
|
|
|
|
toolPaneY = Math.min((int) (parent.getHeight() * toolPaneYRate), (parent.getHeight() - toolPaneHeight)); |
|
|
|
|
parentHeight = parent.getHeight(); |
|
|
|
|
} |
|
|
|
|
System.out.println("toolPaneY:" + toolPaneY + ", rate:" + toolPaneYRate); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -371,6 +377,7 @@ public class UIResizableContainer extends JPanel {
|
|
|
|
|
toolPaneY = e.getYOnScreen() - UIResizableContainer.this.getLocationOnScreen().y; |
|
|
|
|
toolPaneY = toolPaneY < 0 ? 0 : toolPaneY; |
|
|
|
|
toolPaneY = toolPaneY > UIResizableContainer.this.getHeight() - toolPaneHeight ? UIResizableContainer.this.getHeight() - toolPaneHeight - getParameterPaneHeight() : toolPaneY - getParameterPaneHeight(); |
|
|
|
|
adjustToolPaneYRate(); |
|
|
|
|
refreshContainer(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
@ -392,8 +399,10 @@ public class UIResizableContainer extends JPanel {
|
|
|
|
|
public void mouseClicked(MouseEvent e) { |
|
|
|
|
if (e.getX() <= ARROW_RANGE) { |
|
|
|
|
toolPaneY = 0; |
|
|
|
|
UIResizableContainer.this.adjustToolPaneYRate(); |
|
|
|
|
} else if (e.getX() >= getWidth() - ARROW_RANGE) { |
|
|
|
|
toolPaneY = UIResizableContainer.this.getHeight() - toolPaneHeight - getParameterPaneHeight(); |
|
|
|
|
UIResizableContainer.this.adjustToolPaneYRate(); |
|
|
|
|
} else { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
@ -554,4 +563,11 @@ public class UIResizableContainer extends JPanel {
|
|
|
|
|
jf.setSize(500, 500); |
|
|
|
|
jf.setVisible(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 当toolPaneY发生变化时,也需要调整toolPaneYRate |
|
|
|
|
*/ |
|
|
|
|
private void adjustToolPaneYRate() { |
|
|
|
|
this.toolPaneYRate = ((double) toolPaneY) / this.getHeight(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|