diff options
author | David Robillard <d@drobilla.net> | 2007-02-07 05:31:08 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-02-07 05:31:08 +0000 |
commit | 8b8e3a45a6aa40fbb391c6af13a4d7a7baf0a97e (patch) | |
tree | c9ae997543956142bc0f81acfa11d6c546b70f30 /src | |
parent | b0dda1ccccb53f8bb7ad59c96252647f8e4aa124 (diff) | |
download | patchage-8b8e3a45a6aa40fbb391c6af13a4d7a7baf0a97e.tar.gz patchage-8b8e3a45a6aa40fbb391c6af13a4d7a7baf0a97e.tar.bz2 patchage-8b8e3a45a6aa40fbb391c6af13a4d7a7baf0a97e.zip |
Abstracted out "Connectable" concept in FlowCanvas (towards connecting things other than ports).
Fixes for SLV2 API changes.
git-svn-id: http://svn.drobilla.net/lad/patchage@287 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r-- | src/AlsaDriver.cpp | 2 | ||||
-rw-r--r-- | src/JackDriver.cpp | 25 | ||||
-rw-r--r-- | src/PatchageFlowCanvas.cpp | 28 | ||||
-rw-r--r-- | src/PatchageFlowCanvas.h | 6 |
4 files changed, 39 insertions, 22 deletions
diff --git a/src/AlsaDriver.cpp b/src/AlsaDriver.cpp index 3e42df9..c961af1 100644 --- a/src/AlsaDriver.cpp +++ b/src/AlsaDriver.cpp @@ -318,7 +318,7 @@ AlsaDriver::add_connections(boost::shared_ptr<PatchagePort> port) if (existing) { existing->set_flagged(false); } else { - _app->canvas()->add_connection(port, connected_port); + _app->canvas()->add_connection(port, connected_port, port->color() + 0x22222200); } } diff --git a/src/JackDriver.cpp b/src/JackDriver.cpp index 5d4c139..6847b09 100644 --- a/src/JackDriver.cpp +++ b/src/JackDriver.cpp @@ -264,15 +264,30 @@ JackDriver::refresh() port2_name = client2_name.substr(client2_name.find(':')+1); client2_name = client2_name.substr(0, client2_name.find(':')); - boost::shared_ptr<Port> port1 = _app->canvas()->get_port(client1_name, port1_name); - boost::shared_ptr<Port> port2 = _app->canvas()->get_port(client2_name, port2_name); + boost::shared_ptr<Port> port1 + = _app->canvas()->get_port(client1_name, port1_name); + boost::shared_ptr<Port> port2 + = _app->canvas()->get_port(client2_name, port2_name); + + boost::shared_ptr<Port> src; + boost::shared_ptr<Port> dst; + + if (port1->is_output() && port2->is_input()) { + src = port1; + dst = port2; + } else if (port2->is_output() && port1->is_input()) { + src = port2; + dst = port1; + } + + if (src && dst) { + boost::shared_ptr<Connection> existing + = _app->canvas()->get_connection(src, dst); - if (port1 && port2) { - boost::shared_ptr<Connection> existing = _app->canvas()->get_connection(port1, port2); if (existing) { existing->set_flagged(false); } else { - _app->canvas()->add_connection(port1, port2); + _app->canvas()->add_connection(src, dst, port1->color() + 0x22222200); } } } diff --git a/src/PatchageFlowCanvas.cpp b/src/PatchageFlowCanvas.cpp index 881caf8..c979d48 100644 --- a/src/PatchageFlowCanvas.cpp +++ b/src/PatchageFlowCanvas.cpp @@ -65,7 +65,7 @@ PatchageFlowCanvas::find_port(const snd_seq_addr_t* alsa_addr) #endif void -PatchageFlowCanvas::connect(boost::shared_ptr<Port> port1, boost::shared_ptr<Port> port2) +PatchageFlowCanvas::connect(boost::shared_ptr<Connectable> port1, boost::shared_ptr<Connectable> port2) { boost::shared_ptr<PatchagePort> p1 = boost::dynamic_pointer_cast<PatchagePort>(port1); boost::shared_ptr<PatchagePort> p2 = boost::dynamic_pointer_cast<PatchagePort>(port2); @@ -85,20 +85,24 @@ PatchageFlowCanvas::connect(boost::shared_ptr<Port> port1, boost::shared_ptr<Por void -PatchageFlowCanvas::disconnect(boost::shared_ptr<Port> port1, boost::shared_ptr<Port> port2) +PatchageFlowCanvas::disconnect(boost::shared_ptr<Connectable> port1, boost::shared_ptr<Connectable> port2) { - boost::shared_ptr<PatchagePort> input; - boost::shared_ptr<PatchagePort> output; - - if (port1->is_input() && !port2->is_input()) { - input = boost::dynamic_pointer_cast<PatchagePort>(port1); - output = boost::dynamic_pointer_cast<PatchagePort>(port2); - } else if (port2->is_input() && !port1->is_input()) { - input = boost::dynamic_pointer_cast<PatchagePort>(port2); - output = boost::dynamic_pointer_cast<PatchagePort>(port1); + boost::shared_ptr<PatchagePort> input + = boost::dynamic_pointer_cast<PatchagePort>(port1); + boost::shared_ptr<PatchagePort> output + = boost::dynamic_pointer_cast<PatchagePort>(port2); + + if (!input || !output) + return; + + if (input->is_output() && output->is_input()) { + // Damn, guessed wrong + boost::shared_ptr<PatchagePort> swap = input; + input = output; + output = swap; } - if (!input || !output) { + if (!input || !output || input->is_output() || output->is_input()) { status_message("ERROR: Attempt to disconnect mismatched/unknown ports"); return; } diff --git a/src/PatchageFlowCanvas.h b/src/PatchageFlowCanvas.h index f2a126f..19873c5 100644 --- a/src/PatchageFlowCanvas.h +++ b/src/PatchageFlowCanvas.h @@ -24,8 +24,6 @@ #include <flowcanvas/FlowCanvas.h> #include "StateManager.h" - - class Patchage; class PatchageModule; class PatchagePort; @@ -42,8 +40,8 @@ public: #ifdef HAVE_ALSA boost::shared_ptr<PatchagePort> find_port(const snd_seq_addr_t* alsa_addr); #endif - void connect(boost::shared_ptr<Port> port1, boost::shared_ptr<Port> port2); - void disconnect(boost::shared_ptr<Port> port1, boost::shared_ptr<Port> port2); + void connect(boost::shared_ptr<Connectable> port1, boost::shared_ptr<Connectable> port2); + void disconnect(boost::shared_ptr<Connectable> port1, boost::shared_ptr<Connectable> port2); void status_message(const string& msg); |