missing commit in generator.h
[galan.git] / include / control.h
blob510211075b1f00e63820c35800a86ff283c16631
1 /* gAlan - Graphical Audio Language
2 * Copyright (C) 1999 Tony Garnock-Jones
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.
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.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef Control_H
20 #define Control_H
23 Controls we want to play with:
25 - sliders
26 - knobs
27 - togglebuttons
28 - buttons
29 - arbitrary others
32 typedef enum ControlKind ControlKind;
33 /* moved typedef of ControlDescriptor to generator.h */
34 /* moved typedef of Control to generator.h */
36 enum ControlKind {
37 CONTROL_KIND_NONE = 0, /* used to terminate lists of ControlDescriptors */
38 CONTROL_KIND_SLIDER,
39 CONTROL_KIND_KNOB,
40 CONTROL_KIND_TOGGLE,
41 CONTROL_KIND_BUTTON,
42 CONTROL_KIND_USERDEF,
43 CONTROL_KIND_PANEL,
45 CONTROL_MAX_KIND
48 typedef void (* ControlMove_cb)(struct Control *);
51 enum ControlPanelBackgroundType {
52 CONTROL_PANEL_BG_DEFAULT,
53 CONTROL_PANEL_BG_IMAGE,
54 CONTROL_PANEL_BG_COLOR,
55 CONTROL_PANEL_BG_GRADIENT
58 struct ControlPanel {
59 GtkWidget *scrollwin, *fixedwidget;
60 char *name;
61 gboolean visible;
62 struct sheet *sheet;
63 int w,h;
64 GtkWidget *sizer_ebox, *sizer_image;
66 int sizer_x, sizer_y;
67 int sizer_saved_x, sizer_saved_y;
68 int sizer_moving;
69 int sizer_visible;
72 // background rendering...
73 //char *current_bg;
75 enum ControlPanelBackgroundType bg_type;
76 GdkColor color1;
77 GdkColor color2;
78 GdkColor frame_color;
79 guint16 frame_alpha;
81 char *bg_image_name;
84 struct ControlDescriptor {
85 ControlKind kind; /* kind of control */
86 const char *name; /* default control name */
87 gdouble min, max, step, page; /* for sliders and knobs */
88 int size; /* vertical size; optional; only for sliders - 0 =>deflt */
89 gboolean allow_direct_edit; /* put in a GtkEntry? - only for sliders, knobs */
90 gboolean is_dst_gen; /* true if g is a target, false if g is a source */
91 int queue_number; /* which output event queue to send from, if gen is a
92 src gen, or event queue to send to, if gen is a
93 dst gen. */
95 void (*initialize)(Control *control);
96 void (*destroy)(Control *control);
98 void (*refresh)(Control *control);
99 gpointer refresh_data;
102 struct Control {
103 int refcnt;
104 ControlDescriptor *desc;
105 ControlPanel *panel;
106 char *name; /* overriding name. Set to NULL to use default. */
107 int testbg_active;
108 gdouble min, max, step, page; /* overrides desc's values */
110 gboolean frame_visible;
111 gboolean name_visible;
112 gboolean entry_visible;
113 gboolean control_visible;
115 int moving, saved_x, saved_y; /* variables to implement drag-moving of controls */
116 int x, y; /* position within control window */
117 gboolean events_flow; /* TRUE => sends AEvents, FALSE => is silent */
118 gboolean kill_me; /* there is a race in the control deletion with the update thread.
119 to delete a control remove it from the generator, and set kill_me,
120 the call control_update on it. */
121 int update_refcount;
123 GtkWidget *widget; /* the control itself */
124 GtkWidget *whole; /* the control embedded in some wrapping */
125 GtkWidget *title_frame; /* the frame displaying the whole control */
126 GtkWidget *title_label; /* the label displaying the name */
127 GtkWidget *entry; /* The Text field */
129 GtkWidget *ebox; /* An Eventbox for speed */
131 ControlPanel *this_panel;
132 ControlMove_cb move_callback;
133 Generator *g; /* source for output events; owner of control _OR_
134 target of output events; also owner of control?? */
135 void *data; /* user data (mostly for userdef'd controls) */
138 extern GtkWidget *control_panel;
140 extern Control *control_new_control(ControlDescriptor *desc, Generator *g, ControlPanel *panel );
141 extern void control_kill_control(Control *c, gboolean lock_taken);
143 extern void control_ref( Control *c );
144 extern void control_unref( Control *c );
146 extern Control *control_unpickle(ObjectStoreItem *item);
147 extern ObjectStoreItem *control_pickle(Control *c, ObjectStore *db);
149 extern void control_emit(Control *c, gdouble number);
150 extern void control_update_names(Control *c);
151 extern void control_update_range(Control *c);
152 extern void control_update_value(Control *c);
153 extern void control_set_value(Control *c, gfloat value);
154 extern void control_moveto(Control *c, int x, int y);
155 extern void control_update_bg(Control *c);
157 extern void init_control(void);
158 extern void init_control_thread(void);
159 extern Control *control_clone( Control *c, Generator *g, ControlPanel *cp );
161 extern void show_control_panel(void);
162 extern void hide_control_panel(void);
163 extern void reset_control_panel(void);
165 extern ControlPanel *control_panel_new( char *name, gboolean visible, struct sheet *sheet );
166 extern void control_panel_register_panel( ControlPanel *panel, char *name, gboolean add_fixed );
167 extern void control_panel_unregister_panel( ControlPanel *panel );
168 extern void update_panel_name( ControlPanel *panel );
169 extern ControlPanel *control_panel_unpickle(ObjectStoreItem *item);
170 extern ObjectStoreItem *control_panel_pickle(ControlPanel *cp, ObjectStore *db);
172 /* these functions can go into ControlDescriptor.refresh (with a suitable refresh_data) */
173 extern void control_int32_updater(Control *c);
174 extern void control_double_updater(Control *c);
176 #endif