diff options
author | Johannes Mueller <github@johannes-mueller.org> | 2019-04-20 14:08:36 +0200 |
---|---|---|
committer | Johannes Mueller <github@johannes-mueller.org> | 2019-04-20 15:25:32 +0200 |
commit | 5b7bcec529c0b44cacf61298a0df5e7903e111d9 (patch) | |
tree | 6641ada41ecff828d7944fe453b841693ce5d095 /libs/surfaces/us2400 | |
parent | b141d17274c5d778fc8847e6129b37105be858ae (diff) |
Use ActionModel API in the Control Surfaces that can make use of it
Diffstat (limited to 'libs/surfaces/us2400')
-rw-r--r-- | libs/surfaces/us2400/gui.cc | 117 | ||||
-rw-r--r-- | libs/surfaces/us2400/gui.h | 18 |
2 files changed, 10 insertions, 125 deletions
diff --git a/libs/surfaces/us2400/gui.cc b/libs/surfaces/us2400/gui.cc index 9f6543875b..7766b87d41 100644 --- a/libs/surfaces/us2400/gui.cc +++ b/libs/surfaces/us2400/gui.cc @@ -35,6 +35,7 @@ #include "pbd/stacktrace.h" #include "gtkmm2ext/actions.h" +#include "gtkmm2ext/action_model.h" #include "gtkmm2ext/bindings.h" #include "gtkmm2ext/gui_thread.h" #include "gtkmm2ext/utils.h" @@ -89,6 +90,7 @@ US2400Protocol::build_gui () US2400ProtocolGUI::US2400ProtocolGUI (US2400Protocol& p) : _cp (p) , table (2, 9) + , action_model (ActionManager::ActionModel::instance ()) , _device_dependent_widget (0) , _ignore_profile_changed (false) , ignore_active_change (false) @@ -155,7 +157,6 @@ US2400ProtocolGUI::US2400ProtocolGUI (US2400Protocol& p) function_key_scroller.add (function_key_editor); append_page (*fkey_packer, _("Function Keys")); - build_available_action_menu (); build_function_key_editor (); refresh_function_key_editor (); fkey_packer->show_all(); @@ -357,116 +358,6 @@ US2400ProtocolGUI::make_action_renderer (Glib::RefPtr<TreeStore> model, Gtk::Tre } void -US2400ProtocolGUI::build_available_action_menu () -{ - /* build a model of all available actions (needs to be tree structured - * more) - */ - - available_action_model = TreeStore::create (available_action_columns); - - vector<string> paths; - vector<string> labels; - vector<string> tooltips; - vector<string> keys; - vector<Glib::RefPtr<Gtk::Action> > actions; - - typedef std::map<string,TreeIter> NodeMap; - NodeMap nodes; - NodeMap::iterator r; - - ActionManager::get_all_actions (paths, labels, tooltips, keys, actions); - - vector<string>::iterator k; - vector<string>::iterator p; - vector<string>::iterator t; - vector<string>::iterator l; - - available_action_model->clear (); - - /* Because there are button bindings built in that are not - * in the key binding map, there needs to be a way to undo - * a profile edit. */ - TreeIter rowp; - TreeModel::Row parent; - rowp = available_action_model->append(); - parent = *(rowp); - parent[available_action_columns.name] = _("Remove Binding"); - - /* Key aliasing */ - - rowp = available_action_model->append(); - parent = *(rowp); - parent[available_action_columns.name] = _("Shift"); - rowp = available_action_model->append(); - parent = *(rowp); - parent[available_action_columns.name] = _("Control"); - rowp = available_action_model->append(); - parent = *(rowp); - parent[available_action_columns.name] = _("Option"); - rowp = available_action_model->append(); - parent = *(rowp); - parent[available_action_columns.name] = _("CmdAlt"); - - for (l = labels.begin(), k = keys.begin(), p = paths.begin(), t = tooltips.begin(); l != labels.end(); ++k, ++p, ++t, ++l) { - - TreeModel::Row row; - vector<string> parts; - - parts.clear (); - - split (*p, parts, '/'); - - if (parts.empty()) { - continue; - } - - /* kinda kludgy way to avoid displaying menu items as mappable */ - if (parts[0] == _("Main Menu")) - continue; - if (parts[0] == _("JACK")) - continue; - if (parts[0] == _("redirectmenu")) - continue; - if (parts[0] == _("RegionList")) - continue; - if (parts[0] == _("ProcessorMenu")) - continue; - - if ((r = nodes.find (parts[0])) == nodes.end()) { - - /* top level is missing */ - - TreeIter rowp; - TreeModel::Row parent; - rowp = available_action_model->append(); - nodes[parts[0]] = rowp; - parent = *(rowp); - parent[available_action_columns.name] = parts[0]; - - row = *(available_action_model->append (parent.children())); - - } else { - - row = *(available_action_model->append ((*r->second)->children())); - - } - - /* add this action */ - - if (l->empty ()) { - row[available_action_columns.name] = *t; - action_map[*t] = *p; - } else { - row[available_action_columns.name] = *l; - action_map[*l] = *p; - } - - row[available_action_columns.path] = (*p); - } -} - -void US2400ProtocolGUI::build_function_key_editor () { function_key_editor.append_column (_("Key"), function_key_columns.name); @@ -474,12 +365,12 @@ US2400ProtocolGUI::build_function_key_editor () TreeViewColumn* col; CellRendererCombo* renderer; - renderer = make_action_renderer (available_action_model, function_key_columns.plain); + renderer = make_action_renderer (action_model.model(), function_key_columns.plain); col = manage (new TreeViewColumn (_("Plain"), *renderer)); col->add_attribute (renderer->property_text(), function_key_columns.plain); function_key_editor.append_column (*col); - renderer = make_action_renderer (available_action_model, function_key_columns.shift); + renderer = make_action_renderer (action_model.model(), function_key_columns.shift); col = manage (new TreeViewColumn (_("Shift"), *renderer)); col->add_attribute (renderer->property_text(), function_key_columns.shift); function_key_editor.append_column (*col); diff --git a/libs/surfaces/us2400/gui.h b/libs/surfaces/us2400/gui.h index 7e0342bb85..ea3ba0e8e2 100644 --- a/libs/surfaces/us2400/gui.h +++ b/libs/surfaces/us2400/gui.h @@ -35,6 +35,10 @@ namespace Gtk { #include "pbd/i18n.h" +namespace ActionManager { + class ActionModel; +} + namespace ArdourSurface { class US2400Protocol; @@ -66,15 +70,6 @@ class US2400ProtocolGUI : public Gtk::Notebook Gtk::TreeModelColumn<std::string> full_name; }; - struct AvailableActionColumns : public Gtk::TreeModel::ColumnRecord { - AvailableActionColumns() { - add (name); - add (path); - } - Gtk::TreeModelColumn<std::string> name; - Gtk::TreeModelColumn<std::string> path; - }; - struct FunctionKeyColumns : public Gtk::TreeModel::ColumnRecord { FunctionKeyColumns() { add (name); @@ -96,7 +91,6 @@ class US2400ProtocolGUI : public Gtk::Notebook Gtk::TreeModelColumn<std::string> shiftcontrol; }; - AvailableActionColumns available_action_columns; FunctionKeyColumns function_key_columns; MidiPortColumns midi_port_columns; @@ -107,7 +101,8 @@ class US2400ProtocolGUI : public Gtk::Notebook Glib::RefPtr<Gtk::ListStore> build_midi_port_list (bool for_input); - void build_available_action_menu (); + const ActionManager::ActionModel& action_model; + void refresh_function_key_editor (); void build_function_key_editor (); void action_changed (const Glib::ustring &sPath, const Glib::ustring &text, Gtk::TreeModelColumnBase); @@ -139,4 +134,3 @@ class US2400ProtocolGUI : public Gtk::Notebook }; } - |