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