[SCM] calf/master: Better selection of wires and disconnection-by-connecting in jackvis.py

js at users.alioth.debian.org js at users.alioth.debian.org
Tue May 7 15:40:16 UTC 2013


The following commit has been merged in the master branch:
commit b4a0467b0b84826ce8ad234e2555f0f7490f6905
Author: Krzysztof Foltman <wdev at foltman.com>
Date:   Wed May 12 23:39:34 2010 +0100

    Better selection of wires and disconnection-by-connecting in jackvis.py

diff --git a/bigbull/conndiagram.py b/bigbull/conndiagram.py
index 815c85f..f70d66d 100644
--- a/bigbull/conndiagram.py
+++ b/bigbull/conndiagram.py
@@ -62,23 +62,29 @@ class VisibleWire():
         """src is source PortView, dst is destination PortView"""
         self.src = src
         self.dest = dest
-        self.wire = goocanvas.Path(parent = src.get_graph().get_root())
-        self.wire.type = "wire"
+        self.mask = goocanvas.Path(parent = src.get_graph().get_root(), line_width=12, stroke_color_rgba = 0, pointer_events = goocanvas.EVENTS_STROKE)
+        self.mask.type = "wire"
+        self.mask.object = self
+        self.wire = goocanvas.Path(parent = src.get_graph().get_root(), stroke_color_rgba = Colors.connectedWire, pointer_events = 0)
+        self.wire.type = "wirecore"
         self.wire.object = self
-        self.wire.props.stroke_color_rgba = Colors.connectedWire
         self.update_shape()
     
-    def delete(self):
+    def remove(self):
         if self.wire is not None:
             self.wire.remove()
+            self.mask.remove()
             self.src.module.remove_wire(self)
             self.dest.module.remove_wire(self)
             self.wire = None
+            self.mask = None
 
     def update_shape(self):
         (x1, y1) = self.src.get_endpoint()
         (x2, y2) = self.dest.get_endpoint()
-        self.wire.props.data = wireData(x1, y1, x2, y2)
+        data = wireData(x1, y1, x2, y2)
+        self.wire.props.data = data
+        self.mask.props.data = data
         
 
 class Dragging():
@@ -147,7 +153,6 @@ class Dragging():
             if src.isInput:
                 src, dst = dst, src
             self.get_graph().get_controller().connect(src.model, dst.model)
-            self.get_graph().connect(src, dst)
     
     def remove_wire(self):
         self.drag_wire.remove()
@@ -299,7 +304,7 @@ class ModuleView():
     def delete_items(self):
         self.group.remove()
         for w in list(self.wires):
-            w.delete()
+            w.remove()
         
     def port_button_press(self, port_view, box, event):
         if event.button == 1:
@@ -357,8 +362,9 @@ class ConnectionGraphEditor:
     
     def get_items_at(self, x, y):
         cr = self.canvas.create_cairo_context()
-        items = self.canvas.get_items_in_area(goocanvas.Bounds(x - 3, y - 3, x + 3, y + 3), True, True, False)
-        return items
+        #items = self.canvas.get_items_in_area(goocanvas.Bounds(x - 3, y - 3, x + 3, y + 3), True, True, False)
+        items = set()
+        return self.canvas.get_items_at(x, y, True)
         
     def get_data_items_at(self, x, y):
         items = self.get_items_at(x, y)
@@ -374,9 +380,6 @@ class ConnectionGraphEditor:
         bounds = self.canvas.get_bounds()
         return (bounds[2] - bounds[0], bounds[3] - bounds[1])
 
-    def add_module_cb(self, params):
-        self.add_module(*params)
-
     def add_module(self, model, x, y):
         mbox = ModuleView(self.controller, self.canvas.get_root_item(), model, self)
         self.modules.add(mbox)
@@ -398,6 +401,13 @@ class ConnectionGraphEditor:
         for mod in self.modules:
             map.update(mod.portDict)
         return map
+        
+    def get_port_view(self, port_model):
+        for mod in self.modules:
+            for p in mod.ports:
+                if p.model == port_model:
+                    return p
+        return None
 
     def canvas_motion_notify(self, group, widget, event):
         if self.dragging != None:
@@ -434,6 +444,13 @@ class ConnectionGraphEditor:
         dest.module.wires.append(wire)
         return wire
         
+    def disconnect(self, src, dest):
+        for w in src.module.wires:
+            if w.dest == dest:
+                w.remove()
+                return True
+        return False
+        
     def clear(self):
         for m in self.modules:
             m.delete_items()
diff --git a/bigbull/jackvis.py b/bigbull/jackvis.py
index f90d008..7906969 100755
--- a/bigbull/jackvis.py
+++ b/bigbull/jackvis.py
@@ -105,10 +105,19 @@ class JACKGraphController(object):
         if first.is_midi() and second.is_midi():
             return True
         return False
+    def is_connected(self, first, second):
+        return (first.get_id(), second.get_id()) in self.graph.connections_name
     def connect(self, first, second):
+        if self.is_connected(first, second):
+            self.disconnect(first, second)
+            return
         self.patchbay.ConnectPortsByName(first.client_name, first.name, second.client_name, second.name)
+        self.graph.connections_name.add((first.get_id(), second.get_id()))
+        self.view.connect(self.view.get_port_view(first), self.view.get_port_view(second))
     def disconnect(self, first, second):
         self.patchbay.DisconnectPortsByName(first.client_name, first.name, second.client_name, second.name)
+        self.graph.connections_name.remove((first.get_id(), second.get_id()))
+        self.view.disconnect(self.view.get_port_view(first), self.view.get_port_view(second))
     def refresh(self):
         self.fetch_graph()
         self.view.clear()
@@ -167,7 +176,7 @@ class App:
         menu.popup(None, None, None, 3, time)
         
     def disconnect(self, wire):
-        self.parser.disconnect(wire.src.model, wire.dest.model)
+        self.controller.disconnect(wire.src.model, wire.dest.model)
         wire.delete()
         
     def create(self):
diff --git a/bigbull/mainwin.py b/bigbull/mainwin.py
index 9312424..63e4d0d 100755
--- a/bigbull/mainwin.py
+++ b/bigbull/mainwin.py
@@ -52,6 +52,9 @@ class App:
             self.canvas_popup_menu(event.x, event.y, event.time)
             return True
         
+    def add_module_cb(self, params):
+        self.cgraph.add_module(*params)
+
     def canvas_popup_menu(self, x, y, time):
         menu = gtk.Menu()
         items = self.cgraph.get_data_items_at(x, y)
@@ -65,7 +68,7 @@ class App:
         else:
             for uri in self.lv2db.getPluginList():
                 plugin = self.lv2db.getPluginInfo(uri)
-                add_option(menu, plugin.name, self.cgraph.add_module_cb, (plugin, x, y))
+                add_option(menu, plugin.name, self.add_module_cb, (plugin, x, y))
         menu.show_all()
         menu.popup(None, None, None, 3, time)
         
@@ -107,7 +110,7 @@ class App:
             best_path = self.get_best_category(plugin)
             if best_path in self.submenus:
                 parent_menu = self.submenus[best_path]
-            add_option(parent_menu, plugin.name, self.cgraph.add_module_cb, (plugin, None, None))
+            add_option(parent_menu, plugin.name, self.add_module_cb, (plugin, None, None))
         
     def get_best_category(self, plugin):
         max_len = -1

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list