diff options
author | Sebastian Koslowski <koslowski@kit.edu> | 2016-08-01 17:27:09 +0200 |
---|---|---|
committer | Sebastian Koslowski <koslowski@kit.edu> | 2016-08-03 21:46:16 +0200 |
commit | 979cab9bf5d5986c3df3ea97d0082ed41d313190 (patch) | |
tree | 01824c96351f25e4a8a323c221789deff60b924b | |
parent | a59464a7a90715065b600416a3575a734cba51f2 (diff) |
grc: gtk3: better lables/shapes handling during flowgraph update
-rw-r--r-- | grc/gui/Element.py | 34 | ||||
-rw-r--r-- | grc/gui/FlowGraph.py | 14 |
2 files changed, 25 insertions, 23 deletions
diff --git a/grc/gui/Element.py b/grc/gui/Element.py index 73be7b8c92..81a5cbfc40 100644 --- a/grc/gui/Element.py +++ b/grc/gui/Element.py @@ -76,25 +76,6 @@ class Element(object): rotation = rotation or self.rotation return rotation in (90, 270) - def create_labels(self): - """ - Create labels (if applicable) and call on all children. - Call this base method before creating labels in the element. - """ - for child in self.get_children(): - child.create_labels() - - def create_shapes(self): - """ - Create shapes (if applicable) and call on all children. - Call this base method before creating shapes in the element. - """ - for child in self.get_children(): - child.create_shapes() - - def draw(self, widget, cr): - raise NotImplementedError() - def rotate(self, rotation): """ Rotate all of the areas by 90 degrees. @@ -115,6 +96,21 @@ class Element(object): dx, dy = delta_coor self.coordinate = (x + dx, y + dy) + def create_labels(self): + """ + Create labels (if applicable) and call on all children. + Call this base method before creating labels in the element. + """ + + def create_shapes(self): + """ + Create shapes (if applicable) and call on all children. + Call this base method before creating shapes in the element. + """ + + def draw(self, widget, cr): + raise NotImplementedError() + def bounds_from_area(self, area): x1, y1, w, h = area x2 = x1 + w diff --git a/grc/gui/FlowGraph.py b/grc/gui/FlowGraph.py index 5cd575dabe..83796f35fd 100644 --- a/grc/gui/FlowGraph.py +++ b/grc/gui/FlowGraph.py @@ -1,5 +1,5 @@ """ -Copyright 2007-2011 Free Software Foundation, Inc. +Copyright 2007-2011, 2016q Free Software Foundation, Inc. This file is part of GNU Radio GNU Radio Companion is free software; you can redistribute it and/or @@ -168,6 +168,7 @@ class FlowGraph(CoreFlowgraph, Element): """ self.rewrite() self.validate() + self.update_elements_to_draw() self.create_labels() self.create_shapes() @@ -469,6 +470,14 @@ class FlowGraph(CoreFlowgraph, Element): continue # skip hidden disabled blocks and connections self._elements_to_draw.append(element) + def create_labels(self): + for element in self._elements_to_draw: + element.create_labels() + + def create_shapes(self): + for element in self._elements_to_draw: + element.create_shapes() + def _drawables(self): show_comments = Actions.TOGGLE_SHOW_BLOCK_COMMENTS.get_active() for element in self._elements_to_draw: @@ -479,9 +488,6 @@ class FlowGraph(CoreFlowgraph, Element): def draw(self, widget, cr): """Draw blocks connections comment and select rectangle""" - # todo: only update if required, duplicate logic in - self.update_elements_to_draw() - for draw_element in self._drawables(): cr.save() draw_element(widget, cr) |