summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/AlsaDriver.cpp4
-rw-r--r--src/JackDriver.cpp8
-rw-r--r--src/Patchage.cpp6
-rw-r--r--src/PatchageEvent.cpp2
-rw-r--r--src/PatchageFlowCanvas.cpp39
-rw-r--r--src/PatchageFlowCanvas.h4
6 files changed, 49 insertions, 14 deletions
diff --git a/src/AlsaDriver.cpp b/src/AlsaDriver.cpp
index b9d6a48..5a11b67 100644
--- a/src/AlsaDriver.cpp
+++ b/src/AlsaDriver.cpp
@@ -274,9 +274,9 @@ AlsaDriver::refresh_connections()
boost::shared_ptr<PatchageModule> m;
boost::shared_ptr<PatchagePort> p;
- for (ItemMap::iterator i = _app->canvas()->items().begin();
+ for (ItemList::iterator i = _app->canvas()->items().begin();
i != _app->canvas()->items().end(); ++i) {
- m = boost::dynamic_pointer_cast<PatchageModule>((*i).second);
+ m = boost::dynamic_pointer_cast<PatchageModule>(*i);
if (m) {
for (PortVector::const_iterator j = m->ports().begin(); j != m->ports().end(); ++j) {
p = boost::dynamic_pointer_cast<PatchagePort>(*j);
diff --git a/src/JackDriver.cpp b/src/JackDriver.cpp
index 3f2920c..02bd105 100644
--- a/src/JackDriver.cpp
+++ b/src/JackDriver.cpp
@@ -114,9 +114,9 @@ JackDriver::detach()
void
JackDriver::destroy_all_ports()
{
- ItemMap modules = _app->canvas()->items(); // copy
- for (ItemMap::iterator m = modules.begin(); m != modules.end(); ++m) {
- SharedPtr<Module> module = PtrCast<Module>(m->second);
+ ItemList modules = _app->canvas()->items(); // copy
+ for (ItemList::iterator m = modules.begin(); m != modules.end(); ++m) {
+ SharedPtr<Module> module = PtrCast<Module>(*m);
if (!module)
continue;
PortVector ports = module->ports(); // copy
@@ -128,7 +128,7 @@ JackDriver::destroy_all_ports()
}
if (module->ports().empty())
- _app->canvas()->remove_item(module->name());
+ _app->canvas()->remove_item(module);
}
}
diff --git a/src/Patchage.cpp b/src/Patchage.cpp
index ce41c47..0e73a37 100644
--- a/src/Patchage.cpp
+++ b/src/Patchage.cpp
@@ -437,10 +437,10 @@ Patchage::zoom_changed()
void
Patchage::update_state()
{
- for (ItemMap::iterator i = _canvas->items().begin(); i != _canvas->items().end(); ++i) {
- SharedPtr<Module> module = PtrCast<Module>((*i).second);
+ for (ItemList::iterator i = _canvas->items().begin(); i != _canvas->items().end(); ++i) {
+ SharedPtr<Module> module = PtrCast<Module>(*i);
if (module)
- module->load_location();
+ module->load_location();
}
//cerr << "[Patchage] Resizing window: (" << _state_manager->get_window_size().x
diff --git a/src/PatchageEvent.cpp b/src/PatchageEvent.cpp
index 09b28a1..0eed12e 100644
--- a/src/PatchageEvent.cpp
+++ b/src/PatchageEvent.cpp
@@ -75,7 +75,7 @@ PatchageEvent::execute()
}
if (module->num_ports() == 0) {
- _patchage->canvas()->remove_item(module->name()); // FIXME: slow
+ _patchage->canvas()->remove_item(module);
module->hide();
module.reset();
}
diff --git a/src/PatchageFlowCanvas.cpp b/src/PatchageFlowCanvas.cpp
index bdb5c0a..042d259 100644
--- a/src/PatchageFlowCanvas.cpp
+++ b/src/PatchageFlowCanvas.cpp
@@ -33,11 +33,24 @@ PatchageFlowCanvas::PatchageFlowCanvas(Patchage* app, int width, int height)
}
+boost::shared_ptr<Item>
+PatchageFlowCanvas::get_item(const string& name)
+{
+ ItemList::iterator m = _items.begin();
+
+ for ( ; m != _items.end(); ++m)
+ if ((*m)->name() == name)
+ break;
+
+ return (m == _items.end()) ? boost::shared_ptr<Item>() : *m;
+}
+
+
boost::shared_ptr<PatchageModule>
PatchageFlowCanvas::find_module(const string& name, ModuleType type)
{
- for (ItemMap::iterator m = _items.begin(); m != _items.end(); ++m) {
- boost::shared_ptr<PatchageModule> pm = boost::dynamic_pointer_cast<PatchageModule>((*m).second);
+ for (ItemList::iterator m = _items.begin(); m != _items.end(); ++m) {
+ boost::shared_ptr<PatchageModule> pm = boost::dynamic_pointer_cast<PatchageModule>(*m);
if (pm && pm->name() == name && pm->type() == type) {
return pm;
}
@@ -52,8 +65,8 @@ boost::shared_ptr<PatchagePort>
PatchageFlowCanvas::find_port(const snd_seq_addr_t* alsa_addr)
{
boost::shared_ptr<PatchagePort> pp;
- for (ItemMap::iterator m = _items.begin(); m != _items.end(); ++m) {
- SharedPtr<Module> module = PtrCast<Module>(m->second);
+ for (ItemList::iterator m = _items.begin(); m != _items.end(); ++m) {
+ SharedPtr<Module> module = PtrCast<Module>(*m);
if (!module)
continue;
for (PortVector::const_iterator p = module->ports().begin(); p != module->ports().end(); ++p) {
@@ -130,3 +143,21 @@ PatchageFlowCanvas::status_message(const string& msg)
_app->status_message(string("[Canvas] ").append(msg));
}
+
+boost::shared_ptr<Port>
+PatchageFlowCanvas::get_port(const string& node_name, const string& port_name)
+{
+ for (ItemList::iterator i = _items.begin(); i != _items.end(); ++i) {
+ const boost::shared_ptr<Item> item = *i;
+ const boost::shared_ptr<Module> module
+ = boost::dynamic_pointer_cast<Module>(item);
+ if (!module)
+ continue;
+ const boost::shared_ptr<Port> port = module->get_port(port_name);
+ if (module->name() == node_name && port)
+ return port;
+ }
+
+ return boost::shared_ptr<Port>();
+}
+
diff --git a/src/PatchageFlowCanvas.h b/src/PatchageFlowCanvas.h
index 05b7bef..899c503 100644
--- a/src/PatchageFlowCanvas.h
+++ b/src/PatchageFlowCanvas.h
@@ -45,6 +45,10 @@ public:
void disconnect(boost::shared_ptr<Connectable> port1, boost::shared_ptr<Connectable> port2);
void status_message(const string& msg);
+
+ boost::shared_ptr<Item> get_item(const string& name);
+ boost::shared_ptr<Port> get_port(const string& module_name,
+ const string& port_name);
private:
Patchage* _app;