commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] [gnuradio] 01/04: grc: always show the label of the se


From: git
Subject: [Commit-gnuradio] [gnuradio] 01/04: grc: always show the label of the selected port
Date: Fri, 29 Aug 2014 16:39:01 +0000 (UTC)

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

jcorgan pushed a commit to branch master
in repository gnuradio.

commit b395f09dcd8e06f760b732243f5eebfaba9a2aa6
Author: Sebastian Koslowski <address@hidden>
Date:   Wed Aug 27 21:18:52 2014 +0200

    grc: always show the label of the selected port
    
    Suggested by Seth Hitefield
---
 grc/gui/Constants.py |  1 +
 grc/gui/FlowGraph.py | 16 +++++++++++-----
 grc/gui/Port.py      | 30 ++++++++++++++++++++----------
 3 files changed, 32 insertions(+), 15 deletions(-)

diff --git a/grc/gui/Constants.py b/grc/gui/Constants.py
index 8d21ade..7db291d 100644
--- a/grc/gui/Constants.py
+++ b/grc/gui/Constants.py
@@ -57,6 +57,7 @@ PORT_LABEL_PADDING = 2
 PORT_SEPARATION = 32
 PORT_BORDER_SEPARATION = 9
 PORT_MIN_WIDTH = 20
+PORT_LABEL_HIDDEN_WIDTH = 10
 
 #minimal length of connector
 CONNECTOR_EXTENSION_MINIMAL = 11
diff --git a/grc/gui/FlowGraph.py b/grc/gui/FlowGraph.py
index 44d46b9..794d992 100644
--- a/grc/gui/FlowGraph.py
+++ b/grc/gui/FlowGraph.py
@@ -414,8 +414,9 @@ class FlowGraph(Element):
             #single select mode, break
             if not coor_m: break
         #update selected ports
-        self._old_selected_port = self._new_selected_port
-        self._new_selected_port = selected_port
+        if selected_port is not self._new_selected_port:
+            self._old_selected_port = self._new_selected_port
+            self._new_selected_port = selected_port
         return list(selected)
 
     def get_selected_connections(self):
@@ -488,12 +489,17 @@ class FlowGraph(Element):
             if self.get_ctrl_mask() or not (
                 new_selections and new_selections[0] in 
self.get_selected_elements()
             ): selected_elements = new_selections
-        else: #called from a mouse release
+            if self._old_selected_port:
+                self._old_selected_port.force_label_unhidden(False)
+                self.create_shapes()
+                self.queue_draw()
+            elif self._new_selected_port:
+                self._new_selected_port.force_label_unhidden()
+        else:  # called from a mouse release
             if not self.element_moved and (not self.get_selected_elements() or 
self.get_ctrl_mask()):
                 selected_elements = 
self.what_is_selected(self.get_coordinate(), self.press_coor)
         #this selection and the last were ports, try to connect them
-        if self._old_selected_port and self._new_selected_port and \
-            self._old_selected_port is not self._new_selected_port:
+        if self._old_selected_port and self._new_selected_port:
             try:
                 self.connect(self._old_selected_port, self._new_selected_port)
                 Actions.ELEMENT_CREATE()
diff --git a/grc/gui/Port.py b/grc/gui/Port.py
index c56432d..188281a 100644
--- a/grc/gui/Port.py
+++ b/grc/gui/Port.py
@@ -21,7 +21,7 @@ from Element import Element
 from Constants import \
     PORT_SEPARATION, CONNECTOR_EXTENSION_MINIMAL, \
     CONNECTOR_EXTENSION_INCREMENT, \
-    PORT_LABEL_PADDING, PORT_MIN_WIDTH
+    PORT_LABEL_PADDING, PORT_MIN_WIDTH, PORT_LABEL_HIDDEN_WIDTH
 import Utils
 import Actions
 import Colors
@@ -47,7 +47,8 @@ class Port(Element):
         self.W = self.H = self.w = self.h = 0
         self._connector_coordinate = (0,0)
         self._connector_length = 0
-        self._label_hidden = True
+        self._hovering = True
+        self._force_label_unhidden = False
 
     def create_shapes(self):
         """Create new areas and labels for the port."""
@@ -59,7 +60,7 @@ class Port(Element):
         elif self.is_sink(): ports = self.get_parent().get_sinks_gui()
         #get the max width
         self.W = max([port.W for port in ports] + [PORT_MIN_WIDTH])
-        W = self.W if not self.label_hidden() else 10
+        W = self.W if not self._label_hidden() else PORT_LABEL_HIDDEN_WIDTH
         #get a numeric index for this port relative to its sibling ports
         try:
             index = ports.index(self)
@@ -138,7 +139,7 @@ class Port(Element):
             border_color=self.is_highlighted() and Colors.HIGHLIGHT_COLOR or
                          self.get_parent().is_dummy_block() and 
Colors.MISSING_BLOCK_BORDER_COLOR or Colors.BORDER_COLOR,
         )
-        if self.label_hidden():
+        if self._label_hidden():
             return
         X,Y = self.get_coordinate()
         (x,y),(w,h) = self._areas_list[0] #use the first area's sizes to place 
the labels
@@ -234,25 +235,34 @@ class Port(Element):
         """
         return self.get_parent().is_highlighted()
 
-    def label_hidden(self):
+    def _label_hidden(self):
         """
-        Figure out if the label should be shown
+        Figure out if the label should be hidden
 
         Returns:
-            true if the label should be hidden
+            true if the label should not be shown
         """
-        return self._label_hidden and 
Actions.TOGGLE_AUTO_HIDE_PORT_LABELS.get_active()
+        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
 
     def mouse_over(self):
         """
         Called from flow graph on mouse-over
         """
-        self._label_hidden = False
+        self._hovering = False
         return Actions.TOGGLE_AUTO_HIDE_PORT_LABELS.get_active()  # only 
redraw if necessary
 
     def mouse_out(self):
         """
         Called from flow graph on mouse-out
         """
-        self._label_hidden = True
+        self._hovering = True
         return Actions.TOGGLE_AUTO_HIDE_PORT_LABELS.get_active()  # only 
redraw if necessary



reply via email to

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