Add an offset to the position of pasted nodes if a node is hovered

If a node is being hovered when the user performs the paste, an
offset is added to the mouse's position, both in the horizontal and
vertical directions. This aims at avoiding a complete overlap with
the nodes on top of which the clipboard content is pasted.
This commit is contained in:
Candice Bentéjac 2022-09-07 20:18:40 +02:00
parent 9f1b866e78
commit 61e0482a21
3 changed files with 11 additions and 1 deletions

View file

@ -826,6 +826,9 @@ class UIGraph(QObject):
if isinstance(position, QPoint):
position = Position(position.x(), position.y())
if self.hoveredNode:
# If a node is hovered, add an offset to prevent complete occlusion
position = Position(position.x + self.layout.gridSpacing, position.y + self.layout.gridSpacing)
# Get the position of the first node in a zone whose top-left corner is the mouse and the bottom-right
# corner the (x, y) coordinates, with x the maximum of all the nodes' position along the x-axis, and y the