2 * Copyright (C) 2006-2007 John Anderson
3 * Copyright (C) 2011 Carl Hetherington <carl@carlh.net>
4 * Copyright (C) 2012-2019 Paul Davis <paul@linuxaudiosystems.com>
5 * Copyright (C) 2014-2015 Robin Gareus <robin@gareus.org>
6 * Copyright (C) 2015-2017 Len Ovens <len@ovenwerks.net>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include <gtkmm/comboboxtext.h>
24 #include <gtkmm/box.h>
25 #include <gtkmm/spinbutton.h>
26 #include <gtkmm/table.h>
27 #include <gtkmm/treeview.h>
28 #include <gtkmm/liststore.h>
29 #include <gtkmm/treestore.h>
30 #include <gtkmm/notebook.h>
31 #include <gtkmm/cellrenderercombo.h>
32 #include <gtkmm/scale.h>
33 #include <gtkmm/alignment.h>
35 #include "pbd/error.h"
36 #include "pbd/unwind.h"
37 #include "pbd/strsplit.h"
38 #include "pbd/stacktrace.h"
40 #include "gtkmm2ext/actions.h"
41 #include "gtkmm2ext/action_model.h"
42 #include "gtkmm2ext/bindings.h"
43 #include "gtkmm2ext/gui_thread.h"
44 #include "gtkmm2ext/utils.h"
46 #include "ardour/audioengine.h"
47 #include "ardour/port.h"
48 #include "ardour/rc_configuration.h"
50 #include "mackie_control_protocol.h"
51 #include "device_info.h"
54 #include "surface_port.h"
60 using namespace ArdourSurface;
61 using namespace Mackie;
64 MackieControlProtocol::get_gui () const
67 const_cast<MackieControlProtocol*>(this)->build_gui ();
69 static_cast<Gtk::Notebook*>(_gui)->show_all();
74 MackieControlProtocol::tear_down_gui ()
77 Gtk::Widget *w = static_cast<Gtk::Widget*>(_gui)->get_parent();
83 delete (MackieControlProtocolGUI*) _gui;
88 MackieControlProtocol::build_gui ()
90 _gui = (void *) new MackieControlProtocolGUI (*this);
93 MackieControlProtocolGUI::MackieControlProtocolGUI (MackieControlProtocol& p)
96 , action_model (ActionManager::ActionModel::instance ())
97 , touch_sensitivity_adjustment (0, 0, 9, 1, 4)
98 , touch_sensitivity_scale (touch_sensitivity_adjustment)
99 , recalibrate_fader_button (_("Recalibrate Faders"))
100 , ipmidi_base_port_adjustment (_cp.ipmidi_base(), 0, 32767, 1, 1000)
101 , discover_button (_("Discover Mackie Devices"))
102 , _device_dependent_widget (0)
103 , _ignore_profile_changed (false)
104 , ignore_active_change (false)
107 Gtk::Alignment* align;
110 set_border_width (12);
112 table.set_row_spacings (4);
113 table.set_col_spacings (6);
114 table.set_border_width (12);
115 table.set_homogeneous (false);
117 l = manage (new Gtk::Label (_("Device Type:")));
118 l->set_alignment (1.0, 0.5);
119 table.attach (*l, 0, 1, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
120 table.attach (_surface_combo, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
123 vector<string> surfaces;
125 for (std::map<std::string,DeviceInfo>::iterator i = DeviceInfo::device_info.begin(); i != DeviceInfo::device_info.end(); ++i) {
126 surfaces.push_back (i->first);
128 Gtkmm2ext::set_popdown_strings (_surface_combo, surfaces);
129 _surface_combo.signal_changed().connect (sigc::mem_fun (*this, &MackieControlProtocolGUI::surface_combo_changed));
131 _cp.DeviceChanged.connect (device_change_connection, invalidator (*this), boost::bind (&MackieControlProtocolGUI::device_changed, this), gui_context());
132 _cp.ConnectionChange.connect (connection_change_connection, invalidator (*this), boost::bind (&MackieControlProtocolGUI::connection_handler, this), gui_context());
134 ipmidi_base_port_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &MackieControlProtocolGUI::ipmidi_spinner_changed));
136 /* device-dependent part */
138 device_dependent_row = row;
140 if (_device_dependent_widget) {
141 table.remove (*_device_dependent_widget);
142 _device_dependent_widget = 0;
145 _device_dependent_widget = device_dependent_widget ();
146 table.attach (*_device_dependent_widget, 0, 12, row, row+1, AttachOptions(0), AttachOptions(0), 0, 0);
149 /* back to the boilerplate */
151 RadioButtonGroup rb_group = absolute_touch_mode_button.get_group();
152 touch_move_mode_button.set_group (rb_group);
154 recalibrate_fader_button.signal_clicked().connect (sigc::mem_fun (*this, &MackieControlProtocolGUI::recalibrate_faders));
155 backlight_button.signal_clicked().connect (sigc::mem_fun (*this, &MackieControlProtocolGUI::toggle_backlight));
157 touch_sensitivity_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &MackieControlProtocolGUI::touch_sensitive_change));
158 touch_sensitivity_scale.set_update_policy (Gtk::UPDATE_DISCONTINUOUS);
160 l = manage (new Gtk::Label (_("Button click")));
161 l->set_alignment (1.0, 0.5);
162 table.attach (*l, 0, 1, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
163 align = manage (new Alignment);
164 align->set (0.0, 0.5);
165 align->add (relay_click_button);
166 table.attach (*align, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
169 l = manage (new Gtk::Label (_("Backlight")));
170 l->set_alignment (1.0, 0.5);
171 table.attach (*l, 0, 1, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
172 align = manage (new Alignment);
173 align->set (0.0, 0.5);
174 align->add (backlight_button);
175 table.attach (*align, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
178 l = manage (new Gtk::Label (_("Send Fader Position Only When Touched")));
179 l->set_alignment (1.0, 0.5);
180 table.attach (*l, 0, 1, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
181 align = manage (new Alignment);
182 align->set (0.0, 0.5);
183 align->add (absolute_touch_mode_button);
184 table.attach (*align, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
187 l = manage (new Gtk::Label (_("Send Fader Position When Moved")));
188 l->set_alignment (1.0, 0.5);
189 table.attach (*l, 0, 1, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
190 align = manage (new Alignment);
191 align->set (0.0, 0.5);
192 align->add (touch_move_mode_button);
193 table.attach (*align, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
196 l = manage (new Gtk::Label (_("Fader Touch Sense Sensitivity")));
197 l->set_alignment (1.0, 0.5);
198 table.attach (*l, 0, 1, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
199 touch_sensitivity_scale.property_digits() = 0;
200 touch_sensitivity_scale.property_draw_value() = false;
201 table.attach (touch_sensitivity_scale, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
203 table.attach (recalibrate_fader_button, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
207 table.attach (discover_button, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
208 discover_button.signal_clicked().connect (sigc::mem_fun (*this, &MackieControlProtocolGUI::discover_clicked));
211 vector<string> profiles;
213 for (std::map<std::string,DeviceProfile>::iterator i = DeviceProfile::device_profiles.begin(); i != DeviceProfile::device_profiles.end(); ++i) {
214 cerr << "add discovered profile " << i->first << endl;
215 profiles.push_back (i->first);
217 Gtkmm2ext::set_popdown_strings (_profile_combo, profiles);
218 cerr << "set active profile from " << p.device_profile().name() << endl;
219 _profile_combo.set_active_text (p.device_profile().name());
220 _profile_combo.signal_changed().connect (sigc::mem_fun (*this, &MackieControlProtocolGUI::profile_combo_changed));
222 append_page (table, _("Device Setup"));
225 /* function key editor */
227 VBox* fkey_packer = manage (new VBox);
228 HBox* profile_packer = manage (new HBox);
229 HBox* observation_packer = manage (new HBox);
231 l = manage (new Gtk::Label (_("Profile/Settings:")));
232 profile_packer->pack_start (*l, false, false);
233 profile_packer->pack_start (_profile_combo, true, true);
234 profile_packer->set_spacing (12);
235 profile_packer->set_border_width (12);
237 l = manage (new Gtk::Label (_("* Button available at the original Mackie MCU PRO or current device if enabled (NOT implemented yet). Device specific name presented.")));
238 observation_packer->pack_start (*l, false, false);
240 fkey_packer->pack_start (*profile_packer, false, false);
241 fkey_packer->pack_start (function_key_scroller, true, true);
242 fkey_packer->pack_start (*observation_packer, false, false);
243 fkey_packer->set_spacing (12);
244 function_key_scroller.property_shadow_type() = Gtk::SHADOW_NONE;
245 function_key_scroller.add (function_key_editor);
246 append_page (*fkey_packer, _("Function Keys"));
248 build_function_key_editor ();
249 refresh_function_key_editor ();
250 fkey_packer->show_all();
254 MackieControlProtocolGUI::connection_handler ()
256 /* ignore all changes to combobox active strings here, because we're
257 updating them to match a new ("external") reality - we were called
258 because port connections have changed.
261 PBD::Unwinder<bool> ici (ignore_active_change, true);
263 vector<Gtk::ComboBox*>::iterator ic;
264 vector<Gtk::ComboBox*>::iterator oc;
266 vector<string> midi_inputs;
267 vector<string> midi_outputs;
269 ARDOUR::AudioEngine::instance()->get_ports ("", ARDOUR::DataType::MIDI, ARDOUR::PortFlags (ARDOUR::IsOutput|ARDOUR::IsTerminal), midi_inputs);
270 ARDOUR::AudioEngine::instance()->get_ports ("", ARDOUR::DataType::MIDI, ARDOUR::PortFlags (ARDOUR::IsInput|ARDOUR::IsTerminal), midi_outputs);
272 for (ic = input_combos.begin(), oc = output_combos.begin(); ic != input_combos.end() && oc != output_combos.end(); ++ic, ++oc) {
274 boost::shared_ptr<Surface> surface = _cp.get_surface_by_raw_pointer ((*ic)->get_data ("surface"));
277 update_port_combos (midi_inputs, midi_outputs, *ic, *oc, surface);
283 MackieControlProtocolGUI::update_port_combos (vector<string> const& midi_inputs, vector<string> const& midi_outputs,
284 Gtk::ComboBox* input_combo,
285 Gtk::ComboBox* output_combo,
286 boost::shared_ptr<Surface> surface)
288 Glib::RefPtr<Gtk::ListStore> input = build_midi_port_list (midi_inputs, true);
289 Glib::RefPtr<Gtk::ListStore> output = build_midi_port_list (midi_outputs, false);
290 bool input_found = false;
291 bool output_found = false;
294 input_combo->set_model (input);
295 output_combo->set_model (output);
297 Gtk::TreeModel::Children children = input->children();
298 Gtk::TreeModel::Children::iterator i;
299 i = children.begin();
300 ++i; /* skip "Disconnected" */
303 for (n = 1; i != children.end(); ++i, ++n) {
304 string port_name = (*i)[midi_port_columns.full_name];
305 if (surface->port().input().connected_to (port_name)) {
306 input_combo->set_active (n);
313 input_combo->set_active (0); /* disconnected */
316 children = output->children();
317 i = children.begin();
318 ++i; /* skip "Disconnected" */
320 for (n = 1; i != children.end(); ++i, ++n) {
321 string port_name = (*i)[midi_port_columns.full_name];
322 if (surface->port().output().connected_to (port_name)) {
323 output_combo->set_active (n);
330 output_combo->set_active (0); /* disconnected */
335 MackieControlProtocolGUI::device_dependent_widget ()
337 Gtk::Table* dd_table;
341 uint32_t n_surfaces = 1 + _cp.device_info().extenders();
342 uint32_t main_pos = _cp.device_info().master_position();
344 if (!_cp.device_info().uses_ipmidi()) {
345 dd_table = Gtk::manage (new Gtk::Table (n_surfaces, 2));
347 dd_table = Gtk::manage (new Gtk::Table (1, 2));
350 dd_table = Gtk::manage (new Gtk::Table (2, n_surfaces));
351 dd_table->set_row_spacings (4);
352 dd_table->set_col_spacings (6);
353 dd_table->set_border_width (12);
355 _surface_combo.set_active_text (_cp.device_info().name());
357 vector<string> midi_inputs;
358 vector<string> midi_outputs;
360 ARDOUR::AudioEngine::instance()->get_ports ("", ARDOUR::DataType::MIDI, ARDOUR::PortFlags (ARDOUR::IsOutput|ARDOUR::IsPhysical), midi_inputs);
361 ARDOUR::AudioEngine::instance()->get_ports ("", ARDOUR::DataType::MIDI, ARDOUR::PortFlags (ARDOUR::IsInput|ARDOUR::IsPhysical), midi_outputs);
363 input_combos.clear ();
364 output_combos.clear ();
366 if (!_cp.device_info().uses_ipmidi()) {
368 for (uint32_t n = 0; n < n_surfaces; ++n) {
370 boost::shared_ptr<Surface> surface = _cp.nth_surface (n);
373 PBD::fatal << string_compose (_("programming error: %1\n"), string_compose ("n=%1 surface not found!", n)) << endmsg;
374 abort (); /*NOTREACHED*/
377 Gtk::ComboBox* input_combo = manage (new Gtk::ComboBox);
378 Gtk::ComboBox* output_combo = manage (new Gtk::ComboBox);
380 update_port_combos (midi_inputs, midi_outputs, input_combo, output_combo, surface);
382 input_combo->pack_start (midi_port_columns.short_name);
383 input_combo->set_data ("surface", surface.get());
384 input_combos.push_back (input_combo);
385 output_combo->pack_start (midi_port_columns.short_name);
386 output_combo->set_data ("surface", surface.get());
387 output_combos.push_back (output_combo);
389 boost::weak_ptr<Surface> ws (surface);
390 input_combo->signal_changed().connect (sigc::bind (sigc::mem_fun (*this, &MackieControlProtocolGUI::active_port_changed), input_combo, ws, true));
391 output_combo->signal_changed().connect (sigc::bind (sigc::mem_fun (*this, &MackieControlProtocolGUI::active_port_changed), output_combo, ws, false));
394 string receive_string;
396 if (n_surfaces > 1) {
398 send_string = string_compose(_("Main surface at position %1 sends via:"), n + 1);
399 receive_string = string_compose(_("Main surface at position %1 receives via:"), n + 1);
401 send_string = string_compose (_("Extender at position %1 sends via:"), n + 1);
402 receive_string = string_compose (_("Extender at position %1 receives via:"), n + 1);
405 send_string = _("Surface sends via:");
406 receive_string = _("Surface receives via:");
409 l = manage (new Gtk::Label (send_string));
410 l->set_alignment (1.0, 0.5);
411 dd_table->attach (*l, 0, 1, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
412 dd_table->attach (*input_combo, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
415 l = manage (new Gtk::Label (receive_string));
416 l->set_alignment (1.0, 0.5);
417 dd_table->attach (*l, 0, 1, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
418 dd_table->attach (*output_combo, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
424 l = manage (new Gtk::Label (_("ipMIDI Port (lowest)")));
425 l->set_alignment (1.0, 0.5);
427 Gtk::SpinButton* ipmidi_base_port_spinner = manage (new Gtk::SpinButton (ipmidi_base_port_adjustment));
428 dd_table->attach (*l, 0, 1, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
429 dd_table->attach (*ipmidi_base_port_spinner, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
437 MackieControlProtocolGUI::make_action_renderer (Glib::RefPtr<TreeStore> model, Gtk::TreeModelColumnBase column)
439 CellRendererCombo* renderer = manage (new CellRendererCombo);
440 renderer->property_model() = model;
441 renderer->property_editable() = true;
442 renderer->property_text_column() = 0;
443 renderer->property_has_entry() = false;
444 renderer->signal_edited().connect (sigc::bind (sigc::mem_fun(*this, &MackieControlProtocolGUI::action_changed), column));
450 MackieControlProtocolGUI::build_function_key_editor ()
452 function_key_editor.append_column (_("Key"), function_key_columns.name);
455 CellRendererCombo* renderer;
457 renderer = make_action_renderer (action_model.model(), function_key_columns.plain);
458 col = manage (new TreeViewColumn (_("Plain"), *renderer));
459 col->add_attribute (renderer->property_text(), function_key_columns.plain);
460 function_key_editor.append_column (*col);
462 renderer = make_action_renderer (action_model.model(), function_key_columns.shift);
463 col = manage (new TreeViewColumn (_("Shift"), *renderer));
464 col->add_attribute (renderer->property_text(), function_key_columns.shift);
465 function_key_editor.append_column (*col);
467 renderer = make_action_renderer (action_model.model(), function_key_columns.control);
468 col = manage (new TreeViewColumn (_("Control"), *renderer));
469 col->add_attribute (renderer->property_text(), function_key_columns.control);
470 function_key_editor.append_column (*col);
472 renderer = make_action_renderer (action_model.model(), function_key_columns.option);
473 col = manage (new TreeViewColumn (_("Option"), *renderer));
474 col->add_attribute (renderer->property_text(), function_key_columns.option);
475 function_key_editor.append_column (*col);
477 renderer = make_action_renderer (action_model.model(), function_key_columns.cmdalt);
478 col = manage (new TreeViewColumn (_("Cmd/Alt"), *renderer));
479 col->add_attribute (renderer->property_text(), function_key_columns.cmdalt);
480 function_key_editor.append_column (*col);
482 renderer = make_action_renderer (action_model.model(), function_key_columns.shiftcontrol);
483 col = manage (new TreeViewColumn (_("Shift+Control"), *renderer));
484 col->add_attribute (renderer->property_text(), function_key_columns.shiftcontrol);
485 function_key_editor.append_column (*col);
487 function_key_model = ListStore::create (function_key_columns);
488 function_key_editor.set_model (function_key_model);
492 MackieControlProtocolGUI::refresh_function_key_editor ()
494 function_key_editor.set_model (Glib::RefPtr<TreeModel>());
495 function_key_model->clear ();
497 /* now fill with data */
500 DeviceProfile dp (_cp.device_profile());
503 for (int n = 0; n < Mackie::Button::FinalGlobalButton; ++n) {
505 Mackie::Button::ID bid = (Mackie::Button::ID) n;
507 row = *(function_key_model->append());
508 if (di.global_buttons().find (bid) == di.global_buttons().end()) {
509 row[function_key_columns.name] = Mackie::Button::id_to_name (bid);
511 row[function_key_columns.name] = di.get_global_button_name (bid) + "*";
513 row[function_key_columns.id] = bid;
515 Glib::RefPtr<Gtk::Action> act;
517 const string defstring = "\u2022";
519 /* We only allow plain bindings for Fn keys. All others are
520 * reserved for hard-coded actions.
523 if (bid >= Mackie::Button::F1 && bid <= Mackie::Button::F8) {
525 action = dp.get_button_action (bid, 0);
526 if (action.empty()) {
527 row[function_key_columns.plain] = defstring;
529 if (action.find ('/') == string::npos) {
530 /* Probably a key alias */
531 row[function_key_columns.plain] = action;
534 act = ActionManager::get_action (action, false);
536 row[function_key_columns.plain] = act->get_label();
538 row[function_key_columns.plain] = defstring;
544 /* We only allow plain bindings for Fn keys. All others are
545 * reserved for hard-coded actions.
548 if (bid >= Mackie::Button::F1 && bid <= Mackie::Button::F8) {
550 action = dp.get_button_action (bid, MackieControlProtocol::MODIFIER_SHIFT);
551 if (action.empty()) {
552 row[function_key_columns.shift] = defstring;
554 if (action.find ('/') == string::npos) {
555 /* Probably a key alias */
556 row[function_key_columns.shift] = action;
558 act = ActionManager::get_action (action, false);
560 row[function_key_columns.shift] = act->get_label();
562 row[function_key_columns.shift] = defstring;
568 action = dp.get_button_action (bid, MackieControlProtocol::MODIFIER_CONTROL);
569 if (action.empty()) {
570 row[function_key_columns.control] = defstring;
572 if (action.find ('/') == string::npos) {
573 /* Probably a key alias */
574 row[function_key_columns.control] = action;
576 act = ActionManager::get_action (action, false);
578 row[function_key_columns.control] = act->get_label();
580 row[function_key_columns.control] = defstring;
585 action = dp.get_button_action (bid, MackieControlProtocol::MODIFIER_OPTION);
586 if (action.empty()) {
587 row[function_key_columns.option] = defstring;
589 if (action.find ('/') == string::npos) {
590 /* Probably a key alias */
591 row[function_key_columns.option] = action;
593 act = ActionManager::get_action (action, false);
595 row[function_key_columns.option] = act->get_label();
597 row[function_key_columns.option] = defstring;
602 action = dp.get_button_action (bid, MackieControlProtocol::MODIFIER_CMDALT);
603 if (action.empty()) {
604 row[function_key_columns.cmdalt] = defstring;
606 if (action.find ('/') == string::npos) {
607 /* Probably a key alias */
608 row[function_key_columns.cmdalt] = action;
610 act = ActionManager::get_action (action, false);
612 row[function_key_columns.cmdalt] = act->get_label();
614 row[function_key_columns.cmdalt] = defstring;
619 action = dp.get_button_action (bid, (MackieControlProtocol::MODIFIER_SHIFT|MackieControlProtocol::MODIFIER_CONTROL));
620 if (action.empty()) {
621 row[function_key_columns.shiftcontrol] = defstring;
623 act = ActionManager::get_action (action, false);
625 row[function_key_columns.shiftcontrol] = act->get_label();
627 row[function_key_columns.shiftcontrol] = defstring;
632 function_key_editor.set_model (function_key_model);
636 MackieControlProtocolGUI::action_changed (const Glib::ustring &sPath, const Glib::ustring &text, TreeModelColumnBase col)
638 // Remove Binding is not in the action map but still valid
640 if ( text == "Remove Binding") {
643 Gtk::TreePath path(sPath);
644 Gtk::TreeModel::iterator row = function_key_model->get_iter(path);
648 std::map<std::string,std::string>::iterator i = action_map.find (text);
650 if (i == action_map.end()) {
655 Glib::RefPtr<Gtk::Action> act = ActionManager::get_action (i->second, false);
658 /* update visible text, using string supplied by
659 available action model so that it matches and is found
663 Glib::ustring dot = "\u2022";
664 (*row).set_value (col.index(), dot);
666 (*row).set_value (col.index(), text);
669 /* update the current DeviceProfile, using the full
675 switch (col.index()) {
677 modifier = MackieControlProtocol::MODIFIER_SHIFT;
680 modifier = MackieControlProtocol::MODIFIER_CONTROL;
683 modifier = MackieControlProtocol::MODIFIER_OPTION;
686 modifier = MackieControlProtocol::MODIFIER_CMDALT;
689 modifier = (MackieControlProtocol::MODIFIER_SHIFT|MackieControlProtocol::MODIFIER_CONTROL);
696 _cp.device_profile().set_button_action ((*row)[function_key_columns.id], modifier, "");
698 _cp.device_profile().set_button_action ((*row)[function_key_columns.id], modifier, i->second);
701 _ignore_profile_changed = true;
702 _profile_combo.set_active_text ( _cp.device_profile().name() );
703 _ignore_profile_changed = false;
706 std::cerr << "no such action\n";
712 MackieControlProtocolGUI::surface_combo_changed ()
714 _cp.set_device (_surface_combo.get_active_text(), false);
718 MackieControlProtocolGUI::device_changed ()
720 if (_device_dependent_widget) {
721 table.remove (*_device_dependent_widget);
722 _device_dependent_widget = 0;
725 _device_dependent_widget = device_dependent_widget ();
726 _device_dependent_widget->show_all ();
728 table.attach (*_device_dependent_widget, 0, 12, device_dependent_row, device_dependent_row+1, AttachOptions(0), AttachOptions(0), 0, 0);
732 MackieControlProtocolGUI::profile_combo_changed ()
734 if (!_ignore_profile_changed) {
735 string profile = _profile_combo.get_active_text();
737 _cp.set_profile (profile);
739 refresh_function_key_editor ();
744 MackieControlProtocolGUI::ipmidi_spinner_changed ()
746 _cp.set_ipmidi_base ((int16_t) lrintf (ipmidi_base_port_adjustment.get_value()));
750 MackieControlProtocolGUI::discover_clicked ()
752 /* this should help to get things started */
757 MackieControlProtocolGUI::recalibrate_faders ()
759 _cp.recalibrate_faders ();
763 MackieControlProtocolGUI::toggle_backlight ()
765 _cp.toggle_backlight ();
769 MackieControlProtocolGUI::touch_sensitive_change ()
771 int sensitivity = (int) touch_sensitivity_adjustment.get_value ();
772 _cp.set_touch_sensitivity (sensitivity);
775 Glib::RefPtr<Gtk::ListStore>
776 MackieControlProtocolGUI::build_midi_port_list (vector<string> const & ports, bool for_input)
778 Glib::RefPtr<Gtk::ListStore> store = ListStore::create (midi_port_columns);
781 row = *store->append ();
782 row[midi_port_columns.full_name] = string();
783 row[midi_port_columns.short_name] = _("Disconnected");
785 for (vector<string>::const_iterator p = ports.begin(); p != ports.end(); ++p) {
786 row = *store->append ();
787 row[midi_port_columns.full_name] = *p;
788 std::string pn = ARDOUR::AudioEngine::instance()->get_pretty_name_by_name (*p);
790 pn = (*p).substr ((*p).find (':') + 1);
792 row[midi_port_columns.short_name] = pn;
799 MackieControlProtocolGUI::active_port_changed (Gtk::ComboBox* combo, boost::weak_ptr<Surface> ws, bool for_input)
801 if (ignore_active_change) {
805 boost::shared_ptr<Surface> surface = ws.lock();
811 TreeModel::iterator active = combo->get_active ();
812 string new_port = (*active)[midi_port_columns.full_name];
814 if (new_port.empty()) {
816 surface->port().input().disconnect_all ();
818 surface->port().output().disconnect_all ();
825 if (!surface->port().input().connected_to (new_port)) {
826 surface->port().input().disconnect_all ();
827 surface->port().input().connect (new_port);
830 if (!surface->port().output().connected_to (new_port)) {
831 surface->port().output().disconnect_all ();
832 surface->port().output().connect (new_port);