diff options
author | Sebastian Koslowski <koslowski@kit.edu> | 2016-08-30 16:27:31 +0200 |
---|---|---|
committer | Sebastian Koslowski <koslowski@kit.edu> | 2016-09-12 12:15:00 -0600 |
commit | eeea99b45c0a0dccd935dc5203b71e0adf1430fe (patch) | |
tree | 5cac0682d380c04ec323f98ab8f2df36e45e03bd | |
parent | eb6033357a2ca8db17c4fd2cfd6f1bf789e40330 (diff) |
grc: gtk3: calculate flowgraph canvas size
-rw-r--r-- | grc/gui/Block.py | 10 | ||||
-rw-r--r-- | grc/gui/Element.py | 9 | ||||
-rw-r--r-- | grc/gui/FlowGraph.py | 16 |
3 files changed, 29 insertions, 6 deletions
diff --git a/grc/gui/Block.py b/grc/gui/Block.py index 4b6c5b8e9e..b37bec6dfa 100644 --- a/grc/gui/Block.py +++ b/grc/gui/Block.py @@ -311,6 +311,16 @@ class Block(CoreBlock, Element): PangoCairo.show_layout(cr, self._comment_layout) cr.restore() + @property + def extend(self): + extend = Element.extend.fget(self) + x, y = self.coordinate + for port in self.active_ports(): + extend = (min_or_max(xy, offset + p_xy) for offset, min_or_max, xy, p_xy in zip( + (x, y, x, y), (min, min, max, max), extend, port.extend + )) + return tuple(extend) + ############################################## # Controller Modify ############################################## diff --git a/grc/gui/Element.py b/grc/gui/Element.py index 8418bef0cc..17cd6ddd92 100644 --- a/grc/gui/Element.py +++ b/grc/gui/Element.py @@ -168,6 +168,15 @@ class Element(object): if x <= x1 <= x_m and y <= y1 <= y_m: return self + @property + def extend(self): + x_min, y_min = x_max, y_max = self.coordinate + x_min += min(x for x, y in self._bounding_points) + y_min += min(y for x, y in self._bounding_points) + x_max += max(x for x, y in self._bounding_points) + y_max += max(y for x, y in self._bounding_points) + return x_min, y_min, x_max, y_max + def mouse_over(self): pass diff --git a/grc/gui/FlowGraph.py b/grc/gui/FlowGraph.py index f082e4f7f0..df8e668eed 100644 --- a/grc/gui/FlowGraph.py +++ b/grc/gui/FlowGraph.py @@ -742,9 +742,13 @@ class FlowGraph(CoreFlowgraph, Element): self.drawing_area.queue_draw() def get_max_coords(self, initial=(0, 0)): - w, h = initial - for block in self.blocks: - x, y = block.coordinate - w = max(w, x + block.width) - h = max(h, y + block.height) - return w, h + return tuple(max(i, e) for i, e in zip(initial, self.extend[2:])) + + @property + def extend(self): + extend = 100000, 100000, 0, 0 + for element in self._elements_to_draw: + extend = (min_or_max(xy, e_xy) for min_or_max, xy, e_xy in zip( + (min, min, max, max), extend, element.extend + )) + return tuple(extend) |