add a few new actions to Faderport menus, and reorganize them slightly
[ardour.git] / libs / surfaces / faderport / gui.cc
index 593b3554e3a578a8ef39f89cfc6e589d5a81daaf..702ba26dc6bbaf03b50b49e284b6ebf0e64fe0c4 100644 (file)
@@ -110,13 +110,15 @@ FPGUI::FPGUI (FaderPort& p)
        input_combo.signal_changed().connect (sigc::bind (sigc::mem_fun (*this, &FPGUI::active_port_changed), &input_combo, true));
        output_combo.signal_changed().connect (sigc::bind (sigc::mem_fun (*this, &FPGUI::active_port_changed), &output_combo, false));
 
-       l = manage (new Gtk::Label (_("Sends MIDI to:")));
+       l = manage (new Gtk::Label);
+       l->set_markup (string_compose ("<span weight=\"bold\">%1</span>", _("Incoming MIDI on:")));
        l->set_alignment (1.0, 0.5);
        table.attach (*l, 0, 1, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
        table.attach (input_combo, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
        row++;
 
-       l = manage (new Gtk::Label (_("Receives MIDI from:")));
+       l = manage (new Gtk::Label);
+       l->set_markup (string_compose ("<span weight=\"bold\">%1</span>", _("Outgoing MIDI on:")));
        l->set_alignment (1.0, 0.5);
        table.attach (*l, 0, 1, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
        table.attach (output_combo, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
@@ -134,6 +136,15 @@ FPGUI::FPGUI (FaderPort& p)
        build_trns_action_combo (trns_combo[1], FaderPort::ShiftDown);
        build_trns_action_combo (trns_combo[2], FaderPort::LongPress);
 
+       build_available_action_menu ();
+
+       /* No shift-press combo for User because that is labelled as "next"
+        * (marker)
+        */
+
+       build_user_action_combo (user_combo[0], FaderPort::ButtonState(0));
+       build_user_action_combo (user_combo[1], FaderPort::LongPress);
+
        action_table.set_row_spacings (4);
        action_table.set_col_spacings (6);
        action_table.set_border_width (12);
@@ -141,22 +152,22 @@ FPGUI::FPGUI (FaderPort& p)
 
        int action_row = 0;
 
-
-       l = manage (new Gtk::Label (_("Button")));
-       l->set_alignment (1.0, 0.5);
-       action_table.attach (*l, 0, 1, action_row, action_row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
-       l = manage (new Gtk::Label (_("Normal Press/Release Action")));
+       l = manage (new Gtk::Label);
+       l->set_markup (string_compose ("<span weight=\"bold\">%1</span>", _("Press Action")));
        l->set_alignment (0.5, 0.5);
        action_table.attach (*l, 1, 2, action_row, action_row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
-       l = manage (new Gtk::Label (_("Shift-Press Action")));
+       l = manage (new Gtk::Label);
+       l->set_markup (string_compose ("<span weight=\"bold\">%1</span>", _("Shift-Press Action")));
        l->set_alignment (0.5, 0.5);
        action_table.attach (*l, 2, 3, action_row, action_row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
-       l = manage (new Gtk::Label (_("Long Press Action")));
+       l = manage (new Gtk::Label);
+       l->set_markup (string_compose ("<span weight=\"bold\">%1</span>", _("Long Press Action")));
        l->set_alignment (0.5, 0.5);
        action_table.attach (*l, 3, 4, action_row, action_row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
        action_row++;
 
-       l = manage (new Gtk::Label (_("Mix")));
+       l = manage (new Gtk::Label);
+       l->set_markup (string_compose ("<span weight=\"bold\">%1</span>", _("Mix")));
        l->set_alignment (1.0, 0.5);
        action_table.attach (*l, 0, 1, action_row, action_row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
        align = manage (new Alignment);
@@ -173,7 +184,8 @@ FPGUI::FPGUI (FaderPort& p)
        action_table.attach (*align, 3, 4, action_row, action_row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
        action_row++;
 
-       l = manage (new Gtk::Label (_("Proj")));
+       l = manage (new Gtk::Label);
+       l->set_markup (string_compose ("<span weight=\"bold\">%1</span>", _("Proj")));
        l->set_alignment (1.0, 0.5);
        action_table.attach (*l, 0, 1, action_row, action_row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
        align = manage (new Alignment);
@@ -190,7 +202,8 @@ FPGUI::FPGUI (FaderPort& p)
        action_table.attach (*align, 3, 4, action_row, action_row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
        action_row++;
 
-       l = manage (new Gtk::Label (_("Trns")));
+       l = manage (new Gtk::Label);
+       l->set_markup (string_compose ("<span weight=\"bold\">%1</span>", _("Trns")));
        l->set_alignment (1.0, 0.5);
        action_table.attach (*l, 0, 1, action_row, action_row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
        align = manage (new Alignment);
@@ -207,6 +220,21 @@ FPGUI::FPGUI (FaderPort& p)
        action_table.attach (*align, 3, 4, action_row, action_row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
        action_row++;
 
+       l = manage (new Gtk::Label);
+       l->set_markup (string_compose ("<span weight=\"bold\">%1</span>", _("User")));
+       l->set_alignment (1.0, 0.5);
+       action_table.attach (*l, 0, 1, action_row, action_row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
+       align = manage (new Alignment);
+       align->set (0.0, 0.5);
+       align->add (user_combo[0]);
+       action_table.attach (*align, 1, 2, action_row, action_row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
+       /* skip shift press combo */
+       align = manage (new Alignment);
+       align->set (0.0, 0.5);
+       align->add (user_combo[1]);
+       action_table.attach (*align, 3, 4, action_row, action_row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
+       action_row++;
+
        table.attach (action_table, 0, 5, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
        row++;
 
@@ -321,14 +349,14 @@ FPGUI::build_available_action_menu ()
 
        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;
+
+       /* Disabled item (row 0) */
+
        rowp = available_action_model->append();
        parent = *(rowp);
-       parent[action_columns.name] = _("Remove Binding");
+       parent[action_columns.name] = _("Disabled");
 
        /* Key aliasing */
 
@@ -402,7 +430,13 @@ FPGUI::build_available_action_menu ()
                        action_map[*l] = *p;
                }
 
-               row[action_columns.path] = (*p);
+               string path = (*p);
+               /* ControlProtocol::access_action() is not interested in the
+                  legacy "<Actions>/" prefix part of a path.
+               */
+               path = path.substr (strlen ("<Actions>/"));
+
+               row[action_columns.path] = path;
        }
 }
 
@@ -422,7 +456,7 @@ FPGUI::build_action_combo (Gtk::ComboBox& cb, vector<pair<string,string> > const
        Glib::RefPtr<Gtk::ListStore> model (Gtk::ListStore::create (action_columns));
        TreeIter rowp;
        TreeModel::Row row;
-       string current_action = fp.get_action (id, true, bs);
+       string current_action = fp.get_action (id, false, bs); /* lookup release action */
        int active_row = -1;
        int n;
        vector<pair<string,string> >::const_iterator i;
@@ -462,6 +496,8 @@ FPGUI::build_mix_action_combo (Gtk::ComboBox& cb, FaderPort::ButtonState bs)
        vector<pair<string,string> > actions;
 
        actions.push_back (make_pair (string (_("Toggle Editor & Mixer Windows")), string (X_("Common/toggle-editor-mixer"))));
+       actions.push_back (make_pair (string (_("Show/Hide Mixer list")), string (X_("Common/ToggleMixerList"))));
+       actions.push_back (make_pair (string("Toggle Meterbridge"), string(X_("Common/toggle-meterbridge"))));
        actions.push_back (make_pair (string (_("Show/Hide Editor mixer strip")), string (X_("Editor/show-editor-mixer"))));
 
        build_action_combo (cb, actions, FaderPort::Mix, bs);
@@ -472,12 +508,13 @@ FPGUI::build_proj_action_combo (Gtk::ComboBox& cb, FaderPort::ButtonState bs)
 {
        vector<pair<string,string> > actions;
 
-       actions.push_back (make_pair (string("Toggle Meterbridge"), string(X_("Common/toggle-meterbridge"))));
-       actions.push_back (make_pair (string("Toggle Summary"), string(X_("Editor/ToggleSummary"))));
        actions.push_back (make_pair (string("Toggle Editor Lists"), string(X_("Editor/show-editor-list"))));
+       actions.push_back (make_pair (string("Toggle Summary"), string(X_("Editor/ToggleSummary"))));
+       actions.push_back (make_pair (string("Toggle Meterbridge"), string(X_("Common/toggle-meterbridge"))));
        actions.push_back (make_pair (string (_("Zoom to Session")), string (X_("Editor/zoom-to-session"))));
-       actions.push_back (make_pair (string (_("Zoom In")), string (X_("Editor/temporal-zoom-in"))));
-       actions.push_back (make_pair (string (_("Zoom Out")), string (X_("Editor/temporal-zoom-out"))));
+
+//     actions.push_back (make_pair (string (_("Zoom In")), string (X_("Editor/temporal-zoom-in"))));
+//     actions.push_back (make_pair (string (_("Zoom Out")), string (X_("Editor/temporal-zoom-out"))));
 
        build_action_combo (cb, actions, FaderPort::Proj, bs);
 }
@@ -487,14 +524,60 @@ FPGUI::build_trns_action_combo (Gtk::ComboBox& cb, FaderPort::ButtonState bs)
 {
        vector<pair<string,string> > actions;
 
-       actions.push_back (make_pair (string("Toggle Locations"), string(X_("Window/toggle-locations"))));
+       actions.push_back (make_pair (string("Toggle Big Clock"), string(X_("Window/toggle-big-clock"))));  //note:  this would really make sense if the Big Clock had transport buttons on it
+       actions.push_back (make_pair (string("Toggle Locations window"), string(X_("Window/toggle-locations"))));
        actions.push_back (make_pair (string("Toggle Metronome"), string(X_("Transport/ToggleClick"))));
-       actions.push_back (make_pair (string("Toggle Sync"), string(X_("Transport/ToggleExternalSync"))));
-       actions.push_back (make_pair (string("Set Playhead @pointer"), string(X_("Editor/set-playhead"))));
+       actions.push_back (make_pair (string("Toggle External Sync"), string(X_("Transport/ToggleExternalSync"))));
+       actions.push_back (make_pair (string("Toggle Follow Playhead"), string(X_("Editor/toggle-follow-playhead"))));
+
+//     actions.push_back (make_pair (string("Set Playhead @pointer"), string(X_("Editor/set-playhead"))));
+
 
        build_action_combo (cb, actions, FaderPort::Trns, bs);
 }
 
+bool
+FPGUI::find_action_in_model (const TreeModel::iterator& iter, std::string const & action_path, TreeModel::iterator* found)
+{
+       TreeModel::Row row = *iter;
+       string path = row[action_columns.path];
+
+       if (path == action_path) {
+               *found = iter;
+               return true;
+       }
+
+       return false;
+}
+
+void
+FPGUI::build_user_action_combo (Gtk::ComboBox& cb, FaderPort::ButtonState bs)
+{
+       cb.set_model (available_action_model);
+       cb.pack_start (action_columns.name);
+       cb.signal_changed().connect (sigc::bind (sigc::mem_fun (*this, &FPGUI::action_changed), &cb, FaderPort::User, bs));
+
+       /* set the active "row" to the right value for the current button binding */
+
+       string current_action = fp.get_action (FaderPort::User, false, bs); /* lookup release action */
+
+       if (current_action.empty()) {
+               cb.set_active (0); /* "disabled" */
+               return;
+       }
+
+       TreeModel::iterator iter = available_action_model->children().end();
+
+       available_action_model->foreach_iter (sigc::bind (sigc::mem_fun (*this, &FPGUI::find_action_in_model), current_action, &iter));
+
+       if (iter != available_action_model->children().end()) {
+               cb.set_active (iter);
+       } else {
+               cb.set_active (0);
+       }
+
+}
+
 Glib::RefPtr<Gtk::ListStore>
 FPGUI::build_midi_port_list (vector<string> const & ports, bool for_input)
 {