Browse Source

Pull request #5715: REPORT-58919 看看绘制间距线判断的地方有没有优化的空间

Merge in DESIGN/design from ~FANGLEI/design10.0:release/11.0 to release/11.0

* commit 'a5e44c538743761610591e133fb0177145b7330e':
  REPORT-57722 看看绘制间距线判断的地方有没有优化的空间
  REPORT-57722 修正缺少的默认值
  REPORT-57722 看看绘制间距线判断的地方有没有优化的空间
persist/11.0
fanglei 3 years ago
parent
commit
7c359dc4c3
  1. 43
      designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java

43
designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java

@ -31,6 +31,7 @@ public class FormSpacingLineDrawer {
private FormDesigner designer; private FormDesigner designer;
private XCreator hoverCreator = null; private XCreator hoverCreator = null;
private XCreator selectedCreator = null;
private Rectangle selectedRec; private Rectangle selectedRec;
private Rectangle hoveredRec; private Rectangle hoveredRec;
private boolean isMouseMoveEvent = false; private boolean isMouseMoveEvent = false;
@ -40,19 +41,19 @@ public class FormSpacingLineDrawer {
} }
public void updateMouseEvent(MouseEvent e, boolean isMouseMoveEvent) { public void updateMouseEvent(MouseEvent e, boolean isMouseMoveEvent) {
XCreator creator = designer.getSelectionModel().getSelection().getSelectedCreator(); selectedCreator = designer.getSelectionModel().getSelection().getSelectedCreator();
if (creator != null) { if (selectedCreator != null) {
this.hoverCreator = getHoverComponentAt(e.getX(), e.getY()); this.hoverCreator = getHoverComponentAt(e.getX(), e.getY());
} }
this.isMouseMoveEvent = isMouseMoveEvent; this.isMouseMoveEvent = isMouseMoveEvent;
} }
public void draw(Graphics g) { public void draw(Graphics g) {
if (!isDrawSpacingLine()) { if (!isMouseMoveEvent || selectedCreator == null || hoverCreator == null) {
return; return;
} }
if (!hoverCreator.isParentAbsolute()) { if (!isDrawSpacingLine()) {
return; return;
} }
@ -137,15 +138,15 @@ public class FormSpacingLineDrawer {
} }
private boolean isSelectedParaComponent() { private boolean isSelectedParaComponent() {
return designer.getParaComponent() == designer.getSelectionModel().getSelection().getSelectedCreator(); return designer.getParaComponent() == selectedCreator;
} }
private boolean isSelectedRootComponent() { private boolean isSelectedRootComponent() {
return designer.isRoot(designer.getSelectionModel().getSelection().getSelectedCreator()); return designer.isRoot(selectedCreator);
} }
private boolean isSelectedForm() { private boolean isSelectedForm() {
return designer.getSelectionModel().getSelection().getSelectedCreator().getParent() == null; return selectedCreator.getParent() == null;
} }
private boolean isNeedExtendedLine(AbstractFormParallelLine[] nearestSides) { private boolean isNeedExtendedLine(AbstractFormParallelLine[] nearestSides) {
@ -158,33 +159,33 @@ public class FormSpacingLineDrawer {
} }
// 当前组件是否在参数面板里面 // 当前组件是否在参数面板里面
private boolean isCompInPara(XCreator creator) { private boolean isCompInBody(XCreator creator) {
XLayoutContainer container = XCreatorUtils.getHotspotContainer(creator); XLayoutContainer container = XCreatorUtils.getHotspotContainer(creator);
return container != null && !container.acceptType(XWParameterLayout.class);
}
boolean xCreatorAccept = creator.acceptType(XWParameterLayout.class); private boolean isSelectedCompInBody() {
boolean containerAccept = container != null && container.acceptType(XWParameterLayout.class); return isCompInBody(selectedCreator);
return xCreatorAccept || containerAccept;
} }
private boolean isBodyAbsoluteLayout() { private boolean isHoveredCompInBody() {
return !(designer instanceof FormParaDesigner) && FormDesignerUtils.isBodyAbsolute(designer); return isCompInBody(hoverCreator);
} }
private boolean isSelectedCompInPara() { private boolean isCompInBody() {
return isCompInPara(designer.getSelectionModel().getSelection().getSelectedCreator()); return isSelectedCompInBody() && isHoveredCompInBody();
} }
private boolean isHoveredCompInPara() { private boolean isBodyAbsoluteLayout() {
return isCompInPara(hoverCreator); return !(designer instanceof FormParaDesigner) && FormDesignerUtils.isBodyAbsolute(designer);
} }
private boolean isSelectedCompOrHoveredCompInPara() { private boolean isInAbsoluteLayout() {
return isSelectedCompInPara() || isHoveredCompInPara(); return isBodyAbsoluteLayout() && hoverCreator.isParentAbsolute() && selectedCreator.isParentAbsolute();
} }
private boolean isDrawSpacingLine() { private boolean isDrawSpacingLine() {
return isBodyAbsoluteLayout() && !isSelectedRootPane() && hoverCreator != null && !isSelectedCompOrHoveredCompInPara() && isMouseMoveEvent; return isInAbsoluteLayout() && !isSelectedRootPane() && isCompInBody();
} }
private AbstractFormParallelLine[] getNearestHorizontalSide() { private AbstractFormParallelLine[] getNearestHorizontalSide() {

Loading…
Cancel
Save