use correct (RCConfig-based) name for MIDI port in generic MIDI control stuff; make...
[ardour.git] / gtk2_ardour / rc_option_editor.cc
1 #include <gtkmm/liststore.h>
2 #include <gtkmm/stock.h>
3 #include <gtkmm/scale.h>
4 #include <gtkmm2ext/utils.h>
5 #include <gtkmm2ext/slider_controller.h>
6 #include "pbd/fpu.h"
7 #include "midi++/manager.h"
8 #include "midi++/factory.h"
9 #include "ardour/dB.h"
10 #include "ardour/rc_configuration.h"
11 #include "ardour/control_protocol_manager.h"
12 #include "control_protocol/control_protocol.h"
13
14 #include "gui_thread.h"
15 #include "midi_tracer.h"
16 #include "rc_option_editor.h"
17 #include "utils.h"
18 #include "midi_port_dialog.h"
19 #include "sfdb_ui.h"
20 #include "keyboard.h"
21 #include "i18n.h"
22
23 using namespace std;
24 using namespace Gtk;
25 using namespace Gtkmm2ext;
26 using namespace PBD;
27 using namespace ARDOUR;
28
29 class MIDIPorts : public OptionEditorBox
30 {
31 public:
32         MIDIPorts (RCConfiguration* c, list<ComboOption<string>* > const & o)
33                 : _rc_config (c),
34                   _add_port_button (Stock::ADD),
35                   _port_combos (o)
36         {
37                 _store = ListStore::create (_model);
38                 _view.set_model (_store);
39                 _view.append_column (_("Name"), _model.name);
40                 _view.get_column(0)->set_resizable (true);
41                 _view.get_column(0)->set_expand (true);
42                 _view.append_column_editable (_("Online"), _model.online);
43                 _view.append_column_editable (_("Trace input"), _model.trace_input);
44                 _view.append_column_editable (_("Trace output"), _model.trace_output);
45
46                 HBox* h = manage (new HBox);
47                 h->set_spacing (4);
48                 h->pack_start (_view, true, true);
49
50                 VBox* v = manage (new VBox);
51                 v->set_spacing (4);
52                 v->pack_start (_add_port_button, false, false);
53                 h->pack_start (*v, false, false);
54
55                 _box->pack_start (*h);
56
57                 ports_changed ();
58
59                 _store->signal_row_changed().connect (sigc::mem_fun (*this, &MIDIPorts::model_changed));
60
61                 _add_port_button.signal_clicked().connect (sigc::mem_fun (*this, &MIDIPorts::add_port_clicked));
62         }
63
64         void parameter_changed (string const &) {}
65         void set_state_from_config () {}
66
67 private:
68
69         typedef std::map<MIDI::Port*,MidiTracer*> PortTraceMap;
70         PortTraceMap port_input_trace_map;
71         PortTraceMap port_output_trace_map;
72
73         void model_changed (TreeModel::Path const &, TreeModel::iterator const & i)
74         {
75                 TreeModel::Row r = *i;
76
77                 MIDI::Port* port = r[_model.port];
78                 if (!port) {
79                         return;
80                 }
81
82                 if (port->input()) {
83
84                         if (r[_model.online] == port->input()->offline()) {
85                                 port->input()->set_offline (!r[_model.online]);
86                         }
87
88                         if (r[_model.trace_input] != port->input()->tracing()) {
89                                 PortTraceMap::iterator x = port_input_trace_map.find (port);
90                                 MidiTracer* mt;
91
92                                 if (x == port_input_trace_map.end()) {
93                                          mt = new MidiTracer (port->name() + string (" [input]"), *port->input());
94                                          port_input_trace_map.insert (pair<MIDI::Port*,MidiTracer*> (port, mt));
95                                 } else {
96                                         mt = x->second;
97                                 }
98                                 mt->present ();
99                         }
100                 }
101
102                 if (port->output()) {
103
104                         if (r[_model.trace_output] != port->output()->tracing()) {
105                                 PortTraceMap::iterator x = port_output_trace_map.find (port);
106                                 MidiTracer* mt;
107
108                                 if (x == port_output_trace_map.end()) {
109                                         mt = new MidiTracer (port->name() + string (" [output]"), *port->output());
110                                         port_output_trace_map.insert (pair<MIDI::Port*,MidiTracer*> (port, mt));
111                                 } else {
112                                         mt = x->second;
113                                 }
114                                 mt->present ();
115                         }
116
117                 }
118         }
119
120         void setup_ports_combo (ComboOption<string>* c)
121         {
122                 c->clear ();
123                 MIDI::Manager::PortList const & ports = MIDI::Manager::instance()->get_midi_ports ();
124                 for (MIDI::Manager::PortList::const_iterator i = ports.begin(); i != ports.end(); ++i) {
125                         c->add ((*i)->name(), (*i)->name());
126                 }
127         }       
128
129         void ports_changed ()
130         {
131                 /* XXX: why is this coming from here? */
132                 MIDI::Manager::PortList const & ports = MIDI::Manager::instance()->get_midi_ports ();
133
134                 _store->clear ();
135                 port_connections.drop_connections ();
136
137                 for (MIDI::Manager::PortList::const_iterator i = ports.begin(); i != ports.end(); ++i) {
138
139                         TreeModel::Row r = *_store->append ();
140
141                         r[_model.name] = (*i)->name();
142
143                         if ((*i)->input()) {
144                                 r[_model.online] = !(*i)->input()->offline();
145                                 (*i)->input()->OfflineStatusChanged.connect (port_connections, boost::bind (&MIDIPorts::port_offline_changed, this, (*i)), gui_context());
146                                 r[_model.trace_input] = (*i)->input()->tracing();
147                         }
148
149                         if ((*i)->output()) {
150                                 r[_model.trace_output] = (*i)->output()->tracing();
151                         }
152
153                         r[_model.port] = (*i);
154                 }
155
156                 for (list<ComboOption<string>* >::iterator i = _port_combos.begin(); i != _port_combos.end(); ++i) {
157                         setup_ports_combo (*i);
158                 }
159         }
160
161         void port_offline_changed (MIDI::Port* p)
162         {
163                 if (!p->input()) {
164                         return;
165                 }
166
167                 for (TreeModel::Children::iterator i = _store->children().begin(); i != _store->children().end(); ++i) {
168                         if ((*i)[_model.port] == p) {
169                                 (*i)[_model.online] = !p->input()->offline();
170                         }
171                 }
172         }
173
174         void add_port_clicked ()
175         {
176                 MidiPortDialog dialog;
177
178                 dialog.set_position (WIN_POS_MOUSE);
179
180                 dialog.show ();
181
182                 int const r = dialog.run ();
183
184                 switch (r) {
185                 case RESPONSE_ACCEPT:
186                         break;
187                 default:
188                         return;
189                         break;
190                 }
191
192                 Glib::ustring const mode = dialog.port_mode_combo.get_active_text ();
193                 string smod;
194
195                 if (mode == _("input")) {
196                         smod = X_("input");
197                 } else if (mode == (_("output"))) {
198                         smod = X_("output");
199                 } else {
200                         smod = "duplex";
201                 }
202
203                 XMLNode node (X_("MIDI-port"));
204
205                 node.add_property ("tag", dialog.port_name.get_text());
206                 node.add_property ("device", X_("ardour")); // XXX this can't be right for all types
207                 node.add_property ("type", MIDI::PortFactory::default_port_type());
208                 node.add_property ("mode", smod);
209
210                 if (MIDI::Manager::instance()->add_port (node) != 0) {
211                         cerr << " there are now " << MIDI::Manager::instance()->nports() << endl;
212                         ports_changed ();
213                 }
214         }
215
216         class MIDIModelColumns : public TreeModelColumnRecord
217         {
218         public:
219                 MIDIModelColumns ()
220                 {
221                         add (name);
222                         add (online);
223                         add (trace_input);
224                         add (trace_output);
225                         add (port);
226                 }
227
228                 TreeModelColumn<string> name;
229                 TreeModelColumn<bool> online;
230                 TreeModelColumn<bool> trace_input;
231                 TreeModelColumn<bool> trace_output;
232                 TreeModelColumn<MIDI::Port*> port;
233         };
234
235         RCConfiguration* _rc_config;
236         Glib::RefPtr<ListStore> _store;
237         MIDIModelColumns _model;
238         TreeView _view;
239         Button _add_port_button;
240         ComboBoxText _mtc_combo;
241         ComboBoxText _midi_clock_combo;
242         ComboBoxText _mmc_combo;
243         ComboBoxText _mpc_combo;
244         list<ComboOption<string>* > _port_combos;
245         PBD::ScopedConnectionList port_connections;
246 };
247
248
249 class ClickOptions : public OptionEditorBox
250 {
251 public:
252         ClickOptions (RCConfiguration* c, ArdourDialog* p)
253                 : _rc_config (c),
254                   _parent (p)
255         {
256                 Table* t = manage (new Table (2, 3));
257                 t->set_spacings (4);
258
259                 Label* l = manage (new Label (_("Click audio file:")));
260                 l->set_alignment (0, 0.5);
261                 t->attach (*l, 0, 1, 0, 1, FILL);
262                 t->attach (_click_path_entry, 1, 2, 0, 1, FILL);
263                 Button* b = manage (new Button (_("Browse...")));
264                 b->signal_clicked().connect (sigc::mem_fun (*this, &ClickOptions::click_browse_clicked));
265                 t->attach (*b, 2, 3, 0, 1, FILL);
266
267                 l = manage (new Label (_("Click emphasis audio file:")));
268                 l->set_alignment (0, 0.5);
269                 t->attach (*l, 0, 1, 1, 2, FILL);
270                 t->attach (_click_emphasis_path_entry, 1, 2, 1, 2, FILL);
271                 b = manage (new Button (_("Browse...")));
272                 b->signal_clicked().connect (sigc::mem_fun (*this, &ClickOptions::click_emphasis_browse_clicked));
273                 t->attach (*b, 2, 3, 1, 2, FILL);
274
275                 _box->pack_start (*t, false, false);
276         }
277
278         void parameter_changed (string const & p)
279         {
280                 if (p == "click-sound") {
281                         _click_path_entry.set_text (_rc_config->get_click_sound());
282                 } else if (p == "click-emphasis-sound") {
283                         _click_emphasis_path_entry.set_text (_rc_config->get_click_emphasis_sound());
284                 }
285         }
286
287         void set_state_from_config ()
288         {
289                 parameter_changed ("click-sound");
290                 parameter_changed ("click-emphasis-sound");
291         }
292
293 private:
294
295         void click_browse_clicked ()
296         {
297                 SoundFileChooser sfdb (*_parent, _("Choose Click"));
298
299                 sfdb.show_all ();
300                 sfdb.present ();
301
302                 if (sfdb.run () == RESPONSE_OK) {
303                         click_chosen (sfdb.get_filename());
304                 }
305         }
306
307         void click_chosen (string const & path)
308         {
309                 _click_path_entry.set_text (path);
310                 _rc_config->set_click_sound (path);
311         }
312
313         void click_emphasis_browse_clicked ()
314         {
315                 SoundFileChooser sfdb (*_parent, _("Choose Click Emphasis"));
316
317                 sfdb.show_all ();
318                 sfdb.present ();
319
320                 if (sfdb.run () == RESPONSE_OK) {
321                         click_emphasis_chosen (sfdb.get_filename());
322                 }
323         }
324
325         void click_emphasis_chosen (string const & path)
326         {
327                 _click_emphasis_path_entry.set_text (path);
328                 _rc_config->set_click_emphasis_sound (path);
329         }
330
331         RCConfiguration* _rc_config;
332         ArdourDialog* _parent;
333         Entry _click_path_entry;
334         Entry _click_emphasis_path_entry;
335 };
336
337 class UndoOptions : public OptionEditorBox
338 {
339 public:
340         UndoOptions (RCConfiguration* c) :
341                 _rc_config (c),
342                 _limit_undo_button (_("Limit undo history to")),
343                 _save_undo_button (_("Save undo history of"))
344         {
345                 Table* t = new Table (2, 3);
346                 t->set_spacings (4);
347
348                 t->attach (_limit_undo_button, 0, 1, 0, 1, FILL);
349                 _limit_undo_spin.set_range (0, 512);
350                 _limit_undo_spin.set_increments (1, 10);
351                 t->attach (_limit_undo_spin, 1, 2, 0, 1, FILL | EXPAND);
352                 Label* l = manage (new Label (_("commands")));
353                 l->set_alignment (0, 0.5);
354                 t->attach (*l, 2, 3, 0, 1);
355
356                 t->attach (_save_undo_button, 0, 1, 1, 2, FILL);
357                 _save_undo_spin.set_range (0, 512);
358                 _save_undo_spin.set_increments (1, 10);
359                 t->attach (_save_undo_spin, 1, 2, 1, 2, FILL | EXPAND);
360                 l = manage (new Label (_("commands")));
361                 l->set_alignment (0, 0.5);
362                 t->attach (*l, 2, 3, 1, 2);
363
364                 _box->pack_start (*t);
365
366                 _limit_undo_button.signal_toggled().connect (sigc::mem_fun (*this, &UndoOptions::limit_undo_toggled));
367                 _limit_undo_spin.signal_value_changed().connect (sigc::mem_fun (*this, &UndoOptions::limit_undo_changed));
368                 _save_undo_button.signal_toggled().connect (sigc::mem_fun (*this, &UndoOptions::save_undo_toggled));
369                 _save_undo_spin.signal_value_changed().connect (sigc::mem_fun (*this, &UndoOptions::save_undo_changed));
370         }
371
372         void parameter_changed (string const & p)
373         {
374                 if (p == "history-depth") {
375                         int32_t const d = _rc_config->get_history_depth();
376                         _limit_undo_button.set_active (d != 0);
377                         _limit_undo_spin.set_sensitive (d != 0);
378                         _limit_undo_spin.set_value (d);
379                 } else if (p == "save-history") {
380                         bool const x = _rc_config->get_save_history ();
381                         _save_undo_button.set_active (x);
382                         _save_undo_spin.set_sensitive (x);
383                 } else if (p == "save-history-depth") {
384                         _save_undo_spin.set_value (_rc_config->get_saved_history_depth());
385                 }
386         }
387
388         void set_state_from_config ()
389         {
390                 parameter_changed ("save-history");
391                 parameter_changed ("history-depth");
392                 parameter_changed ("save-history-depth");
393         }
394
395         void limit_undo_toggled ()
396         {
397                 bool const x = _limit_undo_button.get_active ();
398                 _limit_undo_spin.set_sensitive (x);
399                 int32_t const n = x ? 16 : 0;
400                 _limit_undo_spin.set_value (n);
401                 _rc_config->set_history_depth (n);
402         }
403
404         void limit_undo_changed ()
405         {
406                 _rc_config->set_history_depth (_limit_undo_spin.get_value_as_int ());
407         }
408
409         void save_undo_toggled ()
410         {
411                 bool const x = _save_undo_button.get_active ();
412                 _rc_config->set_save_history (x);
413         }
414
415         void save_undo_changed ()
416         {
417                 _rc_config->set_saved_history_depth (_save_undo_spin.get_value_as_int ());
418         }
419
420 private:
421         RCConfiguration* _rc_config;
422         CheckButton _limit_undo_button;
423         SpinButton _limit_undo_spin;
424         CheckButton _save_undo_button;
425         SpinButton _save_undo_spin;
426 };
427
428
429
430 static const struct {
431     const char *name;
432     guint modifier;
433 } modifiers[] = {
434
435         { "Unmodified", 0 },
436
437 #ifdef GTKOSX
438
439         /* Command = Meta
440            Option/Alt = Mod1
441         */
442         { "Shift", GDK_SHIFT_MASK },
443         { "Command", GDK_META_MASK },
444         { "Control", GDK_CONTROL_MASK },
445         { "Option", GDK_MOD1_MASK },
446         { "Command-Shift", GDK_MOD1_MASK|GDK_SHIFT_MASK },
447         { "Command-Option", GDK_MOD1_MASK|GDK_MOD5_MASK },
448         { "Shift-Option", GDK_SHIFT_MASK|GDK_MOD5_MASK },
449         { "Shift-Command-Option", GDK_MOD5_MASK|GDK_SHIFT_MASK|GDK_MOD1_MASK },
450
451 #else
452         { "Shift", GDK_SHIFT_MASK },
453         { "Control", GDK_CONTROL_MASK },
454         { "Alt (Mod1)", GDK_MOD1_MASK },
455         { "Control-Shift", GDK_CONTROL_MASK|GDK_SHIFT_MASK },
456         { "Control-Alt", GDK_CONTROL_MASK|GDK_MOD1_MASK },
457         { "Shift-Alt", GDK_SHIFT_MASK|GDK_MOD1_MASK },
458         { "Control-Shift-Alt", GDK_CONTROL_MASK|GDK_SHIFT_MASK|GDK_MOD1_MASK },
459         { "Mod2", GDK_MOD2_MASK },
460         { "Mod3", GDK_MOD3_MASK },
461         { "Mod4", GDK_MOD4_MASK },
462         { "Mod5", GDK_MOD5_MASK },
463 #endif
464         { 0, 0 }
465 };
466
467
468 class KeyboardOptions : public OptionEditorBox
469 {
470 public:
471         KeyboardOptions () :
472                   _delete_button_adjustment (3, 1, 12),
473                   _delete_button_spin (_delete_button_adjustment),
474                   _edit_button_adjustment (3, 1, 5),
475                   _edit_button_spin (_edit_button_adjustment)
476
477         {
478                 /* internationalize and prepare for use with combos */
479
480                 vector<string> dumb;
481                 for (int i = 0; modifiers[i].name; ++i) {
482                         dumb.push_back (_(modifiers[i].name));
483                 }
484
485                 set_popdown_strings (_edit_modifier_combo, dumb);
486                 _edit_modifier_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::edit_modifier_chosen));
487
488                 for (int x = 0; modifiers[x].name; ++x) {
489                         if (modifiers[x].modifier == Keyboard::edit_modifier ()) {
490                                 _edit_modifier_combo.set_active_text (_(modifiers[x].name));
491                                 break;
492                         }
493                 }
494
495                 Table* t = manage (new Table (4, 4));
496                 t->set_spacings (4);
497
498                 Label* l = manage (new Label (_("Edit using:")));
499                 l->set_name ("OptionsLabel");
500                 l->set_alignment (0, 0.5);
501
502                 t->attach (*l, 0, 1, 0, 1, FILL | EXPAND, FILL);
503                 t->attach (_edit_modifier_combo, 1, 2, 0, 1, FILL | EXPAND, FILL);
504
505                 l = manage (new Label (_("+ button")));
506                 l->set_name ("OptionsLabel");
507
508                 t->attach (*l, 3, 4, 0, 1, FILL | EXPAND, FILL);
509                 t->attach (_edit_button_spin, 4, 5, 0, 1, FILL | EXPAND, FILL);
510
511                 _edit_button_spin.set_name ("OptionsEntry");
512                 _edit_button_adjustment.set_value (Keyboard::edit_button());
513                 _edit_button_adjustment.signal_value_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::edit_button_changed));
514
515                 set_popdown_strings (_delete_modifier_combo, dumb);
516                 _delete_modifier_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::delete_modifier_chosen));
517
518                 for (int x = 0; modifiers[x].name; ++x) {
519                         if (modifiers[x].modifier == Keyboard::delete_modifier ()) {
520                                 _delete_modifier_combo.set_active_text (_(modifiers[x].name));
521                                 break;
522                         }
523                 }
524
525                 l = manage (new Label (_("Delete using:")));
526                 l->set_name ("OptionsLabel");
527                 l->set_alignment (0, 0.5);
528
529                 t->attach (*l, 0, 1, 1, 2, FILL | EXPAND, FILL);
530                 t->attach (_delete_modifier_combo, 1, 2, 1, 2, FILL | EXPAND, FILL);
531
532                 l = manage (new Label (_("+ button")));
533                 l->set_name ("OptionsLabel");
534
535                 t->attach (*l, 3, 4, 1, 2, FILL | EXPAND, FILL);
536                 t->attach (_delete_button_spin, 4, 5, 1, 2, FILL | EXPAND, FILL);
537
538                 _delete_button_spin.set_name ("OptionsEntry");
539                 _delete_button_adjustment.set_value (Keyboard::delete_button());
540                 _delete_button_adjustment.signal_value_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::delete_button_changed));
541
542                 set_popdown_strings (_snap_modifier_combo, dumb);
543                 _snap_modifier_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::snap_modifier_chosen));
544
545                 for (int x = 0; modifiers[x].name; ++x) {
546                         if (modifiers[x].modifier == (guint) Keyboard::snap_modifier ()) {
547                                 _snap_modifier_combo.set_active_text (_(modifiers[x].name));
548                                 break;
549                         }
550                 }
551
552                 l = manage (new Label (_("Toggle snap using:")));
553                 l->set_name ("OptionsLabel");
554                 l->set_alignment (0, 0.5);
555
556                 t->attach (*l, 0, 1, 2, 3, FILL | EXPAND, FILL);
557                 t->attach (_snap_modifier_combo, 1, 2, 2, 3, FILL | EXPAND, FILL);
558
559                 vector<string> strs;
560
561                 for (map<string,string>::iterator bf = Keyboard::binding_files.begin(); bf != Keyboard::binding_files.end(); ++bf) {
562                         strs.push_back (bf->first);
563                 }
564
565                 set_popdown_strings (_keyboard_layout_selector, strs);
566                 _keyboard_layout_selector.set_active_text (Keyboard::current_binding_name());
567                 _keyboard_layout_selector.signal_changed().connect (sigc::mem_fun (*this, &KeyboardOptions::bindings_changed));
568
569                 l = manage (new Label (_("Keyboard layout:")));
570                 l->set_name ("OptionsLabel");
571                 l->set_alignment (0, 0.5);
572
573                 t->attach (*l, 0, 1, 3, 4, FILL | EXPAND, FILL);
574                 t->attach (_keyboard_layout_selector, 1, 2, 3, 4, FILL | EXPAND, FILL);
575
576                 _box->pack_start (*t, false, false);
577         }
578
579         void parameter_changed (string const &)
580         {
581                 /* XXX: these aren't really config options... */
582         }
583
584         void set_state_from_config ()
585         {
586                 /* XXX: these aren't really config options... */
587         }
588
589 private:
590
591         void bindings_changed ()
592         {
593                 string const txt = _keyboard_layout_selector.get_active_text();
594
595                 /* XXX: config...?  for all this keyboard stuff */
596
597                 for (map<string,string>::iterator i = Keyboard::binding_files.begin(); i != Keyboard::binding_files.end(); ++i) {
598                         if (txt == i->first) {
599                                 if (Keyboard::load_keybindings (i->second)) {
600                                         Keyboard::save_keybindings ();
601                                 }
602                         }
603                 }
604         }
605
606         void edit_modifier_chosen ()
607         {
608                 string const txt = _edit_modifier_combo.get_active_text();
609
610                 for (int i = 0; modifiers[i].name; ++i) {
611                         if (txt == _(modifiers[i].name)) {
612                                 Keyboard::set_edit_modifier (modifiers[i].modifier);
613                                 break;
614                         }
615                 }
616         }
617
618         void delete_modifier_chosen ()
619         {
620                 string const txt = _delete_modifier_combo.get_active_text();
621
622                 for (int i = 0; modifiers[i].name; ++i) {
623                         if (txt == _(modifiers[i].name)) {
624                                 Keyboard::set_delete_modifier (modifiers[i].modifier);
625                                 break;
626                         }
627                 }
628         }
629
630         void snap_modifier_chosen ()
631         {
632                 string const txt = _snap_modifier_combo.get_active_text();
633
634                 for (int i = 0; modifiers[i].name; ++i) {
635                         if (txt == _(modifiers[i].name)) {
636                                 Keyboard::set_snap_modifier (modifiers[i].modifier);
637                                 break;
638                         }
639                 }
640         }
641
642         void delete_button_changed ()
643         {
644                 Keyboard::set_delete_button (_delete_button_spin.get_value_as_int());
645         }
646
647         void edit_button_changed ()
648         {
649                 Keyboard::set_edit_button (_edit_button_spin.get_value_as_int());
650         }
651
652         ComboBoxText _keyboard_layout_selector;
653         ComboBoxText _edit_modifier_combo;
654         ComboBoxText _delete_modifier_combo;
655         ComboBoxText _snap_modifier_combo;
656         Adjustment _delete_button_adjustment;
657         SpinButton _delete_button_spin;
658         Adjustment _edit_button_adjustment;
659         SpinButton _edit_button_spin;
660 };
661
662 class FontScalingOptions : public OptionEditorBox
663 {
664 public:
665         FontScalingOptions (RCConfiguration* c) :
666                 _rc_config (c),
667                 _dpi_adjustment (50, 50, 250, 1, 10),
668                 _dpi_slider (_dpi_adjustment)
669         {
670                 _dpi_adjustment.set_value (_rc_config->get_font_scale () / 1024);
671
672                 Label* l = manage (new Label (_("Font scaling:")));
673                 l->set_name ("OptionsLabel");
674
675                 _dpi_slider.set_update_policy (UPDATE_DISCONTINUOUS);
676                 HBox* h = manage (new HBox);
677                 h->set_spacing (4);
678                 h->pack_start (*l, false, false);
679                 h->pack_start (_dpi_slider, true, true);
680
681                 _box->pack_start (*h, false, false);
682
683                 _dpi_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &FontScalingOptions::dpi_changed));
684         }
685
686         void parameter_changed (string const & p)
687         {
688                 if (p == "font-scale") {
689                         _dpi_adjustment.set_value (_rc_config->get_font_scale() / 1024);
690                 }
691         }
692
693         void set_state_from_config ()
694         {
695                 parameter_changed ("font-scale");
696         }
697
698 private:
699
700         void dpi_changed ()
701         {
702                 _rc_config->set_font_scale ((long) floor (_dpi_adjustment.get_value() * 1024));
703                 /* XXX: should be triggered from the parameter changed signal */
704                 reset_dpi ();
705         }
706
707         RCConfiguration* _rc_config;
708         Adjustment _dpi_adjustment;
709         HScale _dpi_slider;
710 };
711
712 class SoloMuteOptions : public OptionEditorBox
713 {
714 public:
715         SoloMuteOptions (RCConfiguration* c) :
716                 _rc_config (c),
717                 // 0.781787 is the value needed for gain to be set to 0.
718                 _db_adjustment (0.781787, 0.0, 1.0, 0.01, 0.1)
719
720         {
721                 if ((pix = ::get_icon ("fader_belt_h")) == 0) {
722                         throw failed_constructor();
723                 }
724
725                 _db_slider = manage (new HSliderController (pix,
726                                                             &_db_adjustment,
727                                                             false,
728                                                             115));
729
730
731                 parameter_changed ("solo-mute-gain");
732
733                 Label* l = manage (new Label (_("Solo mute cut (dB):")));
734                 l->set_name ("OptionsLabel");
735
736                 HBox* h = manage (new HBox);
737                 h->set_spacing (4);
738                 h->pack_start (*l, false, false);
739                 h->pack_start (*_db_slider, false, false);
740                 h->pack_start (_db_display, false, false);
741                 h->show_all ();
742
743                 set_size_request_to_display_given_text (_db_display, "-99.0", 12, 12);
744
745                 _box->pack_start (*h, false, false);
746
747                 _db_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &SoloMuteOptions::db_changed));
748         }
749
750         void parameter_changed (string const & p)
751         {
752                 if (p == "solo-mute-gain") {
753                         gain_t val = _rc_config->get_solo_mute_gain();
754
755                         _db_adjustment.set_value (gain_to_slider_position (val));
756
757                         char buf[16];
758
759                         if (val == 0.0) {
760                                 snprintf (buf, sizeof (buf), "-inf");
761                         } else {
762                                 snprintf (buf, sizeof (buf), "%.2f", accurate_coefficient_to_dB (val));
763                         }
764
765                         _db_display.set_text (buf);
766                 }
767         }
768
769         void set_state_from_config ()
770         {
771                 parameter_changed ("solo-mute-gain");
772         }
773
774 private:
775
776         void db_changed ()
777         {
778                 _rc_config->set_solo_mute_gain (slider_position_to_gain (_db_adjustment.get_value()));
779         }
780
781         RCConfiguration* _rc_config;
782         Adjustment _db_adjustment;
783         Gtkmm2ext::HSliderController* _db_slider;
784         Glib::RefPtr<Gdk::Pixbuf> pix;
785         Entry _db_display;
786 };
787
788
789 class ControlSurfacesOptions : public OptionEditorBox
790 {
791 public:
792         ControlSurfacesOptions (ArdourDialog& parent)
793                 : _parent (parent)
794         {
795                 _store = ListStore::create (_model);
796                 _view.set_model (_store);
797                 _view.append_column (_("Name"), _model.name);
798                 _view.get_column(0)->set_resizable (true);
799                 _view.get_column(0)->set_expand (true);
800                 _view.append_column_editable (_("Enabled"), _model.enabled);
801                 _view.append_column_editable (_("Feedback"), _model.feedback);
802
803                 _box->pack_start (_view, false, false);
804
805                 Label* label = manage (new Label);
806                 label->set_markup (string_compose (X_("<i>%1</i>"), _("Double-click on a name to edit settings for an enabled protocol")));
807
808                 _box->pack_start (*label, false, false);
809                 label->show ();
810                 
811                 _store->signal_row_changed().connect (sigc::mem_fun (*this, &ControlSurfacesOptions::model_changed));
812                 _view.signal_button_press_event().connect_notify (sigc::mem_fun(*this, &ControlSurfacesOptions::edit_clicked));
813         }
814
815         void parameter_changed (std::string const &)
816         {
817
818         }
819
820         void set_state_from_config ()
821         {
822                 _store->clear ();
823
824                 ControlProtocolManager& m = ControlProtocolManager::instance ();
825                 for (list<ControlProtocolInfo*>::iterator i = m.control_protocol_info.begin(); i != m.control_protocol_info.end(); ++i) {
826
827                         if (!(*i)->mandatory) {
828                                 TreeModel::Row r = *_store->append ();
829                                 r[_model.name] = (*i)->name;
830                                 r[_model.enabled] = ((*i)->protocol || (*i)->requested);
831                                 r[_model.feedback] = ((*i)->protocol && (*i)->protocol->get_feedback ());
832                                 r[_model.protocol_info] = *i;
833                         }
834                 }
835         }
836
837 private:
838
839         void model_changed (TreeModel::Path const &, TreeModel::iterator const & i)
840         {
841                 TreeModel::Row r = *i;
842
843                 ControlProtocolInfo* cpi = r[_model.protocol_info];
844                 if (!cpi) {
845                         return;
846                 }
847
848                 bool const was_enabled = (cpi->protocol != 0);
849                 bool const is_enabled = r[_model.enabled];
850
851                 if (was_enabled != is_enabled) {
852                         if (!was_enabled) {
853                                 ControlProtocolManager::instance().instantiate (*cpi);
854                         } else {
855                                 ControlProtocolManager::instance().teardown (*cpi);
856                         }
857                 }
858
859                 bool const was_feedback = (cpi->protocol && cpi->protocol->get_feedback ());
860                 bool const is_feedback = r[_model.feedback];
861
862                 if (was_feedback != is_feedback && cpi->protocol) {
863                         cpi->protocol->set_feedback (is_feedback);
864                 }
865         }
866
867         void edit_clicked (GdkEventButton* ev)
868         {
869                 if (ev->type != GDK_2BUTTON_PRESS) {
870                         return;
871                 }
872
873                 std::string name;
874                 ControlProtocolInfo* cpi;
875                 TreeModel::Row row;
876                 
877                 row = *(_view.get_selection()->get_selected());
878
879                 Window* win = row[_model.editor];
880                 if (win && !win->is_visible()) {
881                         win->present (); 
882                 } else {
883                         cpi = row[_model.protocol_info];
884                         
885                         if (cpi && cpi->protocol && cpi->protocol->has_editor ()) {
886                                 Box* box = (Box*) cpi->protocol->get_gui ();
887                                 if (box) {
888                                         string title = row[_model.name];
889                                         ArdourDialog* win = new ArdourDialog (_parent, title);
890                                         win->get_vbox()->pack_start (*box, false, false);
891                                         box->show ();
892                                         win->present ();
893                                         row[_model.editor] = win;
894                                 }
895                         }
896                 }
897         }
898
899         class ControlSurfacesModelColumns : public TreeModelColumnRecord
900         {
901         public:
902
903                 ControlSurfacesModelColumns ()
904                 {
905                         add (name);
906                         add (enabled);
907                         add (feedback);
908                         add (protocol_info);
909                         add (editor);
910                 }
911
912                 TreeModelColumn<string> name;
913                 TreeModelColumn<bool> enabled;
914                 TreeModelColumn<bool> feedback;
915                 TreeModelColumn<ControlProtocolInfo*> protocol_info;
916                 TreeModelColumn<Gtk::Window*> editor;
917         };
918
919         Glib::RefPtr<ListStore> _store;
920         ControlSurfacesModelColumns _model;
921         TreeView _view;
922         Gtk::Window& _parent;
923 };
924
925
926 RCOptionEditor::RCOptionEditor ()
927         : OptionEditor (Config, string_compose (_("%1 Preferences"), PROGRAM_NAME))
928         , _rc_config (Config)
929 {
930         /* MISC */
931
932         add_option (_("Misc"), new OptionEditorHeading (_("Metering")));
933
934         ComboOption<float>* mht = new ComboOption<float> (
935                 "meter-hold",
936                 _("Meter hold time"),
937                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_meter_hold),
938                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_meter_hold)
939                 );
940
941         mht->add (MeterHoldOff, _("off"));
942         mht->add (MeterHoldShort, _("short"));
943         mht->add (MeterHoldMedium, _("medium"));
944         mht->add (MeterHoldLong, _("long"));
945
946         add_option (_("Misc"), mht);
947
948         ComboOption<float>* mfo = new ComboOption<float> (
949                 "meter-falloff",
950                 _("Meter fall-off"),
951                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_meter_falloff),
952                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_meter_falloff)
953                 );
954
955         mfo->add (METER_FALLOFF_OFF, _("off"));
956         mfo->add (METER_FALLOFF_SLOWEST, _("slowest"));
957         mfo->add (METER_FALLOFF_SLOW, _("slow"));
958         mfo->add (METER_FALLOFF_MEDIUM, _("medium"));
959         mfo->add (METER_FALLOFF_FAST, _("fast"));
960         mfo->add (METER_FALLOFF_FASTER, _("faster"));
961         mfo->add (METER_FALLOFF_FASTEST, _("fastest"));
962
963         add_option (_("Misc"), mfo);
964
965         add_option (_("Misc"), new OptionEditorHeading (_("Undo")));
966
967         add_option (_("Misc"), new UndoOptions (_rc_config));
968
969         add_option (_("Misc"), new OptionEditorHeading (_("Misc")));
970
971 #ifndef GTKOSX
972         /* font scaling does nothing with GDK/Quartz */
973         add_option (_("Misc"), new FontScalingOptions (_rc_config));
974 #endif
975
976         add_option (_("Misc"),
977              new BoolOption (
978                      "verify-remove-last-capture",
979                      _("Verify removal of last capture"),
980                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_verify_remove_last_capture),
981                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_verify_remove_last_capture)
982                      ));
983
984         add_option (_("Misc"),
985              new BoolOption (
986                      "periodic-safety-backups",
987                      _("Make periodic backups of the session file"),
988                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_periodic_safety_backups),
989                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_periodic_safety_backups)
990                      ));
991
992         add_option (_("Misc"),
993              new BoolOption (
994                      "sync-all-route-ordering",
995                      _("Syncronise editor and mixer track order"),
996                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_sync_all_route_ordering),
997                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_sync_all_route_ordering)
998                      ));
999
1000         add_option (_("Misc"),
1001              new BoolOption (
1002                      "only-copy-imported-files",
1003                      _("Always copy imported files"),
1004                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_only_copy_imported_files),
1005                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_only_copy_imported_files)
1006                      ));
1007
1008         add_option (_("Misc"),
1009              new BoolOption (
1010                      "default-narrow_ms",
1011                      _("Use narrow mixer strips"),
1012                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_default_narrow_ms),
1013                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_default_narrow_ms)
1014                      ));
1015
1016         add_option (_("Misc"),
1017              new BoolOption (
1018                      "name-new-markers",
1019                      _("Name new markers"),
1020                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_name_new_markers),
1021                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_name_new_markers)
1022                      ));
1023
1024         /* TRANSPORT */
1025
1026         add_option (_("Transport"),
1027              new BoolOption (
1028                      "latched-record-enable",
1029                      _("Keep record-enable engaged on stop"),
1030                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_latched_record_enable),
1031                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_latched_record_enable)
1032                      ));
1033
1034         add_option (_("Transport"),
1035              new BoolOption (
1036                      "stop-recording-on-xrun",
1037                      _("Stop recording when an xrun occurs"),
1038                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_stop_recording_on_xrun),
1039                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_stop_recording_on_xrun)
1040                      ));
1041
1042         add_option (_("Transport"),
1043              new BoolOption (
1044                      "create-xrun-marker",
1045                      _("Create markers where xruns occur"),
1046                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_create_xrun_marker),
1047                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_create_xrun_marker)
1048                      ));
1049
1050         add_option (_("Transport"),
1051              new BoolOption (
1052                      "stop-at-session-end",
1053                      _("Stop at the end of the session"),
1054                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_stop_at_session_end),
1055                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_stop_at_session_end)
1056                      ));
1057
1058         add_option (_("Transport"),
1059              new BoolOption (
1060                      "primary-clock-delta-edit-cursor",
1061                      _("Primary clock delta to edit cursor"),
1062                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_primary_clock_delta_edit_cursor),
1063                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_primary_clock_delta_edit_cursor)
1064                      ));
1065
1066         add_option (_("Transport"),
1067              new BoolOption (
1068                      "secondary-clock-delta-edit-cursor",
1069                      _("Secondary clock delta to edit cursor"),
1070                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_secondary_clock_delta_edit_cursor),
1071                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_secondary_clock_delta_edit_cursor)
1072                      ));
1073
1074         add_option (_("Transport"),
1075              new BoolOption (
1076                      "disable-disarm-during-roll",
1077                      _("Disable per-track record disarm while rolling"),
1078                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_disable_disarm_during_roll),
1079                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_disable_disarm_during_roll)
1080                      ));
1081
1082         /* EDITOR */
1083
1084         add_option (_("Editor"),
1085              new BoolOption (
1086                      "link-region-and-track-selection",
1087                      _("Link selection of regions and tracks"),
1088                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_link_region_and_track_selection),
1089                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_link_region_and_track_selection)
1090                      ));
1091
1092         add_option (_("Editor"),
1093              new BoolOption (
1094                      "automation-follows-regions",
1095                      _("Move relevant automation when regions are moved"),
1096                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_automation_follows_regions),
1097                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_automation_follows_regions)
1098                      ));
1099
1100         add_option (_("Editor"),
1101              new BoolOption (
1102                      "show-track-meters",
1103                      _("Show meters on tracks in the editor"),
1104                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_show_track_meters),
1105                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_show_track_meters)
1106                      ));
1107
1108         add_option (_("Editor"),
1109              new BoolOption (
1110                      "use-overlap-equivalency",
1111                      _("Use overlap equivalency for regions"),
1112                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_use_overlap_equivalency),
1113                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_use_overlap_equivalency)
1114                      ));
1115
1116         add_option (_("Editor"),
1117              new BoolOption (
1118                      "rubberbanding-snaps-to-grid",
1119                      _("Make rubberband selection rectangle snap to the grid"),
1120                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_rubberbanding_snaps_to_grid),
1121                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_rubberbanding_snaps_to_grid)
1122                      ));
1123
1124         add_option (_("Editor"),
1125              new BoolOption (
1126                      "show-waveforms",
1127                      _("Show waveforms in regions"),
1128                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_show_waveforms),
1129                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_show_waveforms)
1130                      ));
1131
1132         ComboOption<WaveformScale>* wfs = new ComboOption<WaveformScale> (
1133                 "waveform-scale",
1134                 _("Waveform scale"),
1135                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_waveform_scale),
1136                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_waveform_scale)
1137                 );
1138
1139         wfs->add (Linear, _("linear"));
1140         wfs->add (Logarithmic, _("logarithmic"));
1141
1142         add_option (_("Editor"), wfs);
1143
1144         ComboOption<WaveformShape>* wfsh = new ComboOption<WaveformShape> (
1145                 "waveform-shape",
1146                 _("Waveform shape"),
1147                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_waveform_shape),
1148                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_waveform_shape)
1149                 );
1150
1151         wfsh->add (Traditional, _("traditional"));
1152         wfsh->add (Rectified, _("rectified"));
1153
1154         add_option (_("Editor"), wfsh);
1155
1156         /* AUDIO */
1157
1158         add_option (_("Audio"), new OptionEditorHeading (_("Solo")));
1159
1160
1161         add_option (_("Audio"),
1162              new BoolOption (
1163                      "solo-control-is-listen-control",
1164                      _("Solo controls are Listen controls"),
1165                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_solo_control_is_listen_control),
1166                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_solo_control_is_listen_control)
1167                      ));
1168
1169         ComboOption<ListenPosition>* lp = new ComboOption<ListenPosition> (
1170                 "listen-position",
1171                 _("Listen Position"),
1172                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_listen_position),
1173                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_listen_position)
1174                 );
1175
1176         lp->add (AfterFaderListen, _("after-fader listen"));
1177         lp->add (PreFaderListen, _("pre-fader listen"));
1178
1179         add_option (_("Audio"), lp);
1180         add_option (_("Audio"), new SoloMuteOptions (_rc_config));
1181
1182         add_option (_("Audio"),
1183              new BoolOption (
1184                      "solo-latched",
1185                      _("Latched solo"),
1186                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_solo_latched),
1187                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_solo_latched)
1188                      ));
1189
1190         add_option (_("Audio"),
1191              new BoolOption (
1192                      "show-solo-mutes",
1193                      _("Show solo muting"),
1194                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_show_solo_mutes),
1195                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_show_solo_mutes)
1196                      ));
1197
1198         add_option (_("Audio"),
1199              new BoolOption (
1200                      "solo-mute-override",
1201                      _("Override muting"),
1202                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_solo_mute_override),
1203                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_solo_mute_override)
1204                      ));
1205
1206         add_option (_("Audio"), new OptionEditorHeading (_("Monitoring")));
1207
1208         add_option (_("Audio"),
1209              new BoolOption (
1210                      "use-monitor-bus",
1211                      _("Use a monitor bus (allows AFL/PFL and more control)"),
1212                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_use_monitor_bus),
1213                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_use_monitor_bus)
1214                      ));
1215
1216         ComboOption<MonitorModel>* mm = new ComboOption<MonitorModel> (
1217                 "monitoring-model",
1218                 _("Monitoring handled by"),
1219                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_monitoring_model),
1220                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_monitoring_model)
1221                 );
1222
1223         mm->add (HardwareMonitoring, _("JACK"));
1224         mm->add (SoftwareMonitoring, _("ardour"));
1225         mm->add (ExternalMonitoring, _("audio hardware"));
1226
1227         add_option (_("Audio"), mm);
1228
1229         add_option (_("Audio"),
1230              new BoolOption (
1231                      "tape-machine-mode",
1232                      _("Tape machine mode"),
1233                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_tape_machine_mode),
1234                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_tape_machine_mode)
1235                      ));
1236
1237         add_option (_("Audio"), new OptionEditorHeading (_("Connection of tracks and busses")));
1238
1239         add_option (_("Audio"),
1240                     new BoolOption (
1241                             "auto-connect-standard-busses",
1242                             _("Auto-connect master/monitor busses"),
1243                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_auto_connect_standard_busses),
1244                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_auto_connect_standard_busses)
1245                             ));
1246
1247         ComboOption<AutoConnectOption>* iac = new ComboOption<AutoConnectOption> (
1248                 "input-auto-connect",
1249                 _("Connect track and bus inputs"),
1250                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_input_auto_connect),
1251                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_input_auto_connect)
1252                 );
1253
1254         iac->add (AutoConnectPhysical, _("automatically to physical inputs"));
1255         iac->add (ManualConnect, _("manually"));
1256
1257         add_option (_("Audio"), iac);
1258
1259         ComboOption<AutoConnectOption>* oac = new ComboOption<AutoConnectOption> (
1260                 "output-auto-connect",
1261                 _("Connect track and bus outputs"),
1262                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_output_auto_connect),
1263                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_output_auto_connect)
1264                 );
1265
1266         oac->add (AutoConnectPhysical, _("automatically to physical outputs"));
1267         oac->add (AutoConnectMaster, _("automatically to master outputs"));
1268         oac->add (ManualConnect, _("manually"));
1269
1270         add_option (_("Audio"), oac);
1271
1272         add_option (_("Audio"), new OptionEditorHeading (_("Denormals")));
1273
1274         add_option (_("Audio"),
1275              new BoolOption (
1276                      "denormal-protection",
1277                      _("Use DC bias to protect against denormals"),
1278                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_denormal_protection),
1279                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_denormal_protection)
1280                      ));
1281
1282         ComboOption<DenormalModel>* dm = new ComboOption<DenormalModel> (
1283                 "denormal-model",
1284                 _("Processor handling"),
1285                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_denormal_model),
1286                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_denormal_model)
1287                 );
1288
1289         dm->add (DenormalNone, _("no processor handling"));
1290
1291         FPU fpu;
1292
1293         if (fpu.has_flush_to_zero()) {
1294                 dm->add (DenormalFTZ, _("use FlushToZero"));
1295         }
1296
1297         if (fpu.has_denormals_are_zero()) {
1298                 dm->add (DenormalDAZ, _("use DenormalsAreZero"));
1299         }
1300
1301         if (fpu.has_flush_to_zero() && fpu.has_denormals_are_zero()) {
1302                 dm->add (DenormalFTZDAZ, _("use FlushToZero and DenormalsAreZerO"));
1303         }
1304
1305         add_option (_("Audio"), dm);
1306
1307         add_option (_("Audio"), new OptionEditorHeading (_("Plugins")));
1308
1309         add_option (_("Audio"),
1310              new BoolOption (
1311                      "plugins-stop-with-transport",
1312                      _("Stop plugins when the transport is stopped"),
1313                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_plugins_stop_with_transport),
1314                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_plugins_stop_with_transport)
1315                      ));
1316
1317         add_option (_("Audio"),
1318              new BoolOption (
1319                      "do-not-record-plugins",
1320                      _("Disable plugins during recording"),
1321                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_do_not_record_plugins),
1322                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_do_not_record_plugins)
1323                      ));
1324
1325         add_option (_("Audio"),
1326              new BoolOption (
1327                      "new-plugins-active",
1328                      _("Make new plugins active"),
1329                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_new_plugins_active),
1330                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_new_plugins_active)
1331                      ));
1332
1333         add_option (_("Audio"),
1334              new BoolOption (
1335                      "auto-analyse-audio",
1336                      _("Enable automatic analysis of audio"),
1337                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_auto_analyse_audio),
1338                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_auto_analyse_audio)
1339                      ));
1340
1341         /* MIDI CONTROL */
1342
1343         list<ComboOption<string>* > midi_combos;
1344
1345         midi_combos.push_back (new ComboOption<string> (
1346                                        "mtc-port-name",
1347                                        _("Send/Receive MTC via"),
1348                                        sigc::mem_fun (*_rc_config, &RCConfiguration::get_mtc_port_name),
1349                                        sigc::mem_fun (*_rc_config, &RCConfiguration::set_mtc_port_name)
1350                                        ));
1351
1352         midi_combos.push_back (new ComboOption<string> (
1353                                        "midi-clock-port-name",
1354                                        _("Send/Receive MIDI clock via"),
1355                                        sigc::mem_fun (*_rc_config, &RCConfiguration::get_midi_clock_port_name),
1356                                        sigc::mem_fun (*_rc_config, &RCConfiguration::set_midi_clock_port_name)
1357                                        ));
1358
1359         midi_combos.push_back (new ComboOption<string> (
1360                                        "mmc-port-name",
1361                                        _("Send/Receive MMC via"),
1362                                        sigc::mem_fun (*_rc_config, &RCConfiguration::get_mmc_port_name),
1363                                        sigc::mem_fun (*_rc_config, &RCConfiguration::set_mmc_port_name)
1364                                        ));
1365
1366         midi_combos.push_back (new ComboOption<string> (
1367                                        "midi-port-name",
1368                                        _("Send/Receive MIDI parameter control via"),
1369                                        sigc::mem_fun (*_rc_config, &RCConfiguration::get_midi_port_name),
1370                                        sigc::mem_fun (*_rc_config, &RCConfiguration::set_midi_port_name)
1371                                        ));
1372         
1373         add_option (_("MIDI control"), new MIDIPorts (_rc_config, midi_combos));
1374
1375         for (list<ComboOption<string>* >::iterator i = midi_combos.begin(); i != midi_combos.end(); ++i) {
1376                 add_option (_("MIDI control"), *i);
1377         }
1378
1379         add_option (_("MIDI control"),
1380                     new BoolOption (
1381                             "send-mtc",
1382                             _("Send MIDI Time Code"),
1383                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_send_mtc),
1384                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_send_mtc)
1385                             ));
1386
1387         add_option (_("MIDI control"),
1388                     new BoolOption (
1389                             "mmc-control",
1390                             _("Obey MIDI Machine Control commands"),
1391                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_mmc_control),
1392                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_mmc_control)
1393                             ));
1394
1395
1396         add_option (_("MIDI control"),
1397                     new BoolOption (
1398                             "send-mmc",
1399                             _("Send MIDI Machine Control commands"),
1400                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_send_mmc),
1401                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_send_mmc)
1402                             ));
1403
1404         add_option (_("MIDI control"),
1405                     new BoolOption (
1406                             "midi-feedback",
1407                             _("Send MIDI control feedback"),
1408                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_midi_feedback),
1409                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_midi_feedback)
1410                             ));
1411
1412         add_option (_("MIDI control"),
1413              new SpinOption<uint8_t> (
1414                      "mmc-receive-device-id",
1415                      _("Inbound MMC device ID"),
1416                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_mmc_receive_device_id),
1417                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_mmc_receive_device_id),
1418                      0, 128, 1, 10
1419                      ));
1420
1421         add_option (_("MIDI control"),
1422              new SpinOption<uint8_t> (
1423                      "mmc-send-device-id",
1424                      _("Outbound MMC device ID"),
1425                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_mmc_send_device_id),
1426                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_mmc_send_device_id),
1427                      0, 128, 1, 10
1428                      ));
1429
1430         add_option (_("MIDI control"),
1431              new SpinOption<int32_t> (
1432                      "initial-program-change",
1433                      _("Initial program change"),
1434                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_initial_program_change),
1435                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_initial_program_change),
1436                      -1, 65536, 1, 10
1437                      ));
1438
1439         /* CONTROL SURFACES */
1440
1441         add_option (_("Control surfaces"), new ControlSurfacesOptions (*this));
1442
1443         ComboOption<RemoteModel>* rm = new ComboOption<RemoteModel> (
1444                 "remote-model",
1445                 _("Control surface remote ID"),
1446                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_remote_model),
1447                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_remote_model)
1448                 );
1449
1450         rm->add (UserOrdered, _("assigned by user"));
1451         rm->add (MixerOrdered, _("follows order of mixer"));
1452         rm->add (EditorOrdered, _("follows order of editor"));
1453
1454         add_option (_("Control surfaces"), rm);
1455
1456         /* CLICK */
1457
1458         add_option (_("Click"), new ClickOptions (_rc_config, this));
1459
1460         /* KEYBOARD */
1461
1462         add_option (_("Keyboard"), new KeyboardOptions);
1463 }
1464
1465