From bbd2f572a06786eafc49f1ba046c3eddbb005917 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 9 Aug 2014 04:55:56 +0000 Subject: Improve object context menu. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5446 a436a847-0d15-0410-975c-d299462d15a1 --- src/gui/NodeMenu.cpp | 20 ++++++++-- src/gui/ObjectMenu.cpp | 1 + src/gui/ObjectMenu.hpp | 1 + src/gui/PortMenu.cpp | 4 ++ src/gui/ingen_gui.ui | 106 +++++++++++++++++++++++++++---------------------- 5 files changed, 80 insertions(+), 52 deletions(-) (limited to 'src') diff --git a/src/gui/NodeMenu.cpp b/src/gui/NodeMenu.cpp index 1a64d04e..5434f6be 100644 --- a/src/gui/NodeMenu.cpp +++ b/src/gui/NodeMenu.cpp @@ -87,6 +87,7 @@ NodeMenu::init(App& app, SPtr block) if (presets) { _presets_menu = Gtk::manage(new Gtk::Menu()); + unsigned n_presets = 0; LILV_FOREACH(nodes, i, presets) { const LilvNode* preset = lilv_nodes_get(presets, i); lilv_world_load_resource(plugin->lilv_world(), preset); @@ -109,6 +110,7 @@ NodeMenu::init(App& app, SPtr block) string(lilv_node_as_string(preset)))); lilv_nodes_free(labels); + ++n_presets; } else { app.log().error( fmt("Preset <%1> has no rdfs:label\n") @@ -116,10 +118,14 @@ NodeMenu::init(App& app, SPtr block) } } - items().push_front(Gtk::Menu_Helpers::ImageMenuElem("_Presets", - *(manage(new Gtk::Image(Gtk::Stock::INDEX, Gtk::ICON_SIZE_MENU))))); - Gtk::MenuItem* presets_menu_item = &(items().front()); - presets_menu_item->set_submenu(*_presets_menu); + if (n_presets > 0) { + items().push_front( + Gtk::Menu_Helpers::ImageMenuElem( + "_Presets", + *(manage(new Gtk::Image(Gtk::Stock::INDEX, Gtk::ICON_SIZE_MENU))))); + Gtk::MenuItem* presets_menu_item = &(items().front()); + presets_menu_item->set_submenu(*_presets_menu); + } lilv_nodes_free(presets); } lilv_node_free(pset_Preset); @@ -137,6 +143,12 @@ NodeMenu::init(App& app, SPtr block) else _learn_menuitem->hide(); + if (!_popup_gui_menuitem->is_visible() && + !_embed_gui_menuitem->is_visible() && + !_randomize_menuitem->is_visible()) { + _separator_menuitem->hide(); + } + _enable_signal = true; } diff --git a/src/gui/ObjectMenu.cpp b/src/gui/ObjectMenu.cpp index a6211797..2d44622b 100644 --- a/src/gui/ObjectMenu.cpp +++ b/src/gui/ObjectMenu.cpp @@ -48,6 +48,7 @@ ObjectMenu::ObjectMenu(BaseObjectType* cobject, xml->get_widget("object_rename_menuitem", _rename_menuitem); xml->get_widget("object_destroy_menuitem", _destroy_menuitem); xml->get_widget("object_properties_menuitem", _properties_menuitem); + xml->get_widget("object_menu_separator", _separator_menuitem); } void diff --git a/src/gui/ObjectMenu.hpp b/src/gui/ObjectMenu.hpp index d3ed647e..344af9f3 100644 --- a/src/gui/ObjectMenu.hpp +++ b/src/gui/ObjectMenu.hpp @@ -66,6 +66,7 @@ protected: Gtk::MenuItem* _rename_menuitem; Gtk::MenuItem* _destroy_menuitem; Gtk::MenuItem* _properties_menuitem; + Gtk::SeparatorMenuItem* _separator_menuitem; bool _enable_signal; }; diff --git a/src/gui/PortMenu.cpp b/src/gui/PortMenu.cpp index 3b8cc741..7eeef5b1 100644 --- a/src/gui/PortMenu.cpp +++ b/src/gui/PortMenu.cpp @@ -83,6 +83,10 @@ PortMenu::init(App& app, SPtr port, bool is_graph_port) _learn_menuitem->set_visible(is_control); _unlearn_menuitem->set_visible(is_control); + if (!is_control && is_on_graph) { + _separator_menuitem->hide(); + } + _enable_signal = true; } diff --git a/src/gui/ingen_gui.ui b/src/gui/ingen_gui.ui index 88bf08d5..1a61bdb7 100644 --- a/src/gui/ingen_gui.ui +++ b/src/gui/ingen_gui.ui @@ -2065,129 +2065,139 @@ Contributors: False GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - + + Show GUI... False - True False GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - P_olyphonic - True + False - + False - True False - _Learn - True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Embed GUI - + + Randomi_ze False - True False - _Unlearn + False True - - Dis_connect + False - True False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Set Value as Mi_nimum True - False - - _Rename... + False - True False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Set Value as Ma_ximum True - False - - gtk-delete + False - True False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Re_set Range True - True - - gtk-properties + False - True False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + _Expose True - True - - Show GUI... + + True + False + + + + False + True False GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - False + P_olyphonic + True - + False + True False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Embed GUI + _Learn + True - - Randomize + False + True False - False + _Unlearn + True - + + Dis_connect False + True False - Set Minimum + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + True + False - + + gtk-delete False + True False - Set Maximum + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + True + True - + + _Rename... False + True False - Reset Range + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + True + False - + + _Properties... False + True False - _Expose + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK True + False -- cgit v1.2.1