diff options
author | Christophe SEGUINOT <christophe.seguinot@univ-lille.fr> | 2021-04-06 13:34:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-06 07:34:40 -0400 |
commit | 42349ff2855c1bb0148c8191339189b0a4cee675 (patch) | |
tree | cd1c6cd6627d251b3a7c33a16ac2e8a13ceecccc /grc/gui | |
parent | 6c75d18485933f26e1ef545ae01779c132b49398 (diff) |
grc : fix block can move outside top and left boundary
* gui : fix block can move outside top and left boundary
Signed-off-by: Christophe Seguinot <christophe.seguinot@univ-lille.fr>
Co-authored-by: Sebastian Koslowski <sebastian.koslowski@gmail.com>
Diffstat (limited to 'grc/gui')
-rw-r--r-- | grc/gui/canvas/flowgraph.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/grc/gui/canvas/flowgraph.py b/grc/gui/canvas/flowgraph.py index 192fd3c1cb..61bf96378c 100644 --- a/grc/gui/canvas/flowgraph.py +++ b/grc/gui/canvas/flowgraph.py @@ -347,7 +347,22 @@ class FlowGraph(CoreFlowgraph, Drawable): Args: delta_coordinate: the change in coordinates """ - for selected_block in self.selected_blocks(): + + # Determine selected blocks top left coordinate + blocks = list(self.selected_blocks()) + if not blocks: + return + + min_x, min_y = self.selected_block.coordinate + for selected_block in blocks: + x, y = selected_block.coordinate + min_x, min_y = min(min_x, x), min(min_y, y) + + # Sanitize delta_coordinate so that blocks don't move to negative coordinate + delta_coordinate = max(delta_coordinate[0],-min_x), max(delta_coordinate[1], -min_y) + + # Move selected blocks + for selected_block in blocks: selected_block.move(delta_coordinate) self.element_moved = True |