[prev in list] [next in list] [prev in thread] [next in thread]
List: gnuradio-commit
Subject: [Commit-gnuradio] [gnuradio] 17/23: grc: preserve block spacing when dragging multiple blocks into c
From: git () gnuradio ! org
Date: 2015-11-28 21:18:08
Message-ID: 20151128211808.81AAC1A8E42 () hertz ! gnuradio ! org
[Download RAW message or body]
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit dcc09deb064453f4add1ece3502ee99f12f3cb25
Author: Glenn Richardson <glenn.richardson@live.com>
Date: Thu Nov 19 20:34:55 2015 -0500
grc: preserve block spacing when dragging multiple blocks into canvas boundary
---
grc/gui/Block.py | 34 ++++++++++++++++++++++++++++++++++
grc/gui/FlowGraph.py | 3 +++
2 files changed, 37 insertions(+)
diff --git a/grc/gui/Block.py b/grc/gui/Block.py
index 6a2e496..8c74fcb 100644
--- a/grc/gui/Block.py
+++ b/grc/gui/Block.py
@@ -127,6 +127,40 @@ class Block(Element):
)
self.get_param('_coordinate').set_value(str(coor))
+ def bound_move_delta(self, delta_coor):
+ """
+ Limit potential moves from exceeding the bounds of the canvas
+
+ Args:
+ delta_coor: requested delta coordinate (dX, dY) to move
+
+ Returns:
+ The delta coordinate possible to move while keeping the block on the canvas
+ or the input (dX, dY) on failure
+ """
+ dX, dY = delta_coor
+
+ try:
+ fgW, fgH = self.get_parent().get_size()
+ x, y = map(int, eval(self.get_param("_coordinate").get_value()))
+ if self.is_horizontal():
+ sW, sH = self.W, self.H
+ else:
+ sW, sH = self.H, self.W
+
+ if x + dX < 0:
+ dX = -x
+ elif dX + x + sW >= fgW:
+ dX = fgW - x - sW
+ if y + dY < 0:
+ dY = -y
+ elif dY + y + sH >= fgH:
+ dY = fgH - y - sH
+ except:
+ pass
+
+ return ( dX, dY )
+
def get_rotation(self):
"""
Get the rotation from the position param.
diff --git a/grc/gui/FlowGraph.py b/grc/gui/FlowGraph.py
index 6d712e5..867a7cd 100644
--- a/grc/gui/FlowGraph.py
+++ b/grc/gui/FlowGraph.py
@@ -280,6 +280,9 @@ class FlowGraph(Element):
delta_coordinate: the change in coordinates
"""
for selected_block in self.get_selected_blocks():
+ delta_coordinate = selected_block.bound_move_delta(delta_coordinate)
+
+ for selected_block in self.get_selected_blocks():
selected_block.move(delta_coordinate)
self.element_moved = True
_______________________________________________
Commit-gnuradio mailing list
Commit-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/commit-gnuradio
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic