52033356e701697592896965183353187b6aedd5
[ardour.git] / gtk2_ardour / rc_option_editor.cc
1 /*
2     Copyright (C) 2001-2011 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
20 #ifdef WAF_BUILD
21 #include "gtk2ardour-config.h"
22 #endif
23
24 #include <gtkmm/liststore.h>
25 #include <gtkmm/stock.h>
26 #include <gtkmm/scale.h>
27 #include <gtkmm2ext/utils.h>
28 #include <gtkmm2ext/slider_controller.h>
29
30 #include "pbd/fpu.h"
31 #include "pbd/cpus.h"
32
33 #include "midi++/manager.h"
34
35 #include "ardour/audioengine.h"
36 #include "ardour/dB.h"
37 #include "ardour/rc_configuration.h"
38 #include "ardour/control_protocol_manager.h"
39 #include "control_protocol/control_protocol.h"
40
41 #include "ardour_window.h"
42 #include "ardour_dialog.h"
43 #include "gui_thread.h"
44 #include "midi_tracer.h"
45 #include "rc_option_editor.h"
46 #include "utils.h"
47 #include "midi_port_dialog.h"
48 #include "sfdb_ui.h"
49 #include "keyboard.h"
50 #include "i18n.h"
51
52 using namespace std;
53 using namespace Gtk;
54 using namespace Gtkmm2ext;
55 using namespace PBD;
56 using namespace ARDOUR;
57
58 class ClickOptions : public OptionEditorBox
59 {
60 public:
61         ClickOptions (RCConfiguration* c, Gtk::Window* p)
62                 : _rc_config (c),
63                   _parent (p)
64         {
65                 Table* t = manage (new Table (2, 3));
66                 t->set_spacings (4);
67
68                 Label* l = manage (left_aligned_label (_("Click audio file:")));
69                 t->attach (*l, 0, 1, 0, 1, FILL);
70                 t->attach (_click_path_entry, 1, 2, 0, 1, FILL);
71                 Button* b = manage (new Button (_("Browse...")));
72                 b->signal_clicked().connect (sigc::mem_fun (*this, &ClickOptions::click_browse_clicked));
73                 t->attach (*b, 2, 3, 0, 1, FILL);
74
75                 l = manage (left_aligned_label (_("Click emphasis audio file:")));
76                 t->attach (*l, 0, 1, 1, 2, FILL);
77                 t->attach (_click_emphasis_path_entry, 1, 2, 1, 2, FILL);
78                 b = manage (new Button (_("Browse...")));
79                 b->signal_clicked().connect (sigc::mem_fun (*this, &ClickOptions::click_emphasis_browse_clicked));
80                 t->attach (*b, 2, 3, 1, 2, FILL);
81                 
82                 _box->pack_start (*t, false, false);
83
84                 _click_path_entry.signal_activate().connect (sigc::mem_fun (*this, &ClickOptions::click_changed));      
85                 _click_emphasis_path_entry.signal_activate().connect (sigc::mem_fun (*this, &ClickOptions::click_emphasis_changed));
86         }
87
88         void parameter_changed (string const & p)
89         {
90                 if (p == "click-sound") {
91                         _click_path_entry.set_text (_rc_config->get_click_sound());
92                 } else if (p == "click-emphasis-sound") {
93                         _click_emphasis_path_entry.set_text (_rc_config->get_click_emphasis_sound());
94                 }
95         }
96
97         void set_state_from_config ()
98         {
99                 parameter_changed ("click-sound");
100                 parameter_changed ("click-emphasis-sound");
101         }
102
103 private:
104
105         void click_browse_clicked ()
106         {
107                 SoundFileChooser sfdb (*_parent, _("Choose Click"));
108
109                 sfdb.show_all ();
110                 sfdb.present ();
111
112                 if (sfdb.run () == RESPONSE_OK) {
113                         click_chosen (sfdb.get_filename());
114                 }
115         }
116
117         void click_chosen (string const & path)
118         {
119                 _click_path_entry.set_text (path);
120                 _rc_config->set_click_sound (path);
121         }
122
123         void click_changed ()
124         {
125                 click_chosen (_click_path_entry.get_text ());
126         }
127         
128         void click_emphasis_browse_clicked ()
129         {
130                 SoundFileChooser sfdb (*_parent, _("Choose Click Emphasis"));
131
132                 sfdb.show_all ();
133                 sfdb.present ();
134
135                 if (sfdb.run () == RESPONSE_OK) {
136                         click_emphasis_chosen (sfdb.get_filename());
137                 }
138         }
139
140         void click_emphasis_chosen (string const & path)
141         {
142                 _click_emphasis_path_entry.set_text (path);
143                 _rc_config->set_click_emphasis_sound (path);
144         }
145
146         void click_emphasis_changed ()
147         {
148                 click_emphasis_chosen (_click_emphasis_path_entry.get_text ());
149         }
150
151         RCConfiguration* _rc_config;
152         Gtk::Window* _parent;
153         Entry _click_path_entry;
154         Entry _click_emphasis_path_entry;
155 };
156
157 class UndoOptions : public OptionEditorBox
158 {
159 public:
160         UndoOptions (RCConfiguration* c) :
161                 _rc_config (c),
162                 _limit_undo_button (_("Limit undo history to")),
163                 _save_undo_button (_("Save undo history of"))
164         {
165                 Table* t = new Table (2, 3);
166                 t->set_spacings (4);
167
168                 t->attach (_limit_undo_button, 0, 1, 0, 1, FILL);
169                 _limit_undo_spin.set_range (0, 512);
170                 _limit_undo_spin.set_increments (1, 10);
171                 t->attach (_limit_undo_spin, 1, 2, 0, 1, FILL | EXPAND);
172                 Label* l = manage (left_aligned_label (_("commands")));
173                 t->attach (*l, 2, 3, 0, 1);
174
175                 t->attach (_save_undo_button, 0, 1, 1, 2, FILL);
176                 _save_undo_spin.set_range (0, 512);
177                 _save_undo_spin.set_increments (1, 10);
178                 t->attach (_save_undo_spin, 1, 2, 1, 2, FILL | EXPAND);
179                 l = manage (left_aligned_label (_("commands")));
180                 t->attach (*l, 2, 3, 1, 2);
181
182                 _box->pack_start (*t);
183
184                 _limit_undo_button.signal_toggled().connect (sigc::mem_fun (*this, &UndoOptions::limit_undo_toggled));
185                 _limit_undo_spin.signal_value_changed().connect (sigc::mem_fun (*this, &UndoOptions::limit_undo_changed));
186                 _save_undo_button.signal_toggled().connect (sigc::mem_fun (*this, &UndoOptions::save_undo_toggled));
187                 _save_undo_spin.signal_value_changed().connect (sigc::mem_fun (*this, &UndoOptions::save_undo_changed));
188         }
189
190         void parameter_changed (string const & p)
191         {
192                 if (p == "history-depth") {
193                         int32_t const d = _rc_config->get_history_depth();
194                         _limit_undo_button.set_active (d != 0);
195                         _limit_undo_spin.set_sensitive (d != 0);
196                         _limit_undo_spin.set_value (d);
197                 } else if (p == "save-history") {
198                         bool const x = _rc_config->get_save_history ();
199                         _save_undo_button.set_active (x);
200                         _save_undo_spin.set_sensitive (x);
201                 } else if (p == "save-history-depth") {
202                         _save_undo_spin.set_value (_rc_config->get_saved_history_depth());
203                 }
204         }
205
206         void set_state_from_config ()
207         {
208                 parameter_changed ("save-history");
209                 parameter_changed ("history-depth");
210                 parameter_changed ("save-history-depth");
211         }
212
213         void limit_undo_toggled ()
214         {
215                 bool const x = _limit_undo_button.get_active ();
216                 _limit_undo_spin.set_sensitive (x);
217                 int32_t const n = x ? 16 : 0;
218                 _limit_undo_spin.set_value (n);
219                 _rc_config->set_history_depth (n);
220         }
221
222         void limit_undo_changed ()
223         {
224                 _rc_config->set_history_depth (_limit_undo_spin.get_value_as_int ());
225         }
226
227         void save_undo_toggled ()
228         {
229                 bool const x = _save_undo_button.get_active ();
230                 _rc_config->set_save_history (x);
231         }
232
233         void save_undo_changed ()
234         {
235                 _rc_config->set_saved_history_depth (_save_undo_spin.get_value_as_int ());
236         }
237
238 private:
239         RCConfiguration* _rc_config;
240         CheckButton _limit_undo_button;
241         SpinButton _limit_undo_spin;
242         CheckButton _save_undo_button;
243         SpinButton _save_undo_spin;
244 };
245
246
247
248 static const struct {
249     const char *name;
250     guint modifier;
251 } modifiers[] = {
252
253         { "Unmodified", 0 },
254
255 #ifdef GTKOSX
256
257         /* Command = Meta
258            Option/Alt = Mod1
259         */
260         { "Key|Shift", GDK_SHIFT_MASK },
261         { "Command", GDK_META_MASK },
262         { "Control", GDK_CONTROL_MASK },
263         { "Option", GDK_MOD1_MASK },
264         { "Command-Shift", GDK_META_MASK|GDK_SHIFT_MASK },
265         { "Command-Option", GDK_MOD1_MASK|GDK_META_MASK },
266         { "Shift-Option", GDK_SHIFT_MASK|GDK_MOD1_MASK },
267         { "Shift-Command-Option", GDK_MOD5_MASK|GDK_SHIFT_MASK|GDK_META_MASK },
268
269 #else
270         { "Key|Shift", GDK_SHIFT_MASK },
271         { "Control", GDK_CONTROL_MASK },
272         { "Alt (Mod1)", GDK_MOD1_MASK },
273         { "Control-Shift", GDK_CONTROL_MASK|GDK_SHIFT_MASK },
274         { "Control-Alt", GDK_CONTROL_MASK|GDK_MOD1_MASK },
275         { "Shift-Alt", GDK_SHIFT_MASK|GDK_MOD1_MASK },
276         { "Control-Shift-Alt", GDK_CONTROL_MASK|GDK_SHIFT_MASK|GDK_MOD1_MASK },
277         { "Mod2", GDK_MOD2_MASK },
278         { "Mod3", GDK_MOD3_MASK },
279         { "Mod4", GDK_MOD4_MASK },
280         { "Mod5", GDK_MOD5_MASK },
281 #endif
282         { 0, 0 }
283 };
284
285
286 class KeyboardOptions : public OptionEditorBox
287 {
288 public:
289         KeyboardOptions () :
290                   _delete_button_adjustment (3, 1, 12),
291                   _delete_button_spin (_delete_button_adjustment),
292                   _edit_button_adjustment (3, 1, 5),
293                   _edit_button_spin (_edit_button_adjustment),
294                   _insert_note_button_adjustment (3, 1, 5),
295                   _insert_note_button_spin (_insert_note_button_adjustment)
296         {
297                 /* internationalize and prepare for use with combos */
298
299                 vector<string> dumb;
300                 for (int i = 0; modifiers[i].name; ++i) {
301                         dumb.push_back (S_(modifiers[i].name));
302                 }
303
304                 set_popdown_strings (_edit_modifier_combo, dumb);
305                 _edit_modifier_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::edit_modifier_chosen));
306
307                 for (int x = 0; modifiers[x].name; ++x) {
308                         if (modifiers[x].modifier == Keyboard::edit_modifier ()) {
309                                 _edit_modifier_combo.set_active_text (S_(modifiers[x].name));
310                                 break;
311                         }
312                 }
313
314                 Table* t = manage (new Table (4, 4));
315                 t->set_spacings (4);
316
317                 Label* l = manage (left_aligned_label (_("Edit using:")));
318                 l->set_name ("OptionsLabel");
319
320                 t->attach (*l, 0, 1, 0, 1, FILL | EXPAND, FILL);
321                 t->attach (_edit_modifier_combo, 1, 2, 0, 1, FILL | EXPAND, FILL);
322
323                 l = manage (new Label (_("+ button")));
324                 l->set_name ("OptionsLabel");
325
326                 t->attach (*l, 3, 4, 0, 1, FILL | EXPAND, FILL);
327                 t->attach (_edit_button_spin, 4, 5, 0, 1, FILL | EXPAND, FILL);
328
329                 _edit_button_spin.set_name ("OptionsEntry");
330                 _edit_button_adjustment.set_value (Keyboard::edit_button());
331                 _edit_button_adjustment.signal_value_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::edit_button_changed));
332
333                 set_popdown_strings (_delete_modifier_combo, dumb);
334                 _delete_modifier_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::delete_modifier_chosen));
335
336                 for (int x = 0; modifiers[x].name; ++x) {
337                         if (modifiers[x].modifier == Keyboard::delete_modifier ()) {
338                                 _delete_modifier_combo.set_active_text (S_(modifiers[x].name));
339                                 break;
340                         }
341                 }
342
343                 l = manage (left_aligned_label (_("Delete using:")));
344                 l->set_name ("OptionsLabel");
345
346                 t->attach (*l, 0, 1, 1, 2, FILL | EXPAND, FILL);
347                 t->attach (_delete_modifier_combo, 1, 2, 1, 2, FILL | EXPAND, FILL);
348
349                 l = manage (new Label (_("+ button")));
350                 l->set_name ("OptionsLabel");
351
352                 t->attach (*l, 3, 4, 1, 2, FILL | EXPAND, FILL);
353                 t->attach (_delete_button_spin, 4, 5, 1, 2, FILL | EXPAND, FILL);
354
355                 _delete_button_spin.set_name ("OptionsEntry");
356                 _delete_button_adjustment.set_value (Keyboard::delete_button());
357                 _delete_button_adjustment.signal_value_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::delete_button_changed));
358
359
360                 set_popdown_strings (_insert_note_modifier_combo, dumb);
361                 _insert_note_modifier_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::insert_note_modifier_chosen));
362
363                 for (int x = 0; modifiers[x].name; ++x) {
364                         if (modifiers[x].modifier == Keyboard::insert_note_modifier ()) {
365                                 _insert_note_modifier_combo.set_active_text (S_(modifiers[x].name));
366                                 break;
367                         }
368                 }
369
370                 l = manage (left_aligned_label (_("Insert note using:")));
371                 l->set_name ("OptionsLabel");
372
373                 t->attach (*l, 0, 1, 2, 3, FILL | EXPAND, FILL);
374                 t->attach (_insert_note_modifier_combo, 1, 2, 2, 3, FILL | EXPAND, FILL);
375
376                 l = manage (new Label (_("+ button")));
377                 l->set_name ("OptionsLabel");
378
379                 t->attach (*l, 3, 4, 2, 3, FILL | EXPAND, FILL);
380                 t->attach (_insert_note_button_spin, 4, 5, 2, 3, FILL | EXPAND, FILL);
381
382                 _insert_note_button_spin.set_name ("OptionsEntry");
383                 _insert_note_button_adjustment.set_value (Keyboard::insert_note_button());
384                 _insert_note_button_adjustment.signal_value_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::insert_note_button_changed));
385
386
387                 set_popdown_strings (_snap_modifier_combo, dumb);
388                 _snap_modifier_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::snap_modifier_chosen));
389
390                 for (int x = 0; modifiers[x].name; ++x) {
391                         if (modifiers[x].modifier == (guint) Keyboard::snap_modifier ()) {
392                                 _snap_modifier_combo.set_active_text (S_(modifiers[x].name));
393                                 break;
394                         }
395                 }
396
397                 l = manage (left_aligned_label (_("Toggle snap using:")));
398                 l->set_name ("OptionsLabel");
399
400                 t->attach (*l, 0, 1, 3, 4, FILL | EXPAND, FILL);
401                 t->attach (_snap_modifier_combo, 1, 2, 3, 4, FILL | EXPAND, FILL);
402
403                 vector<string> strs;
404
405                 for (map<string,string>::iterator bf = Keyboard::binding_files.begin(); bf != Keyboard::binding_files.end(); ++bf) {
406                         strs.push_back (bf->first);
407                 }
408
409                 set_popdown_strings (_keyboard_layout_selector, strs);
410                 _keyboard_layout_selector.set_active_text (Keyboard::current_binding_name());
411                 _keyboard_layout_selector.signal_changed().connect (sigc::mem_fun (*this, &KeyboardOptions::bindings_changed));
412
413                 l = manage (left_aligned_label (_("Keyboard layout:")));
414                 l->set_name ("OptionsLabel");
415
416                 t->attach (*l, 0, 1, 4, 5, FILL | EXPAND, FILL);
417                 t->attach (_keyboard_layout_selector, 1, 2, 4, 5, FILL | EXPAND, FILL);
418
419                 _box->pack_start (*t, false, false);
420         }
421
422         void parameter_changed (string const &)
423         {
424                 /* XXX: these aren't really config options... */
425         }
426
427         void set_state_from_config ()
428         {
429                 /* XXX: these aren't really config options... */
430         }
431
432 private:
433
434         void bindings_changed ()
435         {
436                 string const txt = _keyboard_layout_selector.get_active_text();
437
438                 /* XXX: config...?  for all this keyboard stuff */
439
440                 for (map<string,string>::iterator i = Keyboard::binding_files.begin(); i != Keyboard::binding_files.end(); ++i) {
441                         if (txt == i->first) {
442                                 if (Keyboard::load_keybindings (i->second)) {
443                                         Keyboard::save_keybindings ();
444                                 }
445                         }
446                 }
447         }
448
449         void edit_modifier_chosen ()
450         {
451                 string const txt = _edit_modifier_combo.get_active_text();
452
453                 for (int i = 0; modifiers[i].name; ++i) {
454                         if (txt == _(modifiers[i].name)) {
455                                 Keyboard::set_edit_modifier (modifiers[i].modifier);
456                                 break;
457                         }
458                 }
459         }
460
461         void delete_modifier_chosen ()
462         {
463                 string const txt = _delete_modifier_combo.get_active_text();
464
465                 for (int i = 0; modifiers[i].name; ++i) {
466                         if (txt == _(modifiers[i].name)) {
467                                 Keyboard::set_delete_modifier (modifiers[i].modifier);
468                                 break;
469                         }
470                 }
471         }
472
473         void insert_note_modifier_chosen ()
474         {
475                 string const txt = _insert_note_modifier_combo.get_active_text();
476
477                 for (int i = 0; modifiers[i].name; ++i) {
478                         if (txt == _(modifiers[i].name)) {
479                                 Keyboard::set_insert_note_modifier (modifiers[i].modifier);
480                                 break;
481                         }
482                 }
483         }
484
485         void snap_modifier_chosen ()
486         {
487                 string const txt = _snap_modifier_combo.get_active_text();
488
489                 for (int i = 0; modifiers[i].name; ++i) {
490                         if (txt == _(modifiers[i].name)) {
491                                 Keyboard::set_snap_modifier (modifiers[i].modifier);
492                                 break;
493                         }
494                 }
495         }
496
497         void delete_button_changed ()
498         {
499                 Keyboard::set_delete_button (_delete_button_spin.get_value_as_int());
500         }
501
502         void edit_button_changed ()
503         {
504                 Keyboard::set_edit_button (_edit_button_spin.get_value_as_int());
505         }
506
507         void insert_note_button_changed ()
508         {
509                 Keyboard::set_insert_note_button (_insert_note_button_spin.get_value_as_int());
510         }
511
512         ComboBoxText _keyboard_layout_selector;
513         ComboBoxText _edit_modifier_combo;
514         ComboBoxText _delete_modifier_combo;
515         ComboBoxText _insert_note_modifier_combo;
516         ComboBoxText _snap_modifier_combo;
517         Adjustment _delete_button_adjustment;
518         SpinButton _delete_button_spin;
519         Adjustment _edit_button_adjustment;
520         SpinButton _edit_button_spin;
521         Adjustment _insert_note_button_adjustment;
522         SpinButton _insert_note_button_spin;
523
524 };
525
526 class FontScalingOptions : public OptionEditorBox
527 {
528 public:
529         FontScalingOptions (RCConfiguration* c) :
530                 _rc_config (c),
531                 _dpi_adjustment (50, 50, 250, 1, 10),
532                 _dpi_slider (_dpi_adjustment)
533         {
534                 _dpi_adjustment.set_value (_rc_config->get_font_scale () / 1024);
535
536                 Label* l = manage (new Label (_("Font scaling:")));
537                 l->set_name ("OptionsLabel");
538
539                 _dpi_slider.set_update_policy (UPDATE_DISCONTINUOUS);
540                 HBox* h = manage (new HBox);
541                 h->set_spacing (4);
542                 h->pack_start (*l, false, false);
543                 h->pack_start (_dpi_slider, true, true);
544
545                 _box->pack_start (*h, false, false);
546
547                 _dpi_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &FontScalingOptions::dpi_changed));
548         }
549
550         void parameter_changed (string const & p)
551         {
552                 if (p == "font-scale") {
553                         _dpi_adjustment.set_value (_rc_config->get_font_scale() / 1024);
554                 }
555         }
556
557         void set_state_from_config ()
558         {
559                 parameter_changed ("font-scale");
560         }
561
562 private:
563
564         void dpi_changed ()
565         {
566                 _rc_config->set_font_scale ((long) floor (_dpi_adjustment.get_value() * 1024));
567                 /* XXX: should be triggered from the parameter changed signal */
568                 reset_dpi ();
569         }
570
571         RCConfiguration* _rc_config;
572         Adjustment _dpi_adjustment;
573         HScale _dpi_slider;
574 };
575
576 class BufferingOptions : public OptionEditorBox
577 {
578 public:
579         BufferingOptions (RCConfiguration* c)
580                 : _rc_config (c)
581                 , _playback_adjustment (5, 1, 60, 1, 4)
582                 , _capture_adjustment (5, 1, 60, 1, 4)
583                 , _playback_slider (_playback_adjustment)
584                 , _capture_slider (_capture_adjustment)
585         {
586                 _playback_adjustment.set_value (_rc_config->get_audio_playback_buffer_seconds());
587
588                 Label* l = manage (new Label (_("Playback (seconds of buffering):")));
589                 l->set_name ("OptionsLabel");
590
591                 _playback_slider.set_update_policy (UPDATE_DISCONTINUOUS);
592                 HBox* h = manage (new HBox);
593                 h->set_spacing (4);
594                 h->pack_start (*l, false, false);
595                 h->pack_start (_playback_slider, true, true);
596
597                 _box->pack_start (*h, false, false);
598
599                 _capture_adjustment.set_value (_rc_config->get_audio_capture_buffer_seconds());
600
601                 l = manage (new Label (_("Recording (seconds of buffering):")));
602                 l->set_name ("OptionsLabel");
603
604                 _capture_slider.set_update_policy (UPDATE_DISCONTINUOUS);
605                 h = manage (new HBox);
606                 h->set_spacing (4);
607                 h->pack_start (*l, false, false);
608                 h->pack_start (_capture_slider, true, true);
609
610                 _box->pack_start (*h, false, false);
611
612                 _capture_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &BufferingOptions::capture_changed));
613                 _playback_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &BufferingOptions::playback_changed));
614         }
615
616         void parameter_changed (string const & p)
617         {
618                 if (p == "playback-buffer-seconds") {
619                         _playback_adjustment.set_value (_rc_config->get_audio_playback_buffer_seconds());
620                 } else if (p == "capture-buffer-seconds") {
621                         _capture_adjustment.set_value (_rc_config->get_audio_capture_buffer_seconds());
622                 }
623         }
624
625         void set_state_from_config ()
626         {
627                 parameter_changed ("playback-buffer-seconds");
628                 parameter_changed ("capture-buffer-seconds");
629         }
630
631 private:
632
633         void playback_changed ()
634         {
635                 _rc_config->set_audio_playback_buffer_seconds ((long) _playback_adjustment.get_value());
636         }
637
638         void capture_changed ()
639         {
640                 _rc_config->set_audio_capture_buffer_seconds ((long) _capture_adjustment.get_value());
641         }
642
643         RCConfiguration* _rc_config;
644         Adjustment _playback_adjustment;
645         Adjustment _capture_adjustment;
646         HScale _playback_slider;
647         HScale _capture_slider;
648 };
649
650 class ControlSurfacesOptions : public OptionEditorBox
651 {
652 public:
653         ControlSurfacesOptions (Gtk::Window& parent)
654                 : _parent (parent)
655         {
656                 _store = ListStore::create (_model);
657                 _view.set_model (_store);
658                 _view.append_column (_("Name"), _model.name);
659                 _view.get_column(0)->set_resizable (true);
660                 _view.get_column(0)->set_expand (true);
661                 _view.append_column_editable (_("Enabled"), _model.enabled);
662                 _view.append_column_editable (_("Feedback"), _model.feedback);
663
664                 _box->pack_start (_view, false, false);
665
666                 Label* label = manage (new Label);
667                 label->set_markup (string_compose (X_("<i>%1</i>"), _("Double-click on a name to edit settings for an enabled protocol")));
668
669                 _box->pack_start (*label, false, false);
670                 label->show ();
671
672                 _store->signal_row_changed().connect (sigc::mem_fun (*this, &ControlSurfacesOptions::model_changed));
673                 _view.signal_button_press_event().connect_notify (sigc::mem_fun(*this, &ControlSurfacesOptions::edit_clicked));
674         }
675
676         void parameter_changed (std::string const &)
677         {
678
679         }
680
681         void set_state_from_config ()
682         {
683                 _store->clear ();
684
685                 ControlProtocolManager& m = ControlProtocolManager::instance ();
686                 for (list<ControlProtocolInfo*>::iterator i = m.control_protocol_info.begin(); i != m.control_protocol_info.end(); ++i) {
687
688                         if (!(*i)->mandatory) {
689                                 TreeModel::Row r = *_store->append ();
690                                 r[_model.name] = (*i)->name;
691                                 r[_model.enabled] = ((*i)->protocol || (*i)->requested);
692                                 r[_model.feedback] = ((*i)->protocol && (*i)->protocol->get_feedback ());
693                                 r[_model.protocol_info] = *i;
694                         }
695                 }
696         }
697
698 private:
699
700         void model_changed (TreeModel::Path const &, TreeModel::iterator const & i)
701         {
702                 TreeModel::Row r = *i;
703
704                 ControlProtocolInfo* cpi = r[_model.protocol_info];
705                 if (!cpi) {
706                         return;
707                 }
708
709                 bool const was_enabled = (cpi->protocol != 0);
710                 bool const is_enabled = r[_model.enabled];
711
712                 if (was_enabled != is_enabled) {
713                         if (!was_enabled) {
714                                 ControlProtocolManager::instance().instantiate (*cpi);
715                         } else {
716                                 Gtk::Window* win = r[_model.editor];
717                                 if (win) {
718                                         win->hide ();
719                                 }
720
721                                 ControlProtocolManager::instance().teardown (*cpi);
722                                         
723                                 if (win) {
724                                         delete win;
725                                 }
726                                 r[_model.editor] = 0;
727                                 cpi->requested = false;
728                         }
729                 }
730
731                 bool const was_feedback = (cpi->protocol && cpi->protocol->get_feedback ());
732                 bool const is_feedback = r[_model.feedback];
733
734                 if (was_feedback != is_feedback && cpi->protocol) {
735                         cpi->protocol->set_feedback (is_feedback);
736                 }
737         }
738
739         void edit_clicked (GdkEventButton* ev)
740         {
741                 if (ev->type != GDK_2BUTTON_PRESS) {
742                         return;
743                 }
744
745                 std::string name;
746                 ControlProtocolInfo* cpi;
747                 TreeModel::Row row;
748
749                 row = *(_view.get_selection()->get_selected());
750
751                 Window* win = row[_model.editor];
752                 if (win && !win->is_visible()) {
753                         win->present ();
754                 } else {
755                         cpi = row[_model.protocol_info];
756
757                         if (cpi && cpi->protocol && cpi->protocol->has_editor ()) {
758                                 Box* box = (Box*) cpi->protocol->get_gui ();
759                                 if (box) {
760                                         string title = row[_model.name];
761                                         ArdourWindow* win = new ArdourWindow (_parent, title);
762                                         win->set_title ("Control Protocol Options");
763                                         win->add (*box);
764                                         box->show ();
765                                         win->present ();
766                                         row[_model.editor] = win;
767                                 }
768                         }
769                 }
770         }
771
772         class ControlSurfacesModelColumns : public TreeModelColumnRecord
773         {
774         public:
775
776                 ControlSurfacesModelColumns ()
777                 {
778                         add (name);
779                         add (enabled);
780                         add (feedback);
781                         add (protocol_info);
782                         add (editor);
783                 }
784
785                 TreeModelColumn<string> name;
786                 TreeModelColumn<bool> enabled;
787                 TreeModelColumn<bool> feedback;
788                 TreeModelColumn<ControlProtocolInfo*> protocol_info;
789                 TreeModelColumn<Gtk::Window*> editor;
790         };
791
792         Glib::RefPtr<ListStore> _store;
793         ControlSurfacesModelColumns _model;
794         TreeView _view;
795         Gtk::Window& _parent;
796 };
797
798 /** A class which allows control of visibility of some editor components usign
799  *  a VisibilityGroup.  The caller should pass in a `dummy' VisibilityGroup
800  *  which has the correct members, but with null widget pointers.  This
801  *  class allows the user to set visibility of the members, the details
802  *  of which are stored in a configuration variable which can be watched
803  *  by parts of the editor that actually contain the widgets whose visibility
804  *  is being controlled.
805  */
806
807 class VisibilityOption : public Option
808 {
809 public:
810         /** @param name User-visible name for this group.
811          *  @param g `Dummy' VisibilityGroup (as described above).
812          *  @param get Method to get the value of the appropriate configuration variable.
813          *  @param set Method to set the value of the appropriate configuration variable.
814          */
815         VisibilityOption (string name, VisibilityGroup* g, sigc::slot<string> get, sigc::slot<bool, string> set)
816                 : Option (g->get_state_name(), name)
817                 , _heading (name)
818                 , _visibility_group (g)
819                 , _get (get)
820                 , _set (set)
821         {
822                 /* Watch for changes made by the user to our members */
823                 _visibility_group->VisibilityChanged.connect_same_thread (
824                         _visibility_group_connection, sigc::bind (&VisibilityOption::changed, this)
825                         );
826         }
827
828         void set_state_from_config ()
829         {
830                 /* Set our state from the current configuration */
831                 _visibility_group->set_state (_get ());
832         }
833
834         void add_to_page (OptionEditorPage* p)
835         {
836                 _heading.add_to_page (p);
837                 add_widget_to_page (p, _visibility_group->list_view ());
838         }
839
840 private:
841         void changed ()
842         {
843                 /* The user has changed something, so reflect this change
844                    in the RCConfiguration.
845                 */
846                 _set (_visibility_group->get_state_value ());
847         }
848         
849         OptionEditorHeading _heading;
850         VisibilityGroup* _visibility_group;
851         sigc::slot<std::string> _get;
852         sigc::slot<bool, std::string> _set;
853         PBD::ScopedConnection _visibility_group_connection;
854 };
855
856
857 RCOptionEditor::RCOptionEditor ()
858         : OptionEditor (Config, string_compose (_("%1 Preferences"), PROGRAM_NAME))
859         , _rc_config (Config)
860         , _mixer_strip_visibility ("mixer-strip-visibility")
861 {
862         /* MISC */
863
864         uint32_t hwcpus = hardware_concurrency ();
865
866         if (hwcpus > 1) {
867                 add_option (_("Misc"), new OptionEditorHeading (_("DSP CPU Utilization")));
868
869                 ComboOption<int32_t>* procs = new ComboOption<int32_t> (
870                         "processor-usage",
871                         _("Signal processing uses"),
872                         sigc::mem_fun (*_rc_config, &RCConfiguration::get_processor_usage),
873                         sigc::mem_fun (*_rc_config, &RCConfiguration::set_processor_usage)
874                         );
875
876                 procs->add (-1, _("all but one processor"));
877                 procs->add (0, _("all available processors"));
878
879                 for (uint32_t i = 1; i <= hwcpus; ++i) {
880                         procs->add (i, string_compose (_("%1 processors"), i));
881                 }
882
883                 procs->set_note (string_compose (_("This setting will only take effect when %1 is restarted."), PROGRAM_NAME));
884
885                 add_option (_("Misc"), procs);
886         }
887
888         add_option (_("Misc"), new OptionEditorHeading (S_("Options|Undo")));
889
890         add_option (_("Misc"), new UndoOptions (_rc_config));
891
892         add_option (_("Misc"),
893              new BoolOption (
894                      "verify-remove-last-capture",
895                      _("Verify removal of last capture"),
896                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_verify_remove_last_capture),
897                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_verify_remove_last_capture)
898                      ));
899
900         add_option (_("Misc"),
901              new BoolOption (
902                      "periodic-safety-backups",
903                      _("Make periodic backups of the session file"),
904                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_periodic_safety_backups),
905                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_periodic_safety_backups)
906                      ));
907
908         add_option (_("Misc"), new OptionEditorHeading (_("Session Management")));
909
910         add_option (_("Misc"),
911              new BoolOption (
912                      "only-copy-imported-files",
913                      _("Always copy imported files"),
914                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_only_copy_imported_files),
915                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_only_copy_imported_files)
916                      ));
917
918         add_option (_("Misc"), new DirectoryOption (
919                             X_("default-session-parent-dir"),
920                             _("Default folder for new sessions:"),
921                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_default_session_parent_dir),
922                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_default_session_parent_dir)
923                             ));
924
925         add_option (_("Misc"),
926              new SpinOption<uint32_t> (
927                      "max-recent-sessions",
928                      _("Maximum number of recent sessions"),
929                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_max_recent_sessions),
930                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_max_recent_sessions),
931                      0, 1000, 1, 20
932                      ));
933
934         add_option (_("Misc"), new OptionEditorHeading (_("Click")));
935
936         add_option (_("Misc"), new ClickOptions (_rc_config, this));
937
938         add_option (_("Misc"),
939              new FaderOption (
940                      "click-gain",
941                      _("Click gain level"),
942                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_click_gain),
943                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_click_gain)
944                      ));
945
946         add_option (_("Misc"), new OptionEditorHeading (_("Automation")));
947
948         add_option (_("Misc"),
949              new SpinOption<double> (
950                      "automation-thinning-factor",
951                      _("Thinning factor (larger value => less data)"),
952                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_automation_thinning_factor),
953                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_automation_thinning_factor),
954                      0, 1000, 1, 20
955                      ));
956
957         /* TRANSPORT */
958
959         add_option (_("Transport"),
960              new BoolOption (
961                      "latched-record-enable",
962                      _("Keep record-enable engaged on stop"),
963                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_latched_record_enable),
964                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_latched_record_enable)
965                      ));
966
967         add_option (_("Transport"),
968              new BoolOption (
969                      "stop-recording-on-xrun",
970                      _("Stop recording when an xrun occurs"),
971                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_stop_recording_on_xrun),
972                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_stop_recording_on_xrun)
973                      ));
974
975         add_option (_("Transport"),
976              new BoolOption (
977                      "create-xrun-marker",
978                      _("Create markers where xruns occur"),
979                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_create_xrun_marker),
980                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_create_xrun_marker)
981                      ));
982
983         add_option (_("Transport"),
984              new BoolOption (
985                      "stop-at-session-end",
986                      _("Stop at the end of the session"),
987                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_stop_at_session_end),
988                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_stop_at_session_end)
989                      ));
990
991         add_option (_("Transport"),
992              new BoolOption (
993                      "seamless-loop",
994                      _("Do seamless looping (not possible when slaved to MTC, JACK etc)"),
995                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_seamless_loop),
996                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_seamless_loop)
997                      ));
998
999         add_option (_("Transport"),
1000              new BoolOption (
1001                      "disable-disarm-during-roll",
1002                      _("Disable per-track record disarm while rolling"),
1003                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_disable_disarm_during_roll),
1004                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_disable_disarm_during_roll)
1005                      ));
1006
1007         add_option (_("Transport"),
1008              new BoolOption (
1009                      "quieten_at_speed",
1010                      _("12dB gain reduction during fast-forward and fast-rewind"),
1011                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_quieten_at_speed),
1012                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_quieten_at_speed)
1013                      ));
1014
1015         add_option (_("Transport"), new OptionEditorHeading (S_("Sync/Slave")));
1016
1017         BoolOption* tsf = new BoolOption (
1018                      "timecode-sync-frame-rate",
1019                      _("Force Ardour's timecode rate to match timecode master"),
1020                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_timecode_sync_frame_rate),
1021                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_timecode_sync_frame_rate)
1022                      );
1023         tsf->set_note (_("If off, Ardour will chase the master but will use its own timecode frame rate"));
1024         add_option (_("Transport"), tsf);
1025
1026         /* EDITOR */
1027
1028         add_option (_("Editor"),
1029              new BoolOption (
1030                      "link-region-and-track-selection",
1031                      _("Link selection of regions and tracks"),
1032                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_link_region_and_track_selection),
1033                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_link_region_and_track_selection)
1034                      ));
1035
1036         add_option (_("Editor"),
1037              new BoolOption (
1038                      "automation-follows-regions",
1039                      _("Move relevant automation when audio regions are moved"),
1040                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_automation_follows_regions),
1041                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_automation_follows_regions)
1042                      ));
1043
1044         add_option (_("Editor"),
1045              new BoolOption (
1046                      "show-track-meters",
1047                      _("Show meters on tracks in the editor"),
1048                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_show_track_meters),
1049                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_show_track_meters)
1050                      ));
1051
1052         add_option (_("Editor"),
1053              new BoolOption (
1054                      "use-overlap-equivalency",
1055                      _("Use overlap equivalency for regions"),
1056                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_use_overlap_equivalency),
1057                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_use_overlap_equivalency)
1058                      ));
1059
1060         add_option (_("Editor"),
1061              new BoolOption (
1062                      "rubberbanding-snaps-to-grid",
1063                      _("Make rubberband selection rectangle snap to the grid"),
1064                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_rubberbanding_snaps_to_grid),
1065                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_rubberbanding_snaps_to_grid)
1066                      ));
1067
1068         add_option (_("Editor"),
1069              new BoolOption (
1070                      "show-waveforms",
1071                      _("Show waveforms in regions"),
1072                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_show_waveforms),
1073                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_show_waveforms)
1074                      ));
1075
1076         add_option (_("Editor"),
1077              new BoolComboOption (
1078                      "show-region-gain-envelopes",
1079                      _("Show gain envelopes in audio regions"),
1080                      _("in all modes"),
1081                      _("only in region gain mode"),
1082                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_show_region_gain),
1083                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_show_region_gain)
1084                      ));
1085
1086         ComboOption<WaveformScale>* wfs = new ComboOption<WaveformScale> (
1087                 "waveform-scale",
1088                 _("Waveform scale"),
1089                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_waveform_scale),
1090                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_waveform_scale)
1091                 );
1092
1093         wfs->add (Linear, _("linear"));
1094         wfs->add (Logarithmic, _("logarithmic"));
1095
1096         add_option (_("Editor"), wfs);
1097
1098         ComboOption<WaveformShape>* wfsh = new ComboOption<WaveformShape> (
1099                 "waveform-shape",
1100                 _("Waveform shape"),
1101                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_waveform_shape),
1102                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_waveform_shape)
1103                 );
1104
1105         wfsh->add (Traditional, _("traditional"));
1106         wfsh->add (Rectified, _("rectified"));
1107
1108         add_option (_("Editor"), wfsh);
1109
1110         add_option (_("Editor"),
1111              new BoolOption (
1112                      "show-waveforms-while-recording",
1113                      _("Show waveforms for audio while it is being recorded"),
1114                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_show_waveforms_while_recording),
1115                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_show_waveforms_while_recording)
1116                      ));
1117
1118         add_option (_("Editor"),
1119                     new BoolOption (
1120                             "show-zoom-tools",
1121                             _("Show zoom toolbar"),
1122                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_show_zoom_tools),
1123                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_show_zoom_tools)
1124                             ));
1125
1126         add_option (_("Editor"),
1127                     new BoolOption (
1128                             "color-regions-using-track-color",
1129                             _("Color regions using their track's color"),
1130                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_color_regions_using_track_color),
1131                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_color_regions_using_track_color)
1132                             ));
1133
1134         add_option (_("Editor"),
1135                     new BoolOption (
1136                             "update-editor-during-summary-drag",
1137                             _("Update editor window during drags of the summary"),
1138                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_update_editor_during_summary_drag),
1139                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_update_editor_during_summary_drag)
1140                             ));
1141
1142         add_option (_("Editor"),
1143              new BoolOption (
1144                      "sync-all-route-ordering",
1145                      _("Synchronise editor and mixer track order"),
1146                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_sync_all_route_ordering),
1147                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_sync_all_route_ordering)
1148                      ));
1149
1150         add_option (_("Editor"),
1151              new BoolOption (
1152                      "link-editor-and-mixer-selection",
1153                      _("Synchronise editor and mixer selection"),
1154                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_link_editor_and_mixer_selection),
1155                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_link_editor_and_mixer_selection)
1156                      ));
1157
1158         add_option (_("Editor"),
1159              new BoolOption (
1160                      "name-new-markers",
1161                      _("Name new markers"),
1162                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_name_new_markers),
1163                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_name_new_markers)
1164                      ));
1165
1166         add_option (_("Editor"),
1167             new BoolOption (
1168                     "autoscroll-editor",
1169                     _("Auto-scroll editor window when dragging near its edges"),
1170                     sigc::mem_fun (*_rc_config, &RCConfiguration::get_autoscroll_editor),
1171                     sigc::mem_fun (*_rc_config, &RCConfiguration::set_autoscroll_editor)
1172                     ));
1173
1174         /* AUDIO */
1175
1176         add_option (_("Audio"), new OptionEditorHeading (_("Buffering")));
1177
1178         add_option (_("Audio"), new BufferingOptions (_rc_config));
1179
1180         add_option (_("Audio"), new OptionEditorHeading (_("Monitoring")));
1181
1182         add_option (_("Audio"),
1183              new BoolOption (
1184                      "use-monitor-bus",
1185                      _("Use a monitor bus (allows AFL/PFL and more control)"),
1186                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_use_monitor_bus),
1187                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_use_monitor_bus)
1188                      ));
1189
1190         ComboOption<MonitorModel>* mm = new ComboOption<MonitorModel> (
1191                 "monitoring-model",
1192                 _("Record monitoring handled by"),
1193                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_monitoring_model),
1194                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_monitoring_model)
1195                 );
1196
1197 #ifndef __APPLE__
1198         /* no JACK monitoring on CoreAudio */
1199         if (AudioEngine::instance()->can_request_hardware_monitoring()) {
1200                 mm->add (HardwareMonitoring, _("JACK"));
1201         }
1202 #endif
1203         mm->add (SoftwareMonitoring, _("ardour"));
1204         mm->add (ExternalMonitoring, _("audio hardware"));
1205
1206         add_option (_("Audio"), mm);
1207
1208         add_option (_("Audio"),
1209              new BoolOption (
1210                      "tape-machine-mode",
1211                      _("Tape machine mode"),
1212                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_tape_machine_mode),
1213                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_tape_machine_mode)
1214                      ));
1215
1216         add_option (_("Audio"), new OptionEditorHeading (_("Connection of tracks and busses")));
1217
1218         add_option (_("Audio"),
1219                     new BoolOption (
1220                             "auto-connect-standard-busses",
1221                             _("Auto-connect master/monitor busses"),
1222                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_auto_connect_standard_busses),
1223                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_auto_connect_standard_busses)
1224                             ));
1225
1226         ComboOption<AutoConnectOption>* iac = new ComboOption<AutoConnectOption> (
1227                 "input-auto-connect",
1228                 _("Connect track inputs"),
1229                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_input_auto_connect),
1230                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_input_auto_connect)
1231                 );
1232
1233         iac->add (AutoConnectPhysical, _("automatically to physical inputs"));
1234         iac->add (ManualConnect, _("manually"));
1235
1236         add_option (_("Audio"), iac);
1237
1238         ComboOption<AutoConnectOption>* oac = new ComboOption<AutoConnectOption> (
1239                 "output-auto-connect",
1240                 _("Connect track and bus outputs"),
1241                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_output_auto_connect),
1242                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_output_auto_connect)
1243                 );
1244
1245         oac->add (AutoConnectPhysical, _("automatically to physical outputs"));
1246         oac->add (AutoConnectMaster, _("automatically to master bus"));
1247         oac->add (ManualConnect, _("manually"));
1248
1249         add_option (_("Audio"), oac);
1250
1251         add_option (_("Audio"), new OptionEditorHeading (_("Denormals")));
1252
1253         add_option (_("Audio"),
1254              new BoolOption (
1255                      "denormal-protection",
1256                      _("Use DC bias to protect against denormals"),
1257                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_denormal_protection),
1258                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_denormal_protection)
1259                      ));
1260
1261         ComboOption<DenormalModel>* dm = new ComboOption<DenormalModel> (
1262                 "denormal-model",
1263                 _("Processor handling"),
1264                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_denormal_model),
1265                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_denormal_model)
1266                 );
1267
1268         dm->add (DenormalNone, _("no processor handling"));
1269
1270         FPU fpu;
1271
1272         if (fpu.has_flush_to_zero()) {
1273                 dm->add (DenormalFTZ, _("use FlushToZero"));
1274         }
1275
1276         if (fpu.has_denormals_are_zero()) {
1277                 dm->add (DenormalDAZ, _("use DenormalsAreZero"));
1278         }
1279
1280         if (fpu.has_flush_to_zero() && fpu.has_denormals_are_zero()) {
1281                 dm->add (DenormalFTZDAZ, _("use FlushToZero and DenormalsAreZero"));
1282         }
1283
1284         add_option (_("Audio"), dm);
1285
1286         add_option (_("Audio"), new OptionEditorHeading (_("Plugins")));
1287
1288         add_option (_("Audio"),
1289              new BoolOption (
1290                      "plugins-stop-with-transport",
1291                      _("Silence plugins when the transport is stopped"),
1292                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_plugins_stop_with_transport),
1293                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_plugins_stop_with_transport)
1294                      ));
1295
1296         add_option (_("Audio"),
1297              new BoolOption (
1298                      "do-not-record-plugins",
1299                      _("Disable plugins during recording"),
1300                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_do_not_record_plugins),
1301                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_do_not_record_plugins)
1302                      ));
1303
1304         add_option (_("Audio"),
1305              new BoolOption (
1306                      "new-plugins-active",
1307                      _("Make new plugins active"),
1308                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_new_plugins_active),
1309                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_new_plugins_active)
1310                      ));
1311
1312         add_option (_("Audio"),
1313              new BoolOption (
1314                      "auto-analyse-audio",
1315                      _("Enable automatic analysis of audio"),
1316                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_auto_analyse_audio),
1317                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_auto_analyse_audio)
1318                      ));
1319
1320         add_option (_("Audio"),
1321              new BoolOption (
1322                      "replicate-missing-region-channels",
1323                      _("Replicate missing region channels"),
1324                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_replicate_missing_region_channels),
1325                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_replicate_missing_region_channels)
1326                      ));
1327
1328         /* SOLO AND MUTE */
1329
1330         add_option (_("Solo / mute"),
1331              new FaderOption (
1332                      "solo-mute-gain",
1333                      _("Solo-in-place mute cut (dB)"),
1334                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_solo_mute_gain),
1335                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_solo_mute_gain)
1336                      ));
1337
1338         _solo_control_is_listen_control = new BoolOption (
1339                 "solo-control-is-listen-control",
1340                 _("Solo controls are Listen controls"),
1341                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_solo_control_is_listen_control),
1342                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_solo_control_is_listen_control)
1343                 );
1344
1345         add_option (_("Solo / mute"), _solo_control_is_listen_control);
1346
1347         _listen_position = new ComboOption<ListenPosition> (
1348                 "listen-position",
1349                 _("Listen Position"),
1350                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_listen_position),
1351                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_listen_position)
1352                 );
1353
1354         _listen_position->add (AfterFaderListen, _("after-fader (AFL)"));
1355         _listen_position->add (PreFaderListen, _("pre-fader (PFL)"));
1356
1357         add_option (_("Solo / mute"), _listen_position);
1358
1359         ComboOption<PFLPosition>* pp = new ComboOption<PFLPosition> (
1360                 "pfl-position",
1361                 _("PFL signals come from"),
1362                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_pfl_position),
1363                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_pfl_position)
1364                 );
1365
1366         pp->add (PFLFromBeforeProcessors, _("before pre-fader processors"));
1367         pp->add (PFLFromAfterProcessors, _("pre-fader but after pre-fader processors"));
1368
1369         add_option (_("Solo / mute"), pp);
1370
1371         ComboOption<AFLPosition>* pa = new ComboOption<AFLPosition> (
1372                 "afl-position",
1373                 _("AFL signals come from"),
1374                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_afl_position),
1375                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_afl_position)
1376                 );
1377
1378         pa->add (AFLFromBeforeProcessors, _("immediately post-fader"));
1379         pa->add (AFLFromAfterProcessors, _("after post-fader processors (before pan)"));
1380
1381         add_option (_("Solo / mute"), pa);
1382
1383         parameter_changed ("use-monitor-bus");
1384
1385         add_option (_("Solo / mute"),
1386              new BoolOption (
1387                      "exclusive-solo",
1388                      _("Exclusive solo"),
1389                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_exclusive_solo),
1390                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_exclusive_solo)
1391                      ));
1392
1393         add_option (_("Solo / mute"),
1394              new BoolOption (
1395                      "show-solo-mutes",
1396                      _("Show solo muting"),
1397                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_show_solo_mutes),
1398                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_show_solo_mutes)
1399                      ));
1400
1401         add_option (_("Solo / mute"),
1402              new BoolOption (
1403                      "solo-mute-override",
1404                      _("Soloing overrides muting"),
1405                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_solo_mute_override),
1406                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_solo_mute_override)
1407                      ));
1408
1409         add_option (_("Solo / mute"), new OptionEditorHeading (_("Default track / bus muting options")));
1410
1411         add_option (_("Solo / mute"),
1412              new BoolOption (
1413                      "mute-affects-pre-fader",
1414                      _("Mute affects pre-fader sends"),
1415                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_mute_affects_pre_fader),
1416                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_mute_affects_pre_fader)
1417                      ));
1418
1419         add_option (_("Solo / mute"),
1420              new BoolOption (
1421                      "mute-affects-post-fader",
1422                      _("Mute affects post-fader sends"),
1423                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_mute_affects_post_fader),
1424                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_mute_affects_post_fader)
1425                      ));
1426
1427         add_option (_("Solo / mute"),
1428              new BoolOption (
1429                      "mute-affects-control-outs",
1430                      _("Mute affects control outputs"),
1431                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_mute_affects_control_outs),
1432                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_mute_affects_control_outs)
1433                      ));
1434
1435         add_option (_("Solo / mute"),
1436              new BoolOption (
1437                      "mute-affects-main-outs",
1438                      _("Mute affects main outputs"),
1439                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_mute_affects_main_outs),
1440                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_mute_affects_main_outs)
1441                      ));
1442
1443         add_option (_("MIDI"),
1444                     new BoolOption (
1445                             "send-midi-clock",
1446                             _("Send MIDI Clock"),
1447                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_send_midi_clock),
1448                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_send_midi_clock)
1449                             ));
1450
1451         add_option (_("MIDI"),
1452                     new BoolOption (
1453                             "send-mtc",
1454                             _("Send MIDI Time Code"),
1455                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_send_mtc),
1456                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_send_mtc)
1457                             ));
1458
1459         add_option (_("MIDI"),
1460                     new SpinOption<int> (
1461                             "mtc-qf-speed-tolerance",
1462                             _("Percentage either side of normal transport speed to transmit MTC"),
1463                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_mtc_qf_speed_tolerance),
1464                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_mtc_qf_speed_tolerance),
1465                             0, 20, 1, 5
1466                             ));
1467
1468         add_option (_("MIDI"),
1469                     new BoolOption (
1470                             "mmc-control",
1471                             _("Obey MIDI Machine Control commands"),
1472                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_mmc_control),
1473                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_mmc_control)
1474                             ));
1475
1476         add_option (_("MIDI"),
1477                     new BoolOption (
1478                             "send-mmc",
1479                             _("Send MIDI Machine Control commands"),
1480                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_send_mmc),
1481                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_send_mmc)
1482                             ));
1483
1484         add_option (_("MIDI"),
1485                     new BoolOption (
1486                             "midi-feedback",
1487                             _("Send MIDI control feedback"),
1488                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_midi_feedback),
1489                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_midi_feedback)
1490                             ));
1491
1492         add_option (_("MIDI"),
1493              new SpinOption<uint8_t> (
1494                      "mmc-receive-device-id",
1495                      _("Inbound MMC device ID"),
1496                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_mmc_receive_device_id),
1497                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_mmc_receive_device_id),
1498                      0, 128, 1, 10
1499                      ));
1500
1501         add_option (_("MIDI"),
1502              new SpinOption<uint8_t> (
1503                      "mmc-send-device-id",
1504                      _("Outbound MMC device ID"),
1505                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_mmc_send_device_id),
1506                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_mmc_send_device_id),
1507                      0, 128, 1, 10
1508                      ));
1509
1510         add_option (_("MIDI"),
1511              new SpinOption<int32_t> (
1512                      "initial-program-change",
1513                      _("Initial program change"),
1514                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_initial_program_change),
1515                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_initial_program_change),
1516                      -1, 65536, 1, 10
1517                      ));
1518
1519         add_option (_("MIDI"),
1520                     new BoolOption (
1521                             "diplay-first-midi-bank-as-zero",
1522                             _("Display first MIDI bank/program as 0"),
1523                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_first_midi_bank_is_zero),
1524                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_first_midi_bank_is_zero)
1525                             ));
1526
1527         add_option (_("MIDI"),
1528              new BoolOption (
1529                      "never-display-periodic-midi",
1530                      _("Never display periodic MIDI messages (MTC, MIDI Clock)"),
1531                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_never_display_periodic_midi),
1532                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_never_display_periodic_midi)
1533                      ));
1534
1535         add_option (_("MIDI"),
1536              new BoolOption (
1537                      "sound-midi-notes",
1538                      _("Sound MIDI notes as they are selected"),
1539                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_sound_midi_notes),
1540                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_sound_midi_notes)
1541                      ));
1542
1543         /* USER INTERACTION */
1544
1545         add_option (_("User interaction"), new OptionEditorHeading (_("Keyboard")));
1546
1547         add_option (_("User interaction"), new KeyboardOptions);
1548
1549         add_option (_("User interaction"), new OptionEditorHeading (_("Control surfaces")));
1550
1551         add_option (_("User interaction"), new ControlSurfacesOptions (*this));
1552
1553         ComboOption<RemoteModel>* rm = new ComboOption<RemoteModel> (
1554                 "remote-model",
1555                 _("Control surface remote ID"),
1556                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_remote_model),
1557                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_remote_model)
1558                 );
1559
1560         rm->add (UserOrdered, _("assigned by user"));
1561         rm->add (MixerOrdered, _("follows order of mixer"));
1562         rm->add (EditorOrdered, _("follows order of editor"));
1563
1564         add_option (_("User interaction"), rm);
1565
1566         /* INTERFACE */
1567
1568         add_option (S_("GUI"),
1569              new BoolOption (
1570                      "widget-prelight",
1571                      _("Graphically indicate mouse pointer hovering over various widgets"),
1572                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_widget_prelight),
1573                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_widget_prelight)
1574                      ));
1575
1576 #ifndef GTKOSX
1577         /* font scaling does nothing with GDK/Quartz */
1578         add_option (S_("GUI"), new FontScalingOptions (_rc_config));
1579 #endif
1580         add_option (S_("GUI"),
1581                     new BoolOption (
1582                             "use-own-plugin-gui",
1583                             _("Use plugins' own interfaces instead of Ardour's"),
1584                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_use_plugin_own_gui),
1585                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_use_plugin_own_gui)
1586                             ));
1587
1588         /* The names of these controls must be the same as those given in MixerStrip
1589            for the actual widgets being controlled.
1590         */
1591         _mixer_strip_visibility.add (0, X_("PhaseInvert"), _("Phase Invert"));
1592         _mixer_strip_visibility.add (0, X_("SoloSafe"), _("Solo Safe"));
1593         _mixer_strip_visibility.add (0, X_("SoloIsolated"), _("Solo Isolated"));
1594         _mixer_strip_visibility.add (0, X_("Comments"), _("Comments"));
1595         _mixer_strip_visibility.add (0, X_("Group"), _("Group"));
1596         _mixer_strip_visibility.add (0, X_("MeterPoint"), _("Meter Point"));
1597         
1598         add_option (
1599                 S_("GUI"),
1600                 new VisibilityOption (
1601                         _("Mixer Strip"),
1602                         &_mixer_strip_visibility,
1603                         sigc::mem_fun (*_rc_config, &RCConfiguration::get_mixer_strip_visibility),
1604                         sigc::mem_fun (*_rc_config, &RCConfiguration::set_mixer_strip_visibility)
1605                         )
1606                 );
1607
1608         add_option (S_("GUI"),
1609              new BoolOption (
1610                      "default-narrow_ms",
1611                      _("Use narrow strips in the mixer by default"),
1612                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_default_narrow_ms),
1613                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_default_narrow_ms)
1614                      ));
1615
1616         add_option (S_("GUI"), new OptionEditorHeading (_("Metering")));
1617
1618         ComboOption<float>* mht = new ComboOption<float> (
1619                 "meter-hold",
1620                 _("Meter hold time"),
1621                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_meter_hold),
1622                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_meter_hold)
1623                 );
1624
1625         mht->add (MeterHoldOff, _("off"));
1626         mht->add (MeterHoldShort, _("short"));
1627         mht->add (MeterHoldMedium, _("medium"));
1628         mht->add (MeterHoldLong, _("long"));
1629
1630         add_option (S_("GUI"), mht);
1631
1632         ComboOption<float>* mfo = new ComboOption<float> (
1633                 "meter-falloff",
1634                 _("Meter fall-off"),
1635                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_meter_falloff),
1636                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_meter_falloff)
1637                 );
1638
1639         mfo->add (METER_FALLOFF_OFF, _("off"));
1640         mfo->add (METER_FALLOFF_SLOWEST, _("slowest"));
1641         mfo->add (METER_FALLOFF_SLOW, _("slow"));
1642         mfo->add (METER_FALLOFF_MEDIUM, _("medium"));
1643         mfo->add (METER_FALLOFF_FAST, _("fast"));
1644         mfo->add (METER_FALLOFF_FASTER, _("faster"));
1645         mfo->add (METER_FALLOFF_FASTEST, _("fastest"));
1646
1647         add_option (S_("GUI"), mfo);
1648 }
1649
1650 void
1651 RCOptionEditor::parameter_changed (string const & p)
1652 {
1653         OptionEditor::parameter_changed (p);
1654
1655         if (p == "use-monitor-bus") {
1656                 bool const s = Config->get_use_monitor_bus ();
1657                 if (!s) {
1658                         /* we can't use this if we don't have a monitor bus */
1659                         Config->set_solo_control_is_listen_control (false);
1660                 }
1661                 _solo_control_is_listen_control->set_sensitive (s);
1662                 _listen_position->set_sensitive (s);
1663         }
1664 }