OSC: populate check boxes with default settings at session start
[ardour.git] / libs / surfaces / osc / osc_gui.cc
1 /*
2     Copyright (C) 2016 Robin Gareus <robin@gareus.org
3     Copyright (C) 2009-2012 Paul Davis
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 */
20
21 #include <iostream>
22 #include <list>
23 #include <string>
24
25 #include <gtkmm/box.h>
26 #include <gtkmm/notebook.h>
27 #include <gtkmm/table.h>
28 #include <gtkmm/label.h>
29 #include <gtkmm/button.h>
30 #include <gtkmm/spinbutton.h>
31 #include <gtkmm/comboboxtext.h>
32
33 #include "gtkmm2ext/gtk_ui.h"
34 #include "gtkmm2ext/gui_thread.h"
35 #include "gtkmm2ext/utils.h"
36
37 #include "osc.h"
38
39 #include "pbd/i18n.h"
40
41 namespace ArdourSurface {
42
43 class OSC_GUI : public Gtk::Notebook
44 {
45         public:
46                 OSC_GUI (OSC&);
47                 ~OSC_GUI ();
48
49 private:
50         // settings page
51         Gtk::ComboBoxText debug_combo;
52         Gtk::ComboBoxText portmode_combo;
53         Gtk::SpinButton port_entry;
54         Gtk::SpinButton bank_entry;
55         Gtk::SpinButton striptypes_spin;
56         Gtk::SpinButton feedback_spin;
57         Gtk::ComboBoxText gainmode_combo;
58         void debug_changed ();
59         void portmode_changed ();
60         void gainmode_changed ();
61         void clear_device ();
62         void port_changed ();
63         void bank_changed ();
64         void strips_changed ();
65         void feedback_changed ();
66         // Strip types calculator
67         void calculate_strip_types ();
68         void push_strip_types ();
69         Gtk::Label current_strip_types;
70         Gtk::CheckButton audio_tracks;
71         Gtk::CheckButton midi_tracks;
72         Gtk::CheckButton audio_buses;
73         Gtk::CheckButton midi_buses;
74         Gtk::CheckButton control_masters;
75         Gtk::CheckButton master_type;
76         Gtk::CheckButton monitor_type;
77         Gtk::CheckButton selected_tracks;
78         Gtk::CheckButton hidden_tracks;
79         int stvalue;
80         // feedback calculator
81         void calculate_feedback ();
82         void push_feedback ();
83         Gtk::Label current_feedback;
84         Gtk::CheckButton strip_buttons_button;
85         Gtk::CheckButton strip_control_button;
86         Gtk::CheckButton ssid_as_path;
87         Gtk::CheckButton heart_beat;
88         Gtk::CheckButton master_fb;
89         Gtk::CheckButton bar_and_beat;
90         Gtk::CheckButton smpte;
91         Gtk::CheckButton meter_float;
92         Gtk::CheckButton meter_led;
93         Gtk::CheckButton signal_present;
94         Gtk::CheckButton hp_samples;
95         Gtk::CheckButton hp_min_sec;
96         Gtk::CheckButton hp_gui;
97         Gtk::CheckButton select_fb;
98         int fbvalue;
99         OSC& cp;
100 };
101
102
103 void*
104 OSC::get_gui () const
105 {
106         if (!gui) {
107                 const_cast<OSC*>(this)->build_gui ();
108         }
109         //static_cast<Gtk::VBox*>(gui)->show_all();
110         static_cast<Gtk::Notebook*>(gui)->show_all();
111         return gui;
112 }
113
114 void
115 OSC::tear_down_gui ()
116 {
117         if (gui) {
118                 Gtk::Widget *w = static_cast<Gtk::Notebook*>(gui)->get_parent();
119                 if (w) {
120                         w->hide();
121                         delete w;
122                 }
123         }
124         delete (OSC_GUI*) gui;
125         gui = 0;
126 }
127
128 void
129 OSC::build_gui ()
130 {
131         gui = (void*) new OSC_GUI (*this);
132 }
133
134 } // end namespace
135
136 ///////////////////////////////////////////////////////////////////////////////
137
138 using namespace PBD;
139 using namespace Gtk;
140 using namespace Gtkmm2ext;
141 using namespace ArdourSurface;
142
143 OSC_GUI::OSC_GUI (OSC& p)
144         : cp (p)
145 {
146         int n = 0; // table row
147         uint32_t def_feedback;
148         uint32_t def_strip;
149         Table* table = manage (new Table);
150         Label* label;
151         Button* button;
152         Button* fbbutton;
153         Button* stbutton;
154         table->set_row_spacings (10);
155         table->set_col_spacings (6);
156         table->set_border_width (12);
157
158         // show our url
159         label = manage (new Gtk::Label(_("Connection:")));
160         label->set_alignment(1, .5);
161         table->attach (*label, 0, 1, n, n+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
162         label = manage (new Gtk::Label(cp.get_server_url()));
163         table->attach (*label, 1, 2, n, n+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
164         ++n;
165
166         // show and set port to auto (default) or manual (one surface only)
167         label = manage (new Gtk::Label(_("Port Mode:")));
168         label->set_alignment(1, .5);
169         table->attach (*label, 0, 1, n, n+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
170         table->attach (portmode_combo, 1, 2, n, n+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
171         std::vector<std::string> portmode_options;
172         portmode_options.push_back (_("Auto"));
173         portmode_options.push_back (_("Manual"));
174
175         set_popdown_strings (portmode_combo, portmode_options);
176         portmode_combo.set_active ((int)cp.get_portmode());
177         ++n;
178
179         // port entry box
180         label = manage (new Gtk::Label(_("Manual Port:")));
181         label->set_alignment(1, .5);
182         table->attach (*label, 0, 1, n, n+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
183         table->attach (port_entry, 1, 2, n, n+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
184         port_entry.set_range(1024, 0xffff);
185         port_entry.set_increments (1, 100);
186         port_entry.set_text(cp.get_remote_port().c_str());
187         if (!cp.get_portmode()) {
188                 port_entry.set_sensitive (false);
189         }
190         ++n;
191
192         // default banksize setting
193         label = manage (new Gtk::Label(_("Bank Size:")));
194         label->set_alignment(1, .5);
195         table->attach (*label, 0, 1, n, n+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
196         table->attach (bank_entry, 1, 2, n, n+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
197         bank_entry.set_range (0, 0xffff);
198         bank_entry.set_increments (1, 8);
199         bank_entry.set_value (cp.get_banksize());
200
201         ++n;
202
203         // Default strip types
204         label = manage (new Gtk::Label(_("Strip Types:")));
205         label->set_alignment(1, .5);
206         table->attach (*label, 0, 1, n, n+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
207         table->attach (striptypes_spin, 1, 2, n, n+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
208         striptypes_spin.set_range (0, 0x3ff);
209         striptypes_spin.set_increments (1, 10);
210         def_strip = cp.get_defaultstrip();
211         striptypes_spin.set_value (def_strip);
212
213         ++n;
214
215         // default feedback settings
216         label = manage (new Gtk::Label(_("Feedback:")));
217         label->set_alignment(1, .5);
218         table->attach (*label, 0, 1, n, n+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
219         table->attach (feedback_spin, 1, 2, n, n+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
220         feedback_spin.set_range (0, 0x3fff);
221         feedback_spin.set_increments (1, 10);
222         def_feedback = cp.get_defaultfeedback();
223         feedback_spin.set_value (def_feedback);
224         ++n;
225
226         // Gain Mode
227         label = manage (new Gtk::Label(_("Gain Mode:")));
228         label->set_alignment(1, .5);
229         table->attach (*label, 0, 1, n, n+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
230         table->attach (gainmode_combo, 1, 2, n, n+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
231         std::vector<std::string> gainmode_options;
232         gainmode_options.push_back (_("dB"));
233         gainmode_options.push_back (_("Position"));
234
235         set_popdown_strings (gainmode_combo, gainmode_options);
236         gainmode_combo.set_active ((int)cp.get_gainmode());
237         ++n;
238
239         // debug setting
240         label = manage (new Gtk::Label(_("Debug:")));
241         label->set_alignment(1, .5);
242         table->attach (*label, 0, 1, n, n+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
243         table->attach (debug_combo, 1, 2, n, n+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
244
245         std::vector<std::string> debug_options;
246         debug_options.push_back (_("Off"));
247         debug_options.push_back (_("Log invalid messages"));
248         debug_options.push_back (_("Log all messages"));
249
250         set_popdown_strings (debug_combo, debug_options);
251         debug_combo.set_active ((int)cp.get_debug_mode());
252         ++n;
253
254         // refresh button
255         button = manage (new Gtk::Button(_("Clear OSC Devices")));
256         table->attach (*button, 0, 2, n, n+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
257
258         table->show_all ();
259         append_page (*table, _("OSC Setup"));
260
261         debug_combo.signal_changed().connect (sigc::mem_fun (*this, &OSC_GUI::debug_changed));
262         portmode_combo.signal_changed().connect (sigc::mem_fun (*this, &OSC_GUI::portmode_changed));
263         gainmode_combo.signal_changed().connect (sigc::mem_fun (*this, &OSC_GUI::gainmode_changed));
264         button->signal_clicked().connect (sigc::mem_fun (*this, &OSC_GUI::clear_device));
265         port_entry.signal_activate().connect (sigc::mem_fun (*this, &OSC_GUI::port_changed));
266         bank_entry.signal_activate().connect (sigc::mem_fun (*this, &OSC_GUI::bank_changed));
267         striptypes_spin.signal_activate().connect (sigc::mem_fun (*this, &OSC_GUI::strips_changed));
268         feedback_spin.signal_activate().connect (sigc::mem_fun (*this, &OSC_GUI::feedback_changed));
269
270
271         // Strip Types Calculate Page
272         int stn = 0; // table row
273         Table* sttable = manage (new Table);
274         sttable->set_row_spacings (8);
275         sttable->set_col_spacings (6);
276         sttable->set_border_width (25);
277
278         // show our url
279         label = manage (new Gtk::Label(_("Select Desired Types of Tracks")));
280         sttable->attach (*label, 0, 2, stn, stn+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
281         ++stn;
282
283         label = manage (new Gtk::Label(_("Strip Types Value:")));
284         label->set_alignment(1, .5);
285         sttable->attach (*label, 0, 1, stn, stn+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 15);
286         calculate_strip_types ();
287         current_strip_types.set_width_chars(10);
288         sttable->attach (current_strip_types, 1, 2, stn, stn+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 15);
289         ++stn;
290
291         label = manage (new Gtk::Label(_("Audio Tracks:")));
292         label->set_alignment(1, .5);
293         sttable->attach (*label, 0, 1, stn, stn+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
294         sttable->attach (audio_tracks, 1, 2, stn, stn+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
295         audio_tracks.signal_clicked().connect (sigc::mem_fun (*this, &OSC_GUI::calculate_strip_types));
296         audio_tracks.set_active(def_strip & 1);
297         ++stn;
298
299         label = manage (new Gtk::Label(_("Midi Tracks:")));
300         label->set_alignment(1, .5);
301         sttable->attach (*label, 0, 1, stn, stn+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
302         sttable->attach (midi_tracks, 1, 2, stn, stn+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
303         midi_tracks.signal_clicked().connect (sigc::mem_fun (*this, &OSC_GUI::calculate_strip_types));
304         midi_tracks.set_active(def_strip & 2);
305         ++stn;
306
307         label = manage (new Gtk::Label(_("Audio Buses:")));
308         label->set_alignment(1, .5);
309         sttable->attach (*label, 0, 1, stn, stn+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
310         sttable->attach (audio_buses, 1, 2, stn, stn+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
311         audio_buses.signal_clicked().connect (sigc::mem_fun (*this, &OSC_GUI::calculate_strip_types));
312         audio_buses.set_active(def_strip & 4);
313         ++stn;
314
315         label = manage (new Gtk::Label(_("Midi Buses:")));
316         label->set_alignment(1, .5);
317         sttable->attach (*label, 0, 1, stn, stn+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
318         sttable->attach (midi_buses, 1, 2, stn, stn+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
319         midi_buses.signal_clicked().connect (sigc::mem_fun (*this, &OSC_GUI::calculate_strip_types));
320         midi_buses.set_active(def_strip & 8);
321         ++stn;
322
323         label = manage (new Gtk::Label(_("Control Masters:")));
324         label->set_alignment(1, .5);
325         sttable->attach (*label, 0, 1, stn, stn+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
326         sttable->attach (control_masters, 1, 2, stn, stn+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
327         control_masters.signal_clicked().connect (sigc::mem_fun (*this, &OSC_GUI::calculate_strip_types));
328         control_masters.set_active(def_strip & 16);
329         ++stn;
330
331         label = manage (new Gtk::Label(_("Master (use /master instead):")));
332         label->set_alignment(1, .5);
333         sttable->attach (*label, 0, 1, stn, stn+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
334         sttable->attach (master_type, 1, 2, stn, stn+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
335         master_type.signal_clicked().connect (sigc::mem_fun (*this, &OSC_GUI::calculate_strip_types));
336         master_type.set_active(def_strip & 32);
337         ++stn;
338
339         label = manage (new Gtk::Label(_("Monitor (use /monitor instead):")));
340         label->set_alignment(1, .5);
341         sttable->attach (*label, 0, 1, stn, stn+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
342         sttable->attach (monitor_type, 1, 2, stn, stn+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
343         monitor_type.signal_clicked().connect (sigc::mem_fun (*this, &OSC_GUI::calculate_strip_types));
344         monitor_type.set_active(def_strip & 64);
345         ++stn;
346
347         label = manage (new Gtk::Label(_("Selected Tracks (use for selected tracks only):")));
348         label->set_alignment(1, .5);
349         sttable->attach (*label, 0, 1, stn, stn+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
350         sttable->attach (selected_tracks, 1, 2, stn, stn+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
351         selected_tracks.signal_clicked().connect (sigc::mem_fun (*this, &OSC_GUI::calculate_strip_types));
352         selected_tracks.set_active(def_strip & 256);
353         ++stn;
354
355         label = manage (new Gtk::Label(_("Hidden Tracks:")));
356         label->set_alignment(1, .5);
357         sttable->attach (*label, 0, 1, stn, stn+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
358         sttable->attach (hidden_tracks, 1, 2, stn, stn+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
359         hidden_tracks.signal_clicked().connect (sigc::mem_fun (*this, &OSC_GUI::calculate_strip_types));
360         hidden_tracks.set_active(def_strip & 512);
361         ++stn;
362
363         stbutton = manage (new Gtk::Button(_("Use Value as Strip Types Default")));
364         sttable->attach (*stbutton, 0, 2, stn, stn+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 15);
365         stbutton->signal_clicked().connect (sigc::mem_fun (*this, &OSC_GUI::push_strip_types));
366
367
368         sttable->show_all ();
369         append_page (*sttable, _("Calculate Strip Types"));
370
371
372         // Feedback Calculate Page
373         int fn = 0; // table row
374         Table* fbtable = manage (new Table);
375         fbtable->set_row_spacings (4);
376         fbtable->set_col_spacings (6);
377         fbtable->set_border_width (12);
378
379         // show our url
380         label = manage (new Gtk::Label(_("Select Desired Types of Feedback")));
381         fbtable->attach (*label, 0, 2, fn, fn+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
382         ++fn;
383
384         label = manage (new Gtk::Label(_("Feedback Value:")));
385         label->set_alignment(1, .5);
386         fbtable->attach (*label, 0, 1, fn, fn+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 15);
387         calculate_feedback ();
388         current_feedback.set_width_chars(10);
389         fbtable->attach (current_feedback, 1, 2, fn, fn+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 15);
390         ++fn;
391
392         label = manage (new Gtk::Label(_("Strip Buttons:")));
393         label->set_alignment(1, .5);
394         fbtable->attach (*label, 0, 1, fn, fn+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
395         fbtable->attach (strip_buttons_button, 1, 2, fn, fn+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
396         strip_buttons_button.signal_clicked().connect (sigc::mem_fun (*this, &OSC_GUI::calculate_feedback));
397         strip_buttons_button.set_active(def_feedback & 1);
398         ++fn;
399
400         label = manage (new Gtk::Label(_("Strip Controls:")));
401         label->set_alignment(1, .5);
402         fbtable->attach (*label, 0, 1, fn, fn+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
403         fbtable->attach (strip_control_button, 1, 2, fn, fn+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
404         strip_control_button.signal_clicked().connect (sigc::mem_fun (*this, &OSC_GUI::calculate_feedback));
405         strip_control_button.set_active(def_feedback & 2);
406         ++fn;
407
408         label = manage (new Gtk::Label(_("Use SSID as Path Extension:")));
409         label->set_alignment(1, .5);
410         fbtable->attach (*label, 0, 1, fn, fn+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
411         fbtable->attach (ssid_as_path, 1, 2, fn, fn+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
412         ssid_as_path.signal_clicked().connect (sigc::mem_fun (*this, &OSC_GUI::calculate_feedback));
413         ssid_as_path.set_active(def_feedback & 4);
414         ++fn;
415
416         label = manage (new Gtk::Label(_("Use Heart Beat:")));
417         label->set_alignment(1, .5);
418         fbtable->attach (*label, 0, 1, fn, fn+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
419         fbtable->attach (heart_beat, 1, 2, fn, fn+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
420         heart_beat.signal_clicked().connect (sigc::mem_fun (*this, &OSC_GUI::calculate_feedback));
421         heart_beat.set_active(def_feedback & 8);
422         ++fn;
423
424         label = manage (new Gtk::Label(_("Master Section:")));
425         label->set_alignment(1, .5);
426         fbtable->attach (*label, 0, 1, fn, fn+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
427         fbtable->attach (master_fb, 1, 2, fn, fn+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
428         master_fb.signal_clicked().connect (sigc::mem_fun (*this, &OSC_GUI::calculate_feedback));
429         master_fb.set_active(def_feedback & 16);
430         ++fn;
431
432         label = manage (new Gtk::Label(_("Play Head Position as Bar and Beat:")));
433         label->set_alignment(1, .5);
434         fbtable->attach (*label, 0, 1, fn, fn+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
435         fbtable->attach (bar_and_beat, 1, 2, fn, fn+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
436         bar_and_beat.signal_clicked().connect (sigc::mem_fun (*this, &OSC_GUI::calculate_feedback));
437         bar_and_beat.set_active(def_feedback & 32);
438         ++fn;
439
440         label = manage (new Gtk::Label(_("Play Head Position as SMPTE Time:")));
441         label->set_alignment(1, .5);
442         fbtable->attach (*label, 0, 1, fn, fn+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
443         fbtable->attach (smpte, 1, 2, fn, fn+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
444         smpte.signal_clicked().connect (sigc::mem_fun (*this, &OSC_GUI::calculate_feedback));
445         smpte.set_active(def_feedback & 64);
446         ++fn;
447
448         label = manage (new Gtk::Label(_("Metering as a Float:")));
449         label->set_alignment(1, .5);
450         fbtable->attach (*label, 0, 1, fn, fn+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
451         fbtable->attach (meter_float, 1, 2, fn, fn+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
452         meter_float.signal_clicked().connect (sigc::mem_fun (*this, &OSC_GUI::calculate_feedback));
453         meter_float.set_active(def_feedback & 128);
454         ++fn;
455
456         label = manage (new Gtk::Label(_("Metering as a LED Strip:")));
457         label->set_alignment(1, .5);
458         fbtable->attach (*label, 0, 1, fn, fn+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
459         fbtable->attach (meter_led, 1, 2, fn, fn+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
460         meter_led.signal_clicked().connect (sigc::mem_fun (*this, &OSC_GUI::calculate_feedback));
461         meter_led.set_active(def_feedback & 256);
462         ++fn;
463
464         label = manage (new Gtk::Label(_("Signal Present:")));
465         label->set_alignment(1, .5);
466         fbtable->attach (*label, 0, 1, fn, fn+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
467         fbtable->attach (signal_present, 1, 2, fn, fn+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
468         signal_present.signal_clicked().connect (sigc::mem_fun (*this, &OSC_GUI::calculate_feedback));
469         signal_present.set_active(def_feedback & 512);
470         ++fn;
471
472         label = manage (new Gtk::Label(_("Play Head Position as Samples:")));
473         label->set_alignment(1, .5);
474         fbtable->attach (*label, 0, 1, fn, fn+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
475         fbtable->attach (hp_samples, 1, 2, fn, fn+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
476         hp_samples.signal_clicked().connect (sigc::mem_fun (*this, &OSC_GUI::calculate_feedback));
477         hp_samples.set_active(def_feedback & 1024);
478         ++fn;
479
480         label = manage (new Gtk::Label(_("Playhead Position as Minutes Seconds:")));
481         label->set_alignment(1, .5);
482         fbtable->attach (*label, 0, 1, fn, fn+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
483         fbtable->attach (hp_min_sec, 1, 2, fn, fn+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
484         hp_min_sec.signal_clicked().connect (sigc::mem_fun (*this, &OSC_GUI::calculate_feedback));
485         hp_min_sec.set_active(def_feedback & 2048);
486         ++fn;
487
488         label = manage (new Gtk::Label(_("Playhead Position as per GUI Clock:")));
489         label->set_alignment(1, .5);
490         fbtable->attach (*label, 0, 1, fn, fn+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
491         fbtable->attach (hp_gui, 1, 2, fn, fn+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
492         hp_gui.signal_clicked().connect (sigc::mem_fun (*this, &OSC_GUI::calculate_feedback));
493         hp_gui.set_sensitive (false); // we don't have this yet (Mixbus wants)
494         ++fn;
495
496         label = manage (new Gtk::Label(_("Extra Select Only Feedback:")));
497         label->set_alignment(1, .5);
498         fbtable->attach (*label, 0, 1, fn, fn+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
499         fbtable->attach (select_fb, 1, 2, fn, fn+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
500         select_fb.signal_clicked().connect (sigc::mem_fun (*this, &OSC_GUI::calculate_feedback));
501         select_fb.set_active(def_feedback & 8192);
502         ++fn;
503
504         fbbutton = manage (new Gtk::Button(_("Use Value as Feedback Default")));
505         fbtable->attach (*fbbutton, 0, 2, fn, fn+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 15);
506         fbbutton->signal_clicked().connect (sigc::mem_fun (*this, &OSC_GUI::push_feedback));
507
508
509         fbtable->show_all ();
510         append_page (*fbtable, _("Calculate Feedback"));
511
512 }
513
514 OSC_GUI::~OSC_GUI ()
515 {
516 }
517
518 void
519 OSC_GUI::debug_changed ()
520 {
521         std::string str = debug_combo.get_active_text ();
522         if (str == _("Off")) {
523                 cp.set_debug_mode (OSC::Off);
524         }
525         else if (str == _("Log invalid messages")) {
526                 cp.set_debug_mode (OSC::Unhandled);
527         }
528         else if (str == _("Log all messages")) {
529                 cp.set_debug_mode (OSC::All);
530         }
531         else {
532                 std::cerr << "Invalid OSC Debug Mode\n";
533                 assert (0);
534         }
535 }
536
537 void
538 OSC_GUI::portmode_changed ()
539 {
540         std::string str = portmode_combo.get_active_text ();
541         if (str == _("Auto")) {
542                 cp.set_portmode (0);
543                 port_entry.set_sensitive (false);
544         }
545         else if (str == _("Manual")) {
546                 cp.set_portmode (1);
547                 port_entry.set_sensitive (true);
548         }
549         else {
550                 std::cerr << "Invalid OSC Port Mode\n";
551                 assert (0);
552         }
553 }
554
555 void
556 OSC_GUI::port_changed ()
557 {
558         std::string str = port_entry.get_text ();
559         if (port_entry.get_value() == 3819) {
560                 str = "8000";
561                 port_entry.set_value (8000);
562         }
563         cp.set_remote_port (str);
564 }
565
566 void
567 OSC_GUI::bank_changed ()
568 {
569         uint32_t bsize = bank_entry.get_value ();
570         cp.set_banksize (bsize);
571
572 }
573
574 void
575 OSC_GUI::strips_changed ()
576 {
577         uint32_t st = striptypes_spin.get_value ();
578         cp.set_defaultstrip (st);
579 }
580
581 void
582 OSC_GUI::feedback_changed ()
583 {
584         uint32_t fb = feedback_spin.get_value ();
585         cp.set_defaultfeedback (fb);
586 }
587
588 void
589 OSC_GUI::gainmode_changed ()
590 {
591         std::string str = gainmode_combo.get_active_text ();
592         if (str == _("dB")) {
593                 cp.set_gainmode (0);
594         }
595         else if (str == _("Position")) {
596                 cp.set_gainmode (1);
597         }
598         else {
599                 std::cerr << "Invalid OSC Gain Mode\n";
600                 assert (0);
601         }
602 }
603
604 void
605 OSC_GUI::clear_device ()
606 {
607         cp.clear_devices();
608 }
609
610 void
611 OSC_GUI::calculate_feedback ()
612 {
613         fbvalue = 0;
614         if (strip_buttons_button.get_active()) {
615                 fbvalue += 1;
616         }
617         if (strip_control_button.get_active()) {
618                 fbvalue += 2;
619         }
620         if (ssid_as_path.get_active()) {
621                 fbvalue += 4;
622         }
623         if (heart_beat.get_active()) {
624                 fbvalue += 8;
625         }
626         if (master_fb.get_active()) {
627                 fbvalue += 16;
628         }
629         if (bar_and_beat.get_active()) {
630                 fbvalue += 32;
631         }
632         if (smpte.get_active()) {
633                 fbvalue += 64;
634         }
635         if (meter_float.get_active()) {
636                 fbvalue += 128;
637         }
638         if (meter_led.get_active()) {
639                 fbvalue += 256;
640         }
641         if (signal_present.get_active()) {
642                 fbvalue += 512;
643         }
644         if (hp_samples.get_active()) {
645                 fbvalue += 1024;
646         }
647         if (hp_min_sec.get_active()) {
648                 fbvalue += 2048;
649         }
650         if (hp_gui.get_active()) {
651                 fbvalue += 4096;
652         }
653         if (select_fb.get_active()) {
654                 fbvalue += 8192;
655         }
656
657         current_feedback.set_text(string_compose("%1", fbvalue));
658 }
659
660 void
661 OSC_GUI::push_feedback ()
662 {
663         feedback_spin.set_value (fbvalue);
664         feedback_changed ();
665 }
666
667 void
668 OSC_GUI::calculate_strip_types ()
669 {
670         stvalue = 0;
671         if (audio_tracks.get_active()) {
672                 stvalue += 1;
673         }
674         if (midi_tracks.get_active()) {
675                 stvalue += 2;
676         }
677         if (audio_buses.get_active()) {
678                 stvalue += 4;
679         }
680         if (midi_buses.get_active()) {
681                 stvalue += 8;
682         }
683         if (control_masters.get_active()) {
684                 stvalue += 16;
685         }
686         if (master_type.get_active()) {
687                 stvalue += 32;
688         }
689         if (monitor_type.get_active()) {
690                 stvalue += 64;
691         }
692         /*if (Auditioner_type.get_active()) {
693                 stvalue += 128; // this one has no user accessable controls
694         }*/
695         if (selected_tracks.get_active()) {
696                 stvalue += 256;
697         }
698         if (hidden_tracks.get_active()) {
699                 stvalue += 512;
700         }
701
702         current_strip_types.set_text(string_compose("%1", stvalue));
703 }
704
705 void
706 OSC_GUI::push_strip_types ()
707 {
708         striptypes_spin.set_value (stvalue);
709         strips_changed ();
710 }