From a96166710faf2447ed10194d1829db5564b0dff9 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 4 May 2007 03:59:38 +0000 Subject: Made engine, serialisation, client library, and GUI all dynamically loaded modules. Combined all executables into a single "ingen" program which can do everything. git-svn-id: http://svn.drobilla.net/lad/ingen@493 a436a847-0d15-0410-975c-d299462d15a1 --- src/progs/ingenuity/NodeModule.cpp | 151 ------------------------------------- 1 file changed, 151 deletions(-) delete mode 100644 src/progs/ingenuity/NodeModule.cpp (limited to 'src/progs/ingenuity/NodeModule.cpp') diff --git a/src/progs/ingenuity/NodeModule.cpp b/src/progs/ingenuity/NodeModule.cpp deleted file mode 100644 index dd03fde8..00000000 --- a/src/progs/ingenuity/NodeModule.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/* This file is part of Ingen. - * Copyright (C) 2007 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 -#include -#include "interface/EngineInterface.h" -#include "client/PatchModel.h" -#include "client/NodeModel.h" -#include "App.h" -#include "NodeModule.h" -#include "PatchCanvas.h" -#include "Port.h" -#include "GladeFactory.h" -#include "RenameWindow.h" -#include "PatchWindow.h" -#include "WindowFactory.h" -#include "SubpatchModule.h" -#include "NodeControlWindow.h" - -namespace Ingenuity { - - -NodeModule::NodeModule(boost::shared_ptr canvas, SharedPtr node) -: LibFlowCanvas::Module(canvas, node->path().name()), - _node(node), - _menu(node) -{ - assert(_node); - - if (node->polyphonic()) { - set_border_width(2.0); - } - - 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)); - - signal_clicked.connect(sigc::mem_fun(this, &NodeModule::on_click)); -} - - -NodeModule::~NodeModule() -{ - NodeControlWindow* win = App::instance().window_factory()->control_window(_node); - - if (win) { - // Should remove from window factory via signal - delete win; - } -} - - -boost::shared_ptr -NodeModule::create(boost::shared_ptr canvas, SharedPtr node) -{ - boost::shared_ptr ret; - - SharedPtr patch = PtrCast(node); - if (patch) - ret = boost::shared_ptr(new SubpatchModule(canvas, patch)); - else - ret = boost::shared_ptr(new NodeModule(canvas, node)); - - for (MetadataMap::const_iterator m = node->metadata().begin(); m != node->metadata().end(); ++m) - ret->metadata_update(m->first, m->second); - - for (PortModelList::const_iterator p = node->ports().begin(); p != node->ports().end(); ++p) - ret->add_port(*p, false); - - ret->resize(); - - return ret; -} - - -void -NodeModule::add_port(SharedPtr port, bool resize_to_fit) -{ - Module::add_port(boost::shared_ptr(new Port( - PtrCast(shared_from_this()), port))); - - if (resize_to_fit) - resize(); -} - - -void -NodeModule::remove_port(SharedPtr port) -{ - SharedPtr p = Module::remove_port(port->path().name()); - p.reset(); -} - - -void -NodeModule::show_control_window() -{ - App::instance().window_factory()->present_controls(_node); -} - - -void -NodeModule::store_location() -{ - const float x = static_cast(property_x()); - const float y = static_cast(property_y()); - - const Atom& existing_x = _node->get_metadata("ingenuity:canvas-x"); - const Atom& existing_y = _node->get_metadata("ingenuity:canvas-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(_node->path(), "ingenuity:canvas-x", Atom(x)); - App::instance().engine()->set_metadata(_node->path(), "ingenuity:canvas-y", Atom(y)); - } -} - - -void -NodeModule::on_click(GdkEventButton* event) -{ - if (event->button == 3) - _menu.popup(event->button, event->time); -} - - -void -NodeModule::metadata_update(const string& key, const Atom& value) -{ - if (key == "ingenuity:canvas-x" && value.type() == Atom::FLOAT) - move_to(value.get_float(), property_y()); - else if (key == "ingenuity:canvas-y" && value.type() == Atom::FLOAT) - move_to(property_x(), value.get_float()); -} - - -} // namespace Ingenuity -- cgit v1.2.1