1 /*
2  * Copyright (C) 2016-2017 Len Ovens <len@ovenwerks.net>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 #ifndef osc_gui_h
19 #define osc_gui_h
20 
21 
22 #include "osc.h"
23 
24 #include "pbd/i18n.h"
25 
26 // preset stuff
27 static const char* const preset_dir_name = "osc";
28 static const char* const preset_suffix = ".preset";
29 static const char * const preset_env_variable_name = "ARDOUR_OSC_PATH";
30 
31 namespace ArdourSurface {
32 
33 class OSC_GUI : public Gtk::Notebook
34 {
35 public:
36 	OSC_GUI (OSC&);
37 	~OSC_GUI ();
38 
39 
40 private:
41 	// settings page
42 	Gtk::ComboBoxText debug_combo;
43 	Gtk::ComboBoxText portmode_combo;
44 	Gtk::SpinButton port_entry;
45 	Gtk::SpinButton bank_entry;
46 	Gtk::SpinButton send_page_entry;
47 	Gtk::SpinButton plugin_page_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_send;
59 	uint32_t sesn_plugin;
60 	uint32_t sesn_strips;
61 	uint32_t sesn_feedback;
62 	uint32_t sesn_gainmode;
63 	void save_user ();
64 	void scan_preset_files ();
65 	void load_preset (std::string preset);
66 
67 	void debug_changed ();
68 	void portmode_changed ();
69 	void gainmode_changed ();
70 	void clear_device ();
71 	void factory_reset ();
72 	void reshow_values ();
73 	void port_changed ();
74 	bool port_focus_out (GdkEventFocus*);
75 	void bank_changed ();
76 	void send_page_changed ();
77 	void plugin_page_changed ();
78 	void strips_changed ();
79 	void feedback_changed ();
80 	void preset_changed ();
81 	// Strip types calculator
82 	uint32_t def_strip;
83 	void calculate_strip_types ();
84 	Gtk::Label current_strip_types;
85 	Gtk::CheckButton audio_tracks;
86 	Gtk::CheckButton midi_tracks;
87 	Gtk::CheckButton audio_buses;
88 	Gtk::CheckButton foldback_busses;
89 	Gtk::CheckButton midi_buses;
90 	Gtk::CheckButton control_masters;
91 	Gtk::CheckButton master_type;
92 	Gtk::CheckButton monitor_type;
93 	Gtk::CheckButton selected_tracks;
94 	Gtk::CheckButton hidden_tracks;
95 	Gtk::CheckButton usegroups;
96 	int stvalue;
97 	// feedback calculator
98 	uint32_t def_feedback;
99 	void calculate_feedback ();
100 	Gtk::Label current_feedback;
101 	Gtk::CheckButton strip_buttons_button;
102 	Gtk::CheckButton strip_control_button;
103 	Gtk::CheckButton ssid_as_path;
104 	Gtk::CheckButton heart_beat;
105 	Gtk::CheckButton master_fb;
106 	Gtk::CheckButton bar_and_beat;
107 	Gtk::CheckButton smpte;
108 	Gtk::CheckButton meter_float;
109 	Gtk::CheckButton meter_led;
110 	Gtk::CheckButton signal_present;
111 	Gtk::CheckButton hp_samples;
112 	Gtk::CheckButton hp_min_sec;
113 	Gtk::CheckButton hp_gui;
114 	Gtk::CheckButton select_fb;
115 	Gtk::CheckButton use_osc10;
116 	int fbvalue;
117 	void set_bitsets ();
118 
119 
120 
121 	OSC& cp;
122 };
123 
124 
125 void*
get_gui()126 OSC::get_gui () const
127 {
128 	if (!gui) {
129 		const_cast<OSC*>(this)->build_gui ();
130 	}
131 	static_cast<Gtk::Notebook*>(gui)->show_all();
132 	return gui;
133 }
134 
135 void
tear_down_gui()136 OSC::tear_down_gui ()
137 {
138 	if (gui) {
139 		Gtk::Widget *w = static_cast<Gtk::Notebook*>(gui)->get_parent();
140 		if (w) {
141 			w->hide();
142 			delete w;
143 		}
144 	}
145 	delete (OSC_GUI*) gui;
146 	gui = 0;
147 }
148 
149 void
build_gui()150 OSC::build_gui ()
151 {
152 	gui = (void*) new OSC_GUI (*this);
153 }
154 
155 } // end namespace
156 
157 #endif // osc_gui_h
158