diff options
author | Sebastian Koslowski <koslowski@kit.edu> | 2014-07-05 21:28:15 +0200 |
---|---|---|
committer | Sebastian Koslowski <koslowski@kit.edu> | 2014-07-06 14:35:55 +0200 |
commit | 831d05eb283e1ac4decb312c990cba089cdca316 (patch) | |
tree | fc453477596db9e4f560db61cb95fc79d7eb5a36 /grc/gui/Block.py | |
parent | 085c35a375468179929b690a0d7f037dc6ef23bf (diff) |
grc: allow blocks to dynamically hide some of their ports
Diffstat (limited to 'grc/gui/Block.py')
-rw-r--r-- | grc/gui/Block.py | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/grc/gui/Block.py b/grc/gui/Block.py index b2b391246e..e8a253aa66 100644 --- a/grc/gui/Block.py +++ b/grc/gui/Block.py @@ -175,12 +175,19 @@ class Block(Element): #calculate width and height needed self.W = self.label_width + 2*BLOCK_LABEL_PADDING self.H = max(*( - [self.label_height+2*BLOCK_LABEL_PADDING] + [2*PORT_BORDER_SEPARATION + \ - sum([port.H + PORT_SEPARATION for port in ports]) - PORT_SEPARATION - for ports in (self.get_sources_gui(), self.get_sinks_gui())] + - [4*PORT_BORDER_SEPARATION + \ - sum([(port.H) + PORT_SEPARATION for port in ports]) - PORT_SEPARATION - for ports in ([i for i in self.get_sources_gui() if i.get_type() == 'bus'], [i for i in self.get_sinks_gui() if i.get_type() == 'bus'])] + [ # labels + self.label_height + 2 * BLOCK_LABEL_PADDING + ] + + [ # ports + 2 * PORT_BORDER_SEPARATION + + sum([port.H + PORT_SEPARATION for port in ports if not port.get_hide()]) - PORT_SEPARATION + 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 + for ports in (self.get_sources_gui(), self.get_sinks_gui()) + ] )) def draw(self, gc, window): @@ -205,7 +212,8 @@ class Block(Element): window.draw_drawable(gc, self.vertical_label, 0, 0, x+(self.H-self.label_height)/2, y+BLOCK_LABEL_PADDING, -1, -1) #draw ports for port in self.get_ports_gui(): - port.draw(gc, window) + if not port.get_hide(): + port.draw(gc, window) def what_is_selected(self, coor, coor_m=None): """ |