faderport: show current User button bindings in GUI
[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/image.h>
29 #include <gtkmm/table.h>
30 #include <gtkmm/treestore.h>
31
32 namespace Gtk {
33         class CellRendererCombo;
34         class ListStore;
35 }
36
37 #include "faderport.h"
38
39 namespace ArdourSurface {
40
41 class FPGUI : public Gtk::VBox
42 {
43 public:
44         FPGUI (FaderPort&);
45         ~FPGUI ();
46
47 private:
48         FaderPort& fp;
49         Gtk::HBox hpacker;
50         Gtk::Table table;
51         Gtk::Table action_table;
52         Gtk::ComboBox input_combo;
53         Gtk::ComboBox output_combo;
54         Gtk::Image    image;
55
56         /* the mix, proj, trns and user buttons have no obvious semantics for
57          * ardour, mixbus etc., so we allow the user to define their
58          * functionality from a small, curated set of options.
59          */
60
61         Gtk::ComboBox mix_combo[3];
62         Gtk::ComboBox proj_combo[3];
63         Gtk::ComboBox trns_combo[3];
64         Gtk::ComboBox user_combo[2];
65
66         void update_port_combos ();
67         PBD::ScopedConnection connection_change_connection;
68         void connection_handler ();
69
70         struct MidiPortColumns : public Gtk::TreeModel::ColumnRecord {
71                 MidiPortColumns() {
72                         add (short_name);
73                         add (full_name);
74                 }
75                 Gtk::TreeModelColumn<std::string> short_name;
76                 Gtk::TreeModelColumn<std::string> full_name;
77         };
78
79         MidiPortColumns midi_port_columns;
80         bool ignore_active_change;
81
82         Glib::RefPtr<Gtk::ListStore> build_midi_port_list (std::vector<std::string> const & ports, bool for_input);
83         void active_port_changed (Gtk::ComboBox*,bool for_input);
84
85         struct ActionColumns : public Gtk::TreeModel::ColumnRecord {
86                 ActionColumns() {
87                         add (name);
88                         add (path);
89                 }
90                 Gtk::TreeModelColumn<std::string> name;
91                 Gtk::TreeModelColumn<std::string> path;
92         };
93
94         ActionColumns action_columns;
95         Glib::RefPtr<Gtk::TreeStore> available_action_model;
96         std::map<std::string,std::string> action_map; // map from action names to paths
97
98         void build_action_combo (Gtk::ComboBox& cb, std::vector<std::pair<std::string,std::string> > const & actions, FaderPort::ButtonID, FaderPort::ButtonState);
99         void build_mix_action_combo (Gtk::ComboBox&, FaderPort::ButtonState);
100         void build_proj_action_combo (Gtk::ComboBox&, FaderPort::ButtonState);
101         void build_trns_action_combo (Gtk::ComboBox&, FaderPort::ButtonState);
102         void build_user_action_combo (Gtk::ComboBox&, FaderPort::ButtonState);
103
104         void build_available_action_menu ();
105         void action_changed (Gtk::ComboBox*, FaderPort::ButtonID, FaderPort::ButtonState);
106
107         bool find_action_in_model (const Gtk::TreeModel::iterator& iter, std::string const & action_path, Gtk::TreeModel::iterator* found);
108
109 };
110
111 }
112
113 #endif /* __ardour_faderport_gui_h__ */