diff options
Diffstat (limited to 'grc')
-rw-r--r-- | grc/gui/Block.py | 2 | ||||
-rw-r--r-- | grc/gui/FlowGraph.py | 6 | ||||
-rw-r--r-- | grc/gui/Port.py | 36 |
3 files changed, 19 insertions, 25 deletions
diff --git a/grc/gui/Block.py b/grc/gui/Block.py index 616396c747..e7dc03345b 100644 --- a/grc/gui/Block.py +++ b/grc/gui/Block.py @@ -214,7 +214,7 @@ class Block(CoreBlock, Element): max_width = 0 for port in ports: port.create_labels() - max_width = max(max_width, port.width) + max_width = max(max_width, port.width_with_label) for port in ports: port.width = max_width diff --git a/grc/gui/FlowGraph.py b/grc/gui/FlowGraph.py index c3571231fb..da88636e1b 100644 --- a/grc/gui/FlowGraph.py +++ b/grc/gui/FlowGraph.py @@ -526,11 +526,11 @@ class FlowGraph(Element, _Flowgraph): selected_elements = new_selections if self._old_selected_port: - self._old_selected_port.force_label_unhidden(False) + self._old_selected_port.force_show_label = False self.create_shapes() self.queue_draw() elif self._new_selected_port: - self._new_selected_port.force_label_unhidden() + self._new_selected_port.force_show_label = True else: # called from a mouse release if not self.element_moved and (not self.selected_elements or self.get_ctrl_mask()): @@ -705,7 +705,7 @@ class FlowGraph(Element, _Flowgraph): if not Actions.TOGGLE_AUTO_HIDE_PORT_LABELS.get_active(): return redraw = False - for element in reversed(self.get_elements()): + for element in self._elements_to_draw: over_element = element.what_is_selected(coordinate) if not over_element: continue diff --git a/grc/gui/Port.py b/grc/gui/Port.py index db3ab9da23..6ac216244d 100644 --- a/grc/gui/Port.py +++ b/grc/gui/Port.py @@ -40,12 +40,12 @@ class Port(_Port, Element): super(self.__class__, self).__init__(parent, direction, **n) Element.__init__(self) self._connector_coordinate = (0, 0) - self._hovering = True - self._force_label_unhidden = False + self._hovering = False + self.force_show_label = False self._bg_color = (0, 0, 0) self._line_width_factor = 1.0 - self._width = self.height = 0 + self.width_with_label = self.height = 0 self.connector_length = 0 self.label_layout = Gtk.DrawingArea().create_pango_layout('') @@ -53,11 +53,11 @@ class Port(_Port, Element): @property def width(self): - return self._width if not self._label_hidden() else Constants.PORT_LABEL_HIDDEN_WIDTH + return self.width_with_label if self._show_label else Constants.PORT_LABEL_HIDDEN_WIDTH @width.setter def width(self, value): - self._width = value + self.width_with_label = value self.label_layout.set_width(value * Pango.SCALE) def _get_color(self): @@ -120,7 +120,7 @@ class Port(_Port, Element): cr.set_line_width(self._line_width_factor * cr.get_line_width()) Element.draw(self, widget, cr, border_color, self._bg_color) - if self._label_hidden(): + if not self._show_label: return # this port is folded (no label) if self.is_vertical(): @@ -186,34 +186,28 @@ class Port(_Port, Element): def highlighted(self, value): self.parent_block.highlighted = value - def _label_hidden(self): + @property + def _show_label(self): """ Figure out if the label should be hidden Returns: true if the label should not be shown """ - return self._hovering and not self._force_label_unhidden and Actions.TOGGLE_AUTO_HIDE_PORT_LABELS.get_active() - - def force_label_unhidden(self, enable=True): - """ - Disable showing the label on mouse-over for this port - - Args: - enable: true to override the mouse-over behaviour - """ - self._force_label_unhidden = enable + return self._hovering or self.force_show_label or not Actions.TOGGLE_AUTO_HIDE_PORT_LABELS.get_active() def mouse_over(self): """ Called from flow graph on mouse-over """ - self._hovering = False - return Actions.TOGGLE_AUTO_HIDE_PORT_LABELS.get_active() # only redraw if necessary + changed = not self._show_label + self._hovering = True + return changed def mouse_out(self): """ Called from flow graph on mouse-out """ - self._hovering = True - return Actions.TOGGLE_AUTO_HIDE_PORT_LABELS.get_active() # only redraw if necessary + label_was_shown = self._show_label + self._hovering = False + return label_was_shown != self._show_label |