diff options
author | Sebastian Koslowski <koslowski@kit.edu> | 2016-07-30 14:31:05 +0200 |
---|---|---|
committer | Sebastian Koslowski <koslowski@kit.edu> | 2016-08-03 21:43:24 +0200 |
commit | ab8ceb0c223c6521b112668df4580e93027e38e0 (patch) | |
tree | aed6b62b879c0461ced7c672562299730b2bd69d /grc/gui/Connection.py | |
parent | 9b39ca3a9a2550c51ee934633ff9c655e1676a3b (diff) |
grc: gtk3: draw ports before blocks and simplyfied draw code
Diffstat (limited to 'grc/gui/Connection.py')
-rw-r--r-- | grc/gui/Connection.py | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/grc/gui/Connection.py b/grc/gui/Connection.py index 1c00845356..b1ae32ddcc 100644 --- a/grc/gui/Connection.py +++ b/grc/gui/Connection.py @@ -104,7 +104,6 @@ class Connection(Element, _Connection): def _update_after_move(self): """Calculate coordinates.""" - self.clear() source = self.source_port sink = self.sink_port source_dir = source.get_connector_direction() @@ -136,7 +135,7 @@ class Connection(Element, _Connection): points, alt = alt, points # create 3-line connector i1, i2 = points - self.lines.append([p0, p1, i1, i2, p2, p3]) + self.line = [p0, p1, i1, i2, p2, p3] else: # 2 possible points to create a right-angled connector point, alt = [(x1, y2), (x2, y1)] @@ -150,7 +149,7 @@ class Connection(Element, _Connection): if Utils.get_angle_from_coordinates(point, p1) == source_dir: point, alt = alt, point # create right-angled connector - self.lines.append([p0, p1, point, p2, p3]) + self.line = [p0, p1, point, p2, p3] def draw(self, widget, cr, border_color=None, bg_color=None): """ @@ -169,22 +168,27 @@ class Connection(Element, _Connection): self._sink_coor = sink.parent_block.coordinate self._source_coor = source.parent_block.coordinate # draw - color1, color2 = ( + color1, color2, arrow_color = ( Colors.HIGHLIGHT_COLOR if self.highlighted else Colors.CONNECTION_DISABLED_COLOR if not self.enabled else - color for color in (self._color, self._color2)) + color for color in (self._color, self._color2, self._arrow_color)) - Element.draw(self, widget, cr, color1, Colors.FLOWGRAPH_BACKGROUND_COLOR) + cr.translate(*self.coordinate) + for point in self.line: + cr.line_to(*point) + cr.set_source_rgb(*color1) + cr.stroke_preserve() if color1 != color2: cr.save() - x_pos, y_pos = self.coordinate - cr.translate(-x_pos, -y_pos) cr.set_dash([5.0, 5.0], 5.0) - Element.draw(self, widget, cr, color2, Colors.FLOWGRAPH_BACKGROUND_COLOR) + cr.set_source_rgb(*color2) + cr.stroke() cr.restore() - # draw arrow on sink port - cr.set_source_rgb(*self._arrow_color) + else: + cr.new_path() + + cr.set_source_rgb(*arrow_color) cr.move_to(*self._arrow[0]) cr.line_to(*self._arrow[1]) cr.line_to(*self._arrow[2]) |