faderport: add some "curated" actions for mix, proj and trns; make new bindings use...
[ardour.git] / libs / surfaces / faderport / gui.h
1 /*
2     Copyright (C) 2015 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef __ardour_faderport_gui_h__
21 #define __ardour_faderport_gui_h__
22
23 #include <vector>
24 #include <string>
25
26 #include <gtkmm/box.h>
27 #include <gtkmm/combobox.h>
28 #include <gtkmm/table.h>
29 #include <gtkmm/treestore.h>
30
31 namespace Gtk {
32         class CellRendererCombo;
33         class ListStore;
34 }
35
36 #include "faderport.h"
37
38 namespace ArdourSurface {
39
40 class FPGUI : public Gtk::VBox
41 {
42 public:
43         FPGUI (FaderPort&);
44         ~FPGUI ();
45
46 private:
47         FaderPort& fp;
48         Gtk::Table table;
49         Gtk::Table action_table;
50         Gtk::ComboBox input_combo;
51         Gtk::ComboBox output_combo;
52
53         /* the mix, proj, trns and user buttons have no obvious semantics for
54          * ardour, mixbus etc., so we allow the user to define their
55          * functionality from a small, curated set of options.
56          */
57
58         Gtk::ComboBox mix_combo[4];
59         Gtk::ComboBox proj_combo[4];
60         Gtk::ComboBox trns_combo[4];
61         Gtk::ComboBox user_combo[4];
62
63         void update_port_combos ();
64         PBD::ScopedConnection connection_change_connection;
65         void connection_handler ();
66
67         struct MidiPortColumns : public Gtk::TreeModel::ColumnRecord {
68                 MidiPortColumns() {
69                         add (short_name);
70                         add (full_name);
71                 }
72                 Gtk::TreeModelColumn<std::string> short_name;
73                 Gtk::TreeModelColumn<std::string> full_name;
74         };
75
76         MidiPortColumns midi_port_columns;
77         bool ignore_active_change;
78
79         Glib::RefPtr<Gtk::ListStore> build_midi_port_list (std::vector<std::string> const & ports, bool for_input);
80         void active_port_changed (Gtk::ComboBox*,bool for_input);
81
82         struct ActionColumns : public Gtk::TreeModel::ColumnRecord {
83                 ActionColumns() {
84                         add (name);
85                         add (path);
86                 }
87                 Gtk::TreeModelColumn<std::string> name;
88                 Gtk::TreeModelColumn<std::string> path;
89         };
90
91         ActionColumns action_columns;
92         Glib::RefPtr<Gtk::TreeStore> available_action_model;
93         std::map<std::string,std::string> action_map; // map from action names to paths
94
95         void build_action_combo (Gtk::ComboBox& cb, std::vector<std::pair<std::string,std::string> > const & actions, FaderPort::ButtonID, FaderPort::ButtonState);
96         void build_mix_action_combo (Gtk::ComboBox&, FaderPort::ButtonState);
97         void build_proj_action_combo (Gtk::ComboBox&, FaderPort::ButtonState);
98         void build_trns_action_combo (Gtk::ComboBox&, FaderPort::ButtonState);
99
100         void build_available_action_menu ();
101         void action_changed (Gtk::ComboBox*, FaderPort::ButtonID, FaderPort::ButtonState);
102 };
103
104 }
105
106 #endif /* __ardour_faderport_gui_h__ */