mackie: reverse previous profile editor changes; allow profile to define anything...
authorPaul Davis <paul@linuxaudiosystems.com>
Thu, 4 Feb 2016 16:23:28 +0000 (11:23 -0500)
committerPaul Davis <paul@linuxaudiosystems.com>
Thu, 4 Feb 2016 16:24:26 +0000 (11:24 -0500)
For Fn keys we also allow plain and shift definitions

libs/surfaces/mackie/gui.cc

index 354aeeb9ea2bd359447381ddd80b37447dfed7bc..5d9208b663f6c28156e5ccd0a5cb24c37abcf50d 100644 (file)
@@ -54,8 +54,6 @@ using namespace Gtk;
 using namespace ArdourSurface;
 using namespace Mackie;
 
-#define SHIFT_IS_THE_ONLY_MODIFIER
-
 void*
 MackieControlProtocol::get_gui () const
 {
@@ -205,9 +203,11 @@ MackieControlProtocolGUI::MackieControlProtocolGUI (MackieControlProtocol& p)
        vector<string> profiles;
 
        for (std::map<std::string,DeviceProfile>::iterator i = DeviceProfile::device_profiles.begin(); i != DeviceProfile::device_profiles.end(); ++i) {
+               cerr << "add discovered profile " << i->first << endl;
                profiles.push_back (i->first);
        }
        Gtkmm2ext::set_popdown_strings (_profile_combo, profiles);
+       cerr << "set active profile from " << p.device_profile().name() << endl;
        _profile_combo.set_active_text (p.device_profile().name());
        _profile_combo.signal_changed().connect (sigc::mem_fun (*this, &MackieControlProtocolGUI::profile_combo_changed));
 
@@ -479,7 +479,6 @@ MackieControlProtocolGUI::build_available_action_menu ()
        rowp = available_action_model->append();
        parent = *(rowp);
        parent[available_action_columns.name] = _("Shift");
-#ifndef SHIFT_IS_THE_ONLY_MODIFIER
        rowp = available_action_model->append();
        parent = *(rowp);
        parent[available_action_columns.name] = _("Control");
@@ -489,7 +488,6 @@ MackieControlProtocolGUI::build_available_action_menu ()
        rowp = available_action_model->append();
        parent = *(rowp);
        parent[available_action_columns.name] = _("CmdAlt");
-#endif
 
        for (l = labels.begin(), k = keys.begin(), p = paths.begin(), t = tooltips.begin(); l != labels.end(); ++k, ++p, ++t, ++l) {
 
@@ -560,16 +558,15 @@ MackieControlProtocolGUI::build_function_key_editor ()
        CellRendererCombo* renderer;
 
        renderer = make_action_renderer (available_action_model, function_key_columns.plain);
-       col = manage (new TreeViewColumn (_("Normal Action"), *renderer));
+       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);
-       col = manage (new TreeViewColumn (_("Action with Shift"), *renderer));
+       col = manage (new TreeViewColumn (_("Shift"), *renderer));
        col->add_attribute (renderer->property_text(), function_key_columns.shift);
        function_key_editor.append_column (*col);
 
-#ifndef SHIFT_IS_THE_ONLY_MODIFIER
        renderer = make_action_renderer (available_action_model, function_key_columns.control);
        col = manage (new TreeViewColumn (_("Control"), *renderer));
        col->add_attribute (renderer->property_text(), function_key_columns.control);
@@ -589,7 +586,6 @@ MackieControlProtocolGUI::build_function_key_editor ()
        col = manage (new TreeViewColumn (_("Shift+Control"), *renderer));
        col->add_attribute (renderer->property_text(), function_key_columns.shiftcontrol);
        function_key_editor.append_column (*col);
-#endif
 
        function_key_model = ListStore::create (function_key_columns);
        function_key_editor.set_model (function_key_model);
@@ -607,19 +603,9 @@ MackieControlProtocolGUI::refresh_function_key_editor ()
        DeviceProfile dp (_cp.device_profile());
        DeviceInfo di;
 
-       vector<Mackie::Button::ID> Fn_buttons;
-       Fn_buttons.push_back (Mackie::Button::F1);
-       Fn_buttons.push_back (Mackie::Button::F2);
-       Fn_buttons.push_back (Mackie::Button::F3);
-       Fn_buttons.push_back (Mackie::Button::F4);
-       Fn_buttons.push_back (Mackie::Button::F5);
-       Fn_buttons.push_back (Mackie::Button::F6);
-       Fn_buttons.push_back (Mackie::Button::F7);
-       Fn_buttons.push_back (Mackie::Button::F8);
-
-       for (vector<Mackie::Button::ID>::iterator i = Fn_buttons.begin(); i != Fn_buttons.end(); ++i) {
+       for (int n = 0; n < Mackie::Button::FinalGlobalButton; ++n) {
 
-               Mackie::Button::ID bid = *i;
+               Mackie::Button::ID bid = (Mackie::Button::ID) n;
 
                row = *(function_key_model->append());
                if (di.global_buttons().find (bid) == di.global_buttons().end()) {
@@ -633,42 +619,55 @@ MackieControlProtocolGUI::refresh_function_key_editor ()
                string action;
                const string defstring = "\u2022";
 
-               action = dp.get_button_action (bid, 0);
-               if (action.empty()) {
-                       row[function_key_columns.plain] = defstring;
-               } else {
-                       if (action.find ('/') == string::npos) {
-                               /* Probably a key alias */
-                               row[function_key_columns.plain] = action;
-                       } else {
+               /* We only allow plain bindings for Fn keys. All others are
+                * reserved for hard-coded actions.
+                */
 
-                               act = ActionManager::get_action (action.c_str());
-                               if (act) {
-                                       row[function_key_columns.plain] = act->get_label();
+               if (bid >= Mackie::Button::F1 && bid <= Mackie::Button::F8) {
+
+                       action = dp.get_button_action (bid, 0);
+                       if (action.empty()) {
+                               row[function_key_columns.plain] = defstring;
+                       } else {
+                               if (action.find ('/') == string::npos) {
+                                       /* Probably a key alias */
+                                       row[function_key_columns.plain] = action;
                                } else {
-                                       row[function_key_columns.plain] = defstring;
+
+                                       act = ActionManager::get_action (action.c_str());
+                                       if (act) {
+                                               row[function_key_columns.plain] = act->get_label();
+                                       } else {
+                                               row[function_key_columns.plain] = defstring;
+                                       }
                                }
                        }
                }
 
-               action = dp.get_button_action (bid, MackieControlProtocol::MODIFIER_SHIFT);
-               if (action.empty()) {
-                       row[function_key_columns.shift] = defstring;
-               } else {
-                       if (action.find ('/') == string::npos) {
-                               /* Probably a key alias */
-                               row[function_key_columns.shift] = action;
+               /* We only allow plain bindings for Fn keys. All others are
+                * reserved for hard-coded actions.
+                */
+
+               if (bid >= Mackie::Button::F1 && bid <= Mackie::Button::F8) {
+
+                       action = dp.get_button_action (bid, MackieControlProtocol::MODIFIER_SHIFT);
+                       if (action.empty()) {
+                               row[function_key_columns.shift] = defstring;
                        } else {
-                               act = ActionManager::get_action (action.c_str());
-                               if (act) {
-                                       row[function_key_columns.shift] = act->get_label();
+                               if (action.find ('/') == string::npos) {
+                                       /* Probably a key alias */
+                                       row[function_key_columns.shift] = action;
                                } else {
-                                       row[function_key_columns.shift] = defstring;
+                                       act = ActionManager::get_action (action.c_str());
+                                       if (act) {
+                                               row[function_key_columns.shift] = act->get_label();
+                                       } else {
+                                               row[function_key_columns.shift] = defstring;
+                                       }
                                }
                        }
                }
 
-#ifndef SHIFT_IS_THE_ONLY_MODIFIER
                action = dp.get_button_action (bid, MackieControlProtocol::MODIFIER_CONTROL);
                if (action.empty()) {
                        row[function_key_columns.control] = defstring;
@@ -731,7 +730,6 @@ MackieControlProtocolGUI::refresh_function_key_editor ()
                                row[function_key_columns.shiftcontrol] = defstring;
                        }
                }
-#endif
        }
 
        function_key_editor.set_model (function_key_model);
@@ -781,7 +779,6 @@ MackieControlProtocolGUI::action_changed (const Glib::ustring &sPath, const Glib
                        case 3:
                                modifier = MackieControlProtocol::MODIFIER_SHIFT;
                                break;
-#ifndef SHIFT_IS_THE_ONLY_MODIFIER
                        case 4:
                                modifier = MackieControlProtocol::MODIFIER_CONTROL;
                                break;
@@ -794,7 +791,6 @@ MackieControlProtocolGUI::action_changed (const Glib::ustring &sPath, const Glib
                        case 7:
                                modifier = (MackieControlProtocol::MODIFIER_SHIFT|MackieControlProtocol::MODIFIER_CONTROL);
                                break;
-#endif
                        default:
                                modifier = 0;
                        }