Add option to set default-session-parent-dir (#4438).
[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 (_("Undo")));
882
883         add_option (_("Misc"), new UndoOptions (_rc_config));
884
885         add_option (_("Misc"),
886              new BoolOption (
887                      "verify-remove-last-capture",
888                      _("Verify removal of last capture"),
889                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_verify_remove_last_capture),
890                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_verify_remove_last_capture)
891                      ));
892
893         add_option (_("Misc"),
894              new BoolOption (
895                      "periodic-safety-backups",
896                      _("Make periodic backups of the session file"),
897                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_periodic_safety_backups),
898                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_periodic_safety_backups)
899                      ));
900
901         add_option (_("Misc"), new OptionEditorHeading (_("Misc")));
902
903         add_option (_("Misc"),
904              new BoolOption (
905                      "only-copy-imported-files",
906                      _("Always copy imported files"),
907                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_only_copy_imported_files),
908                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_only_copy_imported_files)
909                      ));
910
911         add_option (_("Misc"), new DirectoryOption (
912                             X_("default-session-parent-dir"),
913                             _("Default folder for new sessions:"),
914                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_default_session_parent_dir),
915                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_default_session_parent_dir)
916                             ));
917
918         add_option (_("Misc"), new OptionEditorHeading (_("Click")));
919
920         add_option (_("Misc"), new ClickOptions (_rc_config, this));
921
922         /* TRANSPORT */
923
924         add_option (_("Transport"),
925              new BoolOption (
926                      "latched-record-enable",
927                      _("Keep record-enable engaged on stop"),
928                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_latched_record_enable),
929                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_latched_record_enable)
930                      ));
931
932         add_option (_("Transport"),
933              new BoolOption (
934                      "stop-recording-on-xrun",
935                      _("Stop recording when an xrun occurs"),
936                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_stop_recording_on_xrun),
937                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_stop_recording_on_xrun)
938                      ));
939
940         add_option (_("Transport"),
941              new BoolOption (
942                      "create-xrun-marker",
943                      _("Create markers where xruns occur"),
944                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_create_xrun_marker),
945                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_create_xrun_marker)
946                      ));
947
948         add_option (_("Transport"),
949              new BoolOption (
950                      "stop-at-session-end",
951                      _("Stop at the end of the session"),
952                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_stop_at_session_end),
953                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_stop_at_session_end)
954                      ));
955
956         add_option (_("Transport"),
957              new BoolOption (
958                      "seamless-loop",
959                      _("Do seamless looping (not possible when slaved to MTC, JACK etc)"),
960                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_seamless_loop),
961                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_seamless_loop)
962                      ));
963
964         add_option (_("Transport"),
965              new BoolOption (
966                      "primary-clock-delta-edit-cursor",
967                      _("Primary clock delta to edit cursor"),
968                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_primary_clock_delta_edit_cursor),
969                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_primary_clock_delta_edit_cursor)
970                      ));
971
972         add_option (_("Transport"),
973              new BoolOption (
974                      "secondary-clock-delta-edit-cursor",
975                      _("Secondary clock delta to edit cursor"),
976                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_secondary_clock_delta_edit_cursor),
977                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_secondary_clock_delta_edit_cursor)
978                      ));
979
980         add_option (_("Transport"),
981              new BoolOption (
982                      "disable-disarm-during-roll",
983                      _("Disable per-track record disarm while rolling"),
984                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_disable_disarm_during_roll),
985                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_disable_disarm_during_roll)
986                      ));
987
988         add_option (_("Transport"),
989              new BoolOption (
990                      "quieten_at_speed",
991                      _("12dB gain reduction during fast-forward and fast-rewind"),
992                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_quieten_at_speed),
993                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_quieten_at_speed)
994                      ));
995
996         /* EDITOR */
997
998         add_option (_("Editor"),
999              new BoolOption (
1000                      "link-region-and-track-selection",
1001                      _("Link selection of regions and tracks"),
1002                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_link_region_and_track_selection),
1003                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_link_region_and_track_selection)
1004                      ));
1005
1006         add_option (_("Editor"),
1007              new BoolOption (
1008                      "automation-follows-regions",
1009                      _("Move relevant automation when audio regions are moved"),
1010                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_automation_follows_regions),
1011                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_automation_follows_regions)
1012                      ));
1013
1014         add_option (_("Editor"),
1015              new BoolOption (
1016                      "show-track-meters",
1017                      _("Show meters on tracks in the editor"),
1018                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_show_track_meters),
1019                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_show_track_meters)
1020                      ));
1021
1022         add_option (_("Editor"),
1023              new BoolOption (
1024                      "use-overlap-equivalency",
1025                      _("Use overlap equivalency for regions"),
1026                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_use_overlap_equivalency),
1027                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_use_overlap_equivalency)
1028                      ));
1029
1030         add_option (_("Editor"),
1031              new BoolOption (
1032                      "rubberbanding-snaps-to-grid",
1033                      _("Make rubberband selection rectangle snap to the grid"),
1034                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_rubberbanding_snaps_to_grid),
1035                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_rubberbanding_snaps_to_grid)
1036                      ));
1037
1038         add_option (_("Editor"),
1039              new BoolOption (
1040                      "show-waveforms",
1041                      _("Show waveforms in regions"),
1042                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_show_waveforms),
1043                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_show_waveforms)
1044                      ));
1045
1046         ComboOption<WaveformScale>* wfs = new ComboOption<WaveformScale> (
1047                 "waveform-scale",
1048                 _("Waveform scale"),
1049                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_waveform_scale),
1050                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_waveform_scale)
1051                 );
1052
1053         wfs->add (Linear, _("linear"));
1054         wfs->add (Logarithmic, _("logarithmic"));
1055
1056         add_option (_("Editor"), wfs);
1057
1058         ComboOption<WaveformShape>* wfsh = new ComboOption<WaveformShape> (
1059                 "waveform-shape",
1060                 _("Waveform shape"),
1061                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_waveform_shape),
1062                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_waveform_shape)
1063                 );
1064
1065         wfsh->add (Traditional, _("traditional"));
1066         wfsh->add (Rectified, _("rectified"));
1067
1068         add_option (_("Editor"), wfsh);
1069
1070         add_option (_("Editor"),
1071              new BoolOption (
1072                      "show-waveforms-while-recording",
1073                      _("Show waveforms for audio while it is being recorded"),
1074                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_show_waveforms_while_recording),
1075                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_show_waveforms_while_recording)
1076                      ));
1077
1078         add_option (_("Editor"),
1079                     new BoolOption (
1080                             "show-zoom-tools",
1081                             _("Show zoom toolbar"),
1082                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_show_zoom_tools),
1083                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_show_zoom_tools)
1084                             ));
1085
1086         add_option (_("Editor"),
1087                     new BoolOption (
1088                             "color-regions-using-track-color",
1089                             _("Color regions using their track's color"),
1090                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_color_regions_using_track_color),
1091                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_color_regions_using_track_color)
1092                             ));
1093
1094         add_option (_("Editor"),
1095                     new BoolOption (
1096                             "update-editor-during-summary-drag",
1097                             _("Update editor window during drags of the summary"),
1098                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_update_editor_during_summary_drag),
1099                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_update_editor_during_summary_drag)
1100                             ));
1101
1102         add_option (_("Editor"),
1103              new BoolOption (
1104                      "sync-all-route-ordering",
1105                      _("Synchronise editor and mixer track order"),
1106                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_sync_all_route_ordering),
1107                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_sync_all_route_ordering)
1108                      ));
1109
1110         add_option (_("Editor"),
1111              new BoolOption (
1112                      "name-new-markers",
1113                      _("Name new markers"),
1114                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_name_new_markers),
1115                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_name_new_markers)
1116                      ));
1117
1118         /* AUDIO */
1119
1120         add_option (_("Audio"), new OptionEditorHeading (_("Buffering")));
1121
1122         add_option (_("Audio"), new BufferingOptions (_rc_config));
1123
1124         add_option (_("Audio"), new OptionEditorHeading (_("Monitoring")));
1125
1126         add_option (_("Audio"),
1127              new BoolOption (
1128                      "use-monitor-bus",
1129                      _("Use a monitor bus (allows AFL/PFL and more control)"),
1130                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_use_monitor_bus),
1131                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_use_monitor_bus)
1132                      ));
1133
1134         ComboOption<MonitorModel>* mm = new ComboOption<MonitorModel> (
1135                 "monitoring-model",
1136                 _("Record monitoring handled by"),
1137                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_monitoring_model),
1138                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_monitoring_model)
1139                 );
1140
1141 #ifndef __APPLE__
1142         /* no JACK monitoring on CoreAudio */
1143         if (AudioEngine::instance()->can_request_hardware_monitoring()) {
1144                 mm->add (HardwareMonitoring, _("JACK"));
1145         }
1146 #endif
1147         mm->add (SoftwareMonitoring, _("ardour"));
1148         mm->add (ExternalMonitoring, _("audio hardware"));
1149
1150         add_option (_("Audio"), mm);
1151
1152         add_option (_("Audio"),
1153              new BoolOption (
1154                      "tape-machine-mode",
1155                      _("Tape machine mode"),
1156                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_tape_machine_mode),
1157                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_tape_machine_mode)
1158                      ));
1159
1160         add_option (_("Audio"), new OptionEditorHeading (_("Connection of tracks and busses")));
1161
1162         add_option (_("Audio"),
1163                     new BoolOption (
1164                             "auto-connect-standard-busses",
1165                             _("Auto-connect master/monitor busses"),
1166                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_auto_connect_standard_busses),
1167                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_auto_connect_standard_busses)
1168                             ));
1169
1170         ComboOption<AutoConnectOption>* iac = new ComboOption<AutoConnectOption> (
1171                 "input-auto-connect",
1172                 _("Connect track inputs"),
1173                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_input_auto_connect),
1174                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_input_auto_connect)
1175                 );
1176
1177         iac->add (AutoConnectPhysical, _("automatically to physical inputs"));
1178         iac->add (ManualConnect, _("manually"));
1179
1180         add_option (_("Audio"), iac);
1181
1182         ComboOption<AutoConnectOption>* oac = new ComboOption<AutoConnectOption> (
1183                 "output-auto-connect",
1184                 _("Connect track and bus outputs"),
1185                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_output_auto_connect),
1186                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_output_auto_connect)
1187                 );
1188
1189         oac->add (AutoConnectPhysical, _("automatically to physical outputs"));
1190         oac->add (AutoConnectMaster, _("automatically to master bus"));
1191         oac->add (ManualConnect, _("manually"));
1192
1193         add_option (_("Audio"), oac);
1194
1195         add_option (_("Audio"), new OptionEditorHeading (_("Denormals")));
1196
1197         add_option (_("Audio"),
1198              new BoolOption (
1199                      "denormal-protection",
1200                      _("Use DC bias to protect against denormals"),
1201                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_denormal_protection),
1202                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_denormal_protection)
1203                      ));
1204
1205         ComboOption<DenormalModel>* dm = new ComboOption<DenormalModel> (
1206                 "denormal-model",
1207                 _("Processor handling"),
1208                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_denormal_model),
1209                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_denormal_model)
1210                 );
1211
1212         dm->add (DenormalNone, _("no processor handling"));
1213
1214         FPU fpu;
1215
1216         if (fpu.has_flush_to_zero()) {
1217                 dm->add (DenormalFTZ, _("use FlushToZero"));
1218         }
1219
1220         if (fpu.has_denormals_are_zero()) {
1221                 dm->add (DenormalDAZ, _("use DenormalsAreZero"));
1222         }
1223
1224         if (fpu.has_flush_to_zero() && fpu.has_denormals_are_zero()) {
1225                 dm->add (DenormalFTZDAZ, _("use FlushToZero and DenormalsAreZerO"));
1226         }
1227
1228         add_option (_("Audio"), dm);
1229
1230         add_option (_("Audio"), new OptionEditorHeading (_("Plugins")));
1231
1232         add_option (_("Audio"),
1233              new BoolOption (
1234                      "plugins-stop-with-transport",
1235                      _("Stop plugins when the transport is stopped"),
1236                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_plugins_stop_with_transport),
1237                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_plugins_stop_with_transport)
1238                      ));
1239
1240         add_option (_("Audio"),
1241              new BoolOption (
1242                      "do-not-record-plugins",
1243                      _("Disable plugins during recording"),
1244                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_do_not_record_plugins),
1245                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_do_not_record_plugins)
1246                      ));
1247
1248         add_option (_("Audio"),
1249              new BoolOption (
1250                      "new-plugins-active",
1251                      _("Make new plugins active"),
1252                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_new_plugins_active),
1253                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_new_plugins_active)
1254                      ));
1255
1256         add_option (_("Audio"),
1257              new BoolOption (
1258                      "auto-analyse-audio",
1259                      _("Enable automatic analysis of audio"),
1260                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_auto_analyse_audio),
1261                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_auto_analyse_audio)
1262                      ));
1263
1264         add_option (_("Audio"),
1265              new BoolOption (
1266                      "replicate-missing-region-channels",
1267                      _("Replicate missing region channels"),
1268                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_replicate_missing_region_channels),
1269                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_replicate_missing_region_channels)
1270                      ));
1271
1272         /* SOLO AND MUTE */
1273
1274         add_option (_("Solo / mute"),
1275              new FaderOption (
1276                      "solo-mute-gain",
1277                      _("Solo-in-place mute cut (dB)"),
1278                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_solo_mute_gain),
1279                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_solo_mute_gain)
1280                      ));
1281
1282         _solo_control_is_listen_control = new BoolOption (
1283                 "solo-control-is-listen-control",
1284                 _("Solo controls are Listen controls"),
1285                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_solo_control_is_listen_control),
1286                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_solo_control_is_listen_control)
1287                 );
1288
1289         add_option (_("Solo / mute"), _solo_control_is_listen_control);
1290
1291         _listen_position = new ComboOption<ListenPosition> (
1292                 "listen-position",
1293                 _("Listen Position"),
1294                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_listen_position),
1295                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_listen_position)
1296                 );
1297
1298         _listen_position->add (AfterFaderListen, _("after-fader (AFL)"));
1299         _listen_position->add (PreFaderListen, _("pre-fader (PFL)"));
1300
1301         add_option (_("Solo / mute"), _listen_position);
1302
1303         ComboOption<PFLPosition>* pp = new ComboOption<PFLPosition> (
1304                 "pfl-position",
1305                 _("PFL signals come from"),
1306                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_pfl_position),
1307                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_pfl_position)
1308                 );
1309
1310         pp->add (PFLFromBeforeProcessors, _("before pre-fader processors"));
1311         pp->add (PFLFromAfterProcessors, _("pre-fader but after pre-fader processors"));
1312
1313         add_option (_("Solo / mute"), pp);
1314
1315         ComboOption<AFLPosition>* pa = new ComboOption<AFLPosition> (
1316                 "afl-position",
1317                 _("AFL signals come from"),
1318                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_afl_position),
1319                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_afl_position)
1320                 );
1321
1322         pa->add (AFLFromBeforeProcessors, _("immediately post-fader"));
1323         pa->add (AFLFromAfterProcessors, _("after post-fader processors (before pan)"));
1324
1325         add_option (_("Solo / mute"), pa);
1326
1327         parameter_changed ("use-monitor-bus");
1328
1329         add_option (_("Solo / mute"),
1330              new BoolOption (
1331                      "exclusive-solo",
1332                      _("Exclusive solo"),
1333                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_exclusive_solo),
1334                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_exclusive_solo)
1335                      ));
1336
1337         add_option (_("Solo / mute"),
1338              new BoolOption (
1339                      "show-solo-mutes",
1340                      _("Show solo muting"),
1341                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_show_solo_mutes),
1342                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_show_solo_mutes)
1343                      ));
1344
1345         add_option (_("Solo / mute"),
1346              new BoolOption (
1347                      "solo-mute-override",
1348                      _("Soloing overrides muting"),
1349                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_solo_mute_override),
1350                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_solo_mute_override)
1351                      ));
1352
1353         add_option (_("Solo / mute"), new OptionEditorHeading (_("Default track / bus muting options")));
1354
1355         add_option (_("Solo / mute"),
1356              new BoolOption (
1357                      "mute-affects-pre-fader",
1358                      _("Mute affects pre-fader sends"),
1359                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_mute_affects_pre_fader),
1360                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_mute_affects_pre_fader)
1361                      ));
1362
1363         add_option (_("Solo / mute"),
1364              new BoolOption (
1365                      "mute-affects-post-fader",
1366                      _("Mute affects post-fader sends"),
1367                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_mute_affects_post_fader),
1368                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_mute_affects_post_fader)
1369                      ));
1370
1371         add_option (_("Solo / mute"),
1372              new BoolOption (
1373                      "mute-affects-control-outs",
1374                      _("Mute affects control outputs"),
1375                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_mute_affects_control_outs),
1376                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_mute_affects_control_outs)
1377                      ));
1378
1379         add_option (_("Solo / mute"),
1380              new BoolOption (
1381                      "mute-affects-main-outs",
1382                      _("Mute affects main outputs"),
1383                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_mute_affects_main_outs),
1384                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_mute_affects_main_outs)
1385                      ));
1386
1387         add_option (_("MIDI"),
1388                     new BoolOption (
1389                             "send-midi-clock",
1390                             _("Send MIDI Clock"),
1391                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_send_midi_clock),
1392                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_send_midi_clock)
1393                             ));
1394
1395         add_option (_("MIDI"),
1396                     new BoolOption (
1397                             "send-mtc",
1398                             _("Send MIDI Time Code"),
1399                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_send_mtc),
1400                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_send_mtc)
1401                             ));
1402
1403         add_option (_("MIDI"),
1404                     new SpinOption<int> (
1405                             "mtc-qf-speed-tolerance",
1406                             _("Percentage either side of normal transport speed to transmit MTC"),
1407                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_mtc_qf_speed_tolerance),
1408                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_mtc_qf_speed_tolerance),
1409                             0, 20, 1, 5
1410                             ));
1411
1412         add_option (_("MIDI"),
1413                     new BoolOption (
1414                             "mmc-control",
1415                             _("Obey MIDI Machine Control commands"),
1416                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_mmc_control),
1417                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_mmc_control)
1418                             ));
1419
1420         add_option (_("MIDI"),
1421                     new BoolOption (
1422                             "send-mmc",
1423                             _("Send MIDI Machine Control commands"),
1424                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_send_mmc),
1425                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_send_mmc)
1426                             ));
1427
1428         add_option (_("MIDI"),
1429                     new BoolOption (
1430                             "midi-feedback",
1431                             _("Send MIDI control feedback"),
1432                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_midi_feedback),
1433                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_midi_feedback)
1434                             ));
1435
1436         add_option (_("MIDI"),
1437              new SpinOption<uint8_t> (
1438                      "mmc-receive-device-id",
1439                      _("Inbound MMC device ID"),
1440                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_mmc_receive_device_id),
1441                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_mmc_receive_device_id),
1442                      0, 128, 1, 10
1443                      ));
1444
1445         add_option (_("MIDI"),
1446              new SpinOption<uint8_t> (
1447                      "mmc-send-device-id",
1448                      _("Outbound MMC device ID"),
1449                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_mmc_send_device_id),
1450                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_mmc_send_device_id),
1451                      0, 128, 1, 10
1452                      ));
1453
1454         add_option (_("MIDI"),
1455              new SpinOption<int32_t> (
1456                      "initial-program-change",
1457                      _("Initial program change"),
1458                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_initial_program_change),
1459                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_initial_program_change),
1460                      -1, 65536, 1, 10
1461                      ));
1462
1463         add_option (_("MIDI"),
1464                     new BoolOption (
1465                             "diplay-first-midi-bank-as-zero",
1466                             _("Display first MIDI bank/program as 0"),
1467                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_first_midi_bank_is_zero),
1468                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_first_midi_bank_is_zero)
1469                             ));
1470
1471         /* USER INTERACTION */
1472
1473         add_option (_("User interaction"), new OptionEditorHeading (_("Keyboard")));
1474
1475         add_option (_("User interaction"), new KeyboardOptions);
1476
1477         add_option (_("User interaction"), new OptionEditorHeading (_("Control surfaces")));
1478
1479         add_option (_("User interaction"), new ControlSurfacesOptions (*this));
1480
1481         ComboOption<RemoteModel>* rm = new ComboOption<RemoteModel> (
1482                 "remote-model",
1483                 _("Control surface remote ID"),
1484                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_remote_model),
1485                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_remote_model)
1486                 );
1487
1488         rm->add (UserOrdered, _("assigned by user"));
1489         rm->add (MixerOrdered, _("follows order of mixer"));
1490         rm->add (EditorOrdered, _("follows order of editor"));
1491
1492         add_option (_("User interaction"), rm);
1493
1494         /* INTERFACE */
1495
1496 #ifndef GTKOSX
1497         /* font scaling does nothing with GDK/Quartz */
1498         add_option (_("Interface"), new FontScalingOptions (_rc_config));
1499 #endif
1500
1501         /* The names of these controls must be the same as those given in MixerStrip
1502            for the actual widgets being controlled.
1503         */
1504         _mixer_strip_visibility.add (0, X_("PhaseInvert"), _("Phase Invert"));
1505         _mixer_strip_visibility.add (0, X_("SoloSafe"), _("Solo Safe"));
1506         _mixer_strip_visibility.add (0, X_("SoloIsolated"), _("Solo Isolated"));
1507         _mixer_strip_visibility.add (0, X_("Comments"), _("Comments"));
1508         _mixer_strip_visibility.add (0, X_("Group"), _("Group"));
1509         _mixer_strip_visibility.add (0, X_("MeterPoint"), _("Meter Point"));
1510         
1511         add_option (
1512                 _("Interface"),
1513                 new VisibilityOption (
1514                         _("Mixer Strip"),
1515                         &_mixer_strip_visibility,
1516                         sigc::mem_fun (*_rc_config, &RCConfiguration::get_mixer_strip_visibility),
1517                         sigc::mem_fun (*_rc_config, &RCConfiguration::set_mixer_strip_visibility)
1518                         )
1519                 );
1520
1521         add_option (_("Interface"),
1522              new BoolOption (
1523                      "default-narrow_ms",
1524                      _("Use narrow mixer strips by default"),
1525                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_default_narrow_ms),
1526                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_default_narrow_ms)
1527                      ));
1528
1529         add_option (_("Interface"), new OptionEditorHeading (_("Metering")));
1530
1531         ComboOption<float>* mht = new ComboOption<float> (
1532                 "meter-hold",
1533                 _("Meter hold time"),
1534                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_meter_hold),
1535                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_meter_hold)
1536                 );
1537
1538         mht->add (MeterHoldOff, _("off"));
1539         mht->add (MeterHoldShort, _("short"));
1540         mht->add (MeterHoldMedium, _("medium"));
1541         mht->add (MeterHoldLong, _("long"));
1542
1543         add_option (_("Interface"), mht);
1544
1545         ComboOption<float>* mfo = new ComboOption<float> (
1546                 "meter-falloff",
1547                 _("Meter fall-off"),
1548                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_meter_falloff),
1549                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_meter_falloff)
1550                 );
1551
1552         mfo->add (METER_FALLOFF_OFF, _("off"));
1553         mfo->add (METER_FALLOFF_SLOWEST, _("slowest"));
1554         mfo->add (METER_FALLOFF_SLOW, _("slow"));
1555         mfo->add (METER_FALLOFF_MEDIUM, _("medium"));
1556         mfo->add (METER_FALLOFF_FAST, _("fast"));
1557         mfo->add (METER_FALLOFF_FASTER, _("faster"));
1558         mfo->add (METER_FALLOFF_FASTEST, _("fastest"));
1559
1560         add_option (_("Interface"), mfo);
1561 }
1562
1563 void
1564 RCOptionEditor::parameter_changed (string const & p)
1565 {
1566         OptionEditor::parameter_changed (p);
1567
1568         if (p == "use-monitor-bus") {
1569                 bool const s = Config->get_use_monitor_bus ();
1570                 if (!s) {
1571                         /* we can't use this if we don't have a monitor bus */
1572                         Config->set_solo_control_is_listen_control (false);
1573                 }
1574                 _solo_control_is_listen_control->set_sensitive (s);
1575                 _listen_position->set_sensitive (s);
1576         }
1577 }