From 03c1ccc659d63a613c3beb7785632a60bb321798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Thu, 19 Aug 2021 15:36:23 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-57128=20=E3=80=90FRM=E5=B8=83=E5=B1=80?= =?UTF-8?q?=E6=8E=A8=E8=8D=90=E3=80=91=E7=BB=84=E4=BB=B6=E5=A4=8D=E7=94=A8?= =?UTF-8?q?-=E5=85=B3=E4=BA=8E=E6=82=AC=E6=B5=AEhover=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E7=9A=84=E4=BA=A4=E4=BA=92=E8=AE=BE=E8=AE=A1=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/EditingMouseListener.java | 1 + .../com/fr/design/mainframe/FormDesigner.java | 2 +- .../mainframe/FormSpacingLineDrawer.java | 28 ++++++++++++++----- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java index 25726a5634..636fdcaaf1 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java @@ -217,6 +217,7 @@ public class EditingMouseListener extends MouseInputAdapter { int oldX = e.getX(); int oldY = e.getY(); offsetEventPoint(e); + designer.getSpacingLineDrawer().updateMouseEvent(e, false); if (e.isPopupTrigger()) { if (stateModel.isDragging()) { stateModel.draggingCancel(); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java b/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java index 7d7b341663..d193b6774f 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java @@ -1145,7 +1145,7 @@ public class FormDesigner extends TargetComponent
implements TreeSelection return comp == null ? container : comp; } - private XLayoutContainer getRootContainer(int y) { + public XLayoutContainer getRootContainer(int y) { XLayoutContainer container = y < paraHeight - formArea.getVerticalValue() ? paraComponent : rootComponent; if (container == null) { container = rootComponent; diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java b/designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java index 284df68e1c..977d55a686 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java @@ -1,6 +1,8 @@ package com.fr.design.mainframe; import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XCreatorUtils; +import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.utils.ComponentUtils; import com.fr.stable.Constants; import com.fr.stable.GraphDrawHelper; @@ -35,7 +37,7 @@ public class FormSpacingLineDrawer { public void updateMouseEvent(MouseEvent e, boolean isMouseMoveEvent) { XCreator creator = designer.getSelectionModel().getSelection().getSelectedCreator(); if (creator != null) { - this.hoverCreator = designer.getComponentAt(e.getX(), e.getY(), creator.getLevel()); + this.hoverCreator = getHoverComponentAt(e.getX(), e.getY()); } this.isMouseMoveEvent = isMouseMoveEvent; } @@ -147,13 +149,8 @@ public class FormSpacingLineDrawer { return isSelectedForm() || isSelectedRootComponent(); } - private boolean isSelectedCreatorSameParentWithHoveredCreator() { - XCreator selectedCreator = designer.getSelectionModel().getSelection().getSelectedCreator(); - return selectedCreator != null && hoverCreator != null && selectedCreator.getParent() == hoverCreator.getParent(); - } - private boolean isDrawSpacingLine() { - return !isSelectedRootPane() && isSelectedCreatorSameParentWithHoveredCreator() && isMouseMoveEvent; + return !isSelectedRootPane() && hoverCreator != null && isMouseMoveEvent; } private AbstractFormParallelLine[] getNearestHorizontalSide() { @@ -197,4 +194,21 @@ public class FormSpacingLineDrawer { } return nearestSides; } + + private XCreator getHoverComponentAt(int x, int y) { + XCreator component = designer.getComponentAt(x, y); + XLayoutContainer parent = XCreatorUtils.getHotspotContainer(component).getTopLayout(); + if (parent != null) { + if (!parent.isEditable()) { + return parent; + } else { + if (parent == component) { + return null; + } + return component; + } + } else { + return component; + } + } }