From 94c0fff479da5e81dede855cf5c382cf23aadf7d Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 15 Jun 2006 07:40:28 +0000 Subject: Subpatches working git-svn-id: http://svn.drobilla.net/lad/grauph@39 a436a847-0d15-0410-975c-d299462d15a1 --- src/progs/gtk/NodeController.cpp | 1 + src/progs/gtk/PatchController.cpp | 95 +++++++++++++++++++-------------------- src/progs/gtk/PatchController.h | 4 +- 3 files changed, 48 insertions(+), 52 deletions(-) (limited to 'src/progs') diff --git a/src/progs/gtk/NodeController.cpp b/src/progs/gtk/NodeController.cpp index 6cc0b94e..b73da18b 100644 --- a/src/progs/gtk/NodeController.cpp +++ b/src/progs/gtk/NodeController.cpp @@ -187,6 +187,7 @@ NodeController::metadata_update(const string& key, const string& value) if (m_bridge_port != NULL) m_bridge_port->metadata_update(key, value); + GtkObjectController::metadata_update(key, value); } diff --git a/src/progs/gtk/PatchController.cpp b/src/progs/gtk/PatchController.cpp index cbc8f626..8246efa6 100644 --- a/src/progs/gtk/PatchController.cpp +++ b/src/progs/gtk/PatchController.cpp @@ -292,7 +292,6 @@ PatchController::create_module(OmFlowCanvas* canvas) create_all_ports(); m_module->move_to(node_model()->x(), node_model()->y()); - m_module->store_location(); } @@ -388,93 +387,91 @@ PatchController::create_connection(CountedPtr cm) } -/** Add a subpatch to this patch. - */ -void -PatchController::add_subpatch(PatchController* patch) -{ - assert(patch != NULL); - assert(patch->patch_model()); - assert(patch->patch_model()->parent()); - - /*if (pm->x() == 0 && pm->y() == 0) { - int x, y; - parent_pc->get_new_module_location(x, y); - pm->x(x); - pm->y(y); - }*/ - - //patch_model()->add_node(patch->patch_model()); - - if (m_patch_view != NULL) { - patch->create_module(m_patch_view->canvas()); - m_patch_view->canvas()->add_module(patch->module()); - patch->module()->resize(); - } -} - - void -PatchController::add_node(CountedPtr nm) +PatchController::add_node(CountedPtr object) { cerr << "ADD NODE\n"; - assert(nm); - assert(nm->parent() == m_patch_model); - assert(nm->path().parent() == m_patch_model->path()); + assert(object); + assert(object->parent() == m_patch_model); + assert(object->path().parent() == m_patch_model->path()); /*if (patch_model()->get_node(nm->name()) != NULL) { cerr << "Ignoring existing\n"; // Node already exists, ignore //delete nm; - } else {*/ - // FIXME: Should PatchController really be responsible for creating these? + } else {*/ + + + CountedPtr node(object); + if (node) { + cerr << "\tNode Child\n"; + assert(node->parent() == m_patch_model); + NodeController* nc = NULL; - - if (nm->plugin() && nm->plugin()->type() == PluginModel::DSSI) - nc = new DSSIController(nm); - else - nc = new NodeController(nm); + + CountedPtr patch(node); + if (patch) { + cerr << "\t.. is a Patch Child\n"; + assert(patch->parent() == m_patch_model); + + nc = new PatchController(patch); + } else { + cerr << "\t... is a Plugin Node Child\n"; + assert(node->plugin()); + if (node->plugin()->type() == PluginModel::DSSI) + nc = new DSSIController(node); + else + nc = new NodeController(node); + } assert(nc != NULL); - assert(nm->controller() == nc); - + assert(node->controller() == nc); + // Check if this is a bridge node - FIXME: remove this - CountedPtr pm = patch_model()->get_port(nm->path().name()); + CountedPtr pm = patch_model()->get_port(node->path().name()); if (pm) { cerr << "Bridge node." << endl; PortController* pc = ((PortController*)pm->controller()); assert(pc != NULL); nc->bridge_port(pc); } - + //nc->add_to_store(); - //patch_model()->add_node(nm); - + //patch_model()->add_node(node); + if (m_patch_view != NULL) { int x, y; get_new_module_location(x, y); - nm->x(x); - nm->y(y); + node->x(x); + node->y(y); // Set zoom to 1.0 so module isn't messed up (Death to GnomeCanvas) float old_zoom = m_patch_view->canvas()->zoom(); if (old_zoom != 1.0) m_patch_view->canvas()->zoom(1.0); - + if (nc->module() == NULL) nc->create_module(m_patch_view->canvas()); assert(nc->module() != NULL); m_patch_view->canvas()->add_module(nc->module()); nc->module()->resize(); - + // Reset zoom if (old_zoom != 1.0) { m_patch_view->canvas()->zoom(old_zoom); nc->module()->zoom(old_zoom); } - // } + } + } + + + /*CountedPtr port(object); + if (port) { + cerr << "\tPort Child??\n"; + //assert(port->parent() == m_patch_model); + }*/ } diff --git a/src/progs/gtk/PatchController.h b/src/progs/gtk/PatchController.h index 840d5fe3..236fd0b6 100644 --- a/src/progs/gtk/PatchController.h +++ b/src/progs/gtk/PatchController.h @@ -78,8 +78,6 @@ public: void disconnection(const Path& src_port_path, const Path& dst_port_path); void clear(); - void add_subpatch(PatchController* patch); - void get_new_module_location(int& x, int& y); void show_control_window(); @@ -108,7 +106,7 @@ public: void disable_controls_menuitem(); private: - void add_node(CountedPtr nm); + void add_node(CountedPtr object); void remove_node(const string& name); void create_connection(CountedPtr cm); -- cgit v1.2.1