summaryrefslogtreecommitdiffstats
path: root/src/progs
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2006-10-03 22:24:22 +0000
committerDavid Robillard <d@drobilla.net>2006-10-03 22:24:22 +0000
commit91d5cb109563c67bdad5f3ebeaafc8e1e8f7e14a (patch)
treecb70af457552eb1b87f745989f41c31da8220583 /src/progs
parent35a5d92cfcf6815553a0939c3e2bf77c1108fd31 (diff)
downloadingen-91d5cb109563c67bdad5f3ebeaafc8e1e8f7e14a.tar.gz
ingen-91d5cb109563c67bdad5f3ebeaafc8e1e8f7e14a.tar.bz2
ingen-91d5cb109563c67bdad5f3ebeaafc8e1e8f7e14a.zip
shared_ptr bugfixes.
Updated Ingen to work with new FlowCanvas. Updated Patchage to work with new(er) FlowCanvas. git-svn-id: http://svn.drobilla.net/lad/ingen@152 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/progs')
-rw-r--r--src/progs/ingenuity/DSSIModule.cpp2
-rw-r--r--src/progs/ingenuity/DSSIModule.h2
-rw-r--r--src/progs/ingenuity/Loader.cpp14
-rw-r--r--src/progs/ingenuity/Loader.h2
-rw-r--r--src/progs/ingenuity/NodeModule.cpp54
-rw-r--r--src/progs/ingenuity/NodeModule.h28
-rw-r--r--src/progs/ingenuity/PatchCanvas.cpp74
-rw-r--r--src/progs/ingenuity/PatchCanvas.h22
-rw-r--r--src/progs/ingenuity/PatchPortModule.cpp29
-rw-r--r--src/progs/ingenuity/PatchPortModule.h13
-rw-r--r--src/progs/ingenuity/PatchView.cpp10
-rw-r--r--src/progs/ingenuity/PatchView.h10
-rw-r--r--src/progs/ingenuity/Port.cpp2
-rw-r--r--src/progs/ingenuity/Port.h2
-rw-r--r--src/progs/ingenuity/SubpatchModule.cpp2
-rw-r--r--src/progs/ingenuity/SubpatchModule.h2
16 files changed, 158 insertions, 110 deletions
diff --git a/src/progs/ingenuity/DSSIModule.cpp b/src/progs/ingenuity/DSSIModule.cpp
index 670c8efb..9506897d 100644
--- a/src/progs/ingenuity/DSSIModule.cpp
+++ b/src/progs/ingenuity/DSSIModule.cpp
@@ -20,7 +20,7 @@
namespace Ingenuity {
-DSSIModule::DSSIModule(PatchCanvas* canvas, CountedPtr<NodeModel> node)
+DSSIModule::DSSIModule(boost::shared_ptr<PatchCanvas> canvas, CountedPtr<NodeModel> node)
: NodeModule(canvas, node)
{
}
diff --git a/src/progs/ingenuity/DSSIModule.h b/src/progs/ingenuity/DSSIModule.h
index e281a2b7..342d5f7b 100644
--- a/src/progs/ingenuity/DSSIModule.h
+++ b/src/progs/ingenuity/DSSIModule.h
@@ -30,7 +30,7 @@ class DSSIController;
class DSSIModule : public Ingenuity::NodeModule
{
public:
- DSSIModule(PatchCanvas* canvas, CountedPtr<NodeModel> node);
+ DSSIModule(boost::shared_ptr<PatchCanvas> canvas, CountedPtr<NodeModel> node);
virtual ~DSSIModule() {}
void on_double_click(GdkEventButton* ev);
diff --git a/src/progs/ingenuity/Loader.cpp b/src/progs/ingenuity/Loader.cpp
index 485e450d..c07d99bf 100644
--- a/src/progs/ingenuity/Loader.cpp
+++ b/src/progs/ingenuity/Loader.cpp
@@ -81,7 +81,7 @@ Loader::save_patch(CountedPtr<PatchModel> model, const string& filename, bool re
_mutex.lock();
_events.push_back(sigc::hide_return(sigc::bind(
- sigc::mem_fun(_serializer, &Serializer::save_patch),
+ sigc::mem_fun(this, &Loader::save_patch_event),
model, filename, recursive)));
_mutex.unlock();
@@ -90,4 +90,16 @@ Loader::save_patch(CountedPtr<PatchModel> model, const string& filename, bool re
}
+void
+Loader::save_patch_event(CountedPtr<PatchModel> model, const string& filename, bool recursive)
+{
+ if (recursive)
+ cerr << "FIXME: Recursive save." << endl;
+
+ _serializer->start_to_filename(filename);
+ _serializer->serialize_patch(model);
+ _serializer->finish();
+}
+
+
} // namespace Ingenuity
diff --git a/src/progs/ingenuity/Loader.h b/src/progs/ingenuity/Loader.h
index 7459378e..3a043c59 100644
--- a/src/progs/ingenuity/Loader.h
+++ b/src/progs/ingenuity/Loader.h
@@ -69,6 +69,8 @@ public:
private:
+ void save_patch_event(CountedPtr<PatchModel> model, const string& filename, bool recursive);
+
/** Returns nothing and takes no parameters (because they have all been bound) */
typedef sigc::slot<void> Closure;
diff --git a/src/progs/ingenuity/NodeModule.cpp b/src/progs/ingenuity/NodeModule.cpp
index 29af857e..6d4e54de 100644
--- a/src/progs/ingenuity/NodeModule.cpp
+++ b/src/progs/ingenuity/NodeModule.cpp
@@ -31,7 +31,7 @@
namespace Ingenuity {
-NodeModule::NodeModule(PatchCanvas* canvas, CountedPtr<NodeModel> node)
+NodeModule::NodeModule(boost::shared_ptr<PatchCanvas> canvas, CountedPtr<NodeModel> node)
: LibFlowCanvas::Module(canvas, node->path().name()),
m_node(node),
m_menu(node)
@@ -39,55 +39,39 @@ NodeModule::NodeModule(PatchCanvas* canvas, CountedPtr<NodeModel> node)
assert(m_node);
if (node->polyphonic()) {
- border_width(2.0);
+ set_border_width(2.0);
}
- create_all_ports();
- set_all_metadata();
-
- node->new_port_sig.connect(sigc::mem_fun(this, &NodeModule::add_port));
+ node->new_port_sig.connect(sigc::bind(sigc::mem_fun(this, &NodeModule::add_port), true));
node->removed_port_sig.connect(sigc::mem_fun(this, &NodeModule::remove_port));
node->metadata_update_sig.connect(sigc::mem_fun(this, &NodeModule::metadata_update));
}
-void
-NodeModule::create_all_ports()
+boost::shared_ptr<NodeModule>
+NodeModule::create(boost::shared_ptr<PatchCanvas> canvas, CountedPtr<NodeModel> node)
{
- for (PortModelList::const_iterator i = m_node->ports().begin();
- i != m_node->ports().end(); ++i) {
- add_port(*i);
- }
-
- resize();
-
- // FIXME
- //if (has_control_inputs())
- // enable_controls_menuitem();
-}
+ boost::shared_ptr<NodeModule> ret = boost::shared_ptr<NodeModule>(
+ new NodeModule(canvas, node));
+ for (MetadataMap::const_iterator m = node->metadata().begin(); m != node->metadata().end(); ++m)
+ ret->metadata_update(m->first, m->second);
-void
-NodeModule::set_all_metadata()
-{
- for (MetadataMap::const_iterator i = m_node->metadata().begin(); i != m_node->metadata().end(); ++i)
- metadata_update(i->first, i->second);
-}
+ for (PortModelList::const_iterator p = node->ports().begin(); p != node->ports().end(); ++p)
+ ret->add_port(*p, false);
+ ret->resize();
-void
-NodeModule::add_port(CountedPtr<PortModel> port)
-{
- manage(new Port(this, port));
- resize();
+ return ret;
}
void
-NodeModule::remove_port(CountedPtr<PortModel> port)
+NodeModule::add_port(CountedPtr<PortModel> port, bool resize_to_fit)
{
- LibFlowCanvas::Port* canvas_port = get_port(port->path().name());
- delete canvas_port;
+ Module::add_port(boost::shared_ptr<Port>(new Port(shared_from_this(), port)));
+ if (resize_to_fit)
+ resize();
}
@@ -101,6 +85,8 @@ NodeModule::show_control_window()
void
NodeModule::store_location()
{
+ cerr << "FIXME: store_location\n";
+#if 0
const float x = static_cast<float>(property_x());
const float y = static_cast<float>(property_y());
@@ -112,7 +98,7 @@ NodeModule::store_location()
App::instance().engine()->set_metadata(m_node->path(), "ingenuity:canvas-x", Atom(x));
App::instance().engine()->set_metadata(m_node->path(), "ingenuity:canvas-y", Atom(y));
}
-
+#endif
}
diff --git a/src/progs/ingenuity/NodeModule.h b/src/progs/ingenuity/NodeModule.h
index 6f7460bf..cbdfc6d2 100644
--- a/src/progs/ingenuity/NodeModule.h
+++ b/src/progs/ingenuity/NodeModule.h
@@ -18,10 +18,12 @@
#define OMMODULE_H
#include <string>
+#include <boost/enable_shared_from_this.hpp>
#include <libgnomecanvasmm.h>
#include <flowcanvas/Module.h>
-#include "NodeMenu.h"
#include "util/CountedPtr.h"
+#include "Port.h"
+#include "NodeMenu.h"
using std::string;
class Atom;
@@ -46,14 +48,16 @@ class Port;
*
* \ingroup Ingenuity
*/
-class NodeModule : public LibFlowCanvas::Module
+class NodeModule : public boost::enable_shared_from_this<NodeModule>, public LibFlowCanvas::Module
{
public:
- NodeModule(PatchCanvas* canvas, CountedPtr<NodeModel> node);
+ static boost::shared_ptr<NodeModule> create (boost::shared_ptr<PatchCanvas> canvas, CountedPtr<NodeModel> node);
+
virtual ~NodeModule() {}
-
- virtual Ingenuity::Port* port(const string& port_name) {
- return (Ingenuity::Port*)Module::get_port(port_name);
+
+ boost::shared_ptr<Port> port(const string& port_name) {
+ return boost::dynamic_pointer_cast<Ingenuity::Port>(
+ Module::get_port(port_name));
}
virtual void store_location();
@@ -65,16 +69,16 @@ public:
CountedPtr<NodeModel> node() const { return m_node; }
protected:
+ NodeModule(boost::shared_ptr<PatchCanvas> canvas, CountedPtr<NodeModel> node);
+
virtual void on_double_click(GdkEventButton* ev) { show_control_window(); }
virtual void on_middle_click(GdkEventButton* ev) { show_control_window(); }
- void set_all_metadata();
void metadata_update(const string& key, const Atom& value);
-
- void create_all_ports();
- void add_port(CountedPtr<PortModel> port);
- void remove_port(CountedPtr<PortModel> port);
-
+
+ void add_port(CountedPtr<PortModel> port, bool resize=true);
+ void remove_port(CountedPtr<PortModel> port) { Module::remove_port(port->path().name()); }
+
CountedPtr<NodeModel> m_node;
NodeMenu m_menu;
};
diff --git a/src/progs/ingenuity/PatchCanvas.cpp b/src/progs/ingenuity/PatchCanvas.cpp
index 707b8856..6d8403eb 100644
--- a/src/progs/ingenuity/PatchCanvas.cpp
+++ b/src/progs/ingenuity/PatchCanvas.cpp
@@ -54,8 +54,6 @@ PatchCanvas::PatchCanvas(CountedPtr<PatchModel> patch, int width, int height)
xml->get_widget("canvas_menu_load_patch", m_menu_load_patch);
xml->get_widget("canvas_menu_new_patch", m_menu_new_patch);
- build_canvas();
-
// Add port menu items
m_menu_add_audio_input->signal_activate().connect(
sigc::bind(sigc::mem_fun(this, &PatchCanvas::menu_add_port),
@@ -92,7 +90,10 @@ PatchCanvas::PatchCanvas(CountedPtr<PatchModel> patch, int width, int height)
void
-PatchCanvas::build_canvas() {
+PatchCanvas::build()
+{
+ boost::shared_ptr<PatchCanvas> shared_this =
+ boost::dynamic_pointer_cast<PatchCanvas>(shared_from_this());
// Create modules for nodes
for (NodeModelMap::const_iterator i = m_patch->nodes().begin();
@@ -103,7 +104,7 @@ PatchCanvas::build_canvas() {
// Create pseudo modules for ports (ports on this canvas, not on our module)
for (PortModelList::const_iterator i = m_patch->ports().begin();
i != m_patch->ports().end(); ++i) {
- manage(new PatchPortModule(this, *i));
+ add_module(PatchPortModule::create(shared_this, *i));
}
// Create connections
@@ -117,26 +118,31 @@ PatchCanvas::build_canvas() {
void
PatchCanvas::add_node(CountedPtr<NodeModel> nm)
{
+ boost::shared_ptr<PatchCanvas> shared_this =
+ boost::dynamic_pointer_cast<PatchCanvas>(shared_from_this());
+
CountedPtr<PatchModel> pm = PtrCast<PatchModel>(nm);
if (pm)
- manage(new SubpatchModule(this, pm));
+ add_module(SubpatchModule::create(shared_this, pm));
else
- manage(new NodeModule(this, nm));
+ add_module(NodeModule::create(shared_this, nm));
}
void
PatchCanvas::remove_node(CountedPtr<NodeModel> nm)
{
- LibFlowCanvas::Module* module = get_module(nm->path().name());
- delete module;
+ remove_module(nm->path().name()); // should cut all references
}
void
PatchCanvas::add_port(CountedPtr<PortModel> pm)
{
- manage(new PatchPortModule(this, pm));
+ boost::shared_ptr<PatchCanvas> shared_this =
+ boost::dynamic_pointer_cast<PatchCanvas>(shared_from_this());
+
+ add_module(PatchPortModule::create(shared_this, pm));
}
@@ -161,11 +167,13 @@ PatchCanvas::connection(CountedPtr<ConnectionModel> cm)
const string& dst_parent_name =
(dst_parent_path == m_patch->path()) ? "" : dst_parent_path.name();
- LibFlowCanvas::Port* src_port = get_port(src_parent_name, cm->src_port_path().name());
- LibFlowCanvas::Port* dst_port = get_port(dst_parent_name, cm->dst_port_path().name());
- assert(src_port && dst_port);
-
- add_connection(src_port, dst_port);
+ boost::shared_ptr<LibFlowCanvas::Port> src = get_port(src_parent_name, cm->src_port_path().name());
+ boost::shared_ptr<LibFlowCanvas::Port> dst = get_port(dst_parent_name, cm->dst_port_path().name());
+
+ if (src && dst)
+ add_connection(src, dst);
+ else
+ cerr << "[Canvas] ERROR: Unable to find ports to create connection." << endl;
}
@@ -177,8 +185,8 @@ PatchCanvas::disconnection(const Path& src_port_path, const Path& dst_port_path)
const string& dst_node_name = dst_port_path.parent().name();
const string& dst_port_name = dst_port_path.name();
- LibFlowCanvas::Port* src_port = get_port(src_node_name, src_port_name);
- LibFlowCanvas::Port* dst_port = get_port(dst_node_name, dst_port_name);
+ boost::shared_ptr<LibFlowCanvas::Port> src_port = get_port(src_node_name, src_port_name);
+ boost::shared_ptr<LibFlowCanvas::Port> dst_port = get_port(dst_node_name, dst_port_name);
if (src_port && dst_port) {
remove_connection(src_port, dst_port);
@@ -199,14 +207,16 @@ PatchCanvas::disconnection(const Path& src_port_path, const Path& dst_port_path)
void
-PatchCanvas::connect(const LibFlowCanvas::Port* src_port, const LibFlowCanvas::Port* dst_port)
+PatchCanvas::connect(boost::shared_ptr<LibFlowCanvas::Port> src_port, boost::shared_ptr<LibFlowCanvas::Port> dst_port)
{
- assert(src_port != NULL);
- assert(dst_port != NULL);
+ const boost::shared_ptr<Ingenuity::Port> src
+ = boost::dynamic_pointer_cast<Ingenuity::Port>(src_port);
+
+ const boost::shared_ptr<Ingenuity::Port> dst
+ = boost::dynamic_pointer_cast<Ingenuity::Port>(dst_port);
- const Ingenuity::Port* const src = dynamic_cast<const Ingenuity::Port* const>(src_port);
- const Ingenuity::Port* const dst = dynamic_cast<const Ingenuity::Port* const>(dst_port);
- assert(src && dst);
+ if (!src || !dst)
+ return;
// Midi binding/learn shortcut
if (src->model()->type() == PortModel::MIDI &&
@@ -240,13 +250,16 @@ PatchCanvas::connect(const LibFlowCanvas::Port* src_port, const LibFlowCanvas::P
void
-PatchCanvas::disconnect(const LibFlowCanvas::Port* src_port, const LibFlowCanvas::Port* dst_port)
+PatchCanvas::disconnect(boost::shared_ptr<LibFlowCanvas::Port> src_port, boost::shared_ptr<LibFlowCanvas::Port> dst_port)
{
- assert(src_port != NULL);
- assert(dst_port != NULL);
+ const boost::shared_ptr<Ingenuity::Port> src
+ = boost::dynamic_pointer_cast<Ingenuity::Port>(src_port);
+
+ const boost::shared_ptr<Ingenuity::Port> dst
+ = boost::dynamic_pointer_cast<Ingenuity::Port>(dst_port);
- App::instance().engine()->disconnect(((Ingenuity::Port*)src_port)->model()->path(),
- ((Ingenuity::Port*)dst_port)->model()->path());
+ App::instance().engine()->disconnect(src->model()->path(),
+ dst->model()->path());
}
@@ -282,8 +295,11 @@ PatchCanvas::canvas_event(GdkEvent* event)
void
PatchCanvas::destroy_selected()
{
- for (list<Module*>::iterator m = m_selected_modules.begin(); m != m_selected_modules.end(); ++m)
- App::instance().engine()->destroy(((NodeModule*)(*m))->node()->path());
+ for (list<boost::shared_ptr<Module> >::iterator m = m_selected_modules.begin(); m != m_selected_modules.end(); ++m) {
+ boost::shared_ptr<NodeModule> module = boost::dynamic_pointer_cast<NodeModule>(*m);
+ App::instance().engine()->destroy(module->node()->path());
+ }
+
}
diff --git a/src/progs/ingenuity/PatchCanvas.h b/src/progs/ingenuity/PatchCanvas.h
index c6abeeb0..15312367 100644
--- a/src/progs/ingenuity/PatchCanvas.h
+++ b/src/progs/ingenuity/PatchCanvas.h
@@ -18,11 +18,14 @@
#define OMPATCHBAYAREA_H
#include <string>
+#include <boost/shared_ptr.hpp>
#include <flowcanvas/FlowCanvas.h>
+#include <flowcanvas/Module.h>
#include "util/CountedPtr.h"
#include "util/Path.h"
#include "ConnectionModel.h"
#include "PatchModel.h"
+#include "NodeModule.h"
using std::string;
using namespace LibFlowCanvas;
@@ -48,8 +51,14 @@ class PatchCanvas : public LibFlowCanvas::FlowCanvas
public:
PatchCanvas(CountedPtr<PatchModel> patch, int width, int height);
- NodeModule* find_module(const string& name)
- { return (NodeModule*)FlowCanvas::get_module(name); }
+ virtual ~PatchCanvas() {}
+
+ boost::shared_ptr<NodeModule> find_module(const string& name) {
+ return boost::dynamic_pointer_cast<NodeModule>(
+ FlowCanvas::get_module(name));
+ }
+
+ void build();
void add_node(CountedPtr<NodeModel> nm);
void remove_node(CountedPtr<NodeModel> nm);
@@ -74,12 +83,13 @@ private:
MetadataMap get_initial_data();
- void build_canvas();
-
bool canvas_event(GdkEvent* event);
- void connect(const LibFlowCanvas::Port* src_port, const LibFlowCanvas::Port* dst_port);
- void disconnect(const LibFlowCanvas::Port* src_port, const LibFlowCanvas::Port* dst_port);
+ void connect(boost::shared_ptr<LibFlowCanvas::Port> src,
+ boost::shared_ptr<LibFlowCanvas::Port> dst);
+
+ void disconnect(boost::shared_ptr<LibFlowCanvas::Port> src,
+ boost::shared_ptr<LibFlowCanvas::Port> dst);
CountedPtr<PatchModel> m_patch;
diff --git a/src/progs/ingenuity/PatchPortModule.cpp b/src/progs/ingenuity/PatchPortModule.cpp
index 8843882b..2804a6a6 100644
--- a/src/progs/ingenuity/PatchPortModule.cpp
+++ b/src/progs/ingenuity/PatchPortModule.cpp
@@ -29,10 +29,9 @@
namespace Ingenuity {
-PatchPortModule::PatchPortModule(PatchCanvas* canvas, CountedPtr<PortModel> port)
+PatchPortModule::PatchPortModule(boost::shared_ptr<PatchCanvas> canvas, CountedPtr<PortModel> port)
: LibFlowCanvas::Module(canvas, "", 0, 0), // FIXME: coords?
- m_port(port),
- m_patch_port(NULL)
+ m_port(port)
{
/*if (port_model()->polyphonic() && port_model()->parent() != NULL
&& port_model()->parent_patch()->poly() > 1) {
@@ -42,12 +41,9 @@ PatchPortModule::PatchPortModule(PatchCanvas* canvas, CountedPtr<PortModel> port
assert(canvas);
assert(port);
- if (PtrCast<PatchModel>(port->parent())) {
- if (m_patch_port)
- delete m_patch_port;
-
- m_patch_port = new Port(this, port, true);
- }
+ //if (PtrCast<PatchModel>(port->parent())) {
+ // m_patch_port = boost::shared_ptr<Port>(new Port(shared_from_this(), port, true));
+ //}
resize();
@@ -67,6 +63,21 @@ PatchPortModule::PatchPortModule(PatchCanvas* canvas, CountedPtr<PortModel> port
}
+boost::shared_ptr<PatchPortModule>
+PatchPortModule::create(boost::shared_ptr<PatchCanvas> canvas, CountedPtr<PortModel> port)
+{
+ boost::shared_ptr<PatchPortModule> ret = boost::shared_ptr<PatchPortModule>(
+ new PatchPortModule(canvas, port));
+
+ for (MetadataMap::const_iterator m = port->metadata().begin(); m != port->metadata().end(); ++m)
+ ret->metadata_update(m->first, m->second);
+
+ ret->resize();
+
+ return ret;
+}
+
+
void
PatchPortModule::store_location()
{
diff --git a/src/progs/ingenuity/PatchPortModule.h b/src/progs/ingenuity/PatchPortModule.h
index 98bc1b1d..3cf55192 100644
--- a/src/progs/ingenuity/PatchPortModule.h
+++ b/src/progs/ingenuity/PatchPortModule.h
@@ -18,6 +18,7 @@
#define OMPORTMODULE_H
#include <string>
+#include <boost/enable_shared_from_this.hpp>
#include <libgnomecanvasmm.h>
#include <flowcanvas/Module.h>
#include "util/Atom.h"
@@ -43,10 +44,12 @@ class Port;
*
* \ingroup Ingenuity
*/
-class PatchPortModule : public LibFlowCanvas::Module
+class PatchPortModule : public LibFlowCanvas::Module//, public boost::enable_shared_from_this<LibFlowCanvas::Module>
{
public:
- PatchPortModule(PatchCanvas* canvas, CountedPtr<PortModel> port);
+ static boost::shared_ptr<PatchPortModule> create (boost::shared_ptr<PatchCanvas> canvas,
+ CountedPtr<PortModel> port);
+
virtual ~PatchPortModule() {}
virtual void store_location();
@@ -56,13 +59,15 @@ public:
CountedPtr<PortModel> port() const { return m_port; }
protected:
+ PatchPortModule(boost::shared_ptr<PatchCanvas> canvas, CountedPtr<PortModel> port);
+
//virtual void on_double_click(GdkEventButton* ev) { show_control_window(); }
//virtual void on_middle_click(GdkEventButton* ev) { show_control_window(); }
void metadata_update(const string& key, const Atom& value);
- CountedPtr<PortModel> m_port;
- Port* m_patch_port; ///< Port on this 'anonymous' module
+ CountedPtr<PortModel> m_port;
+ boost::shared_ptr<Port> m_patch_port; ///< Port on this 'anonymous' module
};
diff --git a/src/progs/ingenuity/PatchView.cpp b/src/progs/ingenuity/PatchView.cpp
index fbebd886..69dcf0b8 100644
--- a/src/progs/ingenuity/PatchView.cpp
+++ b/src/progs/ingenuity/PatchView.cpp
@@ -35,7 +35,6 @@ namespace Ingenuity {
PatchView::PatchView(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& xml)
: Gtk::Box(cobject),
- _canvas(NULL),
_breadcrumb_container(NULL),
_enable_signal(true)
{
@@ -57,12 +56,15 @@ PatchView::PatchView(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::X
void
PatchView::set_patch(CountedPtr<PatchModel> patch)
{
+ assert(!_canvas); // FIXME: remove
+
cerr << "Creating view for " << patch->path() << endl;
assert(_breadcrumb_container); // ensure created
_patch = patch;
- _canvas = new PatchCanvas(patch, 1600*2, 1200*2);
+ _canvas = CountedPtr<PatchCanvas>(new PatchCanvas(patch, 1600*2, 1200*2));
+ _canvas->build();
_canvas_scrolledwindow->add(*_canvas);
@@ -80,10 +82,10 @@ PatchView::set_patch(CountedPtr<PatchModel> patch)
_refresh_but->signal_clicked().connect(sigc::mem_fun(this, &PatchView::refresh_clicked));
_zoom_normal_but->signal_clicked().connect(sigc::bind(sigc::mem_fun(
- static_cast<FlowCanvas*>(_canvas), &FlowCanvas::set_zoom), 1.0));
+ _canvas.get(), &FlowCanvas::set_zoom), 1.0));
_zoom_full_but->signal_clicked().connect(
- sigc::mem_fun(static_cast<FlowCanvas*>(_canvas), &FlowCanvas::zoom_full));
+ sigc::mem_fun(_canvas.get(), &FlowCanvas::zoom_full));
}
diff --git a/src/progs/ingenuity/PatchView.h b/src/progs/ingenuity/PatchView.h
index a0225bda..0a445baa 100644
--- a/src/progs/ingenuity/PatchView.h
+++ b/src/progs/ingenuity/PatchView.h
@@ -57,9 +57,9 @@ public:
PatchView(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& glade_xml);
~PatchView();
- PatchCanvas* canvas() const { return _canvas; }
- CountedPtr<PatchModel> patch() const { return _patch; }
- Gtk::Viewport* breadcrumb_container() const { return _breadcrumb_container; }
+ CountedPtr<PatchCanvas> canvas() const { return _canvas; }
+ CountedPtr<PatchModel> patch() const { return _patch; }
+ Gtk::Viewport* breadcrumb_container() const { return _breadcrumb_container; }
static CountedPtr<PatchView> create(CountedPtr<PatchModel> patch);
@@ -75,8 +75,8 @@ private:
void zoom_full();
- CountedPtr<PatchModel> _patch;
- PatchCanvas* _canvas;
+ CountedPtr<PatchModel> _patch;
+ CountedPtr<PatchCanvas> _canvas;
Gtk::ScrolledWindow* _canvas_scrolledwindow;
diff --git a/src/progs/ingenuity/Port.cpp b/src/progs/ingenuity/Port.cpp
index 863e8a1a..560be981 100644
--- a/src/progs/ingenuity/Port.cpp
+++ b/src/progs/ingenuity/Port.cpp
@@ -31,7 +31,7 @@ namespace Ingenuity {
/** @param flip Make an input port appear as an output port, and vice versa.
*/
-Port::Port(LibFlowCanvas::Module* module, CountedPtr<PortModel> pm, bool flip)
+Port::Port(boost::shared_ptr<LibFlowCanvas::Module> module, CountedPtr<PortModel> pm, bool flip)
: LibFlowCanvas::Port(module,
pm->path().name(),
flip ? (!pm->is_input()) : pm->is_input(),
diff --git a/src/progs/ingenuity/Port.h b/src/progs/ingenuity/Port.h
index c2344aef..84e50e7d 100644
--- a/src/progs/ingenuity/Port.h
+++ b/src/progs/ingenuity/Port.h
@@ -35,7 +35,7 @@ namespace Ingenuity {
class Port : public LibFlowCanvas::Port
{
public:
- Port(LibFlowCanvas::Module* module, CountedPtr<PortModel> pm, bool flip = false);
+ Port(boost::shared_ptr<LibFlowCanvas::Module> module, CountedPtr<PortModel> pm, bool flip = false);
virtual ~Port() {}
diff --git a/src/progs/ingenuity/SubpatchModule.cpp b/src/progs/ingenuity/SubpatchModule.cpp
index 585ccee3..566248f9 100644
--- a/src/progs/ingenuity/SubpatchModule.cpp
+++ b/src/progs/ingenuity/SubpatchModule.cpp
@@ -31,7 +31,7 @@ using std::cerr; using std::cout; using std::endl;
namespace Ingenuity {
-SubpatchModule::SubpatchModule(PatchCanvas* canvas, CountedPtr<PatchModel> patch)
+SubpatchModule::SubpatchModule(boost::shared_ptr<PatchCanvas> canvas, CountedPtr<PatchModel> patch)
: NodeModule(canvas, patch),
m_patch(patch)
{
diff --git a/src/progs/ingenuity/SubpatchModule.h b/src/progs/ingenuity/SubpatchModule.h
index 571ae0fd..6d5d3e35 100644
--- a/src/progs/ingenuity/SubpatchModule.h
+++ b/src/progs/ingenuity/SubpatchModule.h
@@ -47,7 +47,7 @@ class NodeControlWindow;
class SubpatchModule : public NodeModule
{
public:
- SubpatchModule(PatchCanvas* canvas, CountedPtr<PatchModel> controller);
+ SubpatchModule(boost::shared_ptr<PatchCanvas> canvas, CountedPtr<PatchModel> controller);
virtual ~SubpatchModule() {}
void on_double_click(GdkEventButton* ev);