[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 17/23: grc: preserve block spacing when dra
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 17/23: grc: preserve block spacing when dragging multiple blocks into canvas boundary |
Date: |
Sat, 28 Nov 2015 21:18:08 +0000 (UTC) |
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 <address@hidden>
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] [gnuradio] 04/23: grc: try to load block class from <import> and <make> to extract docstring, (continued)
- [Commit-gnuradio] [gnuradio] 04/23: grc: try to load block class from <import> and <make> to extract docstring, git, 2015/11/28
- [Commit-gnuradio] [gnuradio] 03/23: grc: finish doc_string extraction in the background (faster start-up), git, 2015/11/28
- [Commit-gnuradio] [gnuradio] 18/23: Merge branch 'maint', git, 2015/11/28
- [Commit-gnuradio] [gnuradio] 11/23: gr-dtv: Fix Coverity issue #1327838., git, 2015/11/28
- [Commit-gnuradio] [gnuradio] 10/23: gr-dtv: Fix Coverity issue #1327858., git, 2015/11/28
- [Commit-gnuradio] [gnuradio] 20/23: Merge remote-tracking branch 'jdemel/maint', git, 2015/11/28
- [Commit-gnuradio] [gnuradio] 14/23: digital: clarify gmsk doc, git, 2015/11/28
- [Commit-gnuradio] [gnuradio] 15/23: grc: fix Action to str method, git, 2015/11/28
- [Commit-gnuradio] [gnuradio] 22/23: Merge remote-tracking branch 'gnuradio-wg-grc/master_grcwg', git, 2015/11/28
- [Commit-gnuradio] [gnuradio] 02/23: grc: move docstring extraction into subprocess, git, 2015/11/28
- [Commit-gnuradio] [gnuradio] 17/23: grc: preserve block spacing when dragging multiple blocks into canvas boundary,
git <=
- [Commit-gnuradio] [gnuradio] 16/23: grc: Added option to use the default editor when opening embedded python blocks, git, 2015/11/28
- [Commit-gnuradio] [gnuradio] 19/23: Merge remote-tracking branch 'drmpeg/dtv-coverity-clean', git, 2015/11/28
- [Commit-gnuradio] [gnuradio] 12/23: grc: added recently opened flowgraph submenu and toolbar button dropdown menu, git, 2015/11/28
- [Commit-gnuradio] [gnuradio] 06/23: grc: auto-generate missing hier_blocks, git, 2015/11/28
- [Commit-gnuradio] [gnuradio] 08/23: gr-dtv: Fix Coverity issue #1327535., git, 2015/11/28
- [Commit-gnuradio] [gnuradio] 09/23: gr-dtv: Fix Coverity issue #1327847., git, 2015/11/28
- [Commit-gnuradio] [gnuradio] 13/23: ctrlport: pc_throughput_avg registered, git, 2015/11/28
- [Commit-gnuradio] [gnuradio] 23/23: Merge branch 'maint', git, 2015/11/28
- [Commit-gnuradio] [gnuradio] 05/23: grc: refactoring Messages.py, git, 2015/11/28