diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/NodeModel.cpp | 27 | ||||
-rw-r--r-- | src/client/NodeModel.hpp | 2 | ||||
-rw-r--r-- | src/gui/Controls.cpp | 14 | ||||
-rw-r--r-- | src/gui/Controls.hpp | 2 |
4 files changed, 37 insertions, 8 deletions
diff --git a/src/client/NodeModel.cpp b/src/client/NodeModel.cpp index 2ffd751d..1ff3cae6 100644 --- a/src/client/NodeModel.cpp +++ b/src/client/NodeModel.cpp @@ -221,6 +221,33 @@ NodeModel::port_value_range(SharedPtr<PortModel> port, float& min, float& max) c } +std::string +NodeModel::port_label(SharedPtr<PortModel> port) const +{ + const Raul::Atom& name = port->get_property("http://lv2plug.in/ns/lv2core#name"); + if (name.is_valid()) { + return name.get_string(); + } + +#ifdef HAVE_SLV2 + if (_plugin && _plugin->type() == PluginModel::LV2) { + SLV2World c_world = _plugin->slv2_world(); + SLV2Plugin c_plugin = _plugin->slv2_plugin(); + SLV2Value c_sym = slv2_value_new_string(c_world, port->symbol().c_str()); + SLV2Port c_port = slv2_plugin_get_port_by_symbol(c_plugin, c_sym); + if (c_port) { + SLV2Value c_name = slv2_port_get_name(c_plugin, c_port); + if (c_name && slv2_value_is_string(c_name)) { + return slv2_value_as_string(c_name); + } + } + } +#endif + + return port->symbol().c_str(); +} + + void NodeModel::set(SharedPtr<ObjectModel> model) { diff --git a/src/client/NodeModel.hpp b/src/client/NodeModel.hpp index fa4af66c..939197b1 100644 --- a/src/client/NodeModel.hpp +++ b/src/client/NodeModel.hpp @@ -67,6 +67,8 @@ public: void default_port_value_range(SharedPtr<PortModel> port, float& min, float& max) const; void port_value_range(SharedPtr<PortModel> port, float& min, float& max) const; + std::string port_label(SharedPtr<PortModel> port) const; + // Signals sigc::signal<void, SharedPtr<PortModel> > signal_new_port; sigc::signal<void, SharedPtr<PortModel> > signal_removed_port; diff --git a/src/gui/Controls.cpp b/src/gui/Controls.cpp index 0d99b0dc..1a443ec7 100644 --- a/src/gui/Controls.cpp +++ b/src/gui/Controls.cpp @@ -73,6 +73,12 @@ Control::init(ControlPanel* panel, SharedPtr<PortModel> pm) _control_connection.disconnect(); _control_connection = pm->signal_value_changed.connect(sigc::mem_fun(this, &Control::set_value)); + + boost::shared_ptr<NodeModel> parent = PtrCast<NodeModel>(_port_model->parent()); + if (parent) + set_label(parent->port_label(pm)); + else + set_label(pm->symbol().c_str()); } @@ -95,7 +101,7 @@ Control::disable() void -Control::set_name(const string& name) +Control::set_label(const string& name) { const string name_markup = string("<span weight=\"bold\">") + name + "</span>"; _name_label->set_markup(name_markup); @@ -137,8 +143,6 @@ SliderControl::init(ControlPanel* panel, SharedPtr<PortModel> pm) assert(_name_label); assert(_slider); - set_name(pm->path().symbol()); - _slider->set_draw_value(false); signal_button_press_event().connect(sigc::mem_fun(*this, &SliderControl::clicked)); @@ -320,8 +324,6 @@ ToggleControl::init(ControlPanel* panel, SharedPtr<PortModel> pm) assert(_name_label); assert(_checkbutton); - set_name(pm->path().symbol()); - _checkbutton->signal_toggled().connect(sigc::mem_fun(*this, &ToggleControl::toggled)); set_value(pm->value()); @@ -385,8 +387,6 @@ StringControl::init(ControlPanel* panel, SharedPtr<PortModel> pm) assert(_name_label); assert(_entry); - set_name(pm->path().symbol()); - _entry->signal_activate().connect(sigc::mem_fun(*this, &StringControl::activated)); set_value(pm->value()); diff --git a/src/gui/Controls.hpp b/src/gui/Controls.hpp index a26dfd41..1818cc75 100644 --- a/src/gui/Controls.hpp +++ b/src/gui/Controls.hpp @@ -54,7 +54,7 @@ protected: virtual void set_value(const Raul::Atom& value) = 0; virtual void set_range(float min, float max) {} - void set_name(const std::string& name); + void set_label(const std::string& name); void menu_properties(); ControlPanel* _control_panel; |