FP8: add mode to reset gain to unity
[ardour.git] / libs / surfaces / faderport8 / gui.h
1 /*
2  * Copyright (C) 2017 Robin Gareus <robin@gareus.org>
3  * Copyright (C) 2015 Paul Davis
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18  */
19
20 #ifndef __ardour_faderport8_gui_h__
21 #define __ardour_faderport8_gui_h__
22
23 #include <vector>
24 #include <string>
25
26 #include <gtkmm/box.h>
27 #include <gtkmm/combobox.h>
28 #include <gtkmm/comboboxtext.h>
29 #include <gtkmm/image.h>
30 #include <gtkmm/table.h>
31 #include <gtkmm/treestore.h>
32
33 namespace Gtk {
34         class CellRendererCombo;
35         class ListStore;
36 }
37
38 #include "faderport8.h"
39
40 namespace ArdourSurface {
41
42 class FP8GUI : public Gtk::VBox
43 {
44 public:
45         FP8GUI (FaderPort8&);
46         ~FP8GUI ();
47
48 private:
49         FaderPort8& fp;
50         Gtk::HBox hpacker;
51         Gtk::Table table;
52         Gtk::Image image;
53
54         /* port connections */
55         Gtk::ComboBox input_combo;
56         Gtk::ComboBox output_combo;
57
58         void update_port_combos ();
59         void connection_handler ();
60         PBD::ScopedConnection connection_change_connection;
61
62         struct MidiPortColumns : public Gtk::TreeModel::ColumnRecord {
63                 MidiPortColumns() {
64                         add (short_name);
65                         add (full_name);
66                 }
67                 Gtk::TreeModelColumn<std::string> short_name;
68                 Gtk::TreeModelColumn<std::string> full_name;
69         };
70
71         MidiPortColumns midi_port_columns;
72         bool ignore_active_change;
73
74         Glib::RefPtr<Gtk::ListStore> build_midi_port_list (std::vector<std::string> const & ports, bool for_input);
75         void active_port_changed (Gtk::ComboBox*,bool for_input);
76
77         /* misc Prefs */
78         Gtk::ComboBoxText clock_combo;
79         Gtk::ComboBoxText scribble_combo;
80         Gtk::CheckButton  two_line_text_cb;
81         Gtk::CheckButton  auto_pluginui_cb;
82
83         void build_prefs_combos ();
84         void update_prefs_combos ();
85         void clock_mode_changed ();
86         void scribble_mode_changed ();
87         void twolinetext_toggled ();
88         void auto_pluginui_toggled ();
89
90         /* user actions */
91         void build_available_action_menu ();
92         void build_action_combo (Gtk::ComboBox& cb, FP8Controls::ButtonId id);
93         void action_changed (Gtk::ComboBox* cb, FP8Controls::ButtonId id);
94
95         struct ActionColumns : public Gtk::TreeModel::ColumnRecord {
96                 ActionColumns() {
97                         add (name);
98                         add (path);
99                 }
100                 Gtk::TreeModelColumn<std::string> name;
101                 Gtk::TreeModelColumn<std::string> path;
102         };
103
104         ActionColumns action_columns;
105         Glib::RefPtr<Gtk::TreeStore> available_action_model;
106         std::map<std::string,std::string> action_map; // map from action names to paths
107
108         bool find_action_in_model (const Gtk::TreeModel::iterator& iter, std::string const & action_path, Gtk::TreeModel::iterator* found);
109 };
110
111 }
112
113 #endif /* __ardour_faderport8_gui_h__ */