screw up MIDI control "automation" tracks quite a bit while trying to improve menu...
[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
742                 set_size_request_to_display_given_text (_db_display, "-99.0", 12, 12);
743
744                 _box->pack_start (*h, false, false);
745
746                 _db_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &SoloMuteOptions::db_changed));
747         }
748
749         void parameter_changed (string const & p)
750         {
751                 if (p == "solo-mute-gain") {
752                         gain_t val = _rc_config->get_solo_mute_gain();
753
754                         _db_adjustment.set_value (gain_to_slider_position (val));
755
756                         char buf[16];
757
758                         if (val == 0.0) {
759                                 snprintf (buf, sizeof (buf), "-inf");
760                         } else {
761                                 snprintf (buf, sizeof (buf), "%.2f", accurate_coefficient_to_dB (val));
762                         }
763
764                         _db_display.set_text (buf);
765                 }
766         }
767
768         void set_state_from_config ()
769         {
770                 parameter_changed ("solo-mute-gain");
771         }
772
773 private:
774
775         void db_changed ()
776         {
777                 _rc_config->set_solo_mute_gain (slider_position_to_gain (_db_adjustment.get_value()));
778         }
779
780         RCConfiguration* _rc_config;
781         Adjustment _db_adjustment;
782         Gtkmm2ext::HSliderController* _db_slider;
783         Glib::RefPtr<Gdk::Pixbuf> pix;
784         Entry _db_display;
785 };
786
787
788 class ControlSurfacesOptions : public OptionEditorBox
789 {
790 public:
791         ControlSurfacesOptions (ArdourDialog& parent)
792                 : _parent (parent)
793         {
794                 _store = ListStore::create (_model);
795                 _view.set_model (_store);
796                 _view.append_column (_("Name"), _model.name);
797                 _view.get_column(0)->set_resizable (true);
798                 _view.get_column(0)->set_expand (true);
799                 _view.append_column_editable (_("Enabled"), _model.enabled);
800                 _view.append_column_editable (_("Feedback"), _model.feedback);
801
802                 _box->pack_start (_view, false, false);
803
804                 Label* label = manage (new Label);
805                 label->set_markup (string_compose (X_("<i>%1</i>"), _("Double-click on a name to edit settings for an enabled protocol")));
806
807                 _box->pack_start (*label, false, false);
808                 label->show ();
809                 
810                 _store->signal_row_changed().connect (sigc::mem_fun (*this, &ControlSurfacesOptions::model_changed));
811                 _view.signal_button_press_event().connect_notify (sigc::mem_fun(*this, &ControlSurfacesOptions::edit_clicked));
812         }
813
814         void parameter_changed (std::string const &)
815         {
816
817         }
818
819         void set_state_from_config ()
820         {
821                 _store->clear ();
822
823                 ControlProtocolManager& m = ControlProtocolManager::instance ();
824                 for (list<ControlProtocolInfo*>::iterator i = m.control_protocol_info.begin(); i != m.control_protocol_info.end(); ++i) {
825
826                         if (!(*i)->mandatory) {
827                                 TreeModel::Row r = *_store->append ();
828                                 r[_model.name] = (*i)->name;
829                                 r[_model.enabled] = ((*i)->protocol || (*i)->requested);
830                                 r[_model.feedback] = ((*i)->protocol && (*i)->protocol->get_feedback ());
831                                 r[_model.protocol_info] = *i;
832                         }
833                 }
834         }
835
836 private:
837
838         void model_changed (TreeModel::Path const &, TreeModel::iterator const & i)
839         {
840                 TreeModel::Row r = *i;
841
842                 ControlProtocolInfo* cpi = r[_model.protocol_info];
843                 if (!cpi) {
844                         return;
845                 }
846
847                 bool const was_enabled = (cpi->protocol != 0);
848                 bool const is_enabled = r[_model.enabled];
849
850                 if (was_enabled != is_enabled) {
851                         if (!was_enabled) {
852                                 ControlProtocolManager::instance().instantiate (*cpi);
853                         } else {
854                                 ControlProtocolManager::instance().teardown (*cpi);
855                         }
856                 }
857
858                 bool const was_feedback = (cpi->protocol && cpi->protocol->get_feedback ());
859                 bool const is_feedback = r[_model.feedback];
860
861                 if (was_feedback != is_feedback && cpi->protocol) {
862                         cpi->protocol->set_feedback (is_feedback);
863                 }
864         }
865
866         void edit_clicked (GdkEventButton* ev)
867         {
868                 if (ev->type != GDK_2BUTTON_PRESS) {
869                         return;
870                 }
871
872                 std::string name;
873                 ControlProtocolInfo* cpi;
874                 TreeModel::Row row;
875                 
876                 row = *(_view.get_selection()->get_selected());
877
878                 Window* win = row[_model.editor];
879                 if (win && !win->is_visible()) {
880                         win->present (); 
881                 } else {
882                         cpi = row[_model.protocol_info];
883                         
884                         if (cpi && cpi->protocol && cpi->protocol->has_editor ()) {
885                                 Box* box = (Box*) cpi->protocol->get_gui ();
886                                 if (box) {
887                                         string title = row[_model.name];
888                                         ArdourDialog* win = new ArdourDialog (_parent, title);
889                                         win->get_vbox()->pack_start (*box, false, false);
890                                         box->show ();
891                                         win->present ();
892                                         row[_model.editor] = win;
893                                 }
894                         }
895                 }
896         }
897
898         class ControlSurfacesModelColumns : public TreeModelColumnRecord
899         {
900         public:
901
902                 ControlSurfacesModelColumns ()
903                 {
904                         add (name);
905                         add (enabled);
906                         add (feedback);
907                         add (protocol_info);
908                         add (editor);
909                 }
910
911                 TreeModelColumn<string> name;
912                 TreeModelColumn<bool> enabled;
913                 TreeModelColumn<bool> feedback;
914                 TreeModelColumn<ControlProtocolInfo*> protocol_info;
915                 TreeModelColumn<Gtk::Window*> editor;
916         };
917
918         Glib::RefPtr<ListStore> _store;
919         ControlSurfacesModelColumns _model;
920         TreeView _view;
921         Gtk::Window& _parent;
922 };
923
924
925 RCOptionEditor::RCOptionEditor ()
926         : OptionEditor (Config, _("Ardour Preferences")),
927           _rc_config (Config)
928 {
929         /* MISC */
930
931         add_option (_("Misc"), new OptionEditorHeading (_("Metering")));
932
933         ComboOption<float>* mht = new ComboOption<float> (
934                 "meter-hold",
935                 _("Meter hold time"),
936                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_meter_hold),
937                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_meter_hold)
938                 );
939
940         mht->add (MeterHoldOff, _("off"));
941         mht->add (MeterHoldShort, _("short"));
942         mht->add (MeterHoldMedium, _("medium"));
943         mht->add (MeterHoldLong, _("long"));
944
945         add_option (_("Misc"), mht);
946
947         ComboOption<float>* mfo = new ComboOption<float> (
948                 "meter-falloff",
949                 _("Meter fall-off"),
950                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_meter_falloff),
951                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_meter_falloff)
952                 );
953
954         mfo->add (METER_FALLOFF_OFF, _("off"));
955         mfo->add (METER_FALLOFF_SLOWEST, _("slowest"));
956         mfo->add (METER_FALLOFF_SLOW, _("slow"));
957         mfo->add (METER_FALLOFF_MEDIUM, _("medium"));
958         mfo->add (METER_FALLOFF_FAST, _("fast"));
959         mfo->add (METER_FALLOFF_FASTER, _("faster"));
960         mfo->add (METER_FALLOFF_FASTEST, _("fastest"));
961
962         add_option (_("Misc"), mfo);
963
964         add_option (_("Misc"), new OptionEditorHeading (_("Undo")));
965
966         add_option (_("Misc"), new UndoOptions (_rc_config));
967
968         add_option (_("Misc"), new OptionEditorHeading (_("Misc")));
969
970 #ifndef GTKOSX
971         /* font scaling does nothing with GDK/Quartz */
972         add_option (_("Misc"), new FontScalingOptions (_rc_config));
973 #endif
974
975         add_option (_("Misc"),
976              new BoolOption (
977                      "verify-remove-last-capture",
978                      _("Verify removal of last capture"),
979                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_verify_remove_last_capture),
980                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_verify_remove_last_capture)
981                      ));
982
983         add_option (_("Misc"),
984              new BoolOption (
985                      "periodic-safety-backups",
986                      _("Make periodic backups of the session file"),
987                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_periodic_safety_backups),
988                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_periodic_safety_backups)
989                      ));
990
991         add_option (_("Misc"),
992              new BoolOption (
993                      "sync-all-route-ordering",
994                      _("Syncronise editor and mixer track order"),
995                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_sync_all_route_ordering),
996                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_sync_all_route_ordering)
997                      ));
998
999         add_option (_("Misc"),
1000              new BoolOption (
1001                      "only-copy-imported-files",
1002                      _("Always copy imported files"),
1003                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_only_copy_imported_files),
1004                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_only_copy_imported_files)
1005                      ));
1006
1007         add_option (_("Misc"),
1008              new BoolOption (
1009                      "default-narrow_ms",
1010                      _("Use narrow mixer strips"),
1011                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_default_narrow_ms),
1012                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_default_narrow_ms)
1013                      ));
1014
1015         add_option (_("Misc"),
1016              new BoolOption (
1017                      "name-new-markers",
1018                      _("Name new markers"),
1019                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_name_new_markers),
1020                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_name_new_markers)
1021                      ));
1022
1023         /* TRANSPORT */
1024
1025         add_option (_("Transport"),
1026              new BoolOption (
1027                      "latched-record-enable",
1028                      _("Keep record-enable engaged on stop"),
1029                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_latched_record_enable),
1030                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_latched_record_enable)
1031                      ));
1032
1033         add_option (_("Transport"),
1034              new BoolOption (
1035                      "stop-recording-on-xrun",
1036                      _("Stop recording when an xrun occurs"),
1037                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_stop_recording_on_xrun),
1038                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_stop_recording_on_xrun)
1039                      ));
1040
1041         add_option (_("Transport"),
1042              new BoolOption (
1043                      "create-xrun-marker",
1044                      _("Create markers where xruns occur"),
1045                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_create_xrun_marker),
1046                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_create_xrun_marker)
1047                      ));
1048
1049         add_option (_("Transport"),
1050              new BoolOption (
1051                      "stop-at-session-end",
1052                      _("Stop at the end of the session"),
1053                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_stop_at_session_end),
1054                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_stop_at_session_end)
1055                      ));
1056
1057         add_option (_("Transport"),
1058              new BoolOption (
1059                      "primary-clock-delta-edit-cursor",
1060                      _("Primary clock delta to edit cursor"),
1061                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_primary_clock_delta_edit_cursor),
1062                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_primary_clock_delta_edit_cursor)
1063                      ));
1064
1065         add_option (_("Transport"),
1066              new BoolOption (
1067                      "secondary-clock-delta-edit-cursor",
1068                      _("Secondary clock delta to edit cursor"),
1069                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_secondary_clock_delta_edit_cursor),
1070                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_secondary_clock_delta_edit_cursor)
1071                      ));
1072
1073         add_option (_("Transport"),
1074              new BoolOption (
1075                      "disable-disarm-during-roll",
1076                      _("Disable per-track record disarm while rolling"),
1077                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_disable_disarm_during_roll),
1078                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_disable_disarm_during_roll)
1079                      ));
1080
1081         /* EDITOR */
1082
1083         add_option (_("Editor"),
1084              new BoolOption (
1085                      "link-region-and-track-selection",
1086                      _("Link selection of regions and tracks"),
1087                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_link_region_and_track_selection),
1088                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_link_region_and_track_selection)
1089                      ));
1090
1091         add_option (_("Editor"),
1092              new BoolOption (
1093                      "automation-follows-regions",
1094                      _("Move relevant automation when regions are moved"),
1095                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_automation_follows_regions),
1096                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_automation_follows_regions)
1097                      ));
1098
1099         add_option (_("Editor"),
1100              new BoolOption (
1101                      "show-track-meters",
1102                      _("Show meters on tracks in the editor"),
1103                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_show_track_meters),
1104                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_show_track_meters)
1105                      ));
1106
1107         add_option (_("Editor"),
1108              new BoolOption (
1109                      "use-overlap-equivalency",
1110                      _("Use overlap equivalency for regions"),
1111                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_use_overlap_equivalency),
1112                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_use_overlap_equivalency)
1113                      ));
1114
1115         add_option (_("Editor"),
1116              new BoolOption (
1117                      "rubberbanding-snaps-to-grid",
1118                      _("Make rubberband selection rectangle snap to the grid"),
1119                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_rubberbanding_snaps_to_grid),
1120                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_rubberbanding_snaps_to_grid)
1121                      ));
1122
1123         add_option (_("Editor"),
1124              new BoolOption (
1125                      "show-waveforms",
1126                      _("Show waveforms in regions"),
1127                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_show_waveforms),
1128                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_show_waveforms)
1129                      ));
1130
1131         ComboOption<WaveformScale>* wfs = new ComboOption<WaveformScale> (
1132                 "waveform-scale",
1133                 _("Waveform scale"),
1134                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_waveform_scale),
1135                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_waveform_scale)
1136                 );
1137
1138         wfs->add (Linear, _("linear"));
1139         wfs->add (Logarithmic, _("logarithmic"));
1140
1141         add_option (_("Editor"), wfs);
1142
1143         ComboOption<WaveformShape>* wfsh = new ComboOption<WaveformShape> (
1144                 "waveform-shape",
1145                 _("Waveform shape"),
1146                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_waveform_shape),
1147                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_waveform_shape)
1148                 );
1149
1150         wfsh->add (Traditional, _("traditional"));
1151         wfsh->add (Rectified, _("rectified"));
1152
1153         add_option (_("Editor"), wfsh);
1154
1155         /* AUDIO */
1156
1157         add_option (_("Audio"), new OptionEditorHeading (_("Solo")));
1158
1159
1160         add_option (_("Audio"),
1161              new BoolOption (
1162                      "solo-control-is-listen-control",
1163                      _("Solo controls are Listen controls"),
1164                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_solo_control_is_listen_control),
1165                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_solo_control_is_listen_control)
1166                      ));
1167
1168         ComboOption<ListenPosition>* lp = new ComboOption<ListenPosition> (
1169                 "listen-position",
1170                 _("Listen Position"),
1171                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_listen_position),
1172                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_listen_position)
1173                 );
1174
1175         lp->add (AfterFaderListen, _("after-fader listen"));
1176         lp->add (PreFaderListen, _("pre-fader listen"));
1177
1178         add_option (_("Audio"), lp);
1179         add_option (_("Audio"), new SoloMuteOptions (_rc_config));
1180
1181         add_option (_("Audio"),
1182              new BoolOption (
1183                      "solo-latched",
1184                      _("Latched solo"),
1185                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_solo_latched),
1186                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_solo_latched)
1187                      ));
1188
1189         add_option (_("Audio"),
1190              new BoolOption (
1191                      "show-solo-mutes",
1192                      _("Show solo muting"),
1193                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_show_solo_mutes),
1194                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_show_solo_mutes)
1195                      ));
1196
1197         add_option (_("Audio"),
1198              new BoolOption (
1199                      "solo-mute-override",
1200                      _("Override muting"),
1201                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_solo_mute_override),
1202                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_solo_mute_override)
1203                      ));
1204
1205         add_option (_("Audio"), new OptionEditorHeading (_("Monitoring")));
1206
1207         ComboOption<MonitorModel>* mm = new ComboOption<MonitorModel> (
1208                 "monitoring-model",
1209                 _("Monitoring handled by"),
1210                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_monitoring_model),
1211                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_monitoring_model)
1212                 );
1213
1214         mm->add (HardwareMonitoring, _("JACK"));
1215         mm->add (SoftwareMonitoring, _("ardour"));
1216         mm->add (ExternalMonitoring, _("audio hardware"));
1217
1218         add_option (_("Audio"), mm);
1219
1220         add_option (_("Audio"),
1221              new BoolOption (
1222                      "tape-machine-mode",
1223                      _("Tape machine mode"),
1224                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_tape_machine_mode),
1225                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_tape_machine_mode)
1226                      ));
1227
1228         add_option (_("Audio"), new OptionEditorHeading (_("Connection of tracks and busses")));
1229
1230         add_option (_("Audio"),
1231                     new BoolOption (
1232                             "auto-connect-standard-busses",
1233                             _("Auto-connect master/monitor busses"),
1234                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_auto_connect_standard_busses),
1235                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_auto_connect_standard_busses)
1236                             ));
1237
1238         ComboOption<AutoConnectOption>* iac = new ComboOption<AutoConnectOption> (
1239                 "input-auto-connect",
1240                 _("Connect track and bus inputs"),
1241                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_input_auto_connect),
1242                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_input_auto_connect)
1243                 );
1244
1245         iac->add (AutoConnectPhysical, _("automatically to physical inputs"));
1246         iac->add (ManualConnect, _("manually"));
1247
1248         add_option (_("Audio"), iac);
1249
1250         ComboOption<AutoConnectOption>* oac = new ComboOption<AutoConnectOption> (
1251                 "output-auto-connect",
1252                 _("Connect track and bus outputs"),
1253                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_output_auto_connect),
1254                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_output_auto_connect)
1255                 );
1256
1257         oac->add (AutoConnectPhysical, _("automatically to physical outputs"));
1258         oac->add (AutoConnectMaster, _("automatically to master outputs"));
1259         oac->add (ManualConnect, _("manually"));
1260
1261         add_option (_("Audio"), oac);
1262
1263         add_option (_("Audio"), new OptionEditorHeading (_("Denormals")));
1264
1265         add_option (_("Audio"),
1266              new BoolOption (
1267                      "denormal-protection",
1268                      _("Use DC bias to protect against denormals"),
1269                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_denormal_protection),
1270                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_denormal_protection)
1271                      ));
1272
1273         ComboOption<DenormalModel>* dm = new ComboOption<DenormalModel> (
1274                 "denormal-model",
1275                 _("Processor handling"),
1276                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_denormal_model),
1277                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_denormal_model)
1278                 );
1279
1280         dm->add (DenormalNone, _("no processor handling"));
1281
1282         FPU fpu;
1283
1284         if (fpu.has_flush_to_zero()) {
1285                 dm->add (DenormalFTZ, _("use FlushToZero"));
1286         }
1287
1288         if (fpu.has_denormals_are_zero()) {
1289                 dm->add (DenormalDAZ, _("use DenormalsAreZero"));
1290         }
1291
1292         if (fpu.has_flush_to_zero() && fpu.has_denormals_are_zero()) {
1293                 dm->add (DenormalFTZDAZ, _("use FlushToZero and DenormalsAreZerO"));
1294         }
1295
1296         add_option (_("Audio"), dm);
1297
1298         add_option (_("Audio"), new OptionEditorHeading (_("Plugins")));
1299
1300         add_option (_("Audio"),
1301              new BoolOption (
1302                      "plugins-stop-with-transport",
1303                      _("Stop plugins when the transport is stopped"),
1304                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_plugins_stop_with_transport),
1305                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_plugins_stop_with_transport)
1306                      ));
1307
1308         add_option (_("Audio"),
1309              new BoolOption (
1310                      "do-not-record-plugins",
1311                      _("Disable plugins during recording"),
1312                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_do_not_record_plugins),
1313                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_do_not_record_plugins)
1314                      ));
1315
1316         add_option (_("Audio"),
1317              new BoolOption (
1318                      "new-plugins-active",
1319                      _("Make new plugins active"),
1320                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_new_plugins_active),
1321                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_new_plugins_active)
1322                      ));
1323
1324         add_option (_("Audio"),
1325              new BoolOption (
1326                      "auto-analyse-audio",
1327                      _("Enable automatic analysis of audio"),
1328                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_auto_analyse_audio),
1329                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_auto_analyse_audio)
1330                      ));
1331
1332         /* MIDI CONTROL */
1333
1334         list<ComboOption<string>* > midi_combos;
1335
1336         midi_combos.push_back (new ComboOption<string> (
1337                                        "mtc-port-name",
1338                                        _("Send/Receive MTC via"),
1339                                        sigc::mem_fun (*_rc_config, &RCConfiguration::get_mtc_port_name),
1340                                        sigc::mem_fun (*_rc_config, &RCConfiguration::set_mtc_port_name)
1341                                        ));
1342
1343         midi_combos.push_back (new ComboOption<string> (
1344                                        "midi-clock-port-name",
1345                                        _("Send/Receive MIDI clock via"),
1346                                        sigc::mem_fun (*_rc_config, &RCConfiguration::get_midi_clock_port_name),
1347                                        sigc::mem_fun (*_rc_config, &RCConfiguration::set_midi_clock_port_name)
1348                                        ));
1349
1350         midi_combos.push_back (new ComboOption<string> (
1351                                        "mmc-port-name",
1352                                        _("Send/Receive MMC via"),
1353                                        sigc::mem_fun (*_rc_config, &RCConfiguration::get_mmc_port_name),
1354                                        sigc::mem_fun (*_rc_config, &RCConfiguration::set_mmc_port_name)
1355                                        ));
1356
1357         midi_combos.push_back (new ComboOption<string> (
1358                                        "midi-port-name",
1359                                        _("Send/Receive MIDI parameter control via"),
1360                                        sigc::mem_fun (*_rc_config, &RCConfiguration::get_midi_port_name),
1361                                        sigc::mem_fun (*_rc_config, &RCConfiguration::set_midi_port_name)
1362                                        ));
1363         
1364         add_option (_("MIDI control"), new MIDIPorts (_rc_config, midi_combos));
1365
1366         for (list<ComboOption<string>* >::iterator i = midi_combos.begin(); i != midi_combos.end(); ++i) {
1367                 add_option (_("MIDI control"), *i);
1368         }
1369
1370         add_option (_("MIDI control"),
1371                     new BoolOption (
1372                             "mmc-control",
1373                             _("Obey MIDI Machine Control commands"),
1374                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_mmc_control),
1375                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_mmc_control)
1376                             ));
1377
1378
1379         add_option (_("MIDI control"),
1380                     new BoolOption (
1381                             "send-mmc",
1382                             _("Send MIDI Machine Control commands"),
1383                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_send_mmc),
1384                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_send_mmc)
1385                             ));
1386
1387         add_option (_("MIDI control"),
1388                     new BoolOption (
1389                             "midi-feedback",
1390                             _("Send MIDI control feedback"),
1391                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_midi_feedback),
1392                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_midi_feedback)
1393                             ));
1394
1395         add_option (_("MIDI control"),
1396              new SpinOption<uint8_t> (
1397                      "mmc-receive-device-id",
1398                      _("Inbound MMC device ID"),
1399                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_mmc_receive_device_id),
1400                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_mmc_receive_device_id),
1401                      0, 128, 1, 10
1402                      ));
1403
1404         add_option (_("MIDI control"),
1405              new SpinOption<uint8_t> (
1406                      "mmc-send-device-id",
1407                      _("Outbound MMC device ID"),
1408                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_mmc_send_device_id),
1409                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_mmc_send_device_id),
1410                      0, 128, 1, 10
1411                      ));
1412
1413         add_option (_("MIDI control"),
1414              new SpinOption<int32_t> (
1415                      "initial-program-change",
1416                      _("Initial program change"),
1417                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_initial_program_change),
1418                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_initial_program_change),
1419                      -1, 65536, 1, 10
1420                      ));
1421
1422         /* CONTROL SURFACES */
1423
1424         add_option (_("Control surfaces"), new ControlSurfacesOptions (*this));
1425
1426         ComboOption<RemoteModel>* rm = new ComboOption<RemoteModel> (
1427                 "remote-model",
1428                 _("Control surface remote ID"),
1429                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_remote_model),
1430                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_remote_model)
1431                 );
1432
1433         rm->add (UserOrdered, _("assigned by user"));
1434         rm->add (MixerOrdered, _("follows order of mixer"));
1435         rm->add (EditorOrdered, _("follows order of editor"));
1436
1437         add_option (_("Control surfaces"), rm);
1438
1439         /* CLICK */
1440
1441         add_option (_("Click"), new ClickOptions (_rc_config, this));
1442
1443         /* KEYBOARD */
1444
1445         add_option (_("Keyboard"), new KeyboardOptions);
1446 }
1447
1448