[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 07/13: grc: fix bus ports spacing in gui
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 07/13: grc: fix bus ports spacing in gui |
Date: |
Fri, 24 Jul 2015 15:33:49 +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 72048e6e8144d4e0a342a41753ec68d357beb04c
Author: Sebastian Koslowski <address@hidden>
Date: Fri Jul 17 13:49:06 2015 +0200
grc: fix bus ports spacing in gui
---
grc/gui/Block.py | 22 ++++++++++++++--------
grc/gui/Port.py | 26 ++++++++++++++++----------
2 files changed, 30 insertions(+), 18 deletions(-)
diff --git a/grc/gui/Block.py b/grc/gui/Block.py
index 83706ed..11273a5 100644
--- a/grc/gui/Block.py
+++ b/grc/gui/Block.py
@@ -22,10 +22,10 @@ import Utils
import Colors
from .. base import odict
from Constants import BORDER_PROXIMITY_SENSITIVITY
-from Constants import \
- BLOCK_LABEL_PADDING, \
- PORT_SEPARATION, LABEL_SEPARATION, \
+from Constants import (
+ BLOCK_LABEL_PADDING, PORT_SPACING, PORT_SEPARATION, LABEL_SEPARATION,
PORT_BORDER_SEPARATION, POSSIBLE_ROTATIONS, BLOCK_FONT, PARAM_FONT
+)
import Actions
import pygtk
pygtk.require('2.0')
@@ -72,6 +72,7 @@ class Block(Element):
))
Element.__init__(self)
self._comment_pixmap = None
+ self.has_busses = [False, False] # source, sink
def get_coordinate(self):
"""
@@ -190,13 +191,14 @@ class Block(Element):
self.vertical_label = self.get_parent().new_pixmap(height, width)
Utils.rotate_pixmap(gc, self.horizontal_label, self.vertical_label)
#calculate width and height needed
- self.W = self.label_width + 2*BLOCK_LABEL_PADDING
+ self.W = self.label_width + 2 * BLOCK_LABEL_PADDING
+
def get_min_height_for_ports():
visible_ports = filter(lambda p: not p.get_hide(), ports)
H = 2*PORT_BORDER_SEPARATION + len(visible_ports) * PORT_SEPARATION
if visible_ports: H -= ports[0].H
return H
- self.H = max(*(
+ self.H = max(
[ # labels
self.label_height + 2 * BLOCK_LABEL_PADDING
] +
@@ -204,11 +206,15 @@ class Block(Element):
get_min_height_for_ports() for ports in
(self.get_sources_gui(), self.get_sinks_gui())
] +
[ # bus ports only
- 4 * PORT_BORDER_SEPARATION +
- sum([port.H + PORT_SEPARATION for port in ports if
port.get_type() == 'bus']) - PORT_SEPARATION
+ 2 * PORT_BORDER_SEPARATION +
+ sum([port.H + PORT_SPACING for port in ports if
port.get_type() == 'bus']) - PORT_SPACING
for ports in (self.get_sources_gui(), self.get_sinks_gui())
]
- ))
+ )
+ self.has_busses = [
+ any(port.get_type() == 'bus' for port in ports)
+ for ports in (self.get_sources_gui(), self.get_sinks_gui())
+ ]
self.create_comment_label()
def create_comment_label(self):
diff --git a/grc/gui/Port.py b/grc/gui/Port.py
index 5310c1f..93372ea 100644
--- a/grc/gui/Port.py
+++ b/grc/gui/Port.py
@@ -18,10 +18,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA
"""
from Element import Element
-from Constants import \
- PORT_SEPARATION, CONNECTOR_EXTENSION_MINIMAL, \
- CONNECTOR_EXTENSION_INCREMENT, \
+from Constants import (
+ PORT_SEPARATION, PORT_SPACING, CONNECTOR_EXTENSION_MINIMAL,
+ CONNECTOR_EXTENSION_INCREMENT, CANVAS_GRID_SIZE,
PORT_LABEL_PADDING, PORT_MIN_WIDTH, PORT_LABEL_HIDDEN_WIDTH, PORT_FONT
+)
from .. base.Constants import DEFAULT_DOMAIN, GR_MESSAGE_DOMAIN
import Utils
import Actions
@@ -79,26 +80,31 @@ class Port(Element):
#reverse the order of ports for these rotations
if rotation in (180, 270):
index = length-index-1
- offset = (self.get_parent().H - (length-1)*PORT_SEPARATION - self.H)/2
+
+ port_separation = PORT_SEPARATION \
+ if self.get_parent().has_busses[self.is_source()] \
+ else max([port.H for port in ports]) + PORT_SPACING
+
+ offset = (self.get_parent().H - (length-1)*port_separation - self.H)/2
#create areas and connector coordinates
if (self.is_sink() and rotation == 0) or (self.is_source() and
rotation == 180):
- x = -1*W
- y = PORT_SEPARATION*index+offset
+ x = -W
+ y = port_separation*index+offset
self.add_area((x, y), (W, self.H))
self._connector_coordinate = (x-1, y+self.H/2)
elif (self.is_source() and rotation == 0) or (self.is_sink() and
rotation == 180):
x = self.get_parent().W
- y = PORT_SEPARATION*index+offset
+ y = port_separation*index+offset
self.add_area((x, y), (W, self.H))
self._connector_coordinate = (x+1+W, y+self.H/2)
elif (self.is_source() and rotation == 90) or (self.is_sink() and
rotation == 270):
- y = -1*W
- x = PORT_SEPARATION*index+offset
+ y = -W
+ x = port_separation*index+offset
self.add_area((x, y), (self.H, W))
self._connector_coordinate = (x+self.H/2, y-1)
elif (self.is_sink() and rotation == 90) or (self.is_source() and
rotation == 270):
y = self.get_parent().W
- x = PORT_SEPARATION*index+offset
+ x = port_separation*index+offset
self.add_area((x, y), (self.H, W))
self._connector_coordinate = (x+self.H/2, y+1+W)
#the connector length
- [Commit-gnuradio] [gnuradio] branch master updated (cc973de -> 65d6523), git, 2015/07/24
- [Commit-gnuradio] [gnuradio] 12/13: Merge branch 'maint', git, 2015/07/24
- [Commit-gnuradio] [gnuradio] 13/13: Merge remote-tracking branch 'gnuradio-wg-grc/master_grcwg', git, 2015/07/24
- [Commit-gnuradio] [gnuradio] 06/13: grc: align default flowgraph block with canvas grid, git, 2015/07/24
- [Commit-gnuradio] [gnuradio] 11/13: grc: clean-up Block port counters, git, 2015/07/24
- [Commit-gnuradio] [gnuradio] 02/13: grc: show preview of generated code in each blocks properties dialog, git, 2015/07/24
- [Commit-gnuradio] [gnuradio] 07/13: grc: fix bus ports spacing in gui,
git <=
- [Commit-gnuradio] [gnuradio] 03/13: grc: add default value to ToggleActions, git, 2015/07/24
- [Commit-gnuradio] [gnuradio] 04/13: grc: only show code preview tab after user enables it, git, 2015/07/24
- [Commit-gnuradio] [gnuradio] 01/13: grc: refactor Preferences.py, git, 2015/07/24
- [Commit-gnuradio] [gnuradio] 05/13: grc: add user settings for canvas default size and canvas font size (+ clean-ups), git, 2015/07/24
- [Commit-gnuradio] [gnuradio] 08/13: grc: add QT GUI hier blocks (#727), git, 2015/07/24
- [Commit-gnuradio] [gnuradio] 09/13: grc: add support for dynamic param names, git, 2015/07/24
- [Commit-gnuradio] [gnuradio] 10/13: grc: add struct variable block, git, 2015/07/24