Set knobs to old style again (still testing...)
[calf.git] / src / calf / gui_controls.h
blob5c553acb5ef313dc73ddd75f012b623ce5e38db9
1 /* Calf DSP Library
2 * Universal GUI module
3 * Copyright (C) 2007 Krzysztof Foltman
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
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 GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General
16 * Public License along with this program; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02111-1307, USA.
20 #ifndef __CALF_GUI_CONTROLS_H
21 #define __CALF_GUI_CONTROLS_H
23 #include "gui.h"
25 struct CalfCurve;
26 struct CalfKeyboard;
27 struct CalfLed;
29 namespace calf_plugins {
31 /////////////////////////////////////////////////////////////////////////////////////////////
32 // containers
34 struct table_container: public control_base
36 virtual GtkWidget *create(plugin_gui *_gui);
37 virtual void add(control_base *base);
40 struct alignment_container: public control_base
42 virtual GtkWidget *create(plugin_gui *_gui);
45 struct frame_container: public control_base
47 virtual GtkWidget *create(plugin_gui *_gui);
50 struct box_container: public control_base
52 virtual void add(control_base *base);
55 struct vbox_container: public box_container
57 virtual GtkWidget *create(plugin_gui *_gui);
60 struct hbox_container: public box_container
62 virtual GtkWidget *create(plugin_gui *_gui);
65 struct scrolled_container: public control_base
67 virtual void add(control_base *base);
68 virtual GtkWidget *create(plugin_gui *_gui);
71 ////////////////////////////////////////////////////////////////////////////////////////////////////
72 // controls
74 struct notebook_param_control: public param_control
76 int page;
77 virtual bool is_container() { return true; };
78 virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
79 virtual void created();
80 virtual void add(control_base *base);
81 virtual void get();
82 virtual void set();
83 static void notebook_page_changed(GtkWidget *widget, GtkWidget *page, guint id, gpointer user);
86 /// Display-only control: static text
87 struct label_param_control: public param_control
89 virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
90 virtual void get() {}
91 virtual void set() {}
94 /// Display-only control: value text
95 struct value_param_control: public param_control, public send_updates_iface
97 std::string old_value;
99 virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
100 virtual void get() {}
101 virtual void set();
102 virtual void send_status(const char *key, const char *value);
105 /// Display-only control: volume meter
106 struct vumeter_param_control: public param_control
108 virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
109 virtual void get() {}
110 virtual void set();
113 /// Display-only control: LED
114 struct led_param_control: public param_control
116 virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
117 virtual void get() {}
118 virtual void set();
121 /// Display-only control: tube
122 struct tube_param_control: public param_control
124 virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
125 virtual void get() {}
126 virtual void set();
129 /// Horizontal slider
130 struct hscale_param_control: public param_control
132 virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
133 virtual void get();
134 virtual void set();
135 static void hscale_value_changed(GtkHScale *widget, gpointer value);
136 static gchar *hscale_format_value(GtkScale *widget, double arg1, gpointer value);
139 /// Vertical slider
140 struct vscale_param_control: public param_control
142 virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
143 virtual void get();
144 virtual void set();
145 static void vscale_value_changed(GtkHScale *widget, gpointer value);
148 /// Spin button
149 struct spin_param_control: public param_control
151 virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
152 virtual void get();
153 virtual void set();
154 static void value_changed(GtkSpinButton *widget, gpointer value);
157 /// Check box (Markus Schmidt)
158 struct check_param_control: public param_control
160 virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
161 virtual void get();
162 virtual void set();
164 static void check_value_changed(GtkCheckButton *widget, gpointer value);
167 /// Toggle Button
168 struct toggle_param_control: public param_control
170 virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
171 virtual void get();
172 virtual void set();
174 static void toggle_value_changed(GtkWidget *widget, gpointer value);
177 /// Tap Button
178 struct tap_button_param_control: public param_control
180 guint last_time;
181 unsigned long init_time;
182 float avg_value, value;
183 virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
184 virtual void get();
185 virtual void set();
186 static gboolean tap_button_released(GtkWidget *widget, gpointer value);
187 static gboolean tap_button_pressed(GtkWidget *widget, GdkEventButton *event, gpointer value);
190 /// Radio button
191 struct radio_param_control: public param_control
193 int value;
195 virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
196 virtual void get();
197 virtual void set();
199 static void radio_clicked(GtkRadioButton *widget, gpointer value);
202 /// Push button
203 struct button_param_control: public param_control
205 virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
206 virtual void get();
207 virtual void set();
208 static void button_clicked(GtkButton *widget, gpointer value);
209 static void button_press_event(GtkButton *widget, GdkEvent *event, gpointer value);
212 /// Combo list box
213 struct combo_box_param_control: public param_control, public send_updates_iface
215 GtkListStore *lstore;
216 std::map<std::string, GtkTreeIter> key2pos;
217 std::string last_list;
218 std::string last_key;
219 bool populating;
221 virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
222 virtual void get();
223 virtual void set();
224 virtual void send_status(const char *key, const char *value);
225 void set_to_last_key();
226 static void combo_value_changed(GtkComboBox *widget, gpointer value);
229 /// Line graph
230 struct line_graph_param_control: public param_control
232 virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
233 virtual void get();
234 virtual void set();
235 static void freqhandle_value_changed(GtkWidget *widget, gpointer p);
236 virtual void on_idle();
237 virtual ~line_graph_param_control();
240 /// Phase graph
241 struct phase_graph_param_control: public param_control
243 virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
244 virtual void get() {}
245 virtual void set();
246 virtual void on_idle();
247 virtual ~phase_graph_param_control();
250 /// Knob
251 struct knob_param_control: public param_control
253 virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
254 virtual void get();
255 virtual void set();
256 static void knob_value_changed(GtkWidget *widget, gpointer value);
259 /// Static keyboard image
260 struct keyboard_param_control: public param_control
262 CalfKeyboard *kb;
264 virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
265 virtual void get() {}
266 virtual void set() {}
269 /// Curve editor
270 struct curve_param_control: public param_control, public send_configure_iface
272 CalfCurve *curve;
274 virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
275 virtual void get() {}
276 virtual void set() {}
277 virtual void send_configure(const char *key, const char *value);
280 /// Text entry
281 struct entry_param_control: public param_control, public send_configure_iface
283 GtkEntry *entry;
285 virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
286 virtual void get() {}
287 virtual void set() {}
288 virtual void send_configure(const char *key, const char *value);
289 static void entry_value_changed(GtkWidget *widget, gpointer value);
292 /// File chooser button
293 struct filechooser_param_control: public param_control, public send_configure_iface
295 GtkFileChooserButton *filechooser;
297 virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
298 virtual void get() {}
299 virtual void set() {}
300 virtual void send_configure(const char *key, const char *value);
301 static void filechooser_value_changed(GtkWidget *widget, gpointer value);
304 /// List view used for variable-length tabular data
305 struct listview_param_control: public param_control, public send_configure_iface
307 GtkTreeView *tree;
308 GtkListStore *lstore;
309 const calf_plugins::table_metadata_iface *tmif;
310 int cols;
311 std::vector<GtkTreeIter> positions;
313 virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
314 virtual void get() {}
315 virtual void set() {}
316 virtual void send_configure(const char *key, const char *value);
317 protected:
318 void set_rows(unsigned int needed_rows);
319 static void on_edited(GtkCellRenderer *renderer, gchar *path, gchar *new_text, listview_param_control *pThis);
320 static void on_editing_canceled(GtkCellRenderer *renderer, listview_param_control *pThis);
325 #endif