commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 51/101: grc: gtk3: fix port label hiding


From: git
Subject: [Commit-gnuradio] [gnuradio] 51/101: grc: gtk3: fix port label hiding
Date: Thu, 16 Mar 2017 14:58:05 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch python3
in repository gnuradio.

commit dbcc062b337ba7fa24fa98f26984ee61d484d834
Author: Sebastian Koslowski <address@hidden>
Date:   Wed Jul 20 15:06:12 2016 +0200

    grc: gtk3: fix port label hiding
---
 grc/gui/Block.py     |  2 +-
 grc/gui/FlowGraph.py |  6 +++---
 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 616396c..e7dc033 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 c357123..da88636 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 db3ab9d..6ac2162 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]