enough with umpteen "i18n.h" files. Consolidate on pbd/i18n.h
[ardour.git] / libs / surfaces / mackie / gui.h
1 /*
2   Copyright (C) 2010-2012 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 #include <vector>
20
21 #include <gtkmm/combobox.h>
22 #include <gtkmm/box.h>
23 #include <gtkmm/spinbutton.h>
24 #include <gtkmm/table.h>
25 #include <gtkmm/treeview.h>
26 #include <gtkmm/liststore.h>
27 #include <gtkmm/notebook.h>
28 #include <gtkmm/scrolledwindow.h>
29
30 namespace Gtk {
31         class CellRendererCombo;
32 }
33
34 #include "button.h"
35
36 #include "pbd/i18n.h"
37
38 namespace ArdourSurface {
39
40 class MackieControlProtocol;
41
42 namespace Mackie {
43         class Surface;
44 }
45
46 class MackieControlProtocolGUI : public Gtk::Notebook
47 {
48    public:
49         MackieControlProtocolGUI (MackieControlProtocol &);
50
51    private:
52         MackieControlProtocol& _cp;
53         Gtk::Table         table;
54         Gtk::ComboBoxText _surface_combo;
55         Gtk::ComboBoxText _profile_combo;
56
57         typedef std::vector<Gtk::ComboBox*> PortCombos;
58         PortCombos input_combos;
59         PortCombos output_combos;
60
61         struct MidiPortColumns : public Gtk::TreeModel::ColumnRecord {
62                 MidiPortColumns() {
63                         add (short_name);
64                         add (full_name);
65                 }
66                 Gtk::TreeModelColumn<std::string> short_name;
67                 Gtk::TreeModelColumn<std::string> full_name;
68         };
69
70         struct AvailableActionColumns : public Gtk::TreeModel::ColumnRecord {
71                 AvailableActionColumns() {
72                         add (name);
73                         add (path);
74                 }
75                 Gtk::TreeModelColumn<std::string> name;
76                 Gtk::TreeModelColumn<std::string> path;
77         };
78
79         struct FunctionKeyColumns : public Gtk::TreeModel::ColumnRecord {
80                 FunctionKeyColumns() {
81                         add (name);
82                         add (id);
83                         add (plain);
84                         add (shift);
85                         add (control);
86                         add (option);
87                         add (cmdalt);
88                         add (shiftcontrol);
89                 };
90                 Gtk::TreeModelColumn<std::string> name;
91                 Gtk::TreeModelColumn<Mackie::Button::ID>  id;
92                 Gtk::TreeModelColumn<std::string> plain;
93                 Gtk::TreeModelColumn<std::string> shift;
94                 Gtk::TreeModelColumn<std::string> control;
95                 Gtk::TreeModelColumn<std::string> option;
96                 Gtk::TreeModelColumn<std::string> cmdalt;
97                 Gtk::TreeModelColumn<std::string> shiftcontrol;
98         };
99
100         AvailableActionColumns available_action_columns;
101         FunctionKeyColumns function_key_columns;
102         MidiPortColumns midi_port_columns;
103
104         Gtk::ScrolledWindow function_key_scroller;
105         Gtk::TreeView function_key_editor;
106         Glib::RefPtr<Gtk::ListStore> function_key_model;
107         Glib::RefPtr<Gtk::TreeStore> available_action_model;
108
109         Glib::RefPtr<Gtk::ListStore> build_midi_port_list (bool for_input);
110
111         void build_available_action_menu ();
112         void refresh_function_key_editor ();
113         void build_function_key_editor ();
114         void action_changed (const Glib::ustring &sPath, const Glib::ustring &text, Gtk::TreeModelColumnBase);
115         Gtk::CellRendererCombo* make_action_renderer (Glib::RefPtr<Gtk::TreeStore> model, Gtk::TreeModelColumnBase);
116
117         void surface_combo_changed ();
118         void profile_combo_changed ();
119         void ipmidi_spinner_changed ();
120
121         std::map<std::string,std::string> action_map; // map from action names to paths
122
123         Gtk::CheckButton relay_click_button;
124         Gtk::CheckButton backlight_button;
125         Gtk::RadioButton absolute_touch_mode_button;
126         Gtk::RadioButton touch_move_mode_button;
127         Gtk::Adjustment  touch_sensitivity_adjustment;
128         Gtk::HScale      touch_sensitivity_scale;
129         Gtk::Button      recalibrate_fader_button;
130         Gtk::Adjustment  ipmidi_base_port_adjustment;
131         Gtk::Button      discover_button;
132
133         void discover_clicked ();
134         void recalibrate_faders ();
135         void toggle_backlight ();
136         void touch_sensitive_change ();
137
138         Gtk::Widget* device_dependent_widget ();
139         Gtk::Widget* _device_dependent_widget;
140         int device_dependent_row;
141
142         PBD::ScopedConnection device_change_connection;
143         void device_changed ();
144
145         void update_port_combos (std::vector<std::string> const&, std::vector<std::string> const&,
146                                  Gtk::ComboBox* input_combo,
147                                  Gtk::ComboBox* output_combo,
148                                  boost::shared_ptr<Mackie::Surface> surface);
149
150         PBD::ScopedConnection connection_change_connection;
151         void connection_handler ();
152
153         Glib::RefPtr<Gtk::ListStore> build_midi_port_list (std::vector<std::string> const & ports, bool for_input);
154         bool ignore_active_change;
155         void active_port_changed (Gtk::ComboBox* combo, boost::weak_ptr<Mackie::Surface> ws, bool for_input);
156 };
157
158 }
159