diff options
author | David Robillard <d@drobilla.net> | 2010-01-29 07:58:13 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2010-01-29 07:58:13 +0000 |
commit | f02ac2f82a0342c3e548a81950734b4bce383b7d (patch) | |
tree | 06a51f5be2d41bdd8a52f1a6f8888f5f4d3db5f5 /src/gui | |
parent | 96613df7830699dbbfb5c2d9fe3ebdb0598e6aca (diff) | |
download | ingen-f02ac2f82a0342c3e548a81950734b4bce383b7d.tar.gz ingen-f02ac2f82a0342c3e548a81950734b4bce383b7d.tar.bz2 ingen-f02ac2f82a0342c3e548a81950734b4bce383b7d.zip |
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
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/LoadPluginWindow.cpp | 4 | ||||
-rw-r--r-- | src/gui/LoadSubpatchWindow.cpp | 4 | ||||
-rw-r--r-- | src/gui/NodeMenu.cpp | 17 | ||||
-rw-r--r-- | src/gui/NodeModule.cpp | 12 | ||||
-rw-r--r-- | src/gui/PatchCanvas.cpp | 8 | ||||
-rw-r--r-- | src/gui/PatchPortModule.cpp | 12 | ||||
-rw-r--r-- | src/gui/PortMenu.cpp | 65 | ||||
-rw-r--r-- | src/gui/PortMenu.hpp | 8 | ||||
-rw-r--r-- | src/gui/PropertiesWindow.cpp | 8 | ||||
-rw-r--r-- | src/gui/PropertiesWindow.hpp | 3 | ||||
-rw-r--r-- | src/gui/ingen_gui.glade | 26 |
11 files changed, 132 insertions, 35 deletions
diff --git a/src/gui/LoadPluginWindow.cpp b/src/gui/LoadPluginWindow.cpp index 07605f3c..a72277b3 100644 --- a/src/gui/LoadPluginWindow.cpp +++ b/src/gui/LoadPluginWindow.cpp @@ -350,9 +350,9 @@ LoadPluginWindow::load_plugin(const Gtk::TreeModel::iterator& iter) _node_name_entry->set_text(generate_module_name(plugin, _plugin_name_offset + 1)); // Cascade next node - Atom& x = _initial_data.find("ingen-ui:canvas-x")->second; + Atom& x = _initial_data.find("ingenui:canvas-x")->second; x = Atom(x.get_float() + 20.0f); - Atom& y = _initial_data.find("ingen-ui:canvas-y")->second; + Atom& y = _initial_data.find("ingenui:canvas-y")->second; y = Atom(y.get_float() + 20.0f); } } diff --git a/src/gui/LoadSubpatchWindow.cpp b/src/gui/LoadSubpatchWindow.cpp index b2066ff6..e580fa49 100644 --- a/src/gui/LoadSubpatchWindow.cpp +++ b/src/gui/LoadSubpatchWindow.cpp @@ -165,9 +165,9 @@ LoadSubpatchWindow::ok_clicked() std::list<Glib::ustring> uris = get_uris(); for (std::list<Glib::ustring>::iterator i = uris.begin(); i != uris.end(); ++i) { // Cascade - Atom& x = _initial_data.find("ingen-ui:canvas-x")->second; + Atom& x = _initial_data.find("ingenui:canvas-x")->second; x = Atom(x.get_float() + 20.0f); - Atom& y = _initial_data.find("ingen-ui:canvas-y")->second; + Atom& y = _initial_data.find("ingenui:canvas-y")->second; y = Atom(y.get_float() + 20.0f); App::instance().loader()->load_patch(false, *i, Path("/"), diff --git a/src/gui/NodeMenu.cpp b/src/gui/NodeMenu.cpp index f676ed79..887ef06a 100644 --- a/src/gui/NodeMenu.cpp +++ b/src/gui/NodeMenu.cpp @@ -42,16 +42,19 @@ NodeMenu::NodeMenu(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml xml->get_widget("node_embed_gui_menuitem", _embed_gui_menuitem); xml->get_widget("node_randomize_menuitem", _randomize_menuitem); - node_menu->remove(*_controls_menuitem); - node_menu->remove(*_popup_gui_menuitem); - node_menu->remove(*_embed_gui_menuitem); - node_menu->remove(*_randomize_menuitem); + items().push_front(Gtk::Menu_Helpers::SeparatorElem()); + node_menu->remove(*_randomize_menuitem); insert(*_randomize_menuitem, 0); - items().push_front(Gtk::Menu_Helpers::SeparatorElem()); - insert(*_controls_menuitem, 0); - insert(*_popup_gui_menuitem, 0); + + node_menu->remove(*_embed_gui_menuitem); insert(*_embed_gui_menuitem, 0); + + node_menu->remove(*_popup_gui_menuitem); + insert(*_popup_gui_menuitem, 0); + + node_menu->remove(*_controls_menuitem); + insert(*_controls_menuitem, 0); } diff --git a/src/gui/NodeModule.cpp b/src/gui/NodeModule.cpp index 69b8eb55..d9680237 100644 --- a/src/gui/NodeModule.cpp +++ b/src/gui/NodeModule.cpp @@ -379,14 +379,14 @@ NodeModule::store_location() const float x = static_cast<float>(property_x()); const float y = static_cast<float>(property_y()); - const Atom& existing_x = _node->get_property("ingen-ui:canvas-x"); - const Atom& existing_y = _node->get_property("ingen-ui:canvas-y"); + const Atom& existing_x = _node->get_property("ingenui:canvas-x"); + const Atom& existing_y = _node->get_property("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("ingen-ui:canvas-x", Atom(x))); - props.insert(make_pair("ingen-ui:canvas-y", Atom(y))); + props.insert(make_pair("ingenui:canvas-x", Atom(x))); + props.insert(make_pair("ingenui:canvas-y", Atom(y))); App::instance().engine()->put(_node->path(), props); } } @@ -397,9 +397,9 @@ NodeModule::set_property(const URI& key, const Atom& value) { switch (value.type()) { case Atom::FLOAT: - if (key.str() == "ingen-ui:canvas-x") { + if (key.str() == "ingenui:canvas-x") { move_to(value.get_float(), property_y()); - } else if (key.str() == "ingen-ui:canvas-y") { + } else if (key.str() == "ingenui:canvas-y") { move_to(property_x(), value.get_float()); } break; diff --git a/src/gui/PatchCanvas.cpp b/src/gui/PatchCanvas.cpp index c56c965a..6e7374d0 100644 --- a/src/gui/PatchCanvas.cpp +++ b/src/gui/PatchCanvas.cpp @@ -685,10 +685,10 @@ PatchCanvas::paste() for (Store::iterator i = clipboard.begin(); i != clipboard.end(); ++i) { if (_patch->path().is_root() && i->first.is_root()) continue; - GraphObject::Properties::iterator x = i->second->properties().find("ingen-ui:canvas-x"); + GraphObject::Properties::iterator x = i->second->properties().find("ingenui:canvas-x"); if (x != i->second->properties().end()) x->second = x->second.get_float() + (20.0f * _paste_count); - GraphObject::Properties::iterator y = i->second->properties().find("ingen-ui:canvas-y"); + GraphObject::Properties::iterator y = i->second->properties().find("ingenui:canvas-y"); if (y != i->second->properties().end()) y->second = y->second.get_float() + (20.0f * _paste_count); if (i->first.parent().is_root()) { @@ -794,8 +794,8 @@ GraphObject::Properties PatchCanvas::get_initial_data() { GraphObject::Properties result; - result.insert(make_pair("ingen-ui:canvas-x", Atom((float)_last_click_x))); - result.insert(make_pair("ingen-ui:canvas-y", Atom((float)_last_click_y))); + result.insert(make_pair("ingenui:canvas-x", Atom((float)_last_click_x))); + result.insert(make_pair("ingenui:canvas-y", Atom((float)_last_click_y))); return result; } diff --git a/src/gui/PatchPortModule.cpp b/src/gui/PatchPortModule.cpp index 236a6250..6981f2ef 100644 --- a/src/gui/PatchPortModule.cpp +++ b/src/gui/PatchPortModule.cpp @@ -97,14 +97,14 @@ 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("ingen-ui:canvas-x"); - const Atom& existing_y = _model->get_property("ingen-ui:canvas-y"); + const Atom& existing_x = _model->get_property("ingenui:canvas-x"); + const Atom& existing_y = _model->get_property("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("ingen-ui:canvas-x", Atom(x))); - props.insert(make_pair("ingen-ui:canvas-y", Atom(y))); + props.insert(make_pair("ingenui:canvas-x", Atom(x))); + props.insert(make_pair("ingenui:canvas-y", Atom(y))); App::instance().engine()->put(_model->meta_uri(), props); } } @@ -138,9 +138,9 @@ PatchPortModule::set_property(const URI& key, const Atom& value) { switch (value.type()) { case Atom::FLOAT: - if (key.str() == "ingen-ui:canvas-x") { + if (key.str() == "ingenui:canvas-x") { move_to(value.get_float(), property_y()); - } else if (key.str() == "ingen-ui:canvas-y") { + } else if (key.str() == "ingenui:canvas-y") { move_to(property_x(), value.get_float()); } break; 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::RefPtr<Gnome::Glade::Xml : ObjectMenu(cobject, xml) , _patch_port(NULL) { + xml->get_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<PortModel> 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<PatchModel>(port->parent()) ) { _polyphonic_menuitem->set_sensitive(false); _rename_menuitem->hide(); @@ -50,9 +63,21 @@ PortMenu::init(SharedPtr<PortModel> 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<PortModel> model = PtrCast<PortModel>(_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<PortModel> model = PtrCast<PortModel>(_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<PortModel> model = PtrCast<PortModel>(_object); + SharedPtr<NodeModel> parent = PtrCast<NodeModel>(_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 diff --git a/src/gui/PortMenu.hpp b/src/gui/PortMenu.hpp index 44c6d5b6..61ff1cc5 100644 --- a/src/gui/PortMenu.hpp +++ b/src/gui/PortMenu.hpp @@ -43,8 +43,16 @@ public: private: void on_menu_disconnect(); + void on_menu_set_min(); + void on_menu_set_max(); + void on_menu_reset_range(); bool _patch_port; + + Gtk::Menu* _port_menu; + Gtk::MenuItem* _set_min_menuitem; + Gtk::MenuItem* _set_max_menuitem; + Gtk::MenuItem* _reset_range_menuitem; }; diff --git a/src/gui/PropertiesWindow.cpp b/src/gui/PropertiesWindow.cpp index 95ca1d7c..51ca4817 100644 --- a/src/gui/PropertiesWindow.cpp +++ b/src/gui/PropertiesWindow.cpp @@ -99,18 +99,12 @@ PropertiesWindow::set_object(SharedPtr<ObjectModel> model) align->add(*combo); _table->attach(*align, 1, 2, n_rows, n_rows + 1, Gtk::FILL|Gtk::SHRINK, Gtk::SHRINK); - Record record; - record.value = value; - record.type_widget = combo; - // Column 2: Value align = manage(new Gtk::Alignment(0.0, 0.5, 1.0, 0.0)); Gtk::Widget* value_widget = create_value_widget(i->first, value); align->add(*value_widget); _table->attach(*align, 2, 3, n_rows, n_rows + 1, Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK); - record.value_widget = align; - record.row = n_rows; - _records.insert(make_pair(i->first, record)); + _records.insert(make_pair(i->first, Record(value, combo, align, n_rows))); } _table->show_all(); diff --git a/src/gui/PropertiesWindow.hpp b/src/gui/PropertiesWindow.hpp index d2f619f9..2511e78a 100644 --- a/src/gui/PropertiesWindow.hpp +++ b/src/gui/PropertiesWindow.hpp @@ -47,6 +47,9 @@ public: private: /** Record of a property (row in the table) */ struct Record { + Record(const Raul::Atom& v, Gtk::ComboBox* tw, Gtk::Alignment* vw, int r) + : value(v), type_widget(tw), value_widget(vw), row(r) + {} Raul::Atom value; Gtk::ComboBox* type_widget; Gtk::Alignment* value_widget; diff --git a/src/gui/ingen_gui.glade b/src/gui/ingen_gui.glade index ad84483f..1e297c12 100644 --- a/src/gui/ingen_gui.glade +++ b/src/gui/ingen_gui.glade @@ -3262,4 +3262,30 @@ Thank you for contributing.</property> </widget> </child> </widget> + <widget class="GtkMenu" id="port_menu"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <child> + <widget class="GtkMenuItem" id="port_set_min_menuitem"> + <property name="visible">True</property> + <property name="label" translatable="yes">Set m_inimum to current value</property> + <property name="use_underline">True</property> + </widget> + </child> + <child> + <widget class="GtkMenuItem" id="port_set_max_menuitem"> + <property name="visible">True</property> + <property name="label" translatable="yes">Set m_aximum to current value</property> + <property name="use_underline">True</property> + </widget> + </child> + <child> + <widget class="GtkMenuItem" id="port_reset_range_menuitem"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">Reset range to plugin defaults</property> + <property name="label" translatable="yes">R_eset Range</property> + <property name="use_underline">True</property> + </widget> + </child> + </widget> </glade-interface> |