Change option name to clarify that get_default_narrow_ms is applied to the mixer...
[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         /* EDITOR */
1016
1017         add_option (_("Editor"),
1018              new BoolOption (
1019                      "link-region-and-track-selection",
1020                      _("Link selection of regions and tracks"),
1021                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_link_region_and_track_selection),
1022                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_link_region_and_track_selection)
1023                      ));
1024
1025         add_option (_("Editor"),
1026              new BoolOption (
1027                      "automation-follows-regions",
1028                      _("Move relevant automation when audio regions are moved"),
1029                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_automation_follows_regions),
1030                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_automation_follows_regions)
1031                      ));
1032
1033         add_option (_("Editor"),
1034              new BoolOption (
1035                      "show-track-meters",
1036                      _("Show meters on tracks in the editor"),
1037                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_show_track_meters),
1038                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_show_track_meters)
1039                      ));
1040
1041         add_option (_("Editor"),
1042              new BoolOption (
1043                      "use-overlap-equivalency",
1044                      _("Use overlap equivalency for regions"),
1045                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_use_overlap_equivalency),
1046                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_use_overlap_equivalency)
1047                      ));
1048
1049         add_option (_("Editor"),
1050              new BoolOption (
1051                      "rubberbanding-snaps-to-grid",
1052                      _("Make rubberband selection rectangle snap to the grid"),
1053                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_rubberbanding_snaps_to_grid),
1054                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_rubberbanding_snaps_to_grid)
1055                      ));
1056
1057         add_option (_("Editor"),
1058              new BoolOption (
1059                      "show-waveforms",
1060                      _("Show waveforms in regions"),
1061                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_show_waveforms),
1062                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_show_waveforms)
1063                      ));
1064
1065         add_option (_("Editor"),
1066              new BoolOption (
1067                      "show-region-gain-envelopes",
1068                      _("Show gain envelopes in audio regions"),
1069                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_show_region_gain),
1070                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_show_region_gain)
1071                      ));
1072
1073         ComboOption<WaveformScale>* wfs = new ComboOption<WaveformScale> (
1074                 "waveform-scale",
1075                 _("Waveform scale"),
1076                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_waveform_scale),
1077                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_waveform_scale)
1078                 );
1079
1080         wfs->add (Linear, _("linear"));
1081         wfs->add (Logarithmic, _("logarithmic"));
1082
1083         add_option (_("Editor"), wfs);
1084
1085         ComboOption<WaveformShape>* wfsh = new ComboOption<WaveformShape> (
1086                 "waveform-shape",
1087                 _("Waveform shape"),
1088                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_waveform_shape),
1089                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_waveform_shape)
1090                 );
1091
1092         wfsh->add (Traditional, _("traditional"));
1093         wfsh->add (Rectified, _("rectified"));
1094
1095         add_option (_("Editor"), wfsh);
1096
1097         add_option (_("Editor"),
1098              new BoolOption (
1099                      "show-waveforms-while-recording",
1100                      _("Show waveforms for audio while it is being recorded"),
1101                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_show_waveforms_while_recording),
1102                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_show_waveforms_while_recording)
1103                      ));
1104
1105         add_option (_("Editor"),
1106                     new BoolOption (
1107                             "show-zoom-tools",
1108                             _("Show zoom toolbar"),
1109                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_show_zoom_tools),
1110                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_show_zoom_tools)
1111                             ));
1112
1113         add_option (_("Editor"),
1114                     new BoolOption (
1115                             "color-regions-using-track-color",
1116                             _("Color regions using their track's color"),
1117                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_color_regions_using_track_color),
1118                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_color_regions_using_track_color)
1119                             ));
1120
1121         add_option (_("Editor"),
1122                     new BoolOption (
1123                             "update-editor-during-summary-drag",
1124                             _("Update editor window during drags of the summary"),
1125                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_update_editor_during_summary_drag),
1126                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_update_editor_during_summary_drag)
1127                             ));
1128
1129         add_option (_("Editor"),
1130              new BoolOption (
1131                      "sync-all-route-ordering",
1132                      _("Synchronise editor and mixer track order"),
1133                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_sync_all_route_ordering),
1134                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_sync_all_route_ordering)
1135                      ));
1136
1137         add_option (_("Editor"),
1138              new BoolOption (
1139                      "link-editor-and-mixer-selection",
1140                      _("Synchronise editor and mixer selection"),
1141                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_link_editor_and_mixer_selection),
1142                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_link_editor_and_mixer_selection)
1143                      ));
1144
1145         add_option (_("Editor"),
1146              new BoolOption (
1147                      "name-new-markers",
1148                      _("Name new markers"),
1149                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_name_new_markers),
1150                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_name_new_markers)
1151                      ));
1152
1153         add_option (_("Editor"),
1154             new BoolOption (
1155                     "autoscroll-editor",
1156                     _("Auto-scroll editor window when dragging near its edges"),
1157                     sigc::mem_fun (*_rc_config, &RCConfiguration::get_autoscroll_editor),
1158                     sigc::mem_fun (*_rc_config, &RCConfiguration::set_autoscroll_editor)
1159                     ));
1160
1161         /* AUDIO */
1162
1163         add_option (_("Audio"), new OptionEditorHeading (_("Buffering")));
1164
1165         add_option (_("Audio"), new BufferingOptions (_rc_config));
1166
1167         add_option (_("Audio"), new OptionEditorHeading (_("Monitoring")));
1168
1169         add_option (_("Audio"),
1170              new BoolOption (
1171                      "use-monitor-bus",
1172                      _("Use a monitor bus (allows AFL/PFL and more control)"),
1173                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_use_monitor_bus),
1174                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_use_monitor_bus)
1175                      ));
1176
1177         ComboOption<MonitorModel>* mm = new ComboOption<MonitorModel> (
1178                 "monitoring-model",
1179                 _("Record monitoring handled by"),
1180                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_monitoring_model),
1181                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_monitoring_model)
1182                 );
1183
1184 #ifndef __APPLE__
1185         /* no JACK monitoring on CoreAudio */
1186         if (AudioEngine::instance()->can_request_hardware_monitoring()) {
1187                 mm->add (HardwareMonitoring, _("JACK"));
1188         }
1189 #endif
1190         mm->add (SoftwareMonitoring, _("ardour"));
1191         mm->add (ExternalMonitoring, _("audio hardware"));
1192
1193         add_option (_("Audio"), mm);
1194
1195         add_option (_("Audio"),
1196              new BoolOption (
1197                      "tape-machine-mode",
1198                      _("Tape machine mode"),
1199                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_tape_machine_mode),
1200                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_tape_machine_mode)
1201                      ));
1202
1203         add_option (_("Audio"), new OptionEditorHeading (_("Connection of tracks and busses")));
1204
1205         add_option (_("Audio"),
1206                     new BoolOption (
1207                             "auto-connect-standard-busses",
1208                             _("Auto-connect master/monitor busses"),
1209                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_auto_connect_standard_busses),
1210                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_auto_connect_standard_busses)
1211                             ));
1212
1213         ComboOption<AutoConnectOption>* iac = new ComboOption<AutoConnectOption> (
1214                 "input-auto-connect",
1215                 _("Connect track inputs"),
1216                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_input_auto_connect),
1217                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_input_auto_connect)
1218                 );
1219
1220         iac->add (AutoConnectPhysical, _("automatically to physical inputs"));
1221         iac->add (ManualConnect, _("manually"));
1222
1223         add_option (_("Audio"), iac);
1224
1225         ComboOption<AutoConnectOption>* oac = new ComboOption<AutoConnectOption> (
1226                 "output-auto-connect",
1227                 _("Connect track and bus outputs"),
1228                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_output_auto_connect),
1229                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_output_auto_connect)
1230                 );
1231
1232         oac->add (AutoConnectPhysical, _("automatically to physical outputs"));
1233         oac->add (AutoConnectMaster, _("automatically to master bus"));
1234         oac->add (ManualConnect, _("manually"));
1235
1236         add_option (_("Audio"), oac);
1237
1238         add_option (_("Audio"), new OptionEditorHeading (_("Denormals")));
1239
1240         add_option (_("Audio"),
1241              new BoolOption (
1242                      "denormal-protection",
1243                      _("Use DC bias to protect against denormals"),
1244                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_denormal_protection),
1245                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_denormal_protection)
1246                      ));
1247
1248         ComboOption<DenormalModel>* dm = new ComboOption<DenormalModel> (
1249                 "denormal-model",
1250                 _("Processor handling"),
1251                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_denormal_model),
1252                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_denormal_model)
1253                 );
1254
1255         dm->add (DenormalNone, _("no processor handling"));
1256
1257         FPU fpu;
1258
1259         if (fpu.has_flush_to_zero()) {
1260                 dm->add (DenormalFTZ, _("use FlushToZero"));
1261         }
1262
1263         if (fpu.has_denormals_are_zero()) {
1264                 dm->add (DenormalDAZ, _("use DenormalsAreZero"));
1265         }
1266
1267         if (fpu.has_flush_to_zero() && fpu.has_denormals_are_zero()) {
1268                 dm->add (DenormalFTZDAZ, _("use FlushToZero and DenormalsAreZero"));
1269         }
1270
1271         add_option (_("Audio"), dm);
1272
1273         add_option (_("Audio"), new OptionEditorHeading (_("Plugins")));
1274
1275         add_option (_("Audio"),
1276              new BoolOption (
1277                      "plugins-stop-with-transport",
1278                      _("Silence plugins when the transport is stopped"),
1279                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_plugins_stop_with_transport),
1280                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_plugins_stop_with_transport)
1281                      ));
1282
1283         add_option (_("Audio"),
1284              new BoolOption (
1285                      "do-not-record-plugins",
1286                      _("Disable plugins during recording"),
1287                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_do_not_record_plugins),
1288                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_do_not_record_plugins)
1289                      ));
1290
1291         add_option (_("Audio"),
1292              new BoolOption (
1293                      "new-plugins-active",
1294                      _("Make new plugins active"),
1295                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_new_plugins_active),
1296                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_new_plugins_active)
1297                      ));
1298
1299         add_option (_("Audio"),
1300              new BoolOption (
1301                      "auto-analyse-audio",
1302                      _("Enable automatic analysis of audio"),
1303                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_auto_analyse_audio),
1304                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_auto_analyse_audio)
1305                      ));
1306
1307         add_option (_("Audio"),
1308              new BoolOption (
1309                      "replicate-missing-region-channels",
1310                      _("Replicate missing region channels"),
1311                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_replicate_missing_region_channels),
1312                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_replicate_missing_region_channels)
1313                      ));
1314
1315         /* SOLO AND MUTE */
1316
1317         add_option (_("Solo / mute"),
1318              new FaderOption (
1319                      "solo-mute-gain",
1320                      _("Solo-in-place mute cut (dB)"),
1321                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_solo_mute_gain),
1322                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_solo_mute_gain)
1323                      ));
1324
1325         _solo_control_is_listen_control = new BoolOption (
1326                 "solo-control-is-listen-control",
1327                 _("Solo controls are Listen controls"),
1328                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_solo_control_is_listen_control),
1329                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_solo_control_is_listen_control)
1330                 );
1331
1332         add_option (_("Solo / mute"), _solo_control_is_listen_control);
1333
1334         _listen_position = new ComboOption<ListenPosition> (
1335                 "listen-position",
1336                 _("Listen Position"),
1337                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_listen_position),
1338                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_listen_position)
1339                 );
1340
1341         _listen_position->add (AfterFaderListen, _("after-fader (AFL)"));
1342         _listen_position->add (PreFaderListen, _("pre-fader (PFL)"));
1343
1344         add_option (_("Solo / mute"), _listen_position);
1345
1346         ComboOption<PFLPosition>* pp = new ComboOption<PFLPosition> (
1347                 "pfl-position",
1348                 _("PFL signals come from"),
1349                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_pfl_position),
1350                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_pfl_position)
1351                 );
1352
1353         pp->add (PFLFromBeforeProcessors, _("before pre-fader processors"));
1354         pp->add (PFLFromAfterProcessors, _("pre-fader but after pre-fader processors"));
1355
1356         add_option (_("Solo / mute"), pp);
1357
1358         ComboOption<AFLPosition>* pa = new ComboOption<AFLPosition> (
1359                 "afl-position",
1360                 _("AFL signals come from"),
1361                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_afl_position),
1362                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_afl_position)
1363                 );
1364
1365         pa->add (AFLFromBeforeProcessors, _("immediately post-fader"));
1366         pa->add (AFLFromAfterProcessors, _("after post-fader processors (before pan)"));
1367
1368         add_option (_("Solo / mute"), pa);
1369
1370         parameter_changed ("use-monitor-bus");
1371
1372         add_option (_("Solo / mute"),
1373              new BoolOption (
1374                      "exclusive-solo",
1375                      _("Exclusive solo"),
1376                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_exclusive_solo),
1377                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_exclusive_solo)
1378                      ));
1379
1380         add_option (_("Solo / mute"),
1381              new BoolOption (
1382                      "show-solo-mutes",
1383                      _("Show solo muting"),
1384                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_show_solo_mutes),
1385                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_show_solo_mutes)
1386                      ));
1387
1388         add_option (_("Solo / mute"),
1389              new BoolOption (
1390                      "solo-mute-override",
1391                      _("Soloing overrides muting"),
1392                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_solo_mute_override),
1393                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_solo_mute_override)
1394                      ));
1395
1396         add_option (_("Solo / mute"), new OptionEditorHeading (_("Default track / bus muting options")));
1397
1398         add_option (_("Solo / mute"),
1399              new BoolOption (
1400                      "mute-affects-pre-fader",
1401                      _("Mute affects pre-fader sends"),
1402                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_mute_affects_pre_fader),
1403                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_mute_affects_pre_fader)
1404                      ));
1405
1406         add_option (_("Solo / mute"),
1407              new BoolOption (
1408                      "mute-affects-post-fader",
1409                      _("Mute affects post-fader sends"),
1410                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_mute_affects_post_fader),
1411                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_mute_affects_post_fader)
1412                      ));
1413
1414         add_option (_("Solo / mute"),
1415              new BoolOption (
1416                      "mute-affects-control-outs",
1417                      _("Mute affects control outputs"),
1418                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_mute_affects_control_outs),
1419                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_mute_affects_control_outs)
1420                      ));
1421
1422         add_option (_("Solo / mute"),
1423              new BoolOption (
1424                      "mute-affects-main-outs",
1425                      _("Mute affects main outputs"),
1426                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_mute_affects_main_outs),
1427                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_mute_affects_main_outs)
1428                      ));
1429
1430         add_option (_("MIDI"),
1431                     new BoolOption (
1432                             "send-midi-clock",
1433                             _("Send MIDI Clock"),
1434                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_send_midi_clock),
1435                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_send_midi_clock)
1436                             ));
1437
1438         add_option (_("MIDI"),
1439                     new BoolOption (
1440                             "send-mtc",
1441                             _("Send MIDI Time Code"),
1442                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_send_mtc),
1443                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_send_mtc)
1444                             ));
1445
1446         add_option (_("MIDI"),
1447                     new SpinOption<int> (
1448                             "mtc-qf-speed-tolerance",
1449                             _("Percentage either side of normal transport speed to transmit MTC"),
1450                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_mtc_qf_speed_tolerance),
1451                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_mtc_qf_speed_tolerance),
1452                             0, 20, 1, 5
1453                             ));
1454
1455         add_option (_("MIDI"),
1456                     new BoolOption (
1457                             "mmc-control",
1458                             _("Obey MIDI Machine Control commands"),
1459                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_mmc_control),
1460                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_mmc_control)
1461                             ));
1462
1463         add_option (_("MIDI"),
1464                     new BoolOption (
1465                             "send-mmc",
1466                             _("Send MIDI Machine Control commands"),
1467                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_send_mmc),
1468                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_send_mmc)
1469                             ));
1470
1471         add_option (_("MIDI"),
1472                     new BoolOption (
1473                             "midi-feedback",
1474                             _("Send MIDI control feedback"),
1475                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_midi_feedback),
1476                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_midi_feedback)
1477                             ));
1478
1479         add_option (_("MIDI"),
1480              new SpinOption<uint8_t> (
1481                      "mmc-receive-device-id",
1482                      _("Inbound MMC device ID"),
1483                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_mmc_receive_device_id),
1484                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_mmc_receive_device_id),
1485                      0, 128, 1, 10
1486                      ));
1487
1488         add_option (_("MIDI"),
1489              new SpinOption<uint8_t> (
1490                      "mmc-send-device-id",
1491                      _("Outbound MMC device ID"),
1492                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_mmc_send_device_id),
1493                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_mmc_send_device_id),
1494                      0, 128, 1, 10
1495                      ));
1496
1497         add_option (_("MIDI"),
1498              new SpinOption<int32_t> (
1499                      "initial-program-change",
1500                      _("Initial program change"),
1501                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_initial_program_change),
1502                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_initial_program_change),
1503                      -1, 65536, 1, 10
1504                      ));
1505
1506         add_option (_("MIDI"),
1507                     new BoolOption (
1508                             "diplay-first-midi-bank-as-zero",
1509                             _("Display first MIDI bank/program as 0"),
1510                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_first_midi_bank_is_zero),
1511                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_first_midi_bank_is_zero)
1512                             ));
1513
1514         add_option (_("MIDI"),
1515              new BoolOption (
1516                      "never-display-periodic-midi",
1517                      _("Never display periodic MIDI messages (MTC, MIDI Clock)"),
1518                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_never_display_periodic_midi),
1519                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_never_display_periodic_midi)
1520                      ));
1521
1522         add_option (_("MIDI"),
1523              new BoolOption (
1524                      "sound-midi-notes",
1525                      _("Sound MIDI notes as they are selected"),
1526                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_sound_midi_notes),
1527                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_sound_midi_notes)
1528                      ));
1529
1530         /* USER INTERACTION */
1531
1532         add_option (_("User interaction"), new OptionEditorHeading (_("Keyboard")));
1533
1534         add_option (_("User interaction"), new KeyboardOptions);
1535
1536         add_option (_("User interaction"), new OptionEditorHeading (_("Control surfaces")));
1537
1538         add_option (_("User interaction"), new ControlSurfacesOptions (*this));
1539
1540         ComboOption<RemoteModel>* rm = new ComboOption<RemoteModel> (
1541                 "remote-model",
1542                 _("Control surface remote ID"),
1543                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_remote_model),
1544                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_remote_model)
1545                 );
1546
1547         rm->add (UserOrdered, _("assigned by user"));
1548         rm->add (MixerOrdered, _("follows order of mixer"));
1549         rm->add (EditorOrdered, _("follows order of editor"));
1550
1551         add_option (_("User interaction"), rm);
1552
1553         /* INTERFACE */
1554
1555         add_option (S_("Visual|Interface"),
1556              new BoolOption (
1557                      "widget-prelight",
1558                      _("Graphically indicate mouse pointer hovering over various widgets"),
1559                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_widget_prelight),
1560                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_widget_prelight)
1561                      ));
1562
1563 #ifndef GTKOSX
1564         /* font scaling does nothing with GDK/Quartz */
1565         add_option (S_("Visual|Interface"), new FontScalingOptions (_rc_config));
1566 #endif
1567         add_option (S_("Visual|Interface"),
1568                     new BoolOption (
1569                             "use-own-plugin-gui",
1570                             _("Use plugins' own interfaces instead of Ardour's"),
1571                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_use_plugin_own_gui),
1572                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_use_plugin_own_gui)
1573                             ));
1574
1575         /* The names of these controls must be the same as those given in MixerStrip
1576            for the actual widgets being controlled.
1577         */
1578         _mixer_strip_visibility.add (0, X_("PhaseInvert"), _("Phase Invert"));
1579         _mixer_strip_visibility.add (0, X_("SoloSafe"), _("Solo Safe"));
1580         _mixer_strip_visibility.add (0, X_("SoloIsolated"), _("Solo Isolated"));
1581         _mixer_strip_visibility.add (0, X_("Comments"), _("Comments"));
1582         _mixer_strip_visibility.add (0, X_("Group"), _("Group"));
1583         _mixer_strip_visibility.add (0, X_("MeterPoint"), _("Meter Point"));
1584         
1585         add_option (
1586                 S_("Visual|Interface"),
1587                 new VisibilityOption (
1588                         _("Mixer Strip"),
1589                         &_mixer_strip_visibility,
1590                         sigc::mem_fun (*_rc_config, &RCConfiguration::get_mixer_strip_visibility),
1591                         sigc::mem_fun (*_rc_config, &RCConfiguration::set_mixer_strip_visibility)
1592                         )
1593                 );
1594
1595         add_option (S_("Visual|Interface"),
1596              new BoolOption (
1597                      "default-narrow_ms",
1598                      _("Use narrow strips in the mixer by default"),
1599                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_default_narrow_ms),
1600                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_default_narrow_ms)
1601                      ));
1602
1603         add_option (S_("Visual|Interface"), new OptionEditorHeading (_("Metering")));
1604
1605         ComboOption<float>* mht = new ComboOption<float> (
1606                 "meter-hold",
1607                 _("Meter hold time"),
1608                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_meter_hold),
1609                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_meter_hold)
1610                 );
1611
1612         mht->add (MeterHoldOff, _("off"));
1613         mht->add (MeterHoldShort, _("short"));
1614         mht->add (MeterHoldMedium, _("medium"));
1615         mht->add (MeterHoldLong, _("long"));
1616
1617         add_option (S_("Visual|Interface"), mht);
1618
1619         ComboOption<float>* mfo = new ComboOption<float> (
1620                 "meter-falloff",
1621                 _("Meter fall-off"),
1622                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_meter_falloff),
1623                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_meter_falloff)
1624                 );
1625
1626         mfo->add (METER_FALLOFF_OFF, _("off"));
1627         mfo->add (METER_FALLOFF_SLOWEST, _("slowest"));
1628         mfo->add (METER_FALLOFF_SLOW, _("slow"));
1629         mfo->add (METER_FALLOFF_MEDIUM, _("medium"));
1630         mfo->add (METER_FALLOFF_FAST, _("fast"));
1631         mfo->add (METER_FALLOFF_FASTER, _("faster"));
1632         mfo->add (METER_FALLOFF_FASTEST, _("fastest"));
1633
1634         add_option (S_("Visual|Interface"), mfo);
1635 }
1636
1637 void
1638 RCOptionEditor::parameter_changed (string const & p)
1639 {
1640         OptionEditor::parameter_changed (p);
1641
1642         if (p == "use-monitor-bus") {
1643                 bool const s = Config->get_use_monitor_bus ();
1644                 if (!s) {
1645                         /* we can't use this if we don't have a monitor bus */
1646                         Config->set_solo_control_is_listen_control (false);
1647                 }
1648                 _solo_control_is_listen_control->set_sensitive (s);
1649                 _listen_position->set_sensitive (s);
1650         }
1651 }