commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] [gnuradio] 07/22: grc: per element line styles (for cu


From: git
Subject: [Commit-gnuradio] [gnuradio] 07/22: grc: per element line styles (for custom domain ports and message connections)
Date: Tue, 23 Dec 2014 09:38:57 +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 9372ec7daf7856de7c0e1fe782836a5c722c1473
Author: Sebastian Koslowski <address@hidden>
Date:   Wed Dec 3 16:12:13 2014 +0100

    grc: per element line styles (for custom domain ports and message 
connections)
---
 grc/gui/Connection.py | 17 ++++++++++-------
 grc/gui/Element.py    | 13 ++++++++++---
 grc/gui/Port.py       |  5 ++---
 3 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/grc/gui/Connection.py b/grc/gui/Connection.py
index 5f95c99..8fea6f0 100644
--- a/grc/gui/Connection.py
+++ b/grc/gui/Connection.py
@@ -77,15 +77,20 @@ class Connection(Element):
             Utils.get_rotated_coordinate((-CONNECTOR_ARROW_HEIGHT, 
CONNECTOR_ARROW_BASE/2), self.get_sink().get_rotation()),
         ]
         self._update_after_move()
-        if not self.get_enabled(): self._arrow_color = 
Colors.CONNECTION_DISABLED_COLOR
-        elif not self.is_valid(): self._arrow_color = 
Colors.CONNECTION_ERROR_COLOR
-        else: self._arrow_color = Colors.CONNECTION_ENABLED_COLOR
+        if not self.get_enabled():
+            self._arrow_color = Colors.CONNECTION_DISABLED_COLOR
+        elif not self.is_valid():
+            self._arrow_color = Colors.CONNECTION_ERROR_COLOR
+        else:
+            self._arrow_color = Colors.CONNECTION_ENABLED_COLOR
 
     def _update_after_move(self):
         """Calculate coordinates."""
         self.clear() #FIXME do i want this here?
         #source connector
         source = self.get_source()
+        if source.get_type() == "message":
+            self.line_attributes[1] = gtk.gdk.LINE_ON_OFF_DASH
         X, Y = source.get_connector_coordinate()
         x1, y1 = self.x1 + X, self.y1 + Y
         self.add_line((x1, y1), (X, Y))
@@ -152,13 +157,11 @@ class Connection(Element):
         elif self.get_enabled(): border_color = Colors.CONNECTION_ENABLED_COLOR
         else: border_color = Colors.CONNECTION_DISABLED_COLOR
         # make message connections dashed (no areas here)
-        normal_line_style = gc.line_style
-        if source.get_type() == "message": gc.line_style = 
gtk.gdk.LINE_ON_OFF_DASH
         Element.draw(self, gc, window, bg_color=None, 
border_color=border_color)
-        gc.line_style = normal_line_style  # restore line style
         #draw arrow on sink port
         try:
             gc.set_foreground(self._arrow_color)
+            gc.set_line_attributes(0, gtk.gdk.LINE_SOLID, gtk.gdk.CAP_BUTT, 
gtk.gdk.JOIN_MITER)
             window.draw_polygon(gc, True, self._arrow)
         except:
-            return
+            pass
diff --git a/grc/gui/Element.py b/grc/gui/Element.py
index 95a4e2e..67e8e10 100644
--- a/grc/gui/Element.py
+++ b/grc/gui/Element.py
@@ -20,6 +20,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
 02110-1301, USA
 from Constants import LINE_SELECT_SENSITIVITY
 from Constants import POSSIBLE_ROTATIONS
 
+import gtk
+
+
 class Element(object):
     """
     GraphicalElement is the base class for all graphical elements.
@@ -35,6 +38,9 @@ class Element(object):
         self.set_coordinate((0, 0))
         self.clear()
         self.set_highlighted(False)
+        self.line_attributes = [
+            0, gtk.gdk.LINE_SOLID, gtk.gdk.CAP_BUTT, gtk.gdk.JOIN_MITER
+        ]
 
     def is_horizontal(self, rotation=None):
         """
@@ -89,15 +95,16 @@ class Element(object):
             border_color: the color for lines and rectangle borders
             bg_color: the color for the inside of the rectangle
         """
-        X,Y = self.get_coordinate()
-        for (rX,rY),(W,H) in self._areas_list:
+        X, Y = self.get_coordinate()
+        gc.set_line_attributes(*self.line_attributes)
+        for (rX, rY), (W, H) in self._areas_list:
             aX = X + rX
             aY = Y + rY
             gc.set_foreground(bg_color)
             window.draw_rectangle(gc, True, aX, aY, W, H)
             gc.set_foreground(border_color)
             window.draw_rectangle(gc, False, aX, aY, W, H)
-        for (x1, y1),(x2, y2) in self._lines_list:
+        for (x1, y1), (x2, y2) in self._lines_list:
             gc.set_foreground(border_color)
             window.draw_line(gc, X+x1, Y+y1, X+x2, Y+y2)
 
diff --git a/grc/gui/Port.py b/grc/gui/Port.py
index 5f8a733..995750a 100644
--- a/grc/gui/Port.py
+++ b/grc/gui/Port.py
@@ -54,6 +54,8 @@ class Port(Element):
         Element.create_shapes(self)
         if self.get_hide():
             return  # this port is hidden, no need to create shapes
+        if self.get_domain() != DEFAULT_DOMAIN:
+            self.line_attributes[0] = 2
         #get current rotation
         rotation = self.get_rotation()
         #get all sibling ports
@@ -138,15 +140,12 @@ class Port(Element):
             gc: the graphics context
             window: the gtk window to draw on
         """
-        normal_line_width = gc.line_width  # todo: move line properties to 
Element
-        if self.get_domain() != DEFAULT_DOMAIN: gc.line_width = 2
         Element.draw(
             self, gc, window, bg_color=self._bg_color,
             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,
         )
-        gc.line_width = normal_line_width  # restore line style
         if not self._areas_list or self._label_hidden():
             return  # this port is either hidden (no areas) or folded (no 
label)
         X, Y = self.get_coordinate()



reply via email to

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