Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving a node with keyboard crashes when scrollbar appears on its container #359

Closed
lredor opened this issue Apr 15, 2024 · 3 comments
Closed
Assignees
Labels
component: diagrams type: bug Something isn't working
Milestone

Comments

@lredor
Copy link
Contributor

lredor commented Apr 15, 2024

Steps to reproduce:

  • Import "KeyMovePb" project from KeyMovePbProject.zip
  • Open the diagram "diagramWithContainer"
  • Select "C1"
  • Use the right arrow key to move this node to the right
  • The first moves are OK.
  • But as soon as the scroll bar appears on "subPackage", pressing the right arrow key no longer has any effect.
  • If you press on the left arrow key, only the first press has effect. The scrollbar disappears, and the next pressing has no effect.

The video "movingRightElevenTimesThenMovingThreeTimes.mkv" in this archive replays this scenario.

@lredor lredor added type: bug Something isn't working component: diagrams labels Apr 15, 2024
@lredor
Copy link
Contributor Author

lredor commented Apr 17, 2024

Here are some technical analyses :

  • At each key press, NoCopyDragEditPartsTrackerEx.placeMouseInViewer() is called twice:
    • One for org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx.handleKeyDown(KeyEvent) line 296
    • and one for org.eclipse.gef.tools.DragEditPartsTracker.handleKeyDown(KeyEvent) line 461
  • In 2007, some changes have been done in GEF to allow GMF to override the GEF behavior concerning the moving with arrow keys (bugzilla 213359 - Make GEF's snapping and tools extensible to allow moving shapes with arrow keys and commit ecda0d3b. These changes have been done for bugzilla 111901- Ability to move shapes using cursors keys. (by default). If I remove the GMF override, ie in org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx.handleKeyDown(KeyEvent) only call super.handleKeyDown(e), I have no longer the problem. But I observed the problem described by Cherie Revells in the last comment of bug 213359.
  • At handleKeyDown call, org.eclipse.gef.tools.AbstractTool.accStepIncrement() computes the increment according to the duration of the key press (from 1 to 16 to have an acceleration of the move). This can explain a different behavior according the duration of the key press (first gap is from one to four).

Globally, the current GEF/GMF implementation does not allow solving the problem. This implementation is based on a simulation of a mouse move when one of the arrow key is pressed. But this implementation mixes absolutes GMF coordinates and mouse cursor coordinates that uses "screen" coordinates (for example in org.eclipse.gef.tools.AbstractTool.placeMouseInViewer(Point) by using org.eclipse.swt.widgets.Control.toDisplay(Point)). This way of doing things can not handle the case where a container has a scrollbar. Indeed, in this case, the "absolute coordinates" returned by Draw2D do not reflect the reals coordinates and can not be used to set the "mouse location".

Following these analyses, we decided to implement a new strategy that does not rely on mouse movement simulation. But that directly creates the request based on the arrow key pressed.

lredor added a commit that referenced this issue Apr 17, 2024
lredor added a commit that referenced this issue Apr 17, 2024
lredor added a commit that referenced this issue Apr 18, 2024
The test org.eclipse.sirius.tests.swtbot.SnapAllShapesTest.testMoveBorderNodeOnNodeInContainer()
has been updated. It used the same border nodes than
"testMoveBorderNodeOnBorderNode()". This case has been detected because
the new test class is inspired by this one.

Bug: #359
lredor added a commit that referenced this issue Apr 19, 2024
lredor added a commit that referenced this issue Apr 19, 2024
A rounding problem has been detected in GraphicalHelper and fixed during
these tests.

Bug: #359
lredor added a commit that referenced this issue Apr 19, 2024
This commit changes the CheckBoundsCondition to also be able to consider
the HandleBounds figure and the scrollbars.

A rounding problem has been detected in GraphicalHelper and fixed during
these tests.

Bug: #359
lredor added a commit that referenced this issue Apr 19, 2024
This commit changes the CheckBoundsCondition to also be able to consider
the HandleBounds figure and the scrollbars.

A rounding problem has been detected in GraphicalHelper and fixed during
these tests.

Bug: #359
lredor added a commit that referenced this issue Apr 25, 2024
lredor added a commit that referenced this issue Apr 25, 2024
This commit changes the CheckBoundsCondition to also be able to consider
the HandleBounds figure and the scrollbars.

A rounding problem has been detected in GraphicalHelper and fixed during
these tests.

Bug: #359
lredor added a commit that referenced this issue Apr 25, 2024
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: #359
@lredor
Copy link
Contributor Author

lredor commented Apr 25, 2024

Ideally this ticket would have required changes in GEF and GMF. For the moment, the change has been made directly in Sirius. Issues have been created to integrate the changes in GEF/GMF into future releases:

  • New GEF APIs :
    • Ticket GEF #426 - Make AbstractTool's accessibleStep mechanism accessible for subclasses : Closed and will be in next release release 4.20 for Eclipse 2024-06.
    • Ticket GMF #62 - Use GEF version 3.20
    • Ticket Sirius #376 - Clean code done for #359 by using new version of GMF/GEF: A PR is already available, #377 (but could be merged only when a GEF/GMF bump has been done on Sirius side).
  • Small GMF bug :
    • Ticket GMF #63 - Use precise coordinates in DragEditPartsTrackerEx.snapPoint with corresponding PR #64
    • Ticket Sirius #378 - Clean code done for #359 by using new version of GMF : A PR is already available, #379 (but could be merged only when a GMF bump has been done on Sirius side).

@lredor
Copy link
Contributor Author

lredor commented Apr 26, 2024

Known limitations:

Technically the behavior has been changed: The press to an arrow key now directly handle a "move request" to the concerned edit parts and the corresponding SetBoundsCommand are executed. But during the analysis of this issue some behaviors, that can be considered as limitations, have been detected. They are not in the scope of this issue:

  • A- The result of a "long" press to left (or top) arrow key on a node in a container, is that anchors of the node are visible in a "not visible" area. This behavior already existed before. Result in images:
    • Initial state: The node C1 is selected.
      1-1-Initial state
    • Result after long left key press: The diagram has been scrolled (and not the container)
      1-2-Result after long left key press
    • Result after selecting the diagram: The container subPackage has a "long" scrollbar and a manual scroll is necessary to reveal the node C1.
      1-3Result after selecting diagram
  • The grid is "fixed" on the diagram. If container has scrollbars, the "snap to grid" behavior can be sometimes strange.
    • B- The alignment is "true" for the current state of the container scrollbars but becomes "false" as soon as the scrollbar is moved. Result in images:
      • Initial state: The node C1 is selected. Its container has a vertical scrollbar as it contains another node lower down.
        2-1-Initial state
      • After a move to the right and a move to the bottom: The node C1 is aligned on horizontal and vertical grid.
        2-2-After moving node
      • After moving scrollbar: If the scrollbar is moved down, C1 is no longer aligned to the vertical grid.
        2-3-After moving scrollbar
    • C- According to the size of the moved node and the size of the grid step, the behavior can be strange when the node is moved "out of the current limits" of the node. The node seems not aligned to the grid and the following moves will not be as big as the step defined by the grid. Result in images:
      • Initial state: The node C1 is selected.
        3-1-Initial state
      • After a first move to the right: Everything is OK, the node C1 is aligned on the horizontal grid.
        3-2-After the first move
      • After a second move to the right: The node C1 seems not aligned to the grid. If we break down what happened:
        • The node has been moved and aligned on the grid,
        • a scrollbar appeared on the container because it was not big enough,
        • the scrollbar has been moved to reveal the node,
        • and so we fall back into the case above where the alignment on the grid is "temporarily" true.
          3-3-After the second move
      • After moving the scrollbar to its origin, we can see that the node is aligned to the grid.
        3-4-After moving scrollbar
      • If another move is done just after the second move, the move delta will not be a grid step as you can see on the following image.
        3-5-Following move

lredor added a commit that referenced this issue Apr 26, 2024
lredor added a commit that referenced this issue Apr 26, 2024
This commit changes the CheckBoundsCondition to also be able to consider
the HandleBounds figure and the scrollbars.

A rounding problem has been detected in GraphicalHelper and fixed during
these tests.

Bug: #359
lredor added a commit that referenced this issue Apr 26, 2024
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: #359
lredor added a commit that referenced this issue Apr 26, 2024
lredor added a commit that referenced this issue Apr 26, 2024
This commit changes the CheckBoundsCondition to also be able to consider
the HandleBounds figure and the scrollbars.

A rounding problem has been detected in GraphicalHelper and fixed during
these tests.

Bug: #359
lredor added a commit that referenced this issue Apr 26, 2024
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: #359
scosta-obeo added a commit that referenced this issue Apr 29, 2024
When the VSM is changed, the tooltip of all layers is updated. But the
tooltip list was never cleared between two menuShow. So the first n
tooltip text were always the same and the updated tooltips were in an
unreachable position (at the end) in the list.

Bug: #359
Signed-off-by: Séraphin Costa <seraphin.costa@obeosoft.com>
lredor added a commit that referenced this issue Apr 29, 2024
lredor added a commit that referenced this issue Apr 29, 2024
This commit changes the CheckBoundsCondition to also be able to consider
the HandleBounds figure and the scrollbars.

A rounding problem has been detected in GraphicalHelper and fixed during
these tests.

Bug: #359
lredor added a commit that referenced this issue Apr 29, 2024
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: #359
@lredor lredor added this to the v7.4.1 milestone Apr 30, 2024
@lredor lredor closed this as completed Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: diagrams type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant