From 698c38587bd4f0133a132dc363098ff8298ec47b Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 11 May 2009 18:05:24 +0000 Subject: * New ontology. * Display human names on patch ports on creation, if enabled. * Fix copy/paste of subpatches. * Split properties into "properties" (class properties) and "variables" (instance properties). * Names are kind of a legacy leftover... * Remove special set poly / enable / etc events in favour of just setting properties (less API, extensible, RDF compatible). git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1973 a436a847-0d15-0410-975c-d299462d15a1 --- src/gui/PatchPortModule.cpp | 96 ++++++++++++++++++++++++++++++--------------- 1 file changed, 65 insertions(+), 31 deletions(-) (limited to 'src/gui/PatchPortModule.cpp') diff --git a/src/gui/PatchPortModule.cpp b/src/gui/PatchPortModule.cpp index ff482fb7..200ce12f 100644 --- a/src/gui/PatchPortModule.cpp +++ b/src/gui/PatchPortModule.cpp @@ -16,6 +16,7 @@ */ #include +#include #include "PatchPortModule.hpp" #include "interface/EngineInterface.hpp" #include "client/PatchModel.hpp" @@ -33,40 +34,45 @@ namespace Ingen { namespace GUI { -PatchPortModule::PatchPortModule(boost::shared_ptr canvas, SharedPtr port) - : FlowCanvas::Module(canvas, port->path().name(), 0, 0, false) // FIXME: coords? - , _port(port) +PatchPortModule::PatchPortModule(boost::shared_ptr canvas, SharedPtr model) + : FlowCanvas::Module(canvas, model->path().name(), 0, 0, false) // FIXME: coords? + , _model(model) + , _human_name_visible(false) { assert(canvas); - assert(port); + assert(model); - assert(PtrCast(port->parent())); + assert(PtrCast(model->parent())); - set_stacked_border(port->polyphonic()); + set_stacked_border(model->polyphonic()); - port->signal_variable.connect(sigc::mem_fun(this, &PatchPortModule::set_variable)); - port->signal_property.connect(sigc::mem_fun(this, &PatchPortModule::set_property)); + model->signal_variable.connect(sigc::mem_fun(this, &PatchPortModule::set_variable)); + model->signal_property.connect(sigc::mem_fun(this, &PatchPortModule::set_property)); } boost::shared_ptr -PatchPortModule::create(boost::shared_ptr canvas, SharedPtr port) +PatchPortModule::create(boost::shared_ptr canvas, SharedPtr model, bool human) { - boost::shared_ptr ret = boost::shared_ptr( - new PatchPortModule(canvas, port)); - assert(ret); + boost::shared_ptr ret(new PatchPortModule(canvas, model)); + boost::shared_ptr port(new Port(ret, model, model->symbol(), true)); - boost::shared_ptr view(new Port(ret, port, port->symbol(), true)); - ret->add_port(view); - ret->set_menu(view->menu()); + ret->add_port(port); + ret->set_port(port); + ret->set_menu(port->menu()); - for (GraphObject::Variables::const_iterator m = port->variables().begin(); m != port->variables().end(); ++m) + for (GraphObject::Properties::const_iterator m = model->variables().begin(); + m != model->variables().end(); ++m) ret->set_variable(m->first, m->second); - for (GraphObject::Properties::const_iterator m = port->properties().begin(); m != port->properties().end(); ++m) + for (GraphObject::Properties::const_iterator m = model->properties().begin(); + m != model->properties().end(); ++m) ret->set_property(m->first, m->second); - - ret->resize(); + + if (human) + ret->show_human_names(human); + else + ret->resize(); return ret; } @@ -77,7 +83,7 @@ PatchPortModule::create_menu() { Glib::RefPtr xml = GladeFactory::new_glade_reference(); xml->get_widget_derived("object_menu", _menu); - _menu->init(_port, true); + _menu->init(_model, true); set_menu(_menu); } @@ -89,29 +95,42 @@ PatchPortModule::store_location() const float x = static_cast(property_x()); const float y = static_cast(property_y()); - const Atom& existing_x = _port->get_variable("ingenuity:canvas-x"); - const Atom& existing_y = _port->get_variable("ingenuity:canvas-y"); + const Atom& existing_x = _model->get_property("ingenuity:canvas-x"); + const Atom& existing_y = _model->get_property("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_variable(_port->path(), "ingenuity:canvas-x", Atom(x)); - App::instance().engine()->set_variable(_port->path(), "ingenuity:canvas-y", Atom(y)); + App::instance().engine()->set_property(_model->path(), "ingenuity:canvas-x", Atom(x)); + App::instance().engine()->set_property(_model->path(), "ingenuity:canvas-y", Atom(y)); } } void -PatchPortModule::set_variable(const string& key, const Atom& value) +PatchPortModule::show_human_names(bool b) { - 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()); + using namespace std; + _human_name_visible = b; + const Atom& name = _model->get_property("lv2:name"); + if (b && name.is_valid()) + set_name(name.get_string()); + else + set_name(_model->symbol()); + + resize(); } void -PatchPortModule::set_property(const string& key, const Atom& value) +PatchPortModule::set_name(const std::string& n) +{ + _port->set_name(n); + Module::resize(); +} + + +void +PatchPortModule::set_variable(const string& key, const Atom& value) { if (key == "ingen:polyphonic" && value.type() == Atom::BOOL) { set_stacked_border(value.get_bool()); @@ -126,13 +145,28 @@ PatchPortModule::set_property(const string& key, const Atom& value) } +void +PatchPortModule::set_property(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()); + } else if (key == "lv2:name" && value.type() == Atom::STRING && _human_name_visible) { + set_name(value.get_string()); + } else if (key == "lv2:symbol" && value.type() == Atom::STRING && !_human_name_visible) { + set_name(value.get_string()); + } +} + + void PatchPortModule::set_selected(bool b) { if (b != selected()) { Module::set_selected(b); if (App::instance().signal()) - App::instance().engine()->set_property(_port->path(), "ingen:selected", b); + App::instance().engine()->set_variable(_model->path(), "ingen:selected", b); } } -- cgit v1.2.1