diff options
author | Sebastian Koslowski <sebastian.koslowski@gmail.com> | 2020-05-22 21:23:55 +0200 |
---|---|---|
committer | mormj <34754695+mormj@users.noreply.github.com> | 2020-05-28 08:52:46 -0400 |
commit | ffa60a64f42eec1625a2ddd46921c71537cd4d2a (patch) | |
tree | a8159cabbe4a371449e4aaf48fc647c03e5a3e2c /grc/gui | |
parent | dfd31cb19fc8758b32b02609199dbea3e0637db6 (diff) |
grc: auto-shift colliding blocks when pasting
Diffstat (limited to 'grc/gui')
-rw-r--r-- | grc/gui/canvas/flowgraph.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/grc/gui/canvas/flowgraph.py b/grc/gui/canvas/flowgraph.py index 648b6c3d08..598f81b067 100644 --- a/grc/gui/canvas/flowgraph.py +++ b/grc/gui/canvas/flowgraph.py @@ -282,7 +282,12 @@ class FlowGraph(CoreFlowgraph, Drawable): pasted_blocks[block_name] = block # that is before any rename block.move((x_off, y_off)) - #TODO: prevent block from being pasted directly on top of another block + while any(Utils.align_to_grid(block.coordinate) == Utils.align_to_grid(other.coordinate) + for other in self.blocks if other is not block): + block.move((Constants.CANVAS_GRID_SIZE, Constants.CANVAS_GRID_SIZE)) + # shift all following blocks + x_off += Constants.CANVAS_GRID_SIZE + y_off += Constants.CANVAS_GRID_SIZE self.selected_elements = set(pasted_blocks.values()) |