From 161d20e17882e4da6b1b9f4d475df19a104ec03a Mon Sep 17 00:00:00 2001 From: Laurent Redor Date: Thu, 25 Apr 2024 16:37:02 +0200 Subject: [PATCH] [359] Revert the snap to the perpendicular axis of the arrow direction This commit disables the snap to the perpendicular axis of the arrow direction. Indeed, if the user moves a node in the left direction, for example, it doesn't want to see its node moves up or down too. The tests have also been adapted. Bug: https://github.com/eclipse-sirius/sirius-desktop/issues/359 --- .../tools/internal/ui/SnapToAllDragEditPartsTracker.java | 7 +------ .../tests/swtbot/MoveAllShapesWithArrowKeysTest.java | 6 +++--- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/ui/SnapToAllDragEditPartsTracker.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/ui/SnapToAllDragEditPartsTracker.java index 2b0eeeaefa..1e607c59c2 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/ui/SnapToAllDragEditPartsTracker.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/ui/SnapToAllDragEditPartsTracker.java @@ -133,8 +133,7 @@ protected void snapPoint(ChangeBoundsRequest request) { } else { // Copied from // org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx.snapPoint(ChangeBoundsRequest) - // Adapted to force the snap in the expected initial direction but also to allow the snap in other - // perpendicular directions. + // Adapted to use precise coordinates for move delta (in case of zoom of 50% for example). Point moveDelta = request.getMoveDelta(); if (getState() == STATE_ACCESSIBLE_DRAG_IN_PROGRESS) { int restrictedDirection = 0; @@ -143,16 +142,12 @@ protected void snapPoint(ChangeBoundsRequest request) { restrictedDirection = restrictedDirection | PositionConstants.EAST; } else if (moveDelta.preciseX() < 0) { restrictedDirection = restrictedDirection | PositionConstants.WEST; - } else { - restrictedDirection = restrictedDirection | PositionConstants.EAST_WEST; } if (moveDelta.preciseY() > 0) { restrictedDirection = restrictedDirection | PositionConstants.SOUTH; } else if (moveDelta.preciseY() < 0) { restrictedDirection = restrictedDirection | PositionConstants.NORTH; - } else { - restrictedDirection = restrictedDirection | PositionConstants.NORTH_SOUTH; } request.getExtendedData().put(SnapToHelperUtil.RESTRICTED_DIRECTIONS, restrictedDirection); diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/MoveAllShapesWithArrowKeysTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/MoveAllShapesWithArrowKeysTest.java index 1350d89b35..ec4412c274 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/MoveAllShapesWithArrowKeysTest.java +++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/MoveAllShapesWithArrowKeysTest.java @@ -118,7 +118,7 @@ protected void tearDown() throws Exception { * expected one (snap to the grid).
*/ public void testMoveContainer() { - moveInDirection("Container_p1", AbstractDiagramContainerEditPart.class, SWT.ARROW_RIGHT, false); + moveInDirection("Container_p1", AbstractDiagramContainerEditPart.class, SWT.ARROW_RIGHT, false, false, true); } /** @@ -128,7 +128,7 @@ public void testMoveContainer() { * one (snap to the grid).
*/ public void testMoveNode() { - moveInDirection("Node_p1", AbstractDiagramNodeEditPart.class, SWT.ARROW_DOWN, true); + moveInDirection("Node_p1", AbstractDiagramNodeEditPart.class, SWT.ARROW_DOWN, true, true, false); } /** @@ -140,7 +140,7 @@ public void testMoveNode() { * the expected one (snap to the brother).
*/ protected void testMoveNodeInContainer(ZoomLevel zoomLevel) { - moveInDirection("NC_C1", AbstractDiagramNodeEditPart.class, SWT.ARROW_RIGHT, true, false, false, zoomLevel); + moveInDirection("NC_C1", AbstractDiagramNodeEditPart.class, SWT.ARROW_RIGHT, true, false, true, zoomLevel); // Third move with snap to shape (as a brother is near) SWTBotGefEditPart elementToMove = editor.getEditPart("NC_C1", AbstractDiagramNodeEditPart.class);