From ffa60a64f42eec1625a2ddd46921c71537cd4d2a Mon Sep 17 00:00:00 2001 From: Sebastian Koslowski <sebastian.koslowski@gmail.com> Date: Fri, 22 May 2020 21:23:55 +0200 Subject: grc: auto-shift colliding blocks when pasting --- grc/gui/canvas/flowgraph.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'grc/gui/canvas/flowgraph.py') 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()) -- cgit v1.2.3