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/mackie | |
parent | b141d17274c5d778fc8847e6129b37105be858ae (diff) |
Use ActionModel API in the Control Surfaces that can make use of it
Diffstat (limited to 'libs/surfaces/mackie')
-rw-r--r-- | libs/surfaces/mackie/gui.cc | 126 | ||||
-rw-r--r-- | libs/surfaces/mackie/gui.h | 19 |
2 files changed, 14 insertions, 131 deletions
diff --git a/libs/surfaces/mackie/gui.cc b/libs/surfaces/mackie/gui.cc index 613bfb8567..8b9eb26b03 100644 --- a/libs/surfaces/mackie/gui.cc +++ b/libs/surfaces/mackie/gui.cc @@ -34,6 +34,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" @@ -88,6 +89,7 @@ MackieControlProtocol::build_gui () MackieControlProtocolGUI::MackieControlProtocolGUI (MackieControlProtocol& p) : _cp (p) , table (2, 9) + , action_model (ActionManager::ActionModel::instance ()) , touch_sensitivity_adjustment (0, 0, 9, 1, 4) , touch_sensitivity_scale (touch_sensitivity_adjustment) , recalibrate_fader_button (_("Recalibrate Faders")) @@ -239,7 +241,6 @@ MackieControlProtocolGUI::MackieControlProtocolGUI (MackieControlProtocol& 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(); @@ -442,117 +443,6 @@ MackieControlProtocolGUI::make_action_renderer (Glib::RefPtr<TreeStore> model, G } void -MackieControlProtocolGUI::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 MackieControlProtocolGUI::build_function_key_editor () { function_key_editor.append_column (_("Key"), function_key_columns.name); @@ -560,32 +450,32 @@ MackieControlProtocolGUI::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); - renderer = make_action_renderer (available_action_model, function_key_columns.control); + renderer = make_action_renderer (action_model.model(), function_key_columns.control); col = manage (new TreeViewColumn (_("Control"), *renderer)); col->add_attribute (renderer->property_text(), function_key_columns.control); function_key_editor.append_column (*col); - renderer = make_action_renderer (available_action_model, function_key_columns.option); + renderer = make_action_renderer (action_model.model(), function_key_columns.option); col = manage (new TreeViewColumn (_("Option"), *renderer)); col->add_attribute (renderer->property_text(), function_key_columns.option); function_key_editor.append_column (*col); - renderer = make_action_renderer (available_action_model, function_key_columns.cmdalt); + renderer = make_action_renderer (action_model.model(), function_key_columns.cmdalt); col = manage (new TreeViewColumn (_("Cmd/Alt"), *renderer)); col->add_attribute (renderer->property_text(), function_key_columns.cmdalt); function_key_editor.append_column (*col); - renderer = make_action_renderer (available_action_model, function_key_columns.shiftcontrol); + renderer = make_action_renderer (action_model.model(), function_key_columns.shiftcontrol); col = manage (new TreeViewColumn (_("Shift+Control"), *renderer)); col->add_attribute (renderer->property_text(), function_key_columns.shiftcontrol); function_key_editor.append_column (*col); diff --git a/libs/surfaces/mackie/gui.h b/libs/surfaces/mackie/gui.h index 0f91a32e12..f40676630d 100644 --- a/libs/surfaces/mackie/gui.h +++ b/libs/surfaces/mackie/gui.h @@ -35,6 +35,10 @@ namespace Gtk { #include "pbd/i18n.h" +namespace ActionManager { + class ActionModel; +} + namespace ArdourSurface { class MackieControlProtocol; @@ -67,15 +71,6 @@ class MackieControlProtocolGUI : 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); @@ -97,18 +92,17 @@ class MackieControlProtocolGUI : public Gtk::Notebook Gtk::TreeModelColumn<std::string> shiftcontrol; }; - AvailableActionColumns available_action_columns; FunctionKeyColumns function_key_columns; MidiPortColumns midi_port_columns; Gtk::ScrolledWindow function_key_scroller; Gtk::TreeView function_key_editor; Glib::RefPtr<Gtk::ListStore> function_key_model; - Glib::RefPtr<Gtk::TreeStore> available_action_model; + + const ActionManager::ActionModel& action_model; Glib::RefPtr<Gtk::ListStore> build_midi_port_list (bool for_input); - void build_available_action_menu (); void refresh_function_key_editor (); void build_function_key_editor (); void action_changed (const Glib::ustring &sPath, const Glib::ustring &text, Gtk::TreeModelColumnBase); @@ -157,4 +151,3 @@ class MackieControlProtocolGUI : public Gtk::Notebook }; } - |