diff options
author | Sebastian Koslowski <koslowski@kit.edu> | 2017-01-11 21:33:15 +0100 |
---|---|---|
committer | Sebastian Koslowski <koslowski@kit.edu> | 2017-01-11 21:33:29 +0100 |
commit | c33862a14467b1c999d3c4247425c4f7106ae663 (patch) | |
tree | 86d1e181cdb6c9bd4a3057144d30b7ffdb2f92c4 /grc/gui/canvas/connection.py | |
parent | e1eccf55ae78738d102e48bea4804a02fb41f12d (diff) |
grc: gtk3: drag to connect
Diffstat (limited to 'grc/gui/canvas/connection.py')
-rw-r--r-- | grc/gui/canvas/connection.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/grc/gui/canvas/connection.py b/grc/gui/canvas/connection.py index a58a02657e..7de41a85b8 100644 --- a/grc/gui/canvas/connection.py +++ b/grc/gui/canvas/connection.py @@ -19,6 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA from __future__ import absolute_import, division +from argparse import Namespace from math import pi from . import colors @@ -212,3 +213,39 @@ class Connection(CoreConnection, Drawable): if hit: return self + + +class DummyCoreConnection(object): + def __init__(self, source_port, **kwargs): + self.parent_platform = source_port.parent_platform + self.source_port = source_port + self.sink_port = self._dummy_port = Namespace( + domain=source_port.domain, + rotation=0, + coordinate=(0, 0), + connector_coordinate_absolute=(0, 0), + connector_direction=0, + parent_block=Namespace(coordinate=(0, 0)), + ) + + self.enabled = True + self.highlighted = False, + self.is_valid = lambda: True + self.update(**kwargs) + + def update(self, coordinate=None, rotation=None, sink_port=None): + dp = self._dummy_port + self.sink_port = sink_port if sink_port else dp + if coordinate: + dp.coordinate = coordinate + dp.connector_coordinate_absolute = coordinate + dp.parent_block.coordinate = coordinate + if rotation is not None: + dp.rotation = rotation + dp.connector_direction = (180 + rotation) % 360 + + @property + def has_real_sink(self): + return self.sink_port is not self._dummy_port + +DummyConnection = Connection.make_cls_with_base(DummyCoreConnection) |