1 #include <gtkmm/liststore.h>
2 #include <gtkmm/stock.h>
3 #include <gtkmm/scale.h>
4 #include <gtkmm2ext/utils.h>
5 #include <gtkmm2ext/slider_controller.h>
7 #include "midi++/manager.h"
8 #include "midi++/factory.h"
10 #include "ardour/rc_configuration.h"
11 #include "ardour/control_protocol_manager.h"
12 #include "control_protocol/control_protocol.h"
14 #include "gui_thread.h"
15 #include "midi_tracer.h"
16 #include "rc_option_editor.h"
18 #include "midi_port_dialog.h"
25 using namespace Gtkmm2ext;
27 using namespace ARDOUR;
29 class MIDIPorts : public OptionEditorBox
32 MIDIPorts (RCConfiguration* c, list<ComboOption<string>* > const & o)
34 _add_port_button (Stock::ADD),
37 _store = ListStore::create (_model);
38 _view.set_model (_store);
39 _view.append_column (_("Name"), _model.name);
40 _view.get_column(0)->set_resizable (true);
41 _view.get_column(0)->set_expand (true);
42 _view.append_column_editable (_("Online"), _model.online);
43 _view.append_column_editable (_("Trace input"), _model.trace_input);
44 _view.append_column_editable (_("Trace output"), _model.trace_output);
46 HBox* h = manage (new HBox);
48 h->pack_start (_view, true, true);
50 VBox* v = manage (new VBox);
52 v->pack_start (_add_port_button, false, false);
53 h->pack_start (*v, false, false);
55 _box->pack_start (*h);
59 _store->signal_row_changed().connect (sigc::mem_fun (*this, &MIDIPorts::model_changed));
61 _add_port_button.signal_clicked().connect (sigc::mem_fun (*this, &MIDIPorts::add_port_clicked));
64 void parameter_changed (string const &) {}
65 void set_state_from_config () {}
69 typedef std::map<MIDI::Port*,MidiTracer*> PortTraceMap;
70 PortTraceMap port_input_trace_map;
71 PortTraceMap port_output_trace_map;
73 void model_changed (TreeModel::Path const &, TreeModel::iterator const & i)
75 TreeModel::Row r = *i;
77 MIDI::Port* port = r[_model.port];
84 if (r[_model.online] == port->input()->offline()) {
85 port->input()->set_offline (!r[_model.online]);
88 if (r[_model.trace_input] != port->input()->tracing()) {
89 PortTraceMap::iterator x = port_input_trace_map.find (port);
92 if (x == port_input_trace_map.end()) {
93 mt = new MidiTracer (port->name() + string (" [input]"), *port->input());
94 port_input_trace_map.insert (pair<MIDI::Port*,MidiTracer*> (port, mt));
102 if (port->output()) {
104 if (r[_model.trace_output] != port->output()->tracing()) {
105 PortTraceMap::iterator x = port_output_trace_map.find (port);
108 if (x == port_output_trace_map.end()) {
109 mt = new MidiTracer (port->name() + string (" [output]"), *port->output());
110 port_output_trace_map.insert (pair<MIDI::Port*,MidiTracer*> (port, mt));
120 void setup_ports_combo (ComboOption<string>* c)
123 MIDI::Manager::PortList const & ports = MIDI::Manager::instance()->get_midi_ports ();
124 for (MIDI::Manager::PortList::const_iterator i = ports.begin(); i != ports.end(); ++i) {
125 c->add ((*i)->name(), (*i)->name());
129 void ports_changed ()
131 /* XXX: why is this coming from here? */
132 MIDI::Manager::PortList const & ports = MIDI::Manager::instance()->get_midi_ports ();
135 port_connections.drop_connections ();
137 for (MIDI::Manager::PortList::const_iterator i = ports.begin(); i != ports.end(); ++i) {
139 TreeModel::Row r = *_store->append ();
141 r[_model.name] = (*i)->name();
144 r[_model.online] = !(*i)->input()->offline();
145 (*i)->input()->OfflineStatusChanged.connect (port_connections, boost::bind (&MIDIPorts::port_offline_changed, this, (*i)), gui_context());
146 r[_model.trace_input] = (*i)->input()->tracing();
149 if ((*i)->output()) {
150 r[_model.trace_output] = (*i)->output()->tracing();
153 r[_model.port] = (*i);
156 for (list<ComboOption<string>* >::iterator i = _port_combos.begin(); i != _port_combos.end(); ++i) {
157 setup_ports_combo (*i);
161 void port_offline_changed (MIDI::Port* p)
167 for (TreeModel::Children::iterator i = _store->children().begin(); i != _store->children().end(); ++i) {
168 if ((*i)[_model.port] == p) {
169 (*i)[_model.online] = !p->input()->offline();
174 void add_port_clicked ()
176 MidiPortDialog dialog;
178 dialog.set_position (WIN_POS_MOUSE);
182 int const r = dialog.run ();
185 case RESPONSE_ACCEPT:
192 Glib::ustring const mode = dialog.port_mode_combo.get_active_text ();
195 if (mode == _("input")) {
197 } else if (mode == (_("output"))) {
203 XMLNode node (X_("MIDI-port"));
205 node.add_property ("tag", dialog.port_name.get_text());
206 node.add_property ("device", X_("ardour")); // XXX this can't be right for all types
207 node.add_property ("type", MIDI::PortFactory::default_port_type());
208 node.add_property ("mode", smod);
210 if (MIDI::Manager::instance()->add_port (node) != 0) {
211 cerr << " there are now " << MIDI::Manager::instance()->nports() << endl;
216 class MIDIModelColumns : public TreeModelColumnRecord
228 TreeModelColumn<string> name;
229 TreeModelColumn<bool> online;
230 TreeModelColumn<bool> trace_input;
231 TreeModelColumn<bool> trace_output;
232 TreeModelColumn<MIDI::Port*> port;
235 RCConfiguration* _rc_config;
236 Glib::RefPtr<ListStore> _store;
237 MIDIModelColumns _model;
239 Button _add_port_button;
240 ComboBoxText _mtc_combo;
241 ComboBoxText _midi_clock_combo;
242 ComboBoxText _mmc_combo;
243 ComboBoxText _mpc_combo;
244 list<ComboOption<string>* > _port_combos;
245 PBD::ScopedConnectionList port_connections;
249 class ClickOptions : public OptionEditorBox
252 ClickOptions (RCConfiguration* c, ArdourDialog* p)
256 Table* t = manage (new Table (2, 3));
259 Label* l = manage (new Label (_("Click audio file:")));
260 l->set_alignment (0, 0.5);
261 t->attach (*l, 0, 1, 0, 1, FILL);
262 t->attach (_click_path_entry, 1, 2, 0, 1, FILL);
263 Button* b = manage (new Button (_("Browse...")));
264 b->signal_clicked().connect (sigc::mem_fun (*this, &ClickOptions::click_browse_clicked));
265 t->attach (*b, 2, 3, 0, 1, FILL);
267 l = manage (new Label (_("Click emphasis audio file:")));
268 l->set_alignment (0, 0.5);
269 t->attach (*l, 0, 1, 1, 2, FILL);
270 t->attach (_click_emphasis_path_entry, 1, 2, 1, 2, FILL);
271 b = manage (new Button (_("Browse...")));
272 b->signal_clicked().connect (sigc::mem_fun (*this, &ClickOptions::click_emphasis_browse_clicked));
273 t->attach (*b, 2, 3, 1, 2, FILL);
275 _box->pack_start (*t, false, false);
278 void parameter_changed (string const & p)
280 if (p == "click-sound") {
281 _click_path_entry.set_text (_rc_config->get_click_sound());
282 } else if (p == "click-emphasis-sound") {
283 _click_emphasis_path_entry.set_text (_rc_config->get_click_emphasis_sound());
287 void set_state_from_config ()
289 parameter_changed ("click-sound");
290 parameter_changed ("click-emphasis-sound");
295 void click_browse_clicked ()
297 SoundFileChooser sfdb (*_parent, _("Choose Click"));
302 if (sfdb.run () == RESPONSE_OK) {
303 click_chosen (sfdb.get_filename());
307 void click_chosen (string const & path)
309 _click_path_entry.set_text (path);
310 _rc_config->set_click_sound (path);
313 void click_emphasis_browse_clicked ()
315 SoundFileChooser sfdb (*_parent, _("Choose Click Emphasis"));
320 if (sfdb.run () == RESPONSE_OK) {
321 click_emphasis_chosen (sfdb.get_filename());
325 void click_emphasis_chosen (string const & path)
327 _click_emphasis_path_entry.set_text (path);
328 _rc_config->set_click_emphasis_sound (path);
331 RCConfiguration* _rc_config;
332 ArdourDialog* _parent;
333 Entry _click_path_entry;
334 Entry _click_emphasis_path_entry;
337 class UndoOptions : public OptionEditorBox
340 UndoOptions (RCConfiguration* c) :
342 _limit_undo_button (_("Limit undo history to")),
343 _save_undo_button (_("Save undo history of"))
345 Table* t = new Table (2, 3);
348 t->attach (_limit_undo_button, 0, 1, 0, 1, FILL);
349 _limit_undo_spin.set_range (0, 512);
350 _limit_undo_spin.set_increments (1, 10);
351 t->attach (_limit_undo_spin, 1, 2, 0, 1, FILL | EXPAND);
352 Label* l = manage (new Label (_("commands")));
353 l->set_alignment (0, 0.5);
354 t->attach (*l, 2, 3, 0, 1);
356 t->attach (_save_undo_button, 0, 1, 1, 2, FILL);
357 _save_undo_spin.set_range (0, 512);
358 _save_undo_spin.set_increments (1, 10);
359 t->attach (_save_undo_spin, 1, 2, 1, 2, FILL | EXPAND);
360 l = manage (new Label (_("commands")));
361 l->set_alignment (0, 0.5);
362 t->attach (*l, 2, 3, 1, 2);
364 _box->pack_start (*t);
366 _limit_undo_button.signal_toggled().connect (sigc::mem_fun (*this, &UndoOptions::limit_undo_toggled));
367 _limit_undo_spin.signal_value_changed().connect (sigc::mem_fun (*this, &UndoOptions::limit_undo_changed));
368 _save_undo_button.signal_toggled().connect (sigc::mem_fun (*this, &UndoOptions::save_undo_toggled));
369 _save_undo_spin.signal_value_changed().connect (sigc::mem_fun (*this, &UndoOptions::save_undo_changed));
372 void parameter_changed (string const & p)
374 if (p == "history-depth") {
375 int32_t const d = _rc_config->get_history_depth();
376 _limit_undo_button.set_active (d != 0);
377 _limit_undo_spin.set_sensitive (d != 0);
378 _limit_undo_spin.set_value (d);
379 } else if (p == "save-history") {
380 bool const x = _rc_config->get_save_history ();
381 _save_undo_button.set_active (x);
382 _save_undo_spin.set_sensitive (x);
383 } else if (p == "save-history-depth") {
384 _save_undo_spin.set_value (_rc_config->get_saved_history_depth());
388 void set_state_from_config ()
390 parameter_changed ("save-history");
391 parameter_changed ("history-depth");
392 parameter_changed ("save-history-depth");
395 void limit_undo_toggled ()
397 bool const x = _limit_undo_button.get_active ();
398 _limit_undo_spin.set_sensitive (x);
399 int32_t const n = x ? 16 : 0;
400 _limit_undo_spin.set_value (n);
401 _rc_config->set_history_depth (n);
404 void limit_undo_changed ()
406 _rc_config->set_history_depth (_limit_undo_spin.get_value_as_int ());
409 void save_undo_toggled ()
411 bool const x = _save_undo_button.get_active ();
412 _rc_config->set_save_history (x);
415 void save_undo_changed ()
417 _rc_config->set_saved_history_depth (_save_undo_spin.get_value_as_int ());
421 RCConfiguration* _rc_config;
422 CheckButton _limit_undo_button;
423 SpinButton _limit_undo_spin;
424 CheckButton _save_undo_button;
425 SpinButton _save_undo_spin;
430 static const struct {
442 { "Shift", GDK_SHIFT_MASK },
443 { "Command", GDK_META_MASK },
444 { "Control", GDK_CONTROL_MASK },
445 { "Option", GDK_MOD1_MASK },
446 { "Command-Shift", GDK_MOD1_MASK|GDK_SHIFT_MASK },
447 { "Command-Option", GDK_MOD1_MASK|GDK_MOD5_MASK },
448 { "Shift-Option", GDK_SHIFT_MASK|GDK_MOD5_MASK },
449 { "Shift-Command-Option", GDK_MOD5_MASK|GDK_SHIFT_MASK|GDK_MOD1_MASK },
452 { "Shift", GDK_SHIFT_MASK },
453 { "Control", GDK_CONTROL_MASK },
454 { "Alt (Mod1)", GDK_MOD1_MASK },
455 { "Control-Shift", GDK_CONTROL_MASK|GDK_SHIFT_MASK },
456 { "Control-Alt", GDK_CONTROL_MASK|GDK_MOD1_MASK },
457 { "Shift-Alt", GDK_SHIFT_MASK|GDK_MOD1_MASK },
458 { "Control-Shift-Alt", GDK_CONTROL_MASK|GDK_SHIFT_MASK|GDK_MOD1_MASK },
459 { "Mod2", GDK_MOD2_MASK },
460 { "Mod3", GDK_MOD3_MASK },
461 { "Mod4", GDK_MOD4_MASK },
462 { "Mod5", GDK_MOD5_MASK },
468 class KeyboardOptions : public OptionEditorBox
472 _delete_button_adjustment (3, 1, 12),
473 _delete_button_spin (_delete_button_adjustment),
474 _edit_button_adjustment (3, 1, 5),
475 _edit_button_spin (_edit_button_adjustment)
478 /* internationalize and prepare for use with combos */
481 for (int i = 0; modifiers[i].name; ++i) {
482 dumb.push_back (_(modifiers[i].name));
485 set_popdown_strings (_edit_modifier_combo, dumb);
486 _edit_modifier_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::edit_modifier_chosen));
488 for (int x = 0; modifiers[x].name; ++x) {
489 if (modifiers[x].modifier == Keyboard::edit_modifier ()) {
490 _edit_modifier_combo.set_active_text (_(modifiers[x].name));
495 Table* t = manage (new Table (4, 4));
498 Label* l = manage (new Label (_("Edit using:")));
499 l->set_name ("OptionsLabel");
500 l->set_alignment (0, 0.5);
502 t->attach (*l, 0, 1, 0, 1, FILL | EXPAND, FILL);
503 t->attach (_edit_modifier_combo, 1, 2, 0, 1, FILL | EXPAND, FILL);
505 l = manage (new Label (_("+ button")));
506 l->set_name ("OptionsLabel");
508 t->attach (*l, 3, 4, 0, 1, FILL | EXPAND, FILL);
509 t->attach (_edit_button_spin, 4, 5, 0, 1, FILL | EXPAND, FILL);
511 _edit_button_spin.set_name ("OptionsEntry");
512 _edit_button_adjustment.set_value (Keyboard::edit_button());
513 _edit_button_adjustment.signal_value_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::edit_button_changed));
515 set_popdown_strings (_delete_modifier_combo, dumb);
516 _delete_modifier_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::delete_modifier_chosen));
518 for (int x = 0; modifiers[x].name; ++x) {
519 if (modifiers[x].modifier == Keyboard::delete_modifier ()) {
520 _delete_modifier_combo.set_active_text (_(modifiers[x].name));
525 l = manage (new Label (_("Delete using:")));
526 l->set_name ("OptionsLabel");
527 l->set_alignment (0, 0.5);
529 t->attach (*l, 0, 1, 1, 2, FILL | EXPAND, FILL);
530 t->attach (_delete_modifier_combo, 1, 2, 1, 2, FILL | EXPAND, FILL);
532 l = manage (new Label (_("+ button")));
533 l->set_name ("OptionsLabel");
535 t->attach (*l, 3, 4, 1, 2, FILL | EXPAND, FILL);
536 t->attach (_delete_button_spin, 4, 5, 1, 2, FILL | EXPAND, FILL);
538 _delete_button_spin.set_name ("OptionsEntry");
539 _delete_button_adjustment.set_value (Keyboard::delete_button());
540 _delete_button_adjustment.signal_value_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::delete_button_changed));
542 set_popdown_strings (_snap_modifier_combo, dumb);
543 _snap_modifier_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::snap_modifier_chosen));
545 for (int x = 0; modifiers[x].name; ++x) {
546 if (modifiers[x].modifier == (guint) Keyboard::snap_modifier ()) {
547 _snap_modifier_combo.set_active_text (_(modifiers[x].name));
552 l = manage (new Label (_("Toggle snap using:")));
553 l->set_name ("OptionsLabel");
554 l->set_alignment (0, 0.5);
556 t->attach (*l, 0, 1, 2, 3, FILL | EXPAND, FILL);
557 t->attach (_snap_modifier_combo, 1, 2, 2, 3, FILL | EXPAND, FILL);
561 for (map<string,string>::iterator bf = Keyboard::binding_files.begin(); bf != Keyboard::binding_files.end(); ++bf) {
562 strs.push_back (bf->first);
565 set_popdown_strings (_keyboard_layout_selector, strs);
566 _keyboard_layout_selector.set_active_text (Keyboard::current_binding_name());
567 _keyboard_layout_selector.signal_changed().connect (sigc::mem_fun (*this, &KeyboardOptions::bindings_changed));
569 l = manage (new Label (_("Keyboard layout:")));
570 l->set_name ("OptionsLabel");
571 l->set_alignment (0, 0.5);
573 t->attach (*l, 0, 1, 3, 4, FILL | EXPAND, FILL);
574 t->attach (_keyboard_layout_selector, 1, 2, 3, 4, FILL | EXPAND, FILL);
576 _box->pack_start (*t, false, false);
579 void parameter_changed (string const &)
581 /* XXX: these aren't really config options... */
584 void set_state_from_config ()
586 /* XXX: these aren't really config options... */
591 void bindings_changed ()
593 string const txt = _keyboard_layout_selector.get_active_text();
595 /* XXX: config...? for all this keyboard stuff */
597 for (map<string,string>::iterator i = Keyboard::binding_files.begin(); i != Keyboard::binding_files.end(); ++i) {
598 if (txt == i->first) {
599 if (Keyboard::load_keybindings (i->second)) {
600 Keyboard::save_keybindings ();
606 void edit_modifier_chosen ()
608 string const txt = _edit_modifier_combo.get_active_text();
610 for (int i = 0; modifiers[i].name; ++i) {
611 if (txt == _(modifiers[i].name)) {
612 Keyboard::set_edit_modifier (modifiers[i].modifier);
618 void delete_modifier_chosen ()
620 string const txt = _delete_modifier_combo.get_active_text();
622 for (int i = 0; modifiers[i].name; ++i) {
623 if (txt == _(modifiers[i].name)) {
624 Keyboard::set_delete_modifier (modifiers[i].modifier);
630 void snap_modifier_chosen ()
632 string const txt = _snap_modifier_combo.get_active_text();
634 for (int i = 0; modifiers[i].name; ++i) {
635 if (txt == _(modifiers[i].name)) {
636 Keyboard::set_snap_modifier (modifiers[i].modifier);
642 void delete_button_changed ()
644 Keyboard::set_delete_button (_delete_button_spin.get_value_as_int());
647 void edit_button_changed ()
649 Keyboard::set_edit_button (_edit_button_spin.get_value_as_int());
652 ComboBoxText _keyboard_layout_selector;
653 ComboBoxText _edit_modifier_combo;
654 ComboBoxText _delete_modifier_combo;
655 ComboBoxText _snap_modifier_combo;
656 Adjustment _delete_button_adjustment;
657 SpinButton _delete_button_spin;
658 Adjustment _edit_button_adjustment;
659 SpinButton _edit_button_spin;
662 class FontScalingOptions : public OptionEditorBox
665 FontScalingOptions (RCConfiguration* c) :
667 _dpi_adjustment (50, 50, 250, 1, 10),
668 _dpi_slider (_dpi_adjustment)
670 _dpi_adjustment.set_value (_rc_config->get_font_scale () / 1024);
672 Label* l = manage (new Label (_("Font scaling:")));
673 l->set_name ("OptionsLabel");
675 _dpi_slider.set_update_policy (UPDATE_DISCONTINUOUS);
676 HBox* h = manage (new HBox);
678 h->pack_start (*l, false, false);
679 h->pack_start (_dpi_slider, true, true);
681 _box->pack_start (*h, false, false);
683 _dpi_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &FontScalingOptions::dpi_changed));
686 void parameter_changed (string const & p)
688 if (p == "font-scale") {
689 _dpi_adjustment.set_value (_rc_config->get_font_scale() / 1024);
693 void set_state_from_config ()
695 parameter_changed ("font-scale");
702 _rc_config->set_font_scale ((long) floor (_dpi_adjustment.get_value() * 1024));
703 /* XXX: should be triggered from the parameter changed signal */
707 RCConfiguration* _rc_config;
708 Adjustment _dpi_adjustment;
712 class SoloMuteOptions : public OptionEditorBox
715 SoloMuteOptions (RCConfiguration* c) :
717 // 0.781787 is the value needed for gain to be set to 0.
718 _db_adjustment (0.781787, 0.0, 1.0, 0.01, 0.1)
721 if ((pix = ::get_icon ("fader_belt_h")) == 0) {
722 throw failed_constructor();
725 _db_slider = manage (new HSliderController (pix,
731 parameter_changed ("solo-mute-gain");
733 Label* l = manage (new Label (_("Solo mute cut (dB):")));
734 l->set_name ("OptionsLabel");
736 HBox* h = manage (new HBox);
738 h->pack_start (*l, false, false);
739 h->pack_start (*_db_slider, false, false);
740 h->pack_start (_db_display, false, false);
742 set_size_request_to_display_given_text (_db_display, "-99.0", 12, 12);
744 _box->pack_start (*h, false, false);
746 _db_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &SoloMuteOptions::db_changed));
749 void parameter_changed (string const & p)
751 if (p == "solo-mute-gain") {
752 gain_t val = _rc_config->get_solo_mute_gain();
754 _db_adjustment.set_value (gain_to_slider_position (val));
759 snprintf (buf, sizeof (buf), "-inf");
761 snprintf (buf, sizeof (buf), "%.2f", accurate_coefficient_to_dB (val));
764 _db_display.set_text (buf);
768 void set_state_from_config ()
770 parameter_changed ("solo-mute-gain");
777 _rc_config->set_solo_mute_gain (slider_position_to_gain (_db_adjustment.get_value()));
780 RCConfiguration* _rc_config;
781 Adjustment _db_adjustment;
782 Gtkmm2ext::HSliderController* _db_slider;
783 Glib::RefPtr<Gdk::Pixbuf> pix;
788 class ControlSurfacesOptions : public OptionEditorBox
791 ControlSurfacesOptions (ArdourDialog& parent)
794 _store = ListStore::create (_model);
795 _view.set_model (_store);
796 _view.append_column (_("Name"), _model.name);
797 _view.get_column(0)->set_resizable (true);
798 _view.get_column(0)->set_expand (true);
799 _view.append_column_editable (_("Enabled"), _model.enabled);
800 _view.append_column_editable (_("Feedback"), _model.feedback);
802 _box->pack_start (_view, false, false);
804 Label* label = manage (new Label);
805 label->set_markup (string_compose (X_("<i>%1</i>"), _("Double-click on a name to edit settings for an enabled protocol")));
807 _box->pack_start (*label, false, false);
810 _store->signal_row_changed().connect (sigc::mem_fun (*this, &ControlSurfacesOptions::model_changed));
811 _view.signal_button_press_event().connect_notify (sigc::mem_fun(*this, &ControlSurfacesOptions::edit_clicked));
814 void parameter_changed (std::string const &)
819 void set_state_from_config ()
823 ControlProtocolManager& m = ControlProtocolManager::instance ();
824 for (list<ControlProtocolInfo*>::iterator i = m.control_protocol_info.begin(); i != m.control_protocol_info.end(); ++i) {
826 if (!(*i)->mandatory) {
827 TreeModel::Row r = *_store->append ();
828 r[_model.name] = (*i)->name;
829 r[_model.enabled] = ((*i)->protocol || (*i)->requested);
830 r[_model.feedback] = ((*i)->protocol && (*i)->protocol->get_feedback ());
831 r[_model.protocol_info] = *i;
838 void model_changed (TreeModel::Path const &, TreeModel::iterator const & i)
840 TreeModel::Row r = *i;
842 ControlProtocolInfo* cpi = r[_model.protocol_info];
847 bool const was_enabled = (cpi->protocol != 0);
848 bool const is_enabled = r[_model.enabled];
850 if (was_enabled != is_enabled) {
852 ControlProtocolManager::instance().instantiate (*cpi);
854 ControlProtocolManager::instance().teardown (*cpi);
858 bool const was_feedback = (cpi->protocol && cpi->protocol->get_feedback ());
859 bool const is_feedback = r[_model.feedback];
861 if (was_feedback != is_feedback && cpi->protocol) {
862 cpi->protocol->set_feedback (is_feedback);
866 void edit_clicked (GdkEventButton* ev)
868 if (ev->type != GDK_2BUTTON_PRESS) {
873 ControlProtocolInfo* cpi;
876 row = *(_view.get_selection()->get_selected());
878 Window* win = row[_model.editor];
879 if (win && !win->is_visible()) {
882 cpi = row[_model.protocol_info];
884 if (cpi && cpi->protocol && cpi->protocol->has_editor ()) {
885 Box* box = (Box*) cpi->protocol->get_gui ();
887 string title = row[_model.name];
888 ArdourDialog* win = new ArdourDialog (_parent, title);
889 win->get_vbox()->pack_start (*box, false, false);
892 row[_model.editor] = win;
898 class ControlSurfacesModelColumns : public TreeModelColumnRecord
902 ControlSurfacesModelColumns ()
911 TreeModelColumn<string> name;
912 TreeModelColumn<bool> enabled;
913 TreeModelColumn<bool> feedback;
914 TreeModelColumn<ControlProtocolInfo*> protocol_info;
915 TreeModelColumn<Gtk::Window*> editor;
918 Glib::RefPtr<ListStore> _store;
919 ControlSurfacesModelColumns _model;
921 Gtk::Window& _parent;
925 RCOptionEditor::RCOptionEditor ()
926 : OptionEditor (Config, _("Ardour Preferences")),
931 add_option (_("Misc"), new OptionEditorHeading (_("Metering")));
933 ComboOption<float>* mht = new ComboOption<float> (
935 _("Meter hold time"),
936 sigc::mem_fun (*_rc_config, &RCConfiguration::get_meter_hold),
937 sigc::mem_fun (*_rc_config, &RCConfiguration::set_meter_hold)
940 mht->add (MeterHoldOff, _("off"));
941 mht->add (MeterHoldShort, _("short"));
942 mht->add (MeterHoldMedium, _("medium"));
943 mht->add (MeterHoldLong, _("long"));
945 add_option (_("Misc"), mht);
947 ComboOption<float>* mfo = new ComboOption<float> (
950 sigc::mem_fun (*_rc_config, &RCConfiguration::get_meter_falloff),
951 sigc::mem_fun (*_rc_config, &RCConfiguration::set_meter_falloff)
954 mfo->add (METER_FALLOFF_OFF, _("off"));
955 mfo->add (METER_FALLOFF_SLOWEST, _("slowest"));
956 mfo->add (METER_FALLOFF_SLOW, _("slow"));
957 mfo->add (METER_FALLOFF_MEDIUM, _("medium"));
958 mfo->add (METER_FALLOFF_FAST, _("fast"));
959 mfo->add (METER_FALLOFF_FASTER, _("faster"));
960 mfo->add (METER_FALLOFF_FASTEST, _("fastest"));
962 add_option (_("Misc"), mfo);
964 add_option (_("Misc"), new OptionEditorHeading (_("Undo")));
966 add_option (_("Misc"), new UndoOptions (_rc_config));
968 add_option (_("Misc"), new OptionEditorHeading (_("Misc")));
971 /* font scaling does nothing with GDK/Quartz */
972 add_option (_("Misc"), new FontScalingOptions (_rc_config));
975 add_option (_("Misc"),
977 "verify-remove-last-capture",
978 _("Verify removal of last capture"),
979 sigc::mem_fun (*_rc_config, &RCConfiguration::get_verify_remove_last_capture),
980 sigc::mem_fun (*_rc_config, &RCConfiguration::set_verify_remove_last_capture)
983 add_option (_("Misc"),
985 "periodic-safety-backups",
986 _("Make periodic backups of the session file"),
987 sigc::mem_fun (*_rc_config, &RCConfiguration::get_periodic_safety_backups),
988 sigc::mem_fun (*_rc_config, &RCConfiguration::set_periodic_safety_backups)
991 add_option (_("Misc"),
993 "sync-all-route-ordering",
994 _("Syncronise editor and mixer track order"),
995 sigc::mem_fun (*_rc_config, &RCConfiguration::get_sync_all_route_ordering),
996 sigc::mem_fun (*_rc_config, &RCConfiguration::set_sync_all_route_ordering)
999 add_option (_("Misc"),
1001 "only-copy-imported-files",
1002 _("Always copy imported files"),
1003 sigc::mem_fun (*_rc_config, &RCConfiguration::get_only_copy_imported_files),
1004 sigc::mem_fun (*_rc_config, &RCConfiguration::set_only_copy_imported_files)
1007 add_option (_("Misc"),
1009 "default-narrow_ms",
1010 _("Use narrow mixer strips"),
1011 sigc::mem_fun (*_rc_config, &RCConfiguration::get_default_narrow_ms),
1012 sigc::mem_fun (*_rc_config, &RCConfiguration::set_default_narrow_ms)
1015 add_option (_("Misc"),
1018 _("Name new markers"),
1019 sigc::mem_fun (*_rc_config, &RCConfiguration::get_name_new_markers),
1020 sigc::mem_fun (*_rc_config, &RCConfiguration::set_name_new_markers)
1025 add_option (_("Transport"),
1027 "latched-record-enable",
1028 _("Keep record-enable engaged on stop"),
1029 sigc::mem_fun (*_rc_config, &RCConfiguration::get_latched_record_enable),
1030 sigc::mem_fun (*_rc_config, &RCConfiguration::set_latched_record_enable)
1033 add_option (_("Transport"),
1035 "stop-recording-on-xrun",
1036 _("Stop recording when an xrun occurs"),
1037 sigc::mem_fun (*_rc_config, &RCConfiguration::get_stop_recording_on_xrun),
1038 sigc::mem_fun (*_rc_config, &RCConfiguration::set_stop_recording_on_xrun)
1041 add_option (_("Transport"),
1043 "create-xrun-marker",
1044 _("Create markers where xruns occur"),
1045 sigc::mem_fun (*_rc_config, &RCConfiguration::get_create_xrun_marker),
1046 sigc::mem_fun (*_rc_config, &RCConfiguration::set_create_xrun_marker)
1049 add_option (_("Transport"),
1051 "stop-at-session-end",
1052 _("Stop at the end of the session"),
1053 sigc::mem_fun (*_rc_config, &RCConfiguration::get_stop_at_session_end),
1054 sigc::mem_fun (*_rc_config, &RCConfiguration::set_stop_at_session_end)
1057 add_option (_("Transport"),
1059 "primary-clock-delta-edit-cursor",
1060 _("Primary clock delta to edit cursor"),
1061 sigc::mem_fun (*_rc_config, &RCConfiguration::get_primary_clock_delta_edit_cursor),
1062 sigc::mem_fun (*_rc_config, &RCConfiguration::set_primary_clock_delta_edit_cursor)
1065 add_option (_("Transport"),
1067 "secondary-clock-delta-edit-cursor",
1068 _("Secondary clock delta to edit cursor"),
1069 sigc::mem_fun (*_rc_config, &RCConfiguration::get_secondary_clock_delta_edit_cursor),
1070 sigc::mem_fun (*_rc_config, &RCConfiguration::set_secondary_clock_delta_edit_cursor)
1073 add_option (_("Transport"),
1075 "disable-disarm-during-roll",
1076 _("Disable per-track record disarm while rolling"),
1077 sigc::mem_fun (*_rc_config, &RCConfiguration::get_disable_disarm_during_roll),
1078 sigc::mem_fun (*_rc_config, &RCConfiguration::set_disable_disarm_during_roll)
1083 add_option (_("Editor"),
1085 "link-region-and-track-selection",
1086 _("Link selection of regions and tracks"),
1087 sigc::mem_fun (*_rc_config, &RCConfiguration::get_link_region_and_track_selection),
1088 sigc::mem_fun (*_rc_config, &RCConfiguration::set_link_region_and_track_selection)
1091 add_option (_("Editor"),
1093 "automation-follows-regions",
1094 _("Move relevant automation when regions are moved"),
1095 sigc::mem_fun (*_rc_config, &RCConfiguration::get_automation_follows_regions),
1096 sigc::mem_fun (*_rc_config, &RCConfiguration::set_automation_follows_regions)
1099 add_option (_("Editor"),
1101 "show-track-meters",
1102 _("Show meters on tracks in the editor"),
1103 sigc::mem_fun (*_rc_config, &RCConfiguration::get_show_track_meters),
1104 sigc::mem_fun (*_rc_config, &RCConfiguration::set_show_track_meters)
1107 add_option (_("Editor"),
1109 "use-overlap-equivalency",
1110 _("Use overlap equivalency for regions"),
1111 sigc::mem_fun (*_rc_config, &RCConfiguration::get_use_overlap_equivalency),
1112 sigc::mem_fun (*_rc_config, &RCConfiguration::set_use_overlap_equivalency)
1115 add_option (_("Editor"),
1117 "rubberbanding-snaps-to-grid",
1118 _("Make rubberband selection rectangle snap to the grid"),
1119 sigc::mem_fun (*_rc_config, &RCConfiguration::get_rubberbanding_snaps_to_grid),
1120 sigc::mem_fun (*_rc_config, &RCConfiguration::set_rubberbanding_snaps_to_grid)
1123 add_option (_("Editor"),
1126 _("Show waveforms in regions"),
1127 sigc::mem_fun (*_rc_config, &RCConfiguration::get_show_waveforms),
1128 sigc::mem_fun (*_rc_config, &RCConfiguration::set_show_waveforms)
1131 ComboOption<WaveformScale>* wfs = new ComboOption<WaveformScale> (
1133 _("Waveform scale"),
1134 sigc::mem_fun (*_rc_config, &RCConfiguration::get_waveform_scale),
1135 sigc::mem_fun (*_rc_config, &RCConfiguration::set_waveform_scale)
1138 wfs->add (Linear, _("linear"));
1139 wfs->add (Logarithmic, _("logarithmic"));
1141 add_option (_("Editor"), wfs);
1143 ComboOption<WaveformShape>* wfsh = new ComboOption<WaveformShape> (
1145 _("Waveform shape"),
1146 sigc::mem_fun (*_rc_config, &RCConfiguration::get_waveform_shape),
1147 sigc::mem_fun (*_rc_config, &RCConfiguration::set_waveform_shape)
1150 wfsh->add (Traditional, _("traditional"));
1151 wfsh->add (Rectified, _("rectified"));
1153 add_option (_("Editor"), wfsh);
1157 add_option (_("Audio"), new OptionEditorHeading (_("Solo")));
1160 add_option (_("Audio"),
1162 "solo-control-is-listen-control",
1163 _("Solo controls are Listen controls"),
1164 sigc::mem_fun (*_rc_config, &RCConfiguration::get_solo_control_is_listen_control),
1165 sigc::mem_fun (*_rc_config, &RCConfiguration::set_solo_control_is_listen_control)
1168 ComboOption<ListenPosition>* lp = new ComboOption<ListenPosition> (
1170 _("Listen Position"),
1171 sigc::mem_fun (*_rc_config, &RCConfiguration::get_listen_position),
1172 sigc::mem_fun (*_rc_config, &RCConfiguration::set_listen_position)
1175 lp->add (AfterFaderListen, _("after-fader listen"));
1176 lp->add (PreFaderListen, _("pre-fader listen"));
1178 add_option (_("Audio"), lp);
1179 add_option (_("Audio"), new SoloMuteOptions (_rc_config));
1181 add_option (_("Audio"),
1185 sigc::mem_fun (*_rc_config, &RCConfiguration::get_solo_latched),
1186 sigc::mem_fun (*_rc_config, &RCConfiguration::set_solo_latched)
1189 add_option (_("Audio"),
1192 _("Show solo muting"),
1193 sigc::mem_fun (*_rc_config, &RCConfiguration::get_show_solo_mutes),
1194 sigc::mem_fun (*_rc_config, &RCConfiguration::set_show_solo_mutes)
1197 add_option (_("Audio"),
1199 "solo-mute-override",
1200 _("Override muting"),
1201 sigc::mem_fun (*_rc_config, &RCConfiguration::get_solo_mute_override),
1202 sigc::mem_fun (*_rc_config, &RCConfiguration::set_solo_mute_override)
1205 add_option (_("Audio"), new OptionEditorHeading (_("Monitoring")));
1207 ComboOption<MonitorModel>* mm = new ComboOption<MonitorModel> (
1209 _("Monitoring handled by"),
1210 sigc::mem_fun (*_rc_config, &RCConfiguration::get_monitoring_model),
1211 sigc::mem_fun (*_rc_config, &RCConfiguration::set_monitoring_model)
1214 mm->add (HardwareMonitoring, _("JACK"));
1215 mm->add (SoftwareMonitoring, _("ardour"));
1216 mm->add (ExternalMonitoring, _("audio hardware"));
1218 add_option (_("Audio"), mm);
1220 add_option (_("Audio"),
1222 "tape-machine-mode",
1223 _("Tape machine mode"),
1224 sigc::mem_fun (*_rc_config, &RCConfiguration::get_tape_machine_mode),
1225 sigc::mem_fun (*_rc_config, &RCConfiguration::set_tape_machine_mode)
1228 add_option (_("Audio"), new OptionEditorHeading (_("Connection of tracks and busses")));
1230 add_option (_("Audio"),
1232 "auto-connect-standard-busses",
1233 _("Auto-connect master/monitor busses"),
1234 sigc::mem_fun (*_rc_config, &RCConfiguration::get_auto_connect_standard_busses),
1235 sigc::mem_fun (*_rc_config, &RCConfiguration::set_auto_connect_standard_busses)
1238 ComboOption<AutoConnectOption>* iac = new ComboOption<AutoConnectOption> (
1239 "input-auto-connect",
1240 _("Connect track and bus inputs"),
1241 sigc::mem_fun (*_rc_config, &RCConfiguration::get_input_auto_connect),
1242 sigc::mem_fun (*_rc_config, &RCConfiguration::set_input_auto_connect)
1245 iac->add (AutoConnectPhysical, _("automatically to physical inputs"));
1246 iac->add (ManualConnect, _("manually"));
1248 add_option (_("Audio"), iac);
1250 ComboOption<AutoConnectOption>* oac = new ComboOption<AutoConnectOption> (
1251 "output-auto-connect",
1252 _("Connect track and bus outputs"),
1253 sigc::mem_fun (*_rc_config, &RCConfiguration::get_output_auto_connect),
1254 sigc::mem_fun (*_rc_config, &RCConfiguration::set_output_auto_connect)
1257 oac->add (AutoConnectPhysical, _("automatically to physical outputs"));
1258 oac->add (AutoConnectMaster, _("automatically to master outputs"));
1259 oac->add (ManualConnect, _("manually"));
1261 add_option (_("Audio"), oac);
1263 add_option (_("Audio"), new OptionEditorHeading (_("Denormals")));
1265 add_option (_("Audio"),
1267 "denormal-protection",
1268 _("Use DC bias to protect against denormals"),
1269 sigc::mem_fun (*_rc_config, &RCConfiguration::get_denormal_protection),
1270 sigc::mem_fun (*_rc_config, &RCConfiguration::set_denormal_protection)
1273 ComboOption<DenormalModel>* dm = new ComboOption<DenormalModel> (
1275 _("Processor handling"),
1276 sigc::mem_fun (*_rc_config, &RCConfiguration::get_denormal_model),
1277 sigc::mem_fun (*_rc_config, &RCConfiguration::set_denormal_model)
1280 dm->add (DenormalNone, _("no processor handling"));
1284 if (fpu.has_flush_to_zero()) {
1285 dm->add (DenormalFTZ, _("use FlushToZero"));
1288 if (fpu.has_denormals_are_zero()) {
1289 dm->add (DenormalDAZ, _("use DenormalsAreZero"));
1292 if (fpu.has_flush_to_zero() && fpu.has_denormals_are_zero()) {
1293 dm->add (DenormalFTZDAZ, _("use FlushToZero and DenormalsAreZerO"));
1296 add_option (_("Audio"), dm);
1298 add_option (_("Audio"), new OptionEditorHeading (_("Plugins")));
1300 add_option (_("Audio"),
1302 "plugins-stop-with-transport",
1303 _("Stop plugins when the transport is stopped"),
1304 sigc::mem_fun (*_rc_config, &RCConfiguration::get_plugins_stop_with_transport),
1305 sigc::mem_fun (*_rc_config, &RCConfiguration::set_plugins_stop_with_transport)
1308 add_option (_("Audio"),
1310 "do-not-record-plugins",
1311 _("Disable plugins during recording"),
1312 sigc::mem_fun (*_rc_config, &RCConfiguration::get_do_not_record_plugins),
1313 sigc::mem_fun (*_rc_config, &RCConfiguration::set_do_not_record_plugins)
1316 add_option (_("Audio"),
1318 "new-plugins-active",
1319 _("Make new plugins active"),
1320 sigc::mem_fun (*_rc_config, &RCConfiguration::get_new_plugins_active),
1321 sigc::mem_fun (*_rc_config, &RCConfiguration::set_new_plugins_active)
1324 add_option (_("Audio"),
1326 "auto-analyse-audio",
1327 _("Enable automatic analysis of audio"),
1328 sigc::mem_fun (*_rc_config, &RCConfiguration::get_auto_analyse_audio),
1329 sigc::mem_fun (*_rc_config, &RCConfiguration::set_auto_analyse_audio)
1334 list<ComboOption<string>* > midi_combos;
1336 midi_combos.push_back (new ComboOption<string> (
1338 _("Send/Receive MTC via"),
1339 sigc::mem_fun (*_rc_config, &RCConfiguration::get_mtc_port_name),
1340 sigc::mem_fun (*_rc_config, &RCConfiguration::set_mtc_port_name)
1343 midi_combos.push_back (new ComboOption<string> (
1344 "midi-clock-port-name",
1345 _("Send/Receive MIDI clock via"),
1346 sigc::mem_fun (*_rc_config, &RCConfiguration::get_midi_clock_port_name),
1347 sigc::mem_fun (*_rc_config, &RCConfiguration::set_midi_clock_port_name)
1350 midi_combos.push_back (new ComboOption<string> (
1352 _("Send/Receive MMC via"),
1353 sigc::mem_fun (*_rc_config, &RCConfiguration::get_mmc_port_name),
1354 sigc::mem_fun (*_rc_config, &RCConfiguration::set_mmc_port_name)
1357 midi_combos.push_back (new ComboOption<string> (
1359 _("Send/Receive MIDI parameter control via"),
1360 sigc::mem_fun (*_rc_config, &RCConfiguration::get_midi_port_name),
1361 sigc::mem_fun (*_rc_config, &RCConfiguration::set_midi_port_name)
1364 add_option (_("MIDI control"), new MIDIPorts (_rc_config, midi_combos));
1366 for (list<ComboOption<string>* >::iterator i = midi_combos.begin(); i != midi_combos.end(); ++i) {
1367 add_option (_("MIDI control"), *i);
1370 add_option (_("MIDI control"),
1373 _("Obey MIDI Machine Control commands"),
1374 sigc::mem_fun (*_rc_config, &RCConfiguration::get_mmc_control),
1375 sigc::mem_fun (*_rc_config, &RCConfiguration::set_mmc_control)
1379 add_option (_("MIDI control"),
1382 _("Send MIDI Machine Control commands"),
1383 sigc::mem_fun (*_rc_config, &RCConfiguration::get_send_mmc),
1384 sigc::mem_fun (*_rc_config, &RCConfiguration::set_send_mmc)
1387 add_option (_("MIDI control"),
1390 _("Send MIDI control feedback"),
1391 sigc::mem_fun (*_rc_config, &RCConfiguration::get_midi_feedback),
1392 sigc::mem_fun (*_rc_config, &RCConfiguration::set_midi_feedback)
1395 add_option (_("MIDI control"),
1396 new SpinOption<uint8_t> (
1397 "mmc-receive-device-id",
1398 _("Inbound MMC device ID"),
1399 sigc::mem_fun (*_rc_config, &RCConfiguration::get_mmc_receive_device_id),
1400 sigc::mem_fun (*_rc_config, &RCConfiguration::set_mmc_receive_device_id),
1404 add_option (_("MIDI control"),
1405 new SpinOption<uint8_t> (
1406 "mmc-send-device-id",
1407 _("Outbound MMC device ID"),
1408 sigc::mem_fun (*_rc_config, &RCConfiguration::get_mmc_send_device_id),
1409 sigc::mem_fun (*_rc_config, &RCConfiguration::set_mmc_send_device_id),
1413 add_option (_("MIDI control"),
1414 new SpinOption<int32_t> (
1415 "initial-program-change",
1416 _("Initial program change"),
1417 sigc::mem_fun (*_rc_config, &RCConfiguration::get_initial_program_change),
1418 sigc::mem_fun (*_rc_config, &RCConfiguration::set_initial_program_change),
1422 /* CONTROL SURFACES */
1424 add_option (_("Control surfaces"), new ControlSurfacesOptions (*this));
1426 ComboOption<RemoteModel>* rm = new ComboOption<RemoteModel> (
1428 _("Control surface remote ID"),
1429 sigc::mem_fun (*_rc_config, &RCConfiguration::get_remote_model),
1430 sigc::mem_fun (*_rc_config, &RCConfiguration::set_remote_model)
1433 rm->add (UserOrdered, _("assigned by user"));
1434 rm->add (MixerOrdered, _("follows order of mixer"));
1435 rm->add (EditorOrdered, _("follows order of editor"));
1437 add_option (_("Control surfaces"), rm);
1441 add_option (_("Click"), new ClickOptions (_rc_config, this));
1445 add_option (_("Keyboard"), new KeyboardOptions);