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