Button: emit slopes (fix for stuck modulaor plug-ins)
[calf.git] / src / calf / gui_controls.h
blobcbdc8da4c2394f5b174ce1fbfa241e500bae2bfe
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_container
36 virtual GtkWidget *create(plugin_gui *_gui, const char *element, xml_attribute_map &attributes);
37 virtual void add(GtkWidget *w, control_base *base);
40 struct alignment_container: public control_container
42 virtual GtkWidget *create(plugin_gui *_gui, const char *element, xml_attribute_map &attributes);
45 struct frame_container: public control_container
47 virtual GtkWidget *create(plugin_gui *_gui, const char *element, xml_attribute_map &attributes);
50 struct box_container: public control_container
52 virtual void add(GtkWidget *w, control_base *base);
55 struct vbox_container: public box_container
57 virtual GtkWidget *create(plugin_gui *_gui, const char *element, xml_attribute_map &attributes);
60 struct hbox_container: public box_container
62 virtual GtkWidget *create(plugin_gui *_gui, const char *element, xml_attribute_map &attributes);
65 struct scrolled_container: public control_container
67 virtual void add(GtkWidget *w, control_base *base);
68 virtual GtkWidget *create(plugin_gui *_gui, const char *element, xml_attribute_map &attributes);
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(GtkWidget *w, 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 virtual void init_xml(const char *element);
136 static void hscale_value_changed(GtkHScale *widget, gpointer value);
137 static gchar *hscale_format_value(GtkScale *widget, double arg1, gpointer value);
140 /// Vertical slider
141 struct vscale_param_control: public param_control
143 virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
144 virtual void get();
145 virtual void set();
146 virtual void init_xml(const char *element);
147 static void vscale_value_changed(GtkHScale *widget, gpointer value);
150 /// Spin button
151 struct spin_param_control: public param_control
153 virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
154 virtual void get();
155 virtual void set();
156 static void value_changed(GtkSpinButton *widget, gpointer value);
159 /// Check box (Markus Schmidt)
160 struct check_param_control: public param_control
162 virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
163 virtual void get();
164 virtual void set();
166 static void check_value_changed(GtkCheckButton *widget, gpointer value);
169 /// Toggle Button
170 struct toggle_param_control: public param_control
172 virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
173 virtual void get();
174 virtual void set();
176 static void toggle_value_changed(GtkWidget *widget, gpointer value);
179 /// Tap Button
180 struct tap_button_param_control: public param_control
182 guint last_time;
183 unsigned long init_time;
184 float avg_value, value;
185 virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
186 virtual void get();
187 virtual void set();
188 static gboolean tap_button_released(GtkWidget *widget, gpointer value);
189 static gboolean tap_button_pressed(GtkWidget *widget, GdkEventButton *event, gpointer value);
192 /// Radio button
193 struct radio_param_control: public param_control
195 int value;
197 virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
198 virtual void get();
199 virtual void set();
201 static void radio_clicked(GtkRadioButton *widget, gpointer value);
204 /// Push button
205 struct button_param_control: public param_control
207 virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
208 virtual void get();
209 virtual void set();
210 static void button_clicked(GtkButton *widget, gpointer value);
211 static void button_press_event(GtkButton *widget, GdkEvent *event, gpointer value);
214 /// Combo list box
215 struct combo_box_param_control: public param_control, public send_updates_iface
217 GtkListStore *lstore;
218 std::map<std::string, GtkTreeIter> key2pos;
219 std::string last_key;
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