diff options
Diffstat (limited to 'src/gui/PatchPortModule.cpp')
-rw-r--r-- | src/gui/PatchPortModule.cpp | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/src/gui/PatchPortModule.cpp b/src/gui/PatchPortModule.cpp index 6981f2ef..b1a71cf2 100644 --- a/src/gui/PatchPortModule.cpp +++ b/src/gui/PatchPortModule.cpp @@ -19,6 +19,7 @@ #include <utility> #include "PatchPortModule.hpp" #include "interface/EngineInterface.hpp" +#include "shared/LV2URIMap.hpp" #include "client/PatchModel.hpp" #include "client/NodeModel.hpp" #include "App.hpp" @@ -38,7 +39,7 @@ namespace GUI { PatchPortModule::PatchPortModule(boost::shared_ptr<PatchCanvas> canvas, SharedPtr<PortModel> model) - : FlowCanvas::Module(canvas, model->path().name(), 0, 0, false) // FIXME: coords? + : FlowCanvas::Module(canvas, "", 0, 0, false) // FIXME: coords? , _model(model) , _human_name_visible(false) { @@ -57,7 +58,7 @@ boost::shared_ptr<PatchPortModule> PatchPortModule::create(boost::shared_ptr<PatchCanvas> canvas, SharedPtr<PortModel> model, bool human) { boost::shared_ptr<PatchPortModule> ret(new PatchPortModule(canvas, model)); - boost::shared_ptr<Port> port(new Port(ret, model, model->symbol(), true)); + boost::shared_ptr<Port> port(Port::create(ret, model, human, true)); ret->add_port(port); ret->set_port(port); @@ -71,11 +72,7 @@ PatchPortModule::create(boost::shared_ptr<PatchCanvas> canvas, SharedPtr<PortMod m != model->properties().end(); ++m) ret->set_property(m->first, m->second); - if (human) - ret->show_human_names(human); - else - ret->resize(); - + ret->resize(); return ret; } @@ -97,14 +94,16 @@ PatchPortModule::store_location() const float x = static_cast<float>(property_x()); const float y = static_cast<float>(property_y()); - const Atom& existing_x = _model->get_property("ingenui:canvas-x"); - const Atom& existing_y = _model->get_property("ingenui:canvas-y"); + const LV2URIMap& uris = App::instance().uris(); + + const Atom& existing_x = _model->get_property(uris.ingenui_canvas_x); + const Atom& existing_y = _model->get_property(uris.ingenui_canvas_y); if (existing_x.type() != Atom::FLOAT || existing_y.type() != Atom::FLOAT || existing_x.get_float() != x || existing_y.get_float() != y) { Shared::Resource::Properties props; - props.insert(make_pair("ingenui:canvas-x", Atom(x))); - props.insert(make_pair("ingenui:canvas-y", Atom(y))); + props.insert(make_pair(uris.ingenui_canvas_x, Atom(x))); + props.insert(make_pair(uris.ingenui_canvas_y, Atom(y))); App::instance().engine()->put(_model->meta_uri(), props); } } @@ -113,13 +112,14 @@ PatchPortModule::store_location() void PatchPortModule::show_human_names(bool b) { + const LV2URIMap& uris = App::instance().uris(); using namespace std; _human_name_visible = b; - const Atom& name = _model->get_property("lv2:name"); - if (b && name.is_valid()) + const Atom& name = _model->get_property(uris.lv2_name); + if (b && name.type() == Atom::STRING) set_name(name.get_string()); else - set_name(_model->symbol()); + set_name(_model->symbol().c_str()); resize(); } @@ -136,24 +136,25 @@ PatchPortModule::set_name(const std::string& n) void PatchPortModule::set_property(const URI& key, const Atom& value) { + const LV2URIMap& uris = App::instance().uris(); switch (value.type()) { case Atom::FLOAT: - if (key.str() == "ingenui:canvas-x") { + if (key == uris.ingenui_canvas_x) { move_to(value.get_float(), property_y()); - } else if (key.str() == "ingenui:canvas-y") { + } else if (key == uris.ingenui_canvas_y) { move_to(property_x(), value.get_float()); } break; case Atom::STRING: - if (key.str() == "lv2:name" && _human_name_visible) { + if (key == uris.lv2_name && _human_name_visible) { set_name(value.get_string()); - } else if (key.str() == "lv2:symbol" && !_human_name_visible) { + } else if (key == uris.lv2_symbol && !_human_name_visible) { set_name(value.get_string()); } case Atom::BOOL: - if (key.str() == "ingen:polyphonic") { + if (key == uris.ingen_polyphonic) { set_stacked_border(value.get_bool()); - } else if (key.str() == "ingen:selected") { + } else if (key == uris.ingen_selected) { if (value.get_bool() != selected()) { if (value.get_bool()) { _canvas.lock()->select_item(shared_from_this()); @@ -173,7 +174,8 @@ PatchPortModule::set_selected(bool b) if (b != selected()) { Module::set_selected(b); if (App::instance().signal()) - App::instance().engine()->set_property(_model->path(), "ingen:selected", b); + App::instance().engine()->set_property(_model->path(), + App::instance().uris().ingen_selected, b); } } |