summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/App.cpp7
-rw-r--r--src/gui/Connection.cpp12
-rw-r--r--src/gui/Connection.hpp10
-rw-r--r--src/gui/NodeModule.cpp33
-rw-r--r--src/gui/NodeModule.hpp9
-rw-r--r--src/gui/PatchCanvas.cpp82
-rw-r--r--src/gui/PatchCanvas.hpp10
-rw-r--r--src/gui/PatchPortModule.cpp7
-rw-r--r--src/gui/Port.cpp17
-rw-r--r--src/gui/Port.hpp16
10 files changed, 95 insertions, 108 deletions
diff --git a/src/gui/App.cpp b/src/gui/App.cpp
index d76ca7d6..edd4ec06 100644
--- a/src/gui/App.cpp
+++ b/src/gui/App.cpp
@@ -218,10 +218,11 @@ App::port_activity(Port* port)
inserted.first->second = false;
if (port->is_output()) {
- for (Port::Connections::const_iterator i = port->connections().begin(); i != port->connections().end(); ++i) {
- const SharedPtr<Port> dst = PtrCast<Port>(i->lock()->dest().lock());
+ for (Port::Connections::const_iterator i = port->connections().begin();
+ i != port->connections().end(); ++i) {
+ Port* const dst = dynamic_cast<Port*>((*i)->dest());
if (dst)
- port_activity(dst.get());
+ port_activity(dst);
}
}
diff --git a/src/gui/Connection.cpp b/src/gui/Connection.cpp
index 5d1ceed7..511f6044 100644
--- a/src/gui/Connection.cpp
+++ b/src/gui/Connection.cpp
@@ -25,15 +25,15 @@ using namespace std;
namespace Ingen {
namespace GUI {
-Connection::Connection(FlowCanvas::Canvas& canvas,
- boost::shared_ptr<const ConnectionModel> model,
- boost::shared_ptr<FlowCanvas::Connectable> src,
- boost::shared_ptr<FlowCanvas::Connectable> dst,
- uint32_t color)
+Connection::Connection(FlowCanvas::Canvas& canvas,
+ boost::shared_ptr<const ConnectionModel> model,
+ FlowCanvas::Connectable* src,
+ FlowCanvas::Connectable* dst,
+ uint32_t color)
: FlowCanvas::Connection(canvas, src, dst, color)
, _connection_model(model)
{
- boost::shared_ptr<Port> src_port = boost::dynamic_pointer_cast<Port>(src);
+ Port* const src_port = dynamic_cast<Port*>(src);
if (src_port)
_bpath.property_dash() = src_port->dash();
}
diff --git a/src/gui/Connection.hpp b/src/gui/Connection.hpp
index 7bd39ff5..395f5e62 100644
--- a/src/gui/Connection.hpp
+++ b/src/gui/Connection.hpp
@@ -37,11 +37,11 @@ namespace GUI {
class Connection : public FlowCanvas::Connection
{
public:
- Connection(FlowCanvas::Canvas& canvas,
- boost::shared_ptr<const ConnectionModel> model,
- boost::shared_ptr<FlowCanvas::Connectable> src,
- boost::shared_ptr<FlowCanvas::Connectable> dst,
- uint32_t color);
+ Connection(FlowCanvas::Canvas& canvas,
+ boost::shared_ptr<const ConnectionModel> model,
+ FlowCanvas::Connectable* src,
+ FlowCanvas::Connectable* dst,
+ uint32_t color);
SharedPtr<const ConnectionModel> model() const { return _connection_model; }
diff --git a/src/gui/NodeModule.cpp b/src/gui/NodeModule.cpp
index 20f6beb3..ebbca29a 100644
--- a/src/gui/NodeModule.cpp
+++ b/src/gui/NodeModule.cpp
@@ -53,9 +53,9 @@ NodeModule::NodeModule(PatchCanvas& canvas,
assert(_node);
node->signal_new_port().connect(
- sigc::bind(sigc::mem_fun(this, &NodeModule::add_port), true));
+ sigc::bind(sigc::mem_fun(this, &NodeModule::new_port_view), true));
node->signal_removed_port().connect(
- sigc::hide_return(sigc::mem_fun(this, &NodeModule::remove_port)));
+ sigc::hide_return(sigc::mem_fun(this, &NodeModule::delete_port_view)));
node->signal_property().connect(
sigc::mem_fun(this, &NodeModule::property_changed));
node->signal_moved().connect(
@@ -105,7 +105,7 @@ NodeModule::create(PatchCanvas& canvas,
for (NodeModel::Ports::const_iterator p = node->ports().begin();
p != node->ports().end(); ++p)
- ret->add_port(*p, false);
+ ret->new_port_view(*p, false);
ret->set_stacked_border(node->polyphonic());
@@ -134,7 +134,7 @@ NodeModule::show_human_names(bool b)
}
for (Ports::const_iterator i = ports().begin(); i != ports().end(); ++i) {
- SharedPtr<Ingen::GUI::Port> port = PtrCast<Ingen::GUI::Port>(*i);
+ Ingen::GUI::Port* const port = dynamic_cast<Ingen::GUI::Port*>(*i);
Glib::ustring label(port->model()->symbol().c_str());
if (b) {
const Raul::Atom& name_property = port->model()->get_property(uris.lv2_name);
@@ -178,7 +178,7 @@ void
NodeModule::plugin_changed()
{
for (Ports::iterator p = ports().begin(); p != ports().end(); ++p)
- PtrCast<Ingen::GUI::Port>(*p)->update_metadata();
+ dynamic_cast<Ingen::GUI::Port*>(*p)->update_metadata();
}
void
@@ -251,10 +251,10 @@ NodeModule::rename()
}
void
-NodeModule::add_port(SharedPtr<const PortModel> port, bool resize_to_fit)
+NodeModule::new_port_view(SharedPtr<const PortModel> port, bool resize_to_fit)
{
- Module::add_port(Port::create(PtrCast<NodeModule>(shared_from_this()), port,
- App::instance().configuration()->name_style() == Configuration::HUMAN));
+ Port::create(*this, port,
+ App::instance().configuration()->name_style() == Configuration::HUMAN);
port->signal_value_changed().connect(
sigc::bind<0>(sigc::mem_fun(this, &NodeModule::value_changed),
@@ -264,24 +264,23 @@ NodeModule::add_port(SharedPtr<const PortModel> port, bool resize_to_fit)
resize();
}
-boost::shared_ptr<Port>
+Port*
NodeModule::port(boost::shared_ptr<const PortModel> model)
{
for (Ports::const_iterator p = ports().begin(); p != ports().end(); ++p) {
- SharedPtr<Port> port = PtrCast<Port>(*p);
+ Port* const port = dynamic_cast<Port*>(*p);
if (port->model() == model)
return port;
}
- return boost::shared_ptr<Port>();
+ return NULL;
}
void
-NodeModule::remove_port(SharedPtr<const PortModel> model)
+NodeModule::delete_port_view(SharedPtr<const PortModel> model)
{
- SharedPtr<Port> p = port(model);
+ Port* p = port(model);
if (p) {
- Module::remove_port(p);
- p.reset();
+ delete p;
} else {
warn << "Failed to find port on module " << model->path() << endl;
}
@@ -401,9 +400,9 @@ NodeModule::property_changed(const URI& key, const Atom& value)
} else if (key == uris.ingen_selected) {
if (value.get_bool() != selected()) {
if (value.get_bool())
- _canvas->select_item(shared_from_this());
+ _canvas->select_item(this);
else
- _canvas->unselect_item(shared_from_this());
+ _canvas->unselect_item(this);
}
}
break;
diff --git a/src/gui/NodeModule.hpp b/src/gui/NodeModule.hpp
index 7a62b87f..7bf6f996 100644
--- a/src/gui/NodeModule.hpp
+++ b/src/gui/NodeModule.hpp
@@ -1,4 +1,5 @@
-/* This file is part of In* Copyright 2007-2011 David Robillard <http://drobilla.net>
+/* This file is part of Ingen
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
*
* Ingen is free software; you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
@@ -55,9 +56,9 @@ public:
virtual ~NodeModule();
- boost::shared_ptr<Port> port(boost::shared_ptr<const PortModel> model);
+ Port* port(boost::shared_ptr<const PortModel> model);
- void remove_port(SharedPtr<const PortModel> port);
+ void delete_port_view(SharedPtr<const PortModel> port);
virtual void store_location();
void show_human_names(bool b);
@@ -78,7 +79,7 @@ protected:
void rename();
void property_changed(const Raul::URI& predicate, const Raul::Atom& value);
- void add_port(SharedPtr<const PortModel> port, bool resize=true);
+ void new_port_view(SharedPtr<const PortModel> port, bool resize=true);
void value_changed(uint32_t index, const Raul::Atom& value);
void plugin_changed();
diff --git a/src/gui/PatchCanvas.cpp b/src/gui/PatchCanvas.cpp
index 68a4cbab..0b5d4056 100644
--- a/src/gui/PatchCanvas.cpp
+++ b/src/gui/PatchCanvas.cpp
@@ -305,11 +305,11 @@ PatchCanvas::show_human_names(bool b)
{
_human_names = b;
FOREACH_ITEM(m, items()) {
- boost::shared_ptr<NodeModule> mod = boost::dynamic_pointer_cast<NodeModule>(*m);
+ NodeModule* mod = dynamic_cast<NodeModule*>(*m);
if (mod)
mod->show_human_names(b);
- boost::shared_ptr<PatchPortModule> pmod = boost::dynamic_pointer_cast<PatchPortModule>(*m);
+ PatchPortModule* pmod = dynamic_cast<PatchPortModule*>(*m);
if (pmod)
pmod->show_human_names(b);
}
@@ -320,7 +320,7 @@ PatchCanvas::show_port_names(bool b)
{
_show_port_names = b;
FOREACH_ITEM(i, items()) {
- boost::shared_ptr<FlowCanvas::Module> m = boost::dynamic_pointer_cast<FlowCanvas::Module>(*i);
+ FlowCanvas::Module* m = dynamic_cast<FlowCanvas::Module*>(*i);
if (m)
m->set_show_port_labels(b);
}
@@ -390,7 +390,6 @@ PatchCanvas::add_node(SharedPtr<const NodeModel> nm)
module->set_icon(App::instance().icon_from_path(plugm->icon_path(), 100));
}
- add_item(module);
module->show();
_views.insert(std::make_pair(nm, module));
}
@@ -401,7 +400,6 @@ PatchCanvas::remove_node(SharedPtr<const NodeModel> nm)
Views::iterator i = _views.find(nm);
if (i != _views.end()) {
- remove_item(i->second);
_views.erase(i);
}
}
@@ -411,7 +409,6 @@ PatchCanvas::add_port(SharedPtr<const PortModel> pm)
{
SharedPtr<PatchPortModule> view = PatchPortModule::create(*this, pm, _human_names);
_views.insert(std::make_pair(pm, view));
- add_item(view);
view->show();
}
@@ -422,43 +419,39 @@ PatchCanvas::remove_port(SharedPtr<const PortModel> pm)
// Port on this patch
if (i != _views.end()) {
- bool ret = remove_item(i->second);
- if (!ret)
- warn << "Failed to remove port item " << pm->path() << endl;
- i->second.reset();
_views.erase(i);
} else {
SharedPtr<NodeModule> module = PtrCast<NodeModule>(_views[pm->parent()]);
- module->remove_port(pm);
+ module->delete_port_view(pm);
}
assert(_views.find(pm) == _views.end());
}
-SharedPtr<FlowCanvas::Port>
+FlowCanvas::Port*
PatchCanvas::get_port_view(SharedPtr<PortModel> port)
{
SharedPtr<FlowCanvas::Module> module = _views[port];
// Port on this patch
if (module) {
- return (PtrCast<PatchPortModule>(module))
- ? *(PtrCast<PatchPortModule>(module)->ports().begin())
- : PtrCast<FlowCanvas::Port>(module);
+ return (dynamic_cast<PatchPortModule*>(module.get()))
+ ? *(dynamic_cast<PatchPortModule*>(module.get())->ports().begin())
+ : dynamic_cast<FlowCanvas::Port*>(module.get());
} else {
module = PtrCast<NodeModule>(_views[port->parent()]);
if (module) {
for (Module::Ports::const_iterator p = module->ports().begin();
p != module->ports().end(); ++p) {
- boost::shared_ptr<GUI::Port> pv = boost::dynamic_pointer_cast<GUI::Port>(*p);
+ GUI::Port* pv = dynamic_cast<GUI::Port*>(*p);
if (pv && pv->model() == port)
return pv;
}
}
}
- return SharedPtr<FlowCanvas::Port>();
+ return NULL;
}
void
@@ -466,14 +459,13 @@ PatchCanvas::connection(SharedPtr<const ConnectionModel> cm)
{
assert(cm);
- const SharedPtr<FlowCanvas::Port> src = get_port_view(cm->src_port());
- const SharedPtr<FlowCanvas::Port> dst = get_port_view(cm->dst_port());
+ FlowCanvas::Port* const src = get_port_view(cm->src_port());
+ FlowCanvas::Port* const dst = get_port_view(cm->dst_port());
if (src && dst) {
add_connection(
- boost::shared_ptr<GUI::Connection>(
- new GUI::Connection(*this, cm, src, dst,
- src->color() + 0x22222200)));
+ new GUI::Connection(*this, cm, src, dst,
+ src->color() + 0x22222200));
} else {
LOG(error) << "Unable to find ports to connect "
<< cm->src_port_path() << " -> " << cm->dst_port_path() << endl;
@@ -483,8 +475,8 @@ PatchCanvas::connection(SharedPtr<const ConnectionModel> cm)
void
PatchCanvas::disconnection(SharedPtr<const ConnectionModel> cm)
{
- const SharedPtr<FlowCanvas::Port> src = get_port_view(cm->src_port());
- const SharedPtr<FlowCanvas::Port> dst = get_port_view(cm->dst_port());
+ FlowCanvas::Port* const src = get_port_view(cm->src_port());
+ FlowCanvas::Port* const dst = get_port_view(cm->dst_port());
if (src && dst)
remove_connection(src, dst);
@@ -494,14 +486,14 @@ PatchCanvas::disconnection(SharedPtr<const ConnectionModel> cm)
}
void
-PatchCanvas::connect(boost::shared_ptr<FlowCanvas::Connectable> src_port,
- boost::shared_ptr<FlowCanvas::Connectable> dst_port)
+PatchCanvas::connect(FlowCanvas::Connectable* src_port,
+ FlowCanvas::Connectable* dst_port)
{
- const boost::shared_ptr<Ingen::GUI::Port> src
- = boost::dynamic_pointer_cast<Ingen::GUI::Port>(src_port);
+ const Ingen::GUI::Port* const src
+ = dynamic_cast<Ingen::GUI::Port*>(src_port);
- const boost::shared_ptr<Ingen::GUI::Port> dst
- = boost::dynamic_pointer_cast<Ingen::GUI::Port>(dst_port);
+ const Ingen::GUI::Port* const dst
+ = dynamic_cast<Ingen::GUI::Port*>(dst_port);
if (!src || !dst)
return;
@@ -510,14 +502,14 @@ PatchCanvas::connect(boost::shared_ptr<FlowCanvas::Connectable> src_port,
}
void
-PatchCanvas::disconnect(boost::shared_ptr<FlowCanvas::Connectable> src_port,
- boost::shared_ptr<FlowCanvas::Connectable> dst_port)
+PatchCanvas::disconnect(FlowCanvas::Connectable* src_port,
+ FlowCanvas::Connectable* dst_port)
{
- const boost::shared_ptr<Ingen::GUI::Port> src
- = boost::dynamic_pointer_cast<Ingen::GUI::Port>(src_port);
+ const Ingen::GUI::Port* const src
+ = dynamic_cast<Ingen::GUI::Port*>(src_port);
- const boost::shared_ptr<Ingen::GUI::Port> dst
- = boost::dynamic_pointer_cast<Ingen::GUI::Port>(dst_port);
+ const Ingen::GUI::Port* const dst
+ = dynamic_cast<Ingen::GUI::Port*>(dst_port);
App::instance().engine()->disconnect(src->model()->path(),
dst->model()->path());
@@ -606,13 +598,11 @@ void
PatchCanvas::destroy_selection()
{
FOREACH_ITEM(m, selected_items()) {
- boost::shared_ptr<NodeModule> module(
- boost::dynamic_pointer_cast<NodeModule>(*m));
+ NodeModule* module = dynamic_cast<NodeModule*>(*m);
if (module) {
App::instance().engine()->del(module->node()->path());
} else {
- boost::shared_ptr<PatchPortModule> port_module(
- boost::dynamic_pointer_cast<PatchPortModule>(*m));
+ PatchPortModule* port_module = dynamic_cast<PatchPortModule*>(*m);
if (port_module)
App::instance().engine()->del(port_module->port()->path());
}
@@ -624,7 +614,7 @@ PatchCanvas::select_all()
{
unselect_ports();
FOREACH_ITEM(m, items())
- if (boost::dynamic_pointer_cast<FlowCanvas::Module>(*m))
+ if (dynamic_cast<FlowCanvas::Module*>(*m))
if (!(*m)->selected())
select_item(*m);
}
@@ -637,21 +627,19 @@ PatchCanvas::copy_selection()
serialiser.start_to_string(_patch->path(), base_uri);
FOREACH_ITEM(m, selected_items()) {
- boost::shared_ptr<NodeModule> module(
- boost::dynamic_pointer_cast<NodeModule>(*m));
+ NodeModule* module = dynamic_cast<NodeModule*>(*m);
if (module) {
serialiser.serialise(module->node());
} else {
- boost::shared_ptr<PatchPortModule> port_module(
- boost::dynamic_pointer_cast<PatchPortModule>(*m));
+ PatchPortModule* port_module = dynamic_cast<PatchPortModule*>(*m);
if (port_module)
serialiser.serialise(port_module->port());
}
}
- for (list<boost::shared_ptr<FlowCanvas::Connection> >::iterator c = selected_connections().begin();
+ for (SelectedConnections::iterator c = selected_connections().begin();
c != selected_connections().end(); ++c) {
- boost::shared_ptr<Connection> connection = boost::dynamic_pointer_cast<Connection>(*c);
+ Connection* const connection = dynamic_cast<Connection*>(*c);
if (connection) {
const Sord::URI subject(*App::instance().world()->rdf_world(),
base_uri);
diff --git a/src/gui/PatchCanvas.hpp b/src/gui/PatchCanvas.hpp
index cd9e038f..243f76ae 100644
--- a/src/gui/PatchCanvas.hpp
+++ b/src/gui/PatchCanvas.hpp
@@ -124,13 +124,13 @@ private:
GraphObject::Properties get_initial_data();
- SharedPtr<FlowCanvas::Port> get_port_view(SharedPtr<PortModel> port);
+ FlowCanvas::Port* get_port_view(SharedPtr<PortModel> port);
- void connect(boost::shared_ptr<FlowCanvas::Connectable> src,
- boost::shared_ptr<FlowCanvas::Connectable> dst);
+ void connect(FlowCanvas::Connectable* src,
+ FlowCanvas::Connectable* dst);
- void disconnect(boost::shared_ptr<FlowCanvas::Connectable> src,
- boost::shared_ptr<FlowCanvas::Connectable> dst);
+ void disconnect(FlowCanvas::Connectable* src,
+ FlowCanvas::Connectable* dst);
SharedPtr<const PatchModel> _patch;
diff --git a/src/gui/PatchPortModule.cpp b/src/gui/PatchPortModule.cpp
index b04cc6ba..df4d8dc8 100644
--- a/src/gui/PatchPortModule.cpp
+++ b/src/gui/PatchPortModule.cpp
@@ -59,9 +59,8 @@ PatchPortModule::create(PatchCanvas& canvas,
bool human)
{
boost::shared_ptr<PatchPortModule> ret(new PatchPortModule(canvas, model));
- boost::shared_ptr<Port> port(Port::create(ret, model, human, true));
+ boost::shared_ptr<Port> port(Port::create(*ret, model, human, true));
- ret->add_port(port);
ret->set_port(port);
ret->set_menu(port->menu());
@@ -149,9 +148,9 @@ PatchPortModule::property_changed(const URI& key, const Atom& value)
} else if (key == uris.ingen_selected) {
if (value.get_bool() != selected()) {
if (value.get_bool()) {
- _canvas->select_item(shared_from_this());
+ _canvas->select_item(this);
} else {
- _canvas->unselect_item(shared_from_this());
+ _canvas->unselect_item(this);
}
}
}
diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp
index 94b8851e..72c37b12 100644
--- a/src/gui/Port.cpp
+++ b/src/gui/Port.cpp
@@ -41,10 +41,10 @@ namespace GUI {
ArtVpathDash* Port::_dash;
SharedPtr<Port>
-Port::create(boost::shared_ptr<FlowCanvas::Module> module,
- SharedPtr<const PortModel> pm,
- bool human_name,
- bool flip)
+Port::create(FlowCanvas::Module& module,
+ SharedPtr<const PortModel> pm,
+ bool human_name,
+ bool flip)
{
Glib::ustring label(human_name ? "" : pm->path().symbol());
if (human_name) {
@@ -62,10 +62,10 @@ Port::create(boost::shared_ptr<FlowCanvas::Module> module,
/** @a flip Make an input port appear as an output port, and vice versa.
*/
-Port::Port(boost::shared_ptr<FlowCanvas::Module> module,
- SharedPtr<const PortModel> pm,
- const string& name,
- bool flip)
+Port::Port(FlowCanvas::Module& module,
+ SharedPtr<const PortModel> pm,
+ const string& name,
+ bool flip)
: FlowCanvas::Port(module, name,
flip ? (!pm->is_input()) : pm->is_input(),
App::instance().configuration()->get_port_color(pm.get()))
@@ -73,7 +73,6 @@ Port::Port(boost::shared_ptr<FlowCanvas::Module> module,
, _pressed(false)
, _flipped(flip)
{
- assert(module);
assert(pm);
delete _menu;
diff --git a/src/gui/Port.hpp b/src/gui/Port.hpp
index 3d8fc763..17b1c37b 100644
--- a/src/gui/Port.hpp
+++ b/src/gui/Port.hpp
@@ -41,10 +41,10 @@ class Port : public FlowCanvas::Port
{
public:
static SharedPtr<Port> create(
- boost::shared_ptr<FlowCanvas::Module> module,
- SharedPtr<const PortModel> pm,
- bool human_name,
- bool flip=false);
+ FlowCanvas::Module& module,
+ SharedPtr<const PortModel> pm,
+ bool human_name,
+ bool flip = false);
~Port();
@@ -62,10 +62,10 @@ public:
ArtVpathDash* dash();
private:
- Port(boost::shared_ptr<FlowCanvas::Module> module,
- SharedPtr<const PortModel> pm,
- const std::string& name,
- bool flip = false);
+ Port(FlowCanvas::Module& module,
+ SharedPtr<const PortModel> pm,
+ const std::string& name,
+ bool flip=false);
void property_changed(const Raul::URI& key, const Raul::Atom& value);