prmr / JetUML

A desktop application for fast UML diagramming.
GNU General Public License v3.0
620 stars 121 forks source link

Flashing back and forth children nodes in PackageNode #487

Closed RuoyuDeng closed 1 year ago

RuoyuDeng commented 1 year ago

Description When one creates a class diagram with a package node that contains at least three children nodes, this bug will show up. The width of the package node is wider than what can be displayed on canvas. (e.g, the display zone has width 1000, and the package node has width 2000). The full content in the package can not be seen without scrolling the slide bar on the bottom. Let there be class node C1,C2,C3 in the package node. C1,C3 are located at the beginning of the left and right side of the package node and C1,C3 can not be displayed at the same time. After setting up such case, when one tries to move C2, it starts flying all around the places.

Steps to reproduce

  1. Set diagram size to Width = 2000, Height = 1000
  2. Create new 'class' diagram
  3. Click on 'package'
  4. Create 3 'class' nodes inside of the package
  5. Move one of them to the left boundary of the canvas and one of them to the right boundary of the canvas
  6. Any trial to move the third class node should cause the error to occur

Screenshots Before Zoom Out:

image

After Zoom Out:

image

Configuration

Additional information Zoom out can resolve such a problem because if we can see the left and right boundary of the package node at the same time, the renderer can make right decision about what to do when we move nodes around the place.

prmr commented 1 year ago

This issue occurs when trying to auto-scroll while dragging with a selection that exceeds the size of the viewport (area visible in a diagram tab). The auto-scroll feature attempts to always show the entire selection in the direction of the drag (e.g., dragging right, the right parts of the bounds). The calculations are correct but the user experience is not great.

To mitigate the issue, this fix implements two changes:

  1. The bounds of parent nodes are not automatically included in the bounds of a selection, which makes it possible to move the nodes within a package (for example) without the viewport trying to show the entire package. In small viewport environments, the UX will be greatly improved.
  2. When the bounds of the selection exceed the viewport in a dimension (X or Y), auto-scrolling automatically stops to prevent the jitter. Users can still scroll manually to adjust their viewport.