From a135a764751a356ac34c2f35f8ce2c009872f1fd Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 15 Sep 2006 01:20:54 +0000 Subject: Fixed FlowCanvas #include directives (to include FLOWCANVAS prefix). Renamed classes/files in Ingenuity to make more sense (and kill "Om"). Patch port fixes. git-svn-id: http://svn.drobilla.net/lad/ingen@136 a436a847-0d15-0410-975c-d299462d15a1 --- src/progs/ingenuity/App.cpp | 4 +- src/progs/ingenuity/App.h | 4 +- src/progs/ingenuity/DSSIModule.cpp | 4 +- src/progs/ingenuity/DSSIModule.h | 6 +- src/progs/ingenuity/LoadPluginWindow.cpp | 2 +- src/progs/ingenuity/Makefile.am | 20 +- src/progs/ingenuity/NodeMenu.h | 2 +- src/progs/ingenuity/NodeModule.cpp | 138 ++++++++++ src/progs/ingenuity/NodeModule.h | 84 ++++++ src/progs/ingenuity/OmFlowCanvas.cpp | 421 ------------------------------- src/progs/ingenuity/OmFlowCanvas.h | 110 -------- src/progs/ingenuity/OmModule.cpp | 137 ---------- src/progs/ingenuity/OmModule.h | 84 ------ src/progs/ingenuity/OmPatchPort.cpp | 57 ----- src/progs/ingenuity/OmPatchPort.h | 59 ----- src/progs/ingenuity/OmPort.cpp | 57 ----- src/progs/ingenuity/OmPort.h | 59 ----- src/progs/ingenuity/OmPortModule.cpp | 98 ------- src/progs/ingenuity/OmPortModule.h | 75 ------ src/progs/ingenuity/PatchCanvas.cpp | 368 +++++++++++++++++++++++++++ src/progs/ingenuity/PatchCanvas.h | 104 ++++++++ src/progs/ingenuity/PatchPort.cpp | 57 +++++ src/progs/ingenuity/PatchPort.h | 59 +++++ src/progs/ingenuity/PatchPortModule.cpp | 98 +++++++ src/progs/ingenuity/PatchPortModule.h | 71 ++++++ src/progs/ingenuity/PatchView.cpp | 4 +- src/progs/ingenuity/PatchView.h | 6 +- src/progs/ingenuity/PatchWindow.cpp | 2 +- src/progs/ingenuity/PatchWindow.h | 2 +- src/progs/ingenuity/Port.cpp | 40 +++ src/progs/ingenuity/Port.h | 53 ++++ src/progs/ingenuity/SubpatchModule.cpp | 10 +- src/progs/ingenuity/SubpatchModule.h | 9 +- 33 files changed, 1109 insertions(+), 1195 deletions(-) create mode 100644 src/progs/ingenuity/NodeModule.cpp create mode 100644 src/progs/ingenuity/NodeModule.h delete mode 100644 src/progs/ingenuity/OmFlowCanvas.cpp delete mode 100644 src/progs/ingenuity/OmFlowCanvas.h delete mode 100644 src/progs/ingenuity/OmModule.cpp delete mode 100644 src/progs/ingenuity/OmModule.h delete mode 100644 src/progs/ingenuity/OmPatchPort.cpp delete mode 100644 src/progs/ingenuity/OmPatchPort.h delete mode 100644 src/progs/ingenuity/OmPort.cpp delete mode 100644 src/progs/ingenuity/OmPort.h delete mode 100644 src/progs/ingenuity/OmPortModule.cpp delete mode 100644 src/progs/ingenuity/OmPortModule.h create mode 100644 src/progs/ingenuity/PatchCanvas.cpp create mode 100644 src/progs/ingenuity/PatchCanvas.h create mode 100644 src/progs/ingenuity/PatchPort.cpp create mode 100644 src/progs/ingenuity/PatchPort.h create mode 100644 src/progs/ingenuity/PatchPortModule.cpp create mode 100644 src/progs/ingenuity/PatchPortModule.h create mode 100644 src/progs/ingenuity/Port.cpp create mode 100644 src/progs/ingenuity/Port.h (limited to 'src/progs/ingenuity') diff --git a/src/progs/ingenuity/App.cpp b/src/progs/ingenuity/App.cpp index 60482d77..78d2e971 100644 --- a/src/progs/ingenuity/App.cpp +++ b/src/progs/ingenuity/App.cpp @@ -22,7 +22,7 @@ #include #include #include -#include "OmModule.h" +#include "NodeModule.h" #include "ControlPanel.h" #include "SubpatchModule.h" #include "LoadPluginWindow.h" @@ -49,7 +49,7 @@ using namespace Ingen::Client; namespace Ingenuity { -class OmPort; +class Port; /// Singleton instance diff --git a/src/progs/ingenuity/App.h b/src/progs/ingenuity/App.h index d166c37b..553175fb 100644 --- a/src/progs/ingenuity/App.h +++ b/src/progs/ingenuity/App.h @@ -49,9 +49,7 @@ class LoadPatchWindow; class MessagesWindow; class ConfigWindow; class IngenuityObject; -class OmModule; -class OmPort; -class OmFlowCanvas; +class PatchCanvas; class PatchTreeView; class PatchTreeWindow; class ConnectWindow; diff --git a/src/progs/ingenuity/DSSIModule.cpp b/src/progs/ingenuity/DSSIModule.cpp index 5d235be4..670c8efb 100644 --- a/src/progs/ingenuity/DSSIModule.cpp +++ b/src/progs/ingenuity/DSSIModule.cpp @@ -20,8 +20,8 @@ namespace Ingenuity { -DSSIModule::DSSIModule(OmFlowCanvas* canvas, CountedPtr node) -: OmModule(canvas, node) +DSSIModule::DSSIModule(PatchCanvas* canvas, CountedPtr node) +: NodeModule(canvas, node) { } diff --git a/src/progs/ingenuity/DSSIModule.h b/src/progs/ingenuity/DSSIModule.h index 6cffb891..e281a2b7 100644 --- a/src/progs/ingenuity/DSSIModule.h +++ b/src/progs/ingenuity/DSSIModule.h @@ -17,7 +17,7 @@ #ifndef DSSIMODULE_H #define DSSIMODULE_H -#include "OmModule.h" +#include "NodeModule.h" namespace Ingenuity { @@ -27,10 +27,10 @@ class DSSIController; * * \ingroup Ingenuity */ -class DSSIModule : public OmModule +class DSSIModule : public Ingenuity::NodeModule { public: - DSSIModule(OmFlowCanvas* canvas, CountedPtr node); + DSSIModule(PatchCanvas* canvas, CountedPtr node); virtual ~DSSIModule() {} void on_double_click(GdkEventButton* ev); diff --git a/src/progs/ingenuity/LoadPluginWindow.cpp b/src/progs/ingenuity/LoadPluginWindow.cpp index 5235dacd..e99550e5 100644 --- a/src/progs/ingenuity/LoadPluginWindow.cpp +++ b/src/progs/ingenuity/LoadPluginWindow.cpp @@ -26,7 +26,7 @@ #include "Store.h" #include "ModelEngineInterface.h" #include "PatchView.h" -#include "OmFlowCanvas.h" +#include "PatchCanvas.h" using std::cout; using std::cerr; using std::endl; diff --git a/src/progs/ingenuity/Makefile.am b/src/progs/ingenuity/Makefile.am index aaa832f3..0290f37e 100644 --- a/src/progs/ingenuity/Makefile.am +++ b/src/progs/ingenuity/Makefile.am @@ -24,8 +24,8 @@ ingenuity_SOURCES = \ main.cpp \ NodeMenu.h \ NodeMenu.cpp \ - OmFlowCanvas.h \ - OmFlowCanvas.cpp \ + PatchCanvas.h \ + PatchCanvas.cpp \ BreadCrumb.h \ BreadCrumbBox.h \ BreadCrumbBox.cpp \ @@ -59,18 +59,18 @@ ingenuity_SOURCES = \ WindowFactory.cpp \ ../../common/types.h \ ../../common/Path.h \ - OmModule.h \ - OmModule.cpp \ - OmPortModule.h \ - OmPortModule.cpp \ + NodeModule.h \ + NodeModule.cpp \ + PatchPortModule.h \ + PatchPortModule.cpp \ DSSIModule.h \ DSSIModule.cpp \ SubpatchModule.h \ SubpatchModule.cpp \ - OmPort.h \ - OmPort.cpp \ - OmPatchPort.h \ - OmPatchPort.cpp \ + Port.h \ + Port.cpp \ + PatchPort.h \ + PatchPort.cpp \ NewSubpatchWindow.h \ NewSubpatchWindow.cpp \ ConfigWindow.h \ diff --git a/src/progs/ingenuity/NodeMenu.h b/src/progs/ingenuity/NodeMenu.h index a80b7a69..1846ed56 100644 --- a/src/progs/ingenuity/NodeMenu.h +++ b/src/progs/ingenuity/NodeMenu.h @@ -31,7 +31,7 @@ namespace Ingenuity { class Controller; class NodeControlWindow; class NodePropertiesWindow; -class OmFlowCanvas; +class PatchCanvas; /** Controller for a Node. * diff --git a/src/progs/ingenuity/NodeModule.cpp b/src/progs/ingenuity/NodeModule.cpp new file mode 100644 index 00000000..9384917b --- /dev/null +++ b/src/progs/ingenuity/NodeModule.cpp @@ -0,0 +1,138 @@ +/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. + * + * 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 + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "NodeModule.h" +#include +#include "util/Atom.h" +#include "App.h" +#include "ModelEngineInterface.h" +#include "PatchCanvas.h" +#include "PatchModel.h" +#include "NodeModel.h" +#include "Port.h" +#include "GladeFactory.h" +#include "RenameWindow.h" +#include "PatchWindow.h" +#include "WindowFactory.h" + +namespace Ingenuity { + + +NodeModule::NodeModule(PatchCanvas* canvas, CountedPtr node) +: LibFlowCanvas::Module(canvas, node->path().name()), + m_node(node), + m_menu(node) +{ + assert(m_node); + + if (node->polyphonic()) { + border_width(2.0); + } + + create_all_ports(); + + const Atom& x = node->get_metadata("module-x"); + const Atom& y = node->get_metadata("module-y"); + + if (x.type() == Atom::FLOAT && y.type() == Atom::FLOAT) { + move_to(x.get_float(), y.get_float()); + } else { + double x, y; + ((PatchCanvas*)m_canvas)->get_new_module_location(x, y); + } + + node->new_port_sig.connect(sigc::mem_fun(this, &NodeModule::add_port)); + 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() +{ + 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(); +} + + +void +NodeModule::add_port(CountedPtr port) +{ + cerr << "FIXME: port leak\n"; + new Port(this, port); + resize(); +} + + +void +NodeModule::remove_port(CountedPtr port) +{ + LibFlowCanvas::Port* canvas_port = get_port(port->path().name()); + delete canvas_port; +} + + +void +NodeModule::show_control_window() +{ + App::instance().window_factory()->present_controls(m_node); +} + + +void +NodeModule::store_location() +{ + const float x = static_cast(property_x()); + const float y = static_cast(property_y()); + + const Atom& existing_x = m_node->get_metadata("module-x"); + const Atom& existing_y = m_node->get_metadata("module-y"); + + if (existing_x.type() != Atom::FLOAT || existing_y.type() != Atom::FLOAT + || existing_x.get_float() != x || existing_y.get_float() != y) { + App::instance().engine()->set_metadata(m_node->path(), "module-x", Atom(x)); + App::instance().engine()->set_metadata(m_node->path(), "module-y", Atom(y)); + } + +} + + +void +NodeModule::on_right_click(GdkEventButton* event) +{ + m_menu.popup(event->button, event->time); +} + + +void +NodeModule::metadata_update(const string& key, const Atom& value) +{ + if (key == "module-x" && value.type() == Atom::FLOAT) + move_to(value.get_float(), property_y()); + else if (key == "module-y" && value.type() == Atom::FLOAT) + move_to(property_x(), value.get_float()); +} + + +} // namespace Ingenuity diff --git a/src/progs/ingenuity/NodeModule.h b/src/progs/ingenuity/NodeModule.h new file mode 100644 index 00000000..5b4ec922 --- /dev/null +++ b/src/progs/ingenuity/NodeModule.h @@ -0,0 +1,84 @@ +/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. + * + * 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 + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef OMMODULE_H +#define OMMODULE_H + +#include +#include +#include +#include "NodeMenu.h" +#include "util/CountedPtr.h" +using std::string; + +class Atom; + +namespace Ingen { namespace Client { + class PortModel; + class NodeModel; + class ControlModel; +} } +using namespace Ingen::Client; + +namespace Ingenuity { + +class PatchCanvas; +class Port; + + +/** A module in a patch. + * + * This base class is extended for various types of modules - SubpatchModule, + * DSSIModule, etc. + * + * \ingroup Ingenuity + */ +class NodeModule : public LibFlowCanvas::Module +{ +public: + NodeModule(PatchCanvas* canvas, CountedPtr node); + virtual ~NodeModule() {} + + virtual Ingenuity::Port* port(const string& port_name) { + return (Ingenuity::Port*)Module::get_port(port_name); + } + + virtual void store_location(); + + void on_right_click(GdkEventButton* event); + + void show_control_window(); + + CountedPtr node() const { return m_node; } + +protected: + 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); + + void create_all_ports(); + void add_port(CountedPtr port); + void remove_port(CountedPtr port); + + CountedPtr m_node; + NodeMenu m_menu; +}; + + +} // namespace Ingenuity + +#endif // OMMODULE_H diff --git a/src/progs/ingenuity/OmFlowCanvas.cpp b/src/progs/ingenuity/OmFlowCanvas.cpp deleted file mode 100644 index 35b5c064..00000000 --- a/src/progs/ingenuity/OmFlowCanvas.cpp +++ /dev/null @@ -1,421 +0,0 @@ -/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. - * - * 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 - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "OmFlowCanvas.h" -#include -#include -#include "App.h" -#include "ModelEngineInterface.h" -#include "PatchModel.h" -#include "PatchWindow.h" -#include "LoadPluginWindow.h" -#include "LoadSubpatchWindow.h" -#include "NewSubpatchWindow.h" -#include "OmPort.h" -#include "NodeModel.h" -#include "OmModule.h" -#include "OmPortModule.h" -#include "SubpatchModule.h" -#include "GladeFactory.h" -#include "WindowFactory.h" - -namespace Ingenuity { - - -OmFlowCanvas::OmFlowCanvas(CountedPtr patch, int width, int height) -: FlowCanvas(width, height), - m_patch(patch), - m_last_click_x(0), - m_last_click_y(0) -{ - Glib::RefPtr xml = GladeFactory::new_glade_reference(); - xml->get_widget("canvas_menu", m_menu); - - xml->get_widget("canvas_menu_add_audio_input", m_menu_add_audio_input); - xml->get_widget("canvas_menu_add_audio_output", m_menu_add_audio_output); - xml->get_widget("canvas_menu_add_control_input", m_menu_add_control_input); - xml->get_widget("canvas_menu_add_control_output", m_menu_add_control_output); - xml->get_widget("canvas_menu_add_midi_input", m_menu_add_midi_input); - xml->get_widget("canvas_menu_add_midi_output", m_menu_add_midi_output); - xml->get_widget("canvas_menu_load_plugin", m_menu_load_plugin); - 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, &OmFlowCanvas::menu_add_port), - "audio_input", "AUDIO", false)); - m_menu_add_audio_output->signal_activate().connect( - sigc::bind(sigc::mem_fun(this, &OmFlowCanvas::menu_add_port), - "audio_output", "AUDIO", true)); - m_menu_add_control_input->signal_activate().connect( - sigc::bind(sigc::mem_fun(this, &OmFlowCanvas::menu_add_port), - "control_input", "CONTROL", false)); - m_menu_add_control_output->signal_activate().connect( - sigc::bind(sigc::mem_fun(this, &OmFlowCanvas::menu_add_port), - "control_output", "CONTROL", true)); - m_menu_add_midi_input->signal_activate().connect( - sigc::bind(sigc::mem_fun(this, &OmFlowCanvas::menu_add_port), - "midi_input", "MIDI", false)); - m_menu_add_midi_output->signal_activate().connect( - sigc::bind(sigc::mem_fun(this, &OmFlowCanvas::menu_add_port), - "midi_output", "MIDI", true)); - - // Connect to model signals to track state - m_patch->new_node_sig.connect(sigc::mem_fun(this, &OmFlowCanvas::add_node)); - m_patch->removed_node_sig.connect(sigc::mem_fun(this, &OmFlowCanvas::remove_node)); - m_patch->new_port_sig.connect(sigc::mem_fun(this, &OmFlowCanvas::add_port)); - m_patch->removed_port_sig.connect(sigc::mem_fun(this, &OmFlowCanvas::remove_port)); - m_patch->new_connection_sig.connect(sigc::mem_fun(this, &OmFlowCanvas::connection)); - m_patch->removed_connection_sig.connect(sigc::mem_fun(this, &OmFlowCanvas::disconnection)); - - // Connect widget signals to do things - m_menu_load_plugin->signal_activate().connect(sigc::mem_fun(this, &OmFlowCanvas::menu_load_plugin)); - m_menu_load_patch->signal_activate().connect(sigc::mem_fun(this, &OmFlowCanvas::menu_load_patch)); - m_menu_new_patch->signal_activate().connect(sigc::mem_fun(this, &OmFlowCanvas::menu_new_patch)); -} - - -void -OmFlowCanvas::build_canvas() { - - // Create modules for nodes - for (NodeModelMap::const_iterator i = m_patch->nodes().begin(); - i != m_patch->nodes().end(); ++i) { - add_node((*i).second); - } - - // 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) { - cerr << "FIXME: PORT MODULE LEAK!" << endl; - new OmPortModule(this, *i); - } - - // Create connections - for (list >::const_iterator i = m_patch->connections().begin(); - i != m_patch->connections().end(); ++i) { - connection(*i); - } -} - - -void -OmFlowCanvas::add_node(CountedPtr nm) -{ - cerr << "FIXME: MODULE LEAK!" << endl; - - CountedPtr pm = PtrCast(nm); - if (pm) - new SubpatchModule(this, pm); - else - new OmModule(this, nm); -} - - -void -OmFlowCanvas::remove_node(CountedPtr nm) -{ - LibFlowCanvas::Module* module = get_module(nm->path().name()); - delete module; -} - - -void -OmFlowCanvas::add_port(CountedPtr pm) -{ - cerr << "FIXME: PORT MODULE LEAK!" << endl; - - new OmPortModule(this, pm); -} - - -void -OmFlowCanvas::remove_port(CountedPtr pm) -{ - cerr << "FIXME: PORT REMOVE" << endl; - //LibFlowCanvas::Module* module = get_module(pm->path().name()); - //delete module; -} - - -void -OmFlowCanvas::connection(CountedPtr cm) -{ - // Deal with port "anonymous nodes" for this patch's own ports... - const Path& src_parent_path = cm->src_port_path().parent(); - const Path& dst_parent_path = cm->dst_port_path().parent(); - - const string& src_parent_name = - (src_parent_path == m_patch->path()) ? "" : src_parent_path.name(); - const string& dst_parent_name = - (dst_parent_path == m_patch->path()) ? "" : dst_parent_path.name(); - - Port* src_port = get_port(src_parent_name, cm->src_port_path().name()); - Port* dst_port = get_port(dst_parent_name, cm->dst_port_path().name()); - assert(src_port && dst_port); - - add_connection(src_port, dst_port); -} - - -void -OmFlowCanvas::disconnection(const Path& src_port_path, const Path& dst_port_path) -{ - const string& src_node_name = src_port_path.parent().name(); - const string& src_port_name = src_port_path.name(); - const string& dst_node_name = dst_port_path.parent().name(); - const string& dst_port_name = dst_port_path.name(); - - Port* src_port = get_port(src_node_name, src_port_name); - Port* dst_port = get_port(dst_node_name, dst_port_name); - - if (src_port && dst_port) { - remove_connection(src_port, dst_port); - } - - //patch_model()->remove_connection(src_port_path, dst_port_path); - - cerr << "FIXME: disconnection\n"; - /* - // Enable control slider in destination node control window - PortController* p = (PortController)Store::instance().port(dst_port_path)->controller(); - assert(p); - - if (p->control_panel()) - p->control_panel()->enable_port(p->path()); - */ -} - - -void -OmFlowCanvas::connect(const Port* src_port, const Port* dst_port) -{ - assert(src_port != NULL); - assert(dst_port != NULL); - - const OmPort* const src = static_cast(src_port); - const OmPort* const dst = static_cast(dst_port); - - // Midi binding/learn shortcut - if (src->model()->type() == PortModel::MIDI && - dst->model()->type() == PortModel::CONTROL) - { - cerr << "FIXME: MIDI binding" << endl; -#if 0 - CountedPtr pm(new PluginModel(PluginModel::Internal, "", "midi_control_in", "")); - CountedPtr nm(new NodeModel(pm, m_patch->path().base() - + src->name() + "-" + dst->name(), false)); - nm->set_metadata("module-x", Atom((float) - (dst->module()->property_x() - dst->module()->width() - 20))); - nm->set_metadata("module-y", Atom((float) - (dst->module()->property_y()))); - App::instance().engine()->create_node_from_model(nm.get()); - App::instance().engine()->connect(src->model()->path(), nm->path() + "/MIDI_In"); - App::instance().engine()->connect(nm->path() + "/Out_(CR)", dst->model()->path()); - App::instance().engine()->midi_learn(nm->path()); - - // Set control node range to port's user range - - App::instance().engine()->set_port_value_queued(nm->path().base() + "Min", - dst->model()->get_metadata("user-min").get_float()); - App::instance().engine()->set_port_value_queued(nm->path().base() + "Max", - dst->model()->get_metadata("user-max").get_float()); -#endif - } else { - App::instance().engine()->connect(src->model()->path(), dst->model()->path()); - } -} - - -void -OmFlowCanvas::disconnect(const Port* src_port, const Port* dst_port) -{ - assert(src_port != NULL); - assert(dst_port != NULL); - - App::instance().engine()->disconnect(((OmPort*)src_port)->model()->path(), - ((OmPort*)dst_port)->model()->path()); -} - - -bool -OmFlowCanvas::canvas_event(GdkEvent* event) -{ - assert(event != NULL); - - switch (event->type) { - - case GDK_BUTTON_PRESS: - if (event->button.button == 3) { - m_last_click_x = (int)event->button.x; - m_last_click_y = (int)event->button.y; - show_menu(event); - } - break; - - /*case GDK_KEY_PRESS: - if (event->key.keyval == GDK_Delete) - destroy_selected(); - break; - */ - - default: - break; - } - - return FlowCanvas::canvas_event(event); -} - - -void -OmFlowCanvas::destroy_selected() -{ - for (list::iterator m = m_selected_modules.begin(); m != m_selected_modules.end(); ++m) - App::instance().engine()->destroy(((OmModule*)(*m))->node()->path()); -} - - -string -OmFlowCanvas::generate_port_name(const string& base) { - string name = base; - - char num_buf[5]; - for (uint i=1; i < 9999; ++i) { - snprintf(num_buf, 5, "%u", i); - name = base + "_"; - name += num_buf; - if (!m_patch->get_port(name)) - break; - } - - assert(Path::is_valid(string("/") + name)); - - return name; -} - - -void -OmFlowCanvas::menu_add_port(const string& name, const string& type, bool is_output) -{ - const Path& path = m_patch->path().base() + generate_port_name(name); - App::instance().engine()->create_port(path, type, is_output); - - char temp_buf[16]; - snprintf(temp_buf, 16, "%d", m_last_click_x); - App::instance().engine()->set_metadata(path, "module-x", temp_buf); - snprintf(temp_buf, 16, "%d", m_last_click_y); - App::instance().engine()->set_metadata(path, "module-y", temp_buf); -} - - -/** Try to guess a suitable location for a new module. - */ -void -OmFlowCanvas::get_new_module_location(double& x, double& y) -{ - int scroll_x; - int scroll_y; - get_scroll_offsets(scroll_x, scroll_y); - x = scroll_x + 20; - y = scroll_y + 20; -} - - -/* -void -OmFlowCanvas::menu_add_audio_input() -{ - string name = "audio_in"; - App::instance().engine()->create_port(m_patch_controller->path().base() + name, "AUDIO", false); -} - - -void -OmFlowCanvas::menu_add_audio_output() -{ - string name = "audio_out"; - App::instance().engine()->create_port(m_patch_controller->path().base() + name, "AUDIO", true); -} - - -void -OmFlowCanvas::menu_add_control_input() -{ - string name = "control_in"; - App::instance().engine()->create_port(m_patch_controller->path().base() + name, "CONTROL", false); -} - - -void -OmFlowCanvas::menu_add_control_output() -{ - string name = "control_out"; - App::instance().engine()->create_port(m_patch_controller->path().base() + name, "CONTROL", true); -} - - -void -OmFlowCanvas::menu_add_midi_input() -{ - string name = "midi_in"; - App::instance().engine()->create_port(m_patch_controller->path().base() + name, "MIDI", false); -} - - -void -OmFlowCanvas::menu_add_midi_output() -{ - string name = "midi_out"; - App::instance().engine()->create_port(m_patch_controller->path().base() + name, "MIDI", true); -} -*/ - -MetadataMap -OmFlowCanvas::get_initial_data() -{ - MetadataMap result; - - result["module-x"] = Atom((float)m_last_click_x); - result["module-y"] = Atom((float)m_last_click_y); - - return result; -} - -void -OmFlowCanvas::menu_load_plugin() -{ - App::instance().window_factory()->present_load_plugin(m_patch, get_initial_data()); -} - - -void -OmFlowCanvas::menu_load_patch() -{ - App::instance().window_factory()->present_load_subpatch(m_patch, get_initial_data()); -} - - -void -OmFlowCanvas::menu_new_patch() -{ - App::instance().window_factory()->present_new_subpatch(m_patch, get_initial_data()); -} - - -} // namespace Ingenuity diff --git a/src/progs/ingenuity/OmFlowCanvas.h b/src/progs/ingenuity/OmFlowCanvas.h deleted file mode 100644 index ffbaa363..00000000 --- a/src/progs/ingenuity/OmFlowCanvas.h +++ /dev/null @@ -1,110 +0,0 @@ -/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. - * - * 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 - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef OMPATCHBAYAREA_H -#define OMPATCHBAYAREA_H - -#include -#include -#include "util/CountedPtr.h" -#include "util/Path.h" -#include "ConnectionModel.h" -#include "PatchModel.h" - -using std::string; -using namespace LibFlowCanvas; - -using LibFlowCanvas::Port; -using Ingen::Client::ConnectionModel; -using Ingen::Client::PatchModel; -using Ingen::Client::NodeModel; -using Ingen::Client::PortModel; -using Ingen::Client::MetadataMap; - -namespace Ingenuity { - -class OmModule; - - -/** Patch canvas widget. - * - * \ingroup Ingenuity - */ -class OmFlowCanvas : public LibFlowCanvas::FlowCanvas -{ -public: - OmFlowCanvas(CountedPtr patch, int width, int height); - - OmModule* find_module(const string& name) - { return (OmModule*)FlowCanvas::get_module(name); } - - void add_node(CountedPtr nm); - void remove_node(CountedPtr nm); - void add_port(CountedPtr pm); - void remove_port(CountedPtr pm); - void connection(CountedPtr cm); - void disconnection(const Path& src_port_path, const Path& dst_port_path); - - void get_new_module_location(double& x, double& y); - - void destroy_selected(); - - void show_menu(GdkEvent* event) - { m_menu->popup(event->button.button, event->button.time); } - -private: - string generate_port_name(const string& base); - void menu_add_port(const string& name, const string& type, bool is_output); - /*void menu_add_audio_input(); - void menu_add_audio_output(); - void menu_add_control_input(); - void menu_add_control_output(); - void menu_add_midi_input(); - void menu_add_midi_output();*/ - void menu_load_plugin(); - void menu_new_patch(); - void menu_load_patch(); - - MetadataMap get_initial_data(); - - void build_canvas(); - - bool canvas_event(GdkEvent* event); - - void connect(const Port* src_port, const Port* dst_port); - void disconnect(const Port* src_port, const Port* dst_port); - - CountedPtr m_patch; - - int m_last_click_x; - int m_last_click_y; - - Gtk::Menu* m_menu; - Gtk::MenuItem* m_menu_add_audio_input; - Gtk::MenuItem* m_menu_add_audio_output; - Gtk::MenuItem* m_menu_add_control_input; - Gtk::MenuItem* m_menu_add_control_output; - Gtk::MenuItem* m_menu_add_midi_input; - Gtk::MenuItem* m_menu_add_midi_output; - Gtk::MenuItem* m_menu_load_plugin; - Gtk::MenuItem* m_menu_load_patch; - Gtk::MenuItem* m_menu_new_patch; -}; - - -} // namespace Ingenuity - -#endif // OMPATCHBAYAREA_H diff --git a/src/progs/ingenuity/OmModule.cpp b/src/progs/ingenuity/OmModule.cpp deleted file mode 100644 index 489b035a..00000000 --- a/src/progs/ingenuity/OmModule.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. - * - * 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 - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "OmModule.h" -#include -#include "util/Atom.h" -#include "App.h" -#include "ModelEngineInterface.h" -#include "OmFlowCanvas.h" -#include "PatchModel.h" -#include "NodeModel.h" -#include "OmPort.h" -#include "GladeFactory.h" -#include "RenameWindow.h" -#include "PatchWindow.h" -#include "WindowFactory.h" - -namespace Ingenuity { - - -OmModule::OmModule(OmFlowCanvas* canvas, CountedPtr node) -: LibFlowCanvas::Module(canvas, node->path().name()), - m_node(node), - m_menu(node) -{ - assert(m_node); - - if (node->polyphonic()) { - border_width(2.0); - } - - create_all_ports(); - - const Atom& x = node->get_metadata("module-x"); - const Atom& y = node->get_metadata("module-y"); - - if (x.type() == Atom::FLOAT && y.type() == Atom::FLOAT) { - move_to(x.get_float(), y.get_float()); - } else { - double x, y; - ((OmFlowCanvas*)m_canvas)->get_new_module_location(x, y); - } - - node->new_port_sig.connect(sigc::mem_fun(this, &OmModule::add_port)); - node->removed_port_sig.connect(sigc::mem_fun(this, &OmModule::remove_port)); - node->metadata_update_sig.connect(sigc::mem_fun(this, &OmModule::metadata_update)); -} - - -void -OmModule::create_all_ports() -{ - 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(); -} - - -void -OmModule::add_port(CountedPtr port) -{ - new OmPort(this, port); - resize(); -} - - -void -OmModule::remove_port(CountedPtr port) -{ - LibFlowCanvas::Port* canvas_port = get_port(port->path().name()); - delete canvas_port; -} - - -void -OmModule::show_control_window() -{ - App::instance().window_factory()->present_controls(m_node); -} - - -void -OmModule::store_location() -{ - const float x = static_cast(property_x()); - const float y = static_cast(property_y()); - - const Atom& existing_x = m_node->get_metadata("module-x"); - const Atom& existing_y = m_node->get_metadata("module-y"); - - if (existing_x.type() != Atom::FLOAT || existing_y.type() != Atom::FLOAT - || existing_x.get_float() != x || existing_y.get_float() != y) { - App::instance().engine()->set_metadata(m_node->path(), "module-x", Atom(x)); - App::instance().engine()->set_metadata(m_node->path(), "module-y", Atom(y)); - } - -} - - -void -OmModule::on_right_click(GdkEventButton* event) -{ - m_menu.popup(event->button, event->time); -} - - -void -OmModule::metadata_update(const string& key, const Atom& value) -{ - if (key == "module-x" && value.type() == Atom::FLOAT) - move_to(value.get_float(), property_y()); - else if (key == "module-y" && value.type() == Atom::FLOAT) - move_to(property_x(), value.get_float()); -} - - -} // namespace Ingenuity diff --git a/src/progs/ingenuity/OmModule.h b/src/progs/ingenuity/OmModule.h deleted file mode 100644 index e20391c6..00000000 --- a/src/progs/ingenuity/OmModule.h +++ /dev/null @@ -1,84 +0,0 @@ -/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. - * - * 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 - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef OMMODULE_H -#define OMMODULE_H - -#include -#include -#include -#include "NodeMenu.h" -#include "util/CountedPtr.h" -using std::string; - -class Atom; - -namespace Ingen { namespace Client { - class PortModel; - class NodeModel; - class ControlModel; -} } -using namespace Ingen::Client; - -namespace Ingenuity { - -class OmFlowCanvas; -class OmPort; - - -/** A module in a patch. - * - * This base class is extended for various types of modules - SubpatchModule, - * DSSIModule, etc. - * - * \ingroup Ingenuity - */ -class OmModule : public LibFlowCanvas::Module -{ -public: - OmModule(OmFlowCanvas* canvas, CountedPtr node); - virtual ~OmModule() {} - - virtual OmPort* port(const string& port_name) { - return (OmPort*)Module::get_port(port_name); - } - - virtual void store_location(); - - void on_right_click(GdkEventButton* event); - - void show_control_window(); - - CountedPtr node() const { return m_node; } - -protected: - 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); - - void create_all_ports(); - void add_port(CountedPtr port); - void remove_port(CountedPtr port); - - CountedPtr m_node; - NodeMenu m_menu; -}; - - -} // namespace Ingenuity - -#endif // OMMODULE_H diff --git a/src/progs/ingenuity/OmPatchPort.cpp b/src/progs/ingenuity/OmPatchPort.cpp deleted file mode 100644 index 0d3acf76..00000000 --- a/src/progs/ingenuity/OmPatchPort.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. - * - * 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 - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "OmPatchPort.h" -#include -#include -#include "PortModel.h" -#include "OmPortModule.h" -#include "ControlModel.h" -#include "Configuration.h" -#include "App.h" -using std::cerr; using std::endl; - -using namespace Ingen::Client; - -namespace Ingenuity { - -OmPatchPort::OmPatchPort(OmPortModule* module, CountedPtr pm) -: Port(module, pm->path().name(), !pm->is_input(), App::instance().configuration()->get_port_color(pm.get())), - m_port_model(pm) -{ - assert(module); - assert(m_port_model); -} - -#if 0 -void -OmPatchPort::set_name(const string& n) -{ - cerr << "********** OmPatchPort::set_name broken **********************" << endl; - - /* FIXME: move to PortController - string new_path = Path::parent(m_port_model->path()) +"/"+ n; - - for (list::iterator i = m_control_panels.begin(); i != m_control_panels.end(); ++i) - (*i)->rename_port(m_port_model->path(), new_path); - - Port::set_name(n); - m_port_model->path(new_path); - */ -} -#endif - -} // namespace Ingenuity diff --git a/src/progs/ingenuity/OmPatchPort.h b/src/progs/ingenuity/OmPatchPort.h deleted file mode 100644 index e7d5765f..00000000 --- a/src/progs/ingenuity/OmPatchPort.h +++ /dev/null @@ -1,59 +0,0 @@ -/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. - * - * 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 - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef OMPATCHPORT_H -#define OMPATCHPORT_H - -#include -#include -#include -#include "util/CountedPtr.h" - -namespace Ingen { namespace Client { class PortModel; } } -using namespace Ingen::Client; -using namespace LibFlowCanvas; -using std::string; using std::list; - -namespace Ingenuity { - -class FlowCanvas; -class PatchWindow; -class OmPortModule; - - -/** A Port (on a pseudo node) in a patch canvas, to represent a port on that patch. - * - * \ingroup Ingenuity - */ -class OmPatchPort : public LibFlowCanvas::Port -{ -public: - OmPatchPort(OmPortModule* module, CountedPtr pm); - - virtual ~OmPatchPort() {} - - //void set_name(const string& n); - - CountedPtr model() const { return m_port_model; } - -private: - CountedPtr m_port_model; -}; - - -} // namespace Ingenuity - -#endif // OMPATCHPORT_H diff --git a/src/progs/ingenuity/OmPort.cpp b/src/progs/ingenuity/OmPort.cpp deleted file mode 100644 index e2a32652..00000000 --- a/src/progs/ingenuity/OmPort.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. - * - * 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 - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "OmPort.h" -#include -#include -#include "PortModel.h" -#include "OmModule.h" -#include "ControlModel.h" -#include "Configuration.h" -#include "App.h" -using std::cerr; using std::endl; - -using namespace Ingen::Client; - -namespace Ingenuity { - -OmPort::OmPort(Module* module, CountedPtr pm) -: Port(module, pm->path().name(), pm->is_input(), App::instance().configuration()->get_port_color(pm.get())), - m_port_model(pm) -{ - assert(module); - assert(m_port_model); -} - -#if 0 -void -OmPort::set_name(const string& n) -{ - cerr << "********** OmPort::set_name broken **********************" << endl; - - /* FIXME: move to PortController - string new_path = Path::parent(m_port_model->path()) +"/"+ n; - - for (list::iterator i = m_control_panels.begin(); i != m_control_panels.end(); ++i) - (*i)->rename_port(m_port_model->path(), new_path); - - Port::set_name(n); - m_port_model->path(new_path); - */ -} -#endif - -} // namespace Ingenuity diff --git a/src/progs/ingenuity/OmPort.h b/src/progs/ingenuity/OmPort.h deleted file mode 100644 index cedad156..00000000 --- a/src/progs/ingenuity/OmPort.h +++ /dev/null @@ -1,59 +0,0 @@ -/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. - * - * 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 - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef OMPORT_H -#define OMPORT_H - -#include -#include -#include -#include "util/CountedPtr.h" - -namespace Ingen { namespace Client { class PortModel; } } -using namespace Ingen::Client; -using namespace LibFlowCanvas; -using std::string; using std::list; - -namespace Ingenuity { - -class FlowCanvas; -class PatchWindow; -class OmModule; - - -/** A Port on an OmModule. - * - * \ingroup Ingenuity - */ -class OmPort : public LibFlowCanvas::Port -{ -public: - OmPort(Module* module, CountedPtr pm); - - virtual ~OmPort() {} - - //void set_name(const string& n); - - CountedPtr model() const { return m_port_model; } - -private: - CountedPtr m_port_model; -}; - - -} // namespace Ingenuity - -#endif // OMPORT_H diff --git a/src/progs/ingenuity/OmPortModule.cpp b/src/progs/ingenuity/OmPortModule.cpp deleted file mode 100644 index 7496a6a6..00000000 --- a/src/progs/ingenuity/OmPortModule.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. - * - * 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 - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "OmPortModule.h" -#include -#include "App.h" -#include "ModelEngineInterface.h" -#include "OmFlowCanvas.h" -#include "PatchModel.h" -#include "NodeModel.h" -#include "OmPort.h" -#include "GladeFactory.h" -#include "RenameWindow.h" -#include "PatchWindow.h" -#include "OmPatchPort.h" - -namespace Ingenuity { - - -OmPortModule::OmPortModule(OmFlowCanvas* canvas, CountedPtr port) -: LibFlowCanvas::Module(canvas, "", 0, 0), // FIXME: coords? - m_port(port), - m_patch_port(NULL) -{ - /*if (port_model()->polyphonic() && port_model()->parent() != NULL - && port_model()->parent_patch()->poly() > 1) { - border_width(2.0); - }*/ - - assert(canvas); - assert(port); - - if (PtrCast(port->parent())) { - if (m_patch_port) - delete m_patch_port; - - m_patch_port = new OmPatchPort(this, port); - } - - resize(); - - const Atom& x_atom = port->get_metadata("module-x"); - const Atom& y_atom = port->get_metadata("module-y"); - - if (x_atom && y_atom && x_atom.type() == Atom::FLOAT && y_atom.type() == Atom::FLOAT) { - move_to(x_atom.get_float(), y_atom.get_float()); - } else { - double default_x; - double default_y; - canvas->get_new_module_location(default_x, default_y); - move_to(default_x, default_y); - } - - port->metadata_update_sig.connect(sigc::mem_fun(this, &OmPortModule::metadata_update)); -} - - -void -OmPortModule::store_location() -{ - const float x = static_cast(property_x()); - const float y = static_cast(property_y()); - - const Atom& existing_x = m_port->get_metadata("module-x"); - const Atom& existing_y = m_port->get_metadata("module-y"); - - if (existing_x.type() != Atom::FLOAT || existing_y.type() != Atom::FLOAT - || existing_x.get_float() != x || existing_y.get_float() != y) { - App::instance().engine()->set_metadata(m_port->path(), "module-x", Atom(x)); - App::instance().engine()->set_metadata(m_port->path(), "module-y", Atom(y)); - } -} - - -void -OmPortModule::metadata_update(const string& key, const Atom& value) -{ - if (key == "module-x" && value.type() == Atom::FLOAT) - move_to(value.get_float(), property_y()); - else if (key == "module-y" && value.type() == Atom::FLOAT) - move_to(property_x(), value.get_float()); -} - - -} // namespace Ingenuity diff --git a/src/progs/ingenuity/OmPortModule.h b/src/progs/ingenuity/OmPortModule.h deleted file mode 100644 index 028f3c78..00000000 --- a/src/progs/ingenuity/OmPortModule.h +++ /dev/null @@ -1,75 +0,0 @@ -/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. - * - * 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 - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef OMPORTMODULE_H -#define OMPORTMODULE_H - -#include -#include -#include -#include "util/Atom.h" -#include "OmPatchPort.h" -using std::string; - -namespace Ingen { namespace Client { - class PortModel; - class NodeModel; - class ControlModel; -} } -using namespace Ingen::Client; - -namespace Ingenuity { - -class OmFlowCanvas; -class OmPort; - - -/** A "module" to represent a patch's port on it's own canvas. - * - * Translation: This is the nameless single port pseudo module thingy. - * - * \ingroup Ingenuity - */ -class OmPortModule : public LibFlowCanvas::Module -{ -public: - OmPortModule(OmFlowCanvas* canvas, CountedPtr port); - virtual ~OmPortModule() {} - - //virtual OmPort* port(const string& port_name) { - // return (OmPort*)Module::port(port_name); - //} - - virtual void store_location(); - - //void on_right_click(GdkEventButton* event) { m_port->show_menu(event); } - - CountedPtr port() const { return m_port; } - -protected: - //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 m_port; - OmPatchPort* m_patch_port; ///< Port on this 'anonymous' module -}; - - -} // namespace Ingenuity - -#endif // OMPORTMODULE_H diff --git a/src/progs/ingenuity/PatchCanvas.cpp b/src/progs/ingenuity/PatchCanvas.cpp new file mode 100644 index 00000000..fd84443c --- /dev/null +++ b/src/progs/ingenuity/PatchCanvas.cpp @@ -0,0 +1,368 @@ +/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. + * + * 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 + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "PatchCanvas.h" +#include +#include +#include "App.h" +#include "ModelEngineInterface.h" +#include "PatchModel.h" +#include "PatchWindow.h" +#include "PatchPortModule.h" +#include "LoadPluginWindow.h" +#include "LoadSubpatchWindow.h" +#include "NewSubpatchWindow.h" +#include "Port.h" +#include "NodeModel.h" +#include "NodeModule.h" +#include "PatchPortModule.h" +#include "SubpatchModule.h" +#include "GladeFactory.h" +#include "WindowFactory.h" + +namespace Ingenuity { + + +PatchCanvas::PatchCanvas(CountedPtr patch, int width, int height) +: FlowCanvas(width, height), + m_patch(patch), + m_last_click_x(0), + m_last_click_y(0) +{ + Glib::RefPtr xml = GladeFactory::new_glade_reference(); + xml->get_widget("canvas_menu", m_menu); + + xml->get_widget("canvas_menu_add_audio_input", m_menu_add_audio_input); + xml->get_widget("canvas_menu_add_audio_output", m_menu_add_audio_output); + xml->get_widget("canvas_menu_add_control_input", m_menu_add_control_input); + xml->get_widget("canvas_menu_add_control_output", m_menu_add_control_output); + xml->get_widget("canvas_menu_add_midi_input", m_menu_add_midi_input); + xml->get_widget("canvas_menu_add_midi_output", m_menu_add_midi_output); + xml->get_widget("canvas_menu_load_plugin", m_menu_load_plugin); + 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), + "audio_input", "AUDIO", false)); + m_menu_add_audio_output->signal_activate().connect( + sigc::bind(sigc::mem_fun(this, &PatchCanvas::menu_add_port), + "audio_output", "AUDIO", true)); + m_menu_add_control_input->signal_activate().connect( + sigc::bind(sigc::mem_fun(this, &PatchCanvas::menu_add_port), + "control_input", "CONTROL", false)); + m_menu_add_control_output->signal_activate().connect( + sigc::bind(sigc::mem_fun(this, &PatchCanvas::menu_add_port), + "control_output", "CONTROL", true)); + m_menu_add_midi_input->signal_activate().connect( + sigc::bind(sigc::mem_fun(this, &PatchCanvas::menu_add_port), + "midi_input", "MIDI", false)); + m_menu_add_midi_output->signal_activate().connect( + sigc::bind(sigc::mem_fun(this, &PatchCanvas::menu_add_port), + "midi_output", "MIDI", true)); + + // Connect to model signals to track state + m_patch->new_node_sig.connect(sigc::mem_fun(this, &PatchCanvas::add_node)); + m_patch->removed_node_sig.connect(sigc::mem_fun(this, &PatchCanvas::remove_node)); + m_patch->new_port_sig.connect(sigc::mem_fun(this, &PatchCanvas::add_port)); + m_patch->removed_port_sig.connect(sigc::mem_fun(this, &PatchCanvas::remove_port)); + m_patch->new_connection_sig.connect(sigc::mem_fun(this, &PatchCanvas::connection)); + m_patch->removed_connection_sig.connect(sigc::mem_fun(this, &PatchCanvas::disconnection)); + + // Connect widget signals to do things + m_menu_load_plugin->signal_activate().connect(sigc::mem_fun(this, &PatchCanvas::menu_load_plugin)); + m_menu_load_patch->signal_activate().connect(sigc::mem_fun(this, &PatchCanvas::menu_load_patch)); + m_menu_new_patch->signal_activate().connect(sigc::mem_fun(this, &PatchCanvas::menu_new_patch)); +} + + +void +PatchCanvas::build_canvas() { + + // Create modules for nodes + for (NodeModelMap::const_iterator i = m_patch->nodes().begin(); + i != m_patch->nodes().end(); ++i) { + add_node((*i).second); + } + + // 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) { + cerr << "FIXME: PORT MODULE LEAK!" << endl; + new PatchPortModule(this, *i); + } + + // Create connections + for (list >::const_iterator i = m_patch->connections().begin(); + i != m_patch->connections().end(); ++i) { + connection(*i); + } +} + + +void +PatchCanvas::add_node(CountedPtr nm) +{ + cerr << "FIXME: MODULE LEAK!" << endl; + + CountedPtr pm = PtrCast(nm); + if (pm) + new SubpatchModule(this, pm); + else + new NodeModule(this, nm); +} + + +void +PatchCanvas::remove_node(CountedPtr nm) +{ + LibFlowCanvas::Module* module = get_module(nm->path().name()); + delete module; +} + + +void +PatchCanvas::add_port(CountedPtr pm) +{ + cerr << "FIXME: PORT MODULE LEAK!" << endl; + + new PatchPortModule(this, pm); +} + + +void +PatchCanvas::remove_port(CountedPtr pm) +{ + cerr << "FIXME: PORT REMOVE" << endl; + //LibFlowCanvas::Module* module = get_module(pm->path().name()); + //delete module; +} + + +void +PatchCanvas::connection(CountedPtr cm) +{ + // Deal with port "anonymous nodes" for this patch's own ports... + const Path& src_parent_path = cm->src_port_path().parent(); + const Path& dst_parent_path = cm->dst_port_path().parent(); + + const string& src_parent_name = + (src_parent_path == m_patch->path()) ? "" : src_parent_path.name(); + 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); +} + + +void +PatchCanvas::disconnection(const Path& src_port_path, const Path& dst_port_path) +{ + const string& src_node_name = src_port_path.parent().name(); + const string& src_port_name = src_port_path.name(); + 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); + + if (src_port && dst_port) { + remove_connection(src_port, dst_port); + } + + //patch_model()->remove_connection(src_port_path, dst_port_path); + + cerr << "FIXME: disconnection\n"; + /* + // Enable control slider in destination node control window + PortController* p = (PortController)Store::instance().port(dst_port_path)->controller(); + assert(p); + + if (p->control_panel()) + p->control_panel()->enable_port(p->path()); + */ +} + + +void +PatchCanvas::connect(const LibFlowCanvas::Port* src_port, const LibFlowCanvas::Port* dst_port) +{ + assert(src_port != NULL); + assert(dst_port != NULL); + + const Ingenuity::Port* const src = dynamic_cast(src_port); + const Ingenuity::Port* const dst = dynamic_cast(dst_port); + assert(src && dst); + + // Midi binding/learn shortcut + if (src->model()->type() == PortModel::MIDI && + dst->model()->type() == PortModel::CONTROL) + { + cerr << "FIXME: MIDI binding" << endl; +#if 0 + CountedPtr pm(new PluginModel(PluginModel::Internal, "", "midi_control_in", "")); + CountedPtr nm(new NodeModel(pm, m_patch->path().base() + + src->name() + "-" + dst->name(), false)); + nm->set_metadata("module-x", Atom((float) + (dst->module()->property_x() - dst->module()->width() - 20))); + nm->set_metadata("module-y", Atom((float) + (dst->module()->property_y()))); + App::instance().engine()->create_node_from_model(nm.get()); + App::instance().engine()->connect(src->model()->path(), nm->path() + "/MIDI_In"); + App::instance().engine()->connect(nm->path() + "/Out_(CR)", dst->model()->path()); + App::instance().engine()->midi_learn(nm->path()); + + // Set control node range to port's user range + + App::instance().engine()->set_port_value_queued(nm->path().base() + "Min", + dst->model()->get_metadata("user-min").get_float()); + App::instance().engine()->set_port_value_queued(nm->path().base() + "Max", + dst->model()->get_metadata("user-max").get_float()); +#endif + } else { + App::instance().engine()->connect(src->model()->path(), dst->model()->path()); + } +} + + +void +PatchCanvas::disconnect(const LibFlowCanvas::Port* src_port, const LibFlowCanvas::Port* dst_port) +{ + assert(src_port != NULL); + assert(dst_port != NULL); + + App::instance().engine()->disconnect(((Ingenuity::Port*)src_port)->model()->path(), + ((Ingenuity::Port*)dst_port)->model()->path()); +} + + +bool +PatchCanvas::canvas_event(GdkEvent* event) +{ + assert(event != NULL); + + switch (event->type) { + + case GDK_BUTTON_PRESS: + if (event->button.button == 3) { + m_last_click_x = (int)event->button.x; + m_last_click_y = (int)event->button.y; + show_menu(event); + } + break; + + /*case GDK_KEY_PRESS: + if (event->key.keyval == GDK_Delete) + destroy_selected(); + break; + */ + + default: + break; + } + + return FlowCanvas::canvas_event(event); +} + + +void +PatchCanvas::destroy_selected() +{ + for (list::iterator m = m_selected_modules.begin(); m != m_selected_modules.end(); ++m) + App::instance().engine()->destroy(((NodeModule*)(*m))->node()->path()); +} + + +string +PatchCanvas::generate_port_name(const string& base) { + string name = base; + + char num_buf[5]; + for (uint i=1; i < 9999; ++i) { + snprintf(num_buf, 5, "%u", i); + name = base + "_"; + name += num_buf; + if (!m_patch->get_port(name)) + break; + } + + assert(Path::is_valid(string("/") + name)); + + return name; +} + + +void +PatchCanvas::menu_add_port(const string& name, const string& type, bool is_output) +{ + const Path& path = m_patch->path().base() + generate_port_name(name); + App::instance().engine()->create_port_with_data(path, type, is_output, get_initial_data()); +} + + +/** Try to guess a suitable location for a new module. + */ +void +PatchCanvas::get_new_module_location(double& x, double& y) +{ + int scroll_x; + int scroll_y; + get_scroll_offsets(scroll_x, scroll_y); + x = scroll_x + 20; + y = scroll_y + 20; +} + + +MetadataMap +PatchCanvas::get_initial_data() +{ + MetadataMap result; + + result["module-x"] = Atom((float)m_last_click_x); + result["module-y"] = Atom((float)m_last_click_y); + + return result; +} + +void +PatchCanvas::menu_load_plugin() +{ + App::instance().window_factory()->present_load_plugin(m_patch, get_initial_data()); +} + + +void +PatchCanvas::menu_load_patch() +{ + App::instance().window_factory()->present_load_subpatch(m_patch, get_initial_data()); +} + + +void +PatchCanvas::menu_new_patch() +{ + App::instance().window_factory()->present_new_subpatch(m_patch, get_initial_data()); +} + + +} // namespace Ingenuity diff --git a/src/progs/ingenuity/PatchCanvas.h b/src/progs/ingenuity/PatchCanvas.h new file mode 100644 index 00000000..c6abeeb0 --- /dev/null +++ b/src/progs/ingenuity/PatchCanvas.h @@ -0,0 +1,104 @@ +/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. + * + * 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 + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef OMPATCHBAYAREA_H +#define OMPATCHBAYAREA_H + +#include +#include +#include "util/CountedPtr.h" +#include "util/Path.h" +#include "ConnectionModel.h" +#include "PatchModel.h" + +using std::string; +using namespace LibFlowCanvas; + +using LibFlowCanvas::Port; +using Ingen::Client::ConnectionModel; +using Ingen::Client::PatchModel; +using Ingen::Client::NodeModel; +using Ingen::Client::PortModel; +using Ingen::Client::MetadataMap; + +namespace Ingenuity { + +class NodeModule; + + +/** Patch canvas widget. + * + * \ingroup Ingenuity + */ +class PatchCanvas : public LibFlowCanvas::FlowCanvas +{ +public: + PatchCanvas(CountedPtr patch, int width, int height); + + NodeModule* find_module(const string& name) + { return (NodeModule*)FlowCanvas::get_module(name); } + + void add_node(CountedPtr nm); + void remove_node(CountedPtr nm); + void add_port(CountedPtr pm); + void remove_port(CountedPtr pm); + void connection(CountedPtr cm); + void disconnection(const Path& src_port_path, const Path& dst_port_path); + + void get_new_module_location(double& x, double& y); + + void destroy_selected(); + + void show_menu(GdkEvent* event) + { m_menu->popup(event->button.button, event->button.time); } + +private: + string generate_port_name(const string& base); + void menu_add_port(const string& name, const string& type, bool is_output); + void menu_load_plugin(); + void menu_new_patch(); + void menu_load_patch(); + + 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); + + CountedPtr m_patch; + + int m_last_click_x; + int m_last_click_y; + + Gtk::Menu* m_menu; + Gtk::MenuItem* m_menu_add_audio_input; + Gtk::MenuItem* m_menu_add_audio_output; + Gtk::MenuItem* m_menu_add_control_input; + Gtk::MenuItem* m_menu_add_control_output; + Gtk::MenuItem* m_menu_add_midi_input; + Gtk::MenuItem* m_menu_add_midi_output; + Gtk::MenuItem* m_menu_load_plugin; + Gtk::MenuItem* m_menu_load_patch; + Gtk::MenuItem* m_menu_new_patch; +}; + + +} // namespace Ingenuity + +#endif // OMPATCHBAYAREA_H diff --git a/src/progs/ingenuity/PatchPort.cpp b/src/progs/ingenuity/PatchPort.cpp new file mode 100644 index 00000000..7fc75dc8 --- /dev/null +++ b/src/progs/ingenuity/PatchPort.cpp @@ -0,0 +1,57 @@ +/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. + * + * 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 + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "PatchPort.h" +#include +#include +#include "PortModel.h" +#include "PatchPortModule.h" +#include "ControlModel.h" +#include "Configuration.h" +#include "App.h" +using std::cerr; using std::endl; + +using namespace Ingen::Client; + +namespace Ingenuity { + +PatchPort::PatchPort(PatchPortModule* module, CountedPtr pm) +: Port(module, pm->path().name(), !pm->is_input(), App::instance().configuration()->get_port_color(pm.get())), + m_port_model(pm) +{ + assert(module); + assert(m_port_model); +} + +#if 0 +void +PatchPort::set_name(const string& n) +{ + cerr << "********** PatchPort::set_name broken **********************" << endl; + + /* FIXME: move to PortController + string new_path = Path::parent(m_port_model->path()) +"/"+ n; + + for (list::iterator i = m_control_panels.begin(); i != m_control_panels.end(); ++i) + (*i)->rename_port(m_port_model->path(), new_path); + + Port::set_name(n); + m_port_model->path(new_path); + */ +} +#endif + +} // namespace Ingenuity diff --git a/src/progs/ingenuity/PatchPort.h b/src/progs/ingenuity/PatchPort.h new file mode 100644 index 00000000..1b8eb389 --- /dev/null +++ b/src/progs/ingenuity/PatchPort.h @@ -0,0 +1,59 @@ +/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. + * + * 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 + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef PATCHPORT_H +#define PATCHPORT_H + +#include +#include +#include +#include "util/CountedPtr.h" + +namespace Ingen { namespace Client { class PortModel; } } +using namespace Ingen::Client; +using namespace LibFlowCanvas; +using std::string; using std::list; + +namespace Ingenuity { + +class FlowCanvas; +class PatchWindow; +class PatchPortModule; + + +/** A Port (on a pseudo node) in a patch canvas, to represent a port on that patch. + * + * \ingroup Ingenuity + */ +class PatchPort : public LibFlowCanvas::Port +{ +public: + PatchPort(PatchPortModule* module, CountedPtr pm); + + virtual ~PatchPort() {} + + //void set_name(const string& n); + + CountedPtr model() const { return m_port_model; } + +private: + CountedPtr m_port_model; +}; + + +} // namespace Ingenuity + +#endif // PATCHPORT_H diff --git a/src/progs/ingenuity/PatchPortModule.cpp b/src/progs/ingenuity/PatchPortModule.cpp new file mode 100644 index 00000000..17bc6a2a --- /dev/null +++ b/src/progs/ingenuity/PatchPortModule.cpp @@ -0,0 +1,98 @@ +/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. + * + * 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 + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "PatchPortModule.h" +#include +#include "App.h" +#include "ModelEngineInterface.h" +#include "PatchCanvas.h" +#include "PatchModel.h" +#include "NodeModel.h" +#include "Port.h" +#include "GladeFactory.h" +#include "RenameWindow.h" +#include "PatchWindow.h" +#include "PatchPort.h" + +namespace Ingenuity { + + +PatchPortModule::PatchPortModule(PatchCanvas* canvas, CountedPtr port) +: LibFlowCanvas::Module(canvas, "", 0, 0), // FIXME: coords? + m_port(port), + m_patch_port(NULL) +{ + /*if (port_model()->polyphonic() && port_model()->parent() != NULL + && port_model()->parent_patch()->poly() > 1) { + border_width(2.0); + }*/ + + assert(canvas); + assert(port); + + if (PtrCast(port->parent())) { + if (m_patch_port) + delete m_patch_port; + + m_patch_port = new PatchPort(this, port); + } + + resize(); + + const Atom& x_atom = port->get_metadata("module-x"); + const Atom& y_atom = port->get_metadata("module-y"); + + if (x_atom && y_atom && x_atom.type() == Atom::FLOAT && y_atom.type() == Atom::FLOAT) { + move_to(x_atom.get_float(), y_atom.get_float()); + } else { + double default_x; + double default_y; + canvas->get_new_module_location(default_x, default_y); + move_to(default_x, default_y); + } + + port->metadata_update_sig.connect(sigc::mem_fun(this, &PatchPortModule::metadata_update)); +} + + +void +PatchPortModule::store_location() +{ + const float x = static_cast(property_x()); + const float y = static_cast(property_y()); + + const Atom& existing_x = m_port->get_metadata("module-x"); + const Atom& existing_y = m_port->get_metadata("module-y"); + + if (existing_x.type() != Atom::FLOAT || existing_y.type() != Atom::FLOAT + || existing_x.get_float() != x || existing_y.get_float() != y) { + App::instance().engine()->set_metadata(m_port->path(), "module-x", Atom(x)); + App::instance().engine()->set_metadata(m_port->path(), "module-y", Atom(y)); + } +} + + +void +PatchPortModule::metadata_update(const string& key, const Atom& value) +{ + if (key == "module-x" && value.type() == Atom::FLOAT) + move_to(value.get_float(), property_y()); + else if (key == "module-y" && value.type() == Atom::FLOAT) + move_to(property_x(), value.get_float()); +} + + +} // namespace Ingenuity diff --git a/src/progs/ingenuity/PatchPortModule.h b/src/progs/ingenuity/PatchPortModule.h new file mode 100644 index 00000000..56f259e9 --- /dev/null +++ b/src/progs/ingenuity/PatchPortModule.h @@ -0,0 +1,71 @@ +/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. + * + * 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 + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef OMPORTMODULE_H +#define OMPORTMODULE_H + +#include +#include +#include +#include "util/Atom.h" +#include "PatchPort.h" +using std::string; + +namespace Ingen { namespace Client { + class PortModel; + class NodeModel; + class ControlModel; +} } +using namespace Ingen::Client; + +namespace Ingenuity { + +class PatchCanvas; +class Port; + + +/** A "module" to represent a patch's port on it's own canvas. + * + * Translation: This is the nameless single port pseudo module thingy. + * + * \ingroup Ingenuity + */ +class PatchPortModule : public LibFlowCanvas::Module +{ +public: + PatchPortModule(PatchCanvas* canvas, CountedPtr port); + virtual ~PatchPortModule() {} + + virtual void store_location(); + + //void on_right_click(GdkEventButton* event) { m_port->show_menu(event); } + + CountedPtr port() const { return m_port; } + +protected: + //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 m_port; + PatchPort* m_patch_port; ///< Port on this 'anonymous' module +}; + + +} // namespace Ingenuity + +#endif // OMPORTMODULE_H diff --git a/src/progs/ingenuity/PatchView.cpp b/src/progs/ingenuity/PatchView.cpp index 0ae82f45..e8cf9e5f 100644 --- a/src/progs/ingenuity/PatchView.cpp +++ b/src/progs/ingenuity/PatchView.cpp @@ -20,7 +20,7 @@ #include #include "App.h" #include "ModelEngineInterface.h" -#include "OmFlowCanvas.h" +#include "PatchCanvas.h" #include "LoadPluginWindow.h" #include "PatchModel.h" #include "NewSubpatchWindow.h" @@ -62,7 +62,7 @@ PatchView::set_patch(CountedPtr patch) assert(_breadcrumb_container); // ensure created _patch = patch; - _canvas = new OmFlowCanvas(patch, 1600*2, 1200*2); + _canvas = new PatchCanvas(patch, 1600*2, 1200*2); _canvas_scrolledwindow->add(*_canvas); diff --git a/src/progs/ingenuity/PatchView.h b/src/progs/ingenuity/PatchView.h index a6484b97..d0c9c4c4 100644 --- a/src/progs/ingenuity/PatchView.h +++ b/src/progs/ingenuity/PatchView.h @@ -36,7 +36,7 @@ using namespace Ingen::Client; namespace Ingenuity { -class OmFlowCanvas; +class PatchCanvas; class LoadPluginWindow; class NewSubpatchWindow; class LoadSubpatchWindow; @@ -57,7 +57,7 @@ public: PatchView(BaseObjectType* cobject, const Glib::RefPtr& glade_xml); ~PatchView(); - OmFlowCanvas* canvas() const { return _canvas; } + PatchCanvas* canvas() const { return _canvas; } CountedPtr patch() const { return _patch; } Gtk::Viewport* breadcrumb_container() const { return _breadcrumb_container; } @@ -75,7 +75,7 @@ private: void zoom_full(); CountedPtr _patch; - OmFlowCanvas* _canvas; + PatchCanvas* _canvas; Gtk::ScrolledWindow* _canvas_scrolledwindow; diff --git a/src/progs/ingenuity/PatchWindow.cpp b/src/progs/ingenuity/PatchWindow.cpp index d3bfd14b..edf2e9d0 100644 --- a/src/progs/ingenuity/PatchWindow.cpp +++ b/src/progs/ingenuity/PatchWindow.cpp @@ -20,7 +20,7 @@ #include #include "App.h" #include "ModelEngineInterface.h" -#include "OmFlowCanvas.h" +#include "PatchCanvas.h" #include "LoadPluginWindow.h" #include "PatchModel.h" #include "NewSubpatchWindow.h" diff --git a/src/progs/ingenuity/PatchWindow.h b/src/progs/ingenuity/PatchWindow.h index 79284cb5..0ab5fe48 100644 --- a/src/progs/ingenuity/PatchWindow.h +++ b/src/progs/ingenuity/PatchWindow.h @@ -42,7 +42,7 @@ using namespace Ingen::Client; namespace Ingenuity { -class OmFlowCanvas; +class PatchCanvas; class LoadPluginWindow; class LoadPatchWindow; class NewSubpatchWindow; diff --git a/src/progs/ingenuity/Port.cpp b/src/progs/ingenuity/Port.cpp new file mode 100644 index 00000000..e6f70e16 --- /dev/null +++ b/src/progs/ingenuity/Port.cpp @@ -0,0 +1,40 @@ +/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. + * + * 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 + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "Port.h" +#include +#include +#include "PortModel.h" +#include "NodeModule.h" +#include "ControlModel.h" +#include "Configuration.h" +#include "App.h" +using std::cerr; using std::endl; + +using namespace Ingen::Client; + +namespace Ingenuity { + +Port::Port(NodeModule* module, CountedPtr pm) +: LibFlowCanvas::Port(module, pm->path().name(), pm->is_input(), App::instance().configuration()->get_port_color(pm.get())), + m_port_model(pm) +{ + assert(module); + assert(m_port_model); +} + + +} // namespace Ingenuity diff --git a/src/progs/ingenuity/Port.h b/src/progs/ingenuity/Port.h new file mode 100644 index 00000000..16edd71a --- /dev/null +++ b/src/progs/ingenuity/Port.h @@ -0,0 +1,53 @@ +/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. + * + * 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 + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef PORT_H +#define PORT_H + +#include +#include +#include +#include "util/CountedPtr.h" + +namespace Ingen { namespace Client { class PortModel; } } +using Ingen::Client::PortModel; + +namespace Ingenuity { + +class NodeModule; + + +/** A Port on an Module. + * + * \ingroup Ingenuity + */ +class Port : public LibFlowCanvas::Port +{ +public: + Port(NodeModule* module, CountedPtr pm); + + virtual ~Port() {} + + CountedPtr model() const { return m_port_model; } + +private: + CountedPtr m_port_model; +}; + + +} // namespace Ingenuity + +#endif // PORT_H diff --git a/src/progs/ingenuity/SubpatchModule.cpp b/src/progs/ingenuity/SubpatchModule.cpp index 47465b09..585ccee3 100644 --- a/src/progs/ingenuity/SubpatchModule.cpp +++ b/src/progs/ingenuity/SubpatchModule.cpp @@ -19,20 +19,20 @@ #include #include "App.h" #include "ModelEngineInterface.h" -#include "OmModule.h" +#include "NodeModule.h" #include "NodeControlWindow.h" #include "PatchModel.h" #include "PatchWindow.h" -#include "OmFlowCanvas.h" -#include "OmPort.h" +#include "PatchCanvas.h" +#include "Port.h" #include "WindowFactory.h" using std::cerr; using std::cout; using std::endl; namespace Ingenuity { -SubpatchModule::SubpatchModule(OmFlowCanvas* canvas, CountedPtr patch) -: OmModule(canvas, patch), +SubpatchModule::SubpatchModule(PatchCanvas* canvas, CountedPtr patch) +: NodeModule(canvas, patch), m_patch(patch) { assert(canvas); diff --git a/src/progs/ingenuity/SubpatchModule.h b/src/progs/ingenuity/SubpatchModule.h index 0f52ae2b..571ae0fd 100644 --- a/src/progs/ingenuity/SubpatchModule.h +++ b/src/progs/ingenuity/SubpatchModule.h @@ -20,9 +20,10 @@ #include #include -#include "OmModule.h" +#include "NodeModule.h" #include "util/CountedPtr.h" #include "PatchModel.h" +#include "PatchPortModule.h" using std::string; using std::list; namespace Ingen { namespace Client { @@ -35,7 +36,7 @@ using namespace Ingen::Client; namespace Ingenuity { -class OmFlowCanvas; +class PatchCanvas; class NodeControlWindow; @@ -43,10 +44,10 @@ class NodeControlWindow; * * \ingroup Ingenuity */ -class SubpatchModule : public OmModule +class SubpatchModule : public NodeModule { public: - SubpatchModule(OmFlowCanvas* canvas, CountedPtr controller); + SubpatchModule(PatchCanvas* canvas, CountedPtr controller); virtual ~SubpatchModule() {} void on_double_click(GdkEventButton* ev); -- cgit v1.2.1