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