diff options
author | Nicholas McCarthy <namccart@gmail.com> | 2013-07-07 18:08:20 -0400 |
---|---|---|
committer | Johnathan Corgan <johnathan@corganlabs.com> | 2013-07-08 07:19:33 -0700 |
commit | cd99526b5d1c8b1130ac1ba87e21f96c621b1bdc (patch) | |
tree | 12836648bf75868b17b04a2c3ead9c1b6fa2d4c5 /grc/gui/Block.py | |
parent | 2dc1b6f2ed0cabd2bccbcc58487e93be4295df84 (diff) |
grc: add bus ports
Bus ports allow ganging together of block input or output ports into
a single display item for connection to other bus ports.
Diffstat (limited to 'grc/gui/Block.py')
-rw-r--r-- | grc/gui/Block.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/grc/gui/Block.py b/grc/gui/Block.py index 11e66bff85..e69fe1a418 100644 --- a/grc/gui/Block.py +++ b/grc/gui/Block.py @@ -124,6 +124,7 @@ class Block(Element): def create_shapes(self): """Update the block, parameters, and ports when a change occurs.""" + Element.create_shapes(self) if self.is_horizontal(): self.add_area((0, 0), (self.W, self.H)) elif self.is_vertical(): self.add_area((0, 0), (self.H, self.W)) @@ -173,7 +174,10 @@ class Block(Element): 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(), self.get_sinks())] + 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'])] )) def draw(self, gc, window): @@ -196,7 +200,10 @@ class Block(Element): elif self.is_vertical(): 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(): port.draw(gc, window) + + + for port in self.get_ports_gui(): + port.draw(gc, window) def what_is_selected(self, coor, coor_m=None): """ @@ -209,7 +216,7 @@ class Block(Element): Returns: this block, a port, or None """ - for port in self.get_ports(): + for port in self.get_ports_gui(): port_selected = port.what_is_selected(coor, coor_m) if port_selected: return port_selected return Element.what_is_selected(self, coor, coor_m) |