2 Copyright (C) 2010-2012 Paul Davis
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.
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.
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.
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>
31 class CellRendererCombo;
38 namespace ArdourSurface {
40 class MackieControlProtocol;
46 class MackieControlProtocolGUI : public Gtk::Notebook
49 MackieControlProtocolGUI (MackieControlProtocol &);
52 MackieControlProtocol& _cp;
54 Gtk::ComboBoxText _surface_combo;
55 Gtk::ComboBoxText _profile_combo;
57 typedef std::vector<Gtk::ComboBox*> PortCombos;
58 PortCombos input_combos;
59 PortCombos output_combos;
61 struct MidiPortColumns : public Gtk::TreeModel::ColumnRecord {
66 Gtk::TreeModelColumn<std::string> short_name;
67 Gtk::TreeModelColumn<std::string> full_name;
70 struct AvailableActionColumns : public Gtk::TreeModel::ColumnRecord {
71 AvailableActionColumns() {
75 Gtk::TreeModelColumn<std::string> name;
76 Gtk::TreeModelColumn<std::string> path;
79 struct FunctionKeyColumns : public Gtk::TreeModel::ColumnRecord {
80 FunctionKeyColumns() {
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;
100 AvailableActionColumns available_action_columns;
101 FunctionKeyColumns function_key_columns;
102 MidiPortColumns midi_port_columns;
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;
109 Glib::RefPtr<Gtk::ListStore> build_midi_port_list (bool for_input);
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);
117 void surface_combo_changed ();
118 void profile_combo_changed ();
119 void ipmidi_spinner_changed ();
121 std::map<std::string,std::string> action_map; // map from action names to paths
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;
133 void discover_clicked ();
134 void recalibrate_faders ();
135 void toggle_backlight ();
136 void touch_sensitive_change ();
138 Gtk::Widget* device_dependent_widget ();
139 Gtk::Widget* _device_dependent_widget;
140 int device_dependent_row;
142 PBD::ScopedConnection device_change_connection;
143 void device_changed ();
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);
150 PBD::ScopedConnection connection_change_connection;
151 void connection_handler ();
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);