OSC: Add preset loading to OSC GUI
[ardour.git] / libs / surfaces / osc / osc_gui.h
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 #ifndef osc_gui_h
21 #define osc_gui_h
22
23
24 #include "osc.h"
25
26 #include "pbd/i18n.h"
27
28 // preset stuff
29 static const char* const preset_dir_name = "osc";
30 static const char* const preset_suffix = ".preset";
31 static const char * const preset_env_variable_name = "ARDOUR_OSC_PATH";
32
33 namespace ArdourSurface {
34
35 class OSC_GUI : public Gtk::Notebook
36 {
37 public:
38         OSC_GUI (OSC&);
39         ~OSC_GUI ();
40
41
42 private:
43         // settings page
44         Gtk::ComboBoxText debug_combo;
45         Gtk::ComboBoxText portmode_combo;
46         Gtk::SpinButton port_entry;
47         Gtk::SpinButton bank_entry;
48         Gtk::ComboBoxText gainmode_combo;
49         Gtk::ComboBoxText preset_combo;
50         std::vector<std::string> preset_options;
51         std::map<std::string,std::string> preset_files;
52         bool preset_busy;
53         void get_session ();
54         void restore_sesn_values ();
55         uint32_t sesn_portmode;
56         std::string sesn_port;
57         uint32_t sesn_bank;
58         uint32_t sesn_strips;
59         uint32_t sesn_feedback;
60         uint32_t sesn_gainmode;
61         void save_user ();
62         void scan_preset_files ();
63         void load_preset (std::string preset);
64
65         void debug_changed ();
66         void portmode_changed ();
67         void gainmode_changed ();
68         void clear_device ();
69         void factory_reset ();
70         void reshow_values ();
71         void port_changed ();
72         void bank_changed ();
73         void strips_changed ();
74         void feedback_changed ();
75         void preset_changed ();
76         // Strip types calculator
77         uint32_t def_strip;
78         void calculate_strip_types ();
79         void push_strip_types ();
80         Gtk::Label current_strip_types;
81         Gtk::CheckButton audio_tracks;
82         Gtk::CheckButton midi_tracks;
83         Gtk::CheckButton audio_buses;
84         Gtk::CheckButton midi_buses;
85         Gtk::CheckButton control_masters;
86         Gtk::CheckButton master_type;
87         Gtk::CheckButton monitor_type;
88         Gtk::CheckButton selected_tracks;
89         Gtk::CheckButton hidden_tracks;
90         int stvalue;
91         // feedback calculator
92         uint32_t def_feedback;
93         void calculate_feedback ();
94         void push_feedback ();
95         Gtk::Label current_feedback;
96         Gtk::CheckButton strip_buttons_button;
97         Gtk::CheckButton strip_control_button;
98         Gtk::CheckButton ssid_as_path;
99         Gtk::CheckButton heart_beat;
100         Gtk::CheckButton master_fb;
101         Gtk::CheckButton bar_and_beat;
102         Gtk::CheckButton smpte;
103         Gtk::CheckButton meter_float;
104         Gtk::CheckButton meter_led;
105         Gtk::CheckButton signal_present;
106         Gtk::CheckButton hp_samples;
107         Gtk::CheckButton hp_min_sec;
108         Gtk::CheckButton hp_gui;
109         Gtk::CheckButton select_fb;
110         int fbvalue;
111         void set_bitsets ();
112
113
114
115         OSC& cp;
116 };
117
118
119 void*
120 OSC::get_gui () const
121 {
122         if (!gui) {
123                 const_cast<OSC*>(this)->build_gui ();
124         }
125         //static_cast<Gtk::VBox*>(gui)->show_all();
126         static_cast<Gtk::Notebook*>(gui)->show_all();
127         return gui;
128 }
129
130 void
131 OSC::tear_down_gui ()
132 {
133         if (gui) {
134                 Gtk::Widget *w = static_cast<Gtk::Notebook*>(gui)->get_parent();
135                 if (w) {
136                         w->hide();
137                         delete w;
138                 }
139         }
140         delete (OSC_GUI*) gui;
141         gui = 0;
142 }
143
144 void
145 OSC::build_gui ()
146 {
147         gui = (void*) new OSC_GUI (*this);
148 }
149
150 } // end namespace
151
152 #endif // osc_gui_h