From f02ac2f82a0342c3e548a81950734b4bce383b7d Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 29 Jan 2010 07:58:13 +0000 Subject: Improved/quicker/easier handling of control port ranges. * Add "Set minimum to current value", "Set maximum to current value", and "Reset range" to control port context menu. * Only serialise properties (e.g. lv2:minimum) if they differ from the meta object's (prototype's, e.g. plugin) value. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2395 a436a847-0d15-0410-975c-d299462d15a1 --- src/gui/PortMenu.cpp | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) (limited to 'src/gui/PortMenu.cpp') diff --git a/src/gui/PortMenu.cpp b/src/gui/PortMenu.cpp index 3cb8c071..4a6ce582 100644 --- a/src/gui/PortMenu.cpp +++ b/src/gui/PortMenu.cpp @@ -32,6 +32,10 @@ PortMenu::PortMenu(BaseObjectType* cobject, const Glib::RefPtrget_widget("port_menu", _port_menu); + xml->get_widget("port_set_min_menuitem", _set_min_menuitem); + xml->get_widget("port_set_max_menuitem", _set_max_menuitem); + xml->get_widget("port_reset_range_menuitem", _reset_range_menuitem); } @@ -41,6 +45,15 @@ PortMenu::init(SharedPtr port, bool patch_port) ObjectMenu::init(port); _patch_port = patch_port; + _set_min_menuitem->signal_activate().connect(sigc::mem_fun(this, + &PortMenu::on_menu_set_min)); + + _set_max_menuitem->signal_activate().connect(sigc::mem_fun(this, + &PortMenu::on_menu_set_max)); + + _reset_range_menuitem->signal_activate().connect(sigc::mem_fun(this, + &PortMenu::on_menu_reset_range)); + if ( ! PtrCast(port->parent()) ) { _polyphonic_menuitem->set_sensitive(false); _rename_menuitem->hide(); @@ -50,9 +63,21 @@ PortMenu::init(SharedPtr port, bool patch_port) if (port->type() == PortType::EVENTS) _polyphonic_menuitem->hide(); - if (port->type() == PortType::CONTROL) + if (port->type() == PortType::CONTROL) { _learn_menuitem->show(); + items().push_front(Gtk::Menu_Helpers::SeparatorElem()); + + _port_menu->remove(*_reset_range_menuitem); + insert(*_reset_range_menuitem, 0); + + _port_menu->remove(*_set_max_menuitem); + insert(*_set_max_menuitem, 0); + + _port_menu->remove(*_set_min_menuitem); + insert(*_set_min_menuitem, 0); + } + _enable_signal = true; } @@ -70,6 +95,44 @@ PortMenu::on_menu_disconnect() } +void +PortMenu::on_menu_set_min() +{ + SharedPtr model = PtrCast(_object); + const Raul::Atom& value = model->get_property("ingen:value"); + std::cout << model->path() << " SET MIN " << value << std::endl; + if (value.is_valid()) + App::instance().engine()->set_property(_object->path(), "lv2:minimum", value); +} + + +void +PortMenu::on_menu_set_max() +{ + SharedPtr model = PtrCast(_object); + const Raul::Atom& value = model->get_property("ingen:value"); + if (value.is_valid()) + App::instance().engine()->set_property(_object->path(), "lv2:maximum", value); +} + + +void +PortMenu::on_menu_reset_range() +{ + SharedPtr model = PtrCast(_object); + SharedPtr parent = PtrCast(_object->parent()); + + float min, max; + parent->default_port_value_range(model, min, max); + + if (!isnan(min)) + App::instance().engine()->set_property(_object->path(), "lv2:minimum", min); + + if (!isnan(max)) + App::instance().engine()->set_property(_object->path(), "lv2:maximum", max); +} + + } // namespace GUI } // namespace Ingen -- cgit v1.2.1