diff options
author | Sebastian Koslowski <koslowski@kit.edu> | 2014-08-19 17:02:33 +0200 |
---|---|---|
committer | Sebastian Koslowski <koslowski@kit.edu> | 2014-08-19 17:31:33 +0200 |
commit | 0dd158155c074113ec1cc6a3de7ecdd2be7d65e8 (patch) | |
tree | c29e8d9382426d23ae110187a6b2c375c8864bd9 /grc/gui/Block.py | |
parent | 842d8c9d9aac5f7a48a78a9d6babc865570b81c8 (diff) |
grc: snap-to-grid (WIP)
Diffstat (limited to 'grc/gui/Block.py')
-rw-r--r-- | grc/gui/Block.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/grc/gui/Block.py b/grc/gui/Block.py index 0afb351647..589ed34de1 100644 --- a/grc/gui/Block.py +++ b/grc/gui/Block.py @@ -43,6 +43,8 @@ class Block(Element): Block contructor. Add graphics related params to the block. """ + self.W = 0 + self.H = 0 #add the position param self.get_params().append(self.get_parent().get_parent().Param( block=self, @@ -85,6 +87,9 @@ class Block(Element): y = 0 elif y >= fgH - BORDER_PROXIMITY_SENSITIVITY: y = fgH - BORDER_PROXIMITY_SENSITIVITY + offset_x, offset_y = (0, self.H/2) if self.is_horizontal() else (self.H/2, 0) + x = Utils.align_to_grid(x + offset_x) - offset_x + y = Utils.align_to_grid(y + offset_y) - offset_y return (x, y) except: self.set_coordinate((0, 0)) @@ -179,8 +184,7 @@ class Block(Element): 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 + PORT_SEPARATION * len(filter(lambda p: not p.get_hide(), ports)) for ports in (self.get_sources_gui(), self.get_sinks_gui()) ] + [ # bus ports only |