35e7e898346ef6feb712722d4a7bea4c8aee20ca
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / sketcher / sketcherwindow.h
1 /*
2  * CINELERRA
3  * Copyright (C) 2008-2015 Adam Williams <broadcast at earthling dot net>
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  *
19  */
20
21 #ifndef __CRIKEYWINDOW_H__
22 #define __CRIKEYWINDOW_H__
23
24 #include "guicast.h"
25 #include "colorpicker.h"
26
27 class Sketcher;
28 class SketcherNum;
29 class SketcherCurveTypeItem;
30 class SketcherCurveType;
31 class SketcherCurvePenItem;
32 class SketcherCurvePen;
33 class SketcherCurveColor;
34 class SketcherCurveColorPicker;
35 class SketcherCurveColorThread;
36 class SketcherNewCurve;
37 class SketcherDelCurve;
38 class SketcherCurveUp;
39 class SketcherCurveDn;
40 class SketcherCurveRadius;
41 class SketcherCurveList;
42 class SketcherPointX;
43 class SketcherPointY;
44 class SketcherDrag;
45 class SketcherPointTypeItem;
46 class SketcherPointType;
47 class SketcherPointList;
48 class SketcherNewPoint;
49 class SketcherDelPoint;
50 class SketcherPointUp;
51 class SketcherPointDn;
52 class SketcherResetCurves;
53 class SketcherResetPoints;
54 class SketcherWindow;
55
56
57 class SketcherNum : public BC_TumbleTextBox
58 {
59 public:
60         SketcherWindow *gui;
61
62         SketcherNum(SketcherWindow *gui, int x, int y, int output,
63                 int mn=-32767, int mx=32767);
64         ~SketcherNum();
65         int update(int v) { return BC_TumbleTextBox::update((int64_t)v); }
66 };
67
68 class SketcherCurvePenItem : public BC_MenuItem
69 {
70 public:
71         SketcherCurvePenItem(int pen);
72         int handle_event();
73         int pen;
74 };
75
76 class SketcherCurvePen : public BC_PopupMenu
77 {
78 public:
79         SketcherCurvePen(SketcherWindow *gui, int x, int y, int pen);
80         void create_objects();
81         void update(int pen);
82
83         SketcherWindow *gui;
84 };
85
86 class SketcherCurveColor : public BC_Button
87 {
88 public:
89         SketcherCurveColor(SketcherWindow *gui, int x, int y, int w, int h);
90         ~SketcherCurveColor();
91
92         void set_color(int color);
93         void update_gui(int color);
94         int handle_event();
95
96         int color;
97         VFrame *vframes[3];
98         SketcherWindow *gui;
99 };
100
101 class SketcherCurveColorPicker : public ColorPicker
102 {
103 public:
104         SketcherCurveColorPicker(SketcherWindow *gui, SketcherCurveColor *curve_color);
105         ~SketcherCurveColorPicker();
106         void start(int color);
107         int handle_new_color(int color, int alpha);
108         void update_gui();
109         void handle_done_event(int result);
110
111         SketcherWindow *gui;
112         int color;
113         SketcherCurveColor *color_button;
114         SketcherCurveColorThread *color_update;
115 };
116
117 class SketcherCurveColorThread : public Thread
118 {
119 public:
120         SketcherCurveColorThread(SketcherCurveColorPicker *color_picker);
121         ~SketcherCurveColorThread();
122
123         void start();
124         void stop();
125         void run();
126
127         SketcherCurveColorPicker *color_picker;
128         int done;
129         Condition *update_lock;
130 };
131
132 class SketcherNewCurve : public BC_GenericButton
133 {
134 public:
135         SketcherNewCurve(SketcherWindow *gui, Sketcher *plugin, int x, int y);
136         ~SketcherNewCurve();
137
138         int handle_event();
139
140         SketcherWindow *gui;
141         Sketcher *plugin;
142 };
143
144 class SketcherDelCurve : public BC_GenericButton
145 {
146 public:
147         SketcherDelCurve(SketcherWindow *gui, Sketcher *plugin, int x, int y);
148         ~SketcherDelCurve();
149
150         int handle_event();
151
152         Sketcher *plugin;
153         SketcherWindow *gui;
154 };
155
156 class SketcherCurveUp : public BC_GenericButton
157 {
158 public:
159         SketcherCurveUp(SketcherWindow *gui, int x, int y);
160         ~SketcherCurveUp();
161
162         int handle_event();
163
164         SketcherWindow *gui;
165 };
166
167 class SketcherCurveDn : public BC_GenericButton
168 {
169 public:
170         SketcherCurveDn(SketcherWindow *gui, int x, int y);
171         ~SketcherCurveDn();
172
173         int handle_event();
174
175         SketcherWindow *gui;
176 };
177
178 class SketcherCurveRadius : public SketcherNum
179 {
180 public:
181         SketcherCurveRadius(SketcherWindow *gui, int x, int y, float output)
182          : SketcherNum(gui, x, y, output, 0, 255) {}
183         ~SketcherCurveRadius() {}
184
185         int handle_event();
186 };
187
188 class SketcherCurveList : public BC_ListBox
189 {
190 public:
191         SketcherCurveList(SketcherWindow *gui, Sketcher *plugin, int x, int y);
192         ~SketcherCurveList();
193
194         int handle_event();
195         int selection_changed();
196         int column_resize_event();
197         ArrayList<BC_ListBoxItem*> cols[CV_SZ];
198         void clear();
199         void add_curve(const char *id, const char *pen,
200                 const char *radius, const char *color);
201         void del_curve(int i);
202         void set_curve(int i, int c, const char *cp);
203         void set_selected(int k);
204         void update(int k);
205         void update_list(int k);
206
207         SketcherWindow *gui;
208         Sketcher *plugin;
209         const char *titles[CV_SZ];
210         int widths[CV_SZ];
211 };
212
213
214 class SketcherPointX : public SketcherNum
215 {
216 public:
217         SketcherPointX(SketcherWindow *gui, int x, int y, float output)
218          : SketcherNum(gui, x, y, output) {}
219         ~SketcherPointX() {}
220
221         int handle_event();
222 };
223 class SketcherPointY : public SketcherNum
224 {
225 public:
226         SketcherPointY(SketcherWindow *gui, int x, int y, float output)
227          : SketcherNum(gui, x, y, output) {}
228         ~SketcherPointY() {}
229
230         int handle_event();
231 };
232
233
234 class SketcherDrag : public BC_CheckBox
235 {
236 public:
237         SketcherDrag(SketcherWindow *gui, int x, int y);
238
239         int handle_event();
240         SketcherWindow *gui;
241 };
242
243 class SketcherPointTypeItem : public BC_MenuItem
244 {
245 public:
246         SketcherPointTypeItem(int pty);
247         int handle_event();
248         int pty;
249 };
250
251 class SketcherPointType : public BC_PopupMenu
252 {
253 public:
254         SketcherPointType(SketcherWindow *gui, int x, int y, int pty);
255         void create_objects();
256         void update(int pty);
257
258         SketcherWindow *gui;
259 };
260
261
262 class SketcherPointList : public BC_ListBox
263 {
264 public:
265         SketcherPointList(SketcherWindow *gui, Sketcher *plugin, int x, int y);
266         ~SketcherPointList();
267
268         int handle_event();
269         int selection_changed();
270         int column_resize_event();
271         ArrayList<BC_ListBoxItem*> cols[PT_SZ];
272         void clear();
273         void add_point(const char *id, const char *ty, const char *xp, const char *yp);
274         void set_point(int i, int c, int v);
275         void set_point(int i, int c, const char *cp);
276         void set_selected(int k);
277         void update(int k);
278         void update_list(int k);
279
280
281         SketcherWindow *gui;
282         Sketcher *plugin;
283         const char *titles[PT_SZ];
284         int widths[PT_SZ];
285 };
286
287 class SketcherNewPoint : public BC_GenericButton
288 {
289 public:
290         SketcherNewPoint(SketcherWindow *gui, Sketcher *plugin, int x, int y);
291         ~SketcherNewPoint();
292
293         int handle_event();
294
295         SketcherWindow *gui;
296         Sketcher *plugin;
297 };
298
299 class SketcherDelPoint : public BC_GenericButton
300 {
301 public:
302         SketcherDelPoint(SketcherWindow *gui, Sketcher *plugin, int x, int y);
303         ~SketcherDelPoint();
304
305         int handle_event();
306
307         Sketcher *plugin;
308         SketcherWindow *gui;
309 };
310
311 class SketcherPointUp : public BC_GenericButton
312 {
313 public:
314         SketcherPointUp(SketcherWindow *gui, int x, int y);
315         ~SketcherPointUp();
316
317         int handle_event();
318
319         SketcherWindow *gui;
320 };
321
322 class SketcherPointDn : public BC_GenericButton
323 {
324 public:
325         SketcherPointDn(SketcherWindow *gui, int x, int y);
326         ~SketcherPointDn();
327
328         int handle_event();
329
330         SketcherWindow *gui;
331 };
332
333 class SketcherResetCurves : public BC_GenericButton
334 {
335 public:
336         SketcherResetCurves(SketcherWindow *gui, Sketcher *plugin, int x, int y);
337         ~SketcherResetCurves();
338
339         int handle_event();
340
341         Sketcher *plugin;
342         SketcherWindow *gui;
343 };
344
345 class SketcherResetPoints : public BC_GenericButton
346 {
347 public:
348         SketcherResetPoints(SketcherWindow *gui, Sketcher *plugin, int x, int y);
349         ~SketcherResetPoints();
350
351         int handle_event();
352
353         Sketcher *plugin;
354         SketcherWindow *gui;
355 };
356
357
358 class SketcherWindow : public PluginClientWindow
359 {
360 public:
361         SketcherWindow(Sketcher *plugin);
362         ~SketcherWindow();
363
364         void create_objects();
365         void update_gui();
366         void start_color_thread(SketcherCurveColor *curve_color);
367         int grab_event(XEvent *event);
368         int do_grab_event(XEvent *event);
369         void done_event(int result);
370         void send_configure_change();
371         int keypress_event();
372
373         Sketcher *plugin;
374
375         BC_Title *title_pen, *title_color, *title_radius;
376         SketcherCurveType *curve_type;
377         SketcherCurvePen *curve_pen;
378         SketcherCurveColor *curve_color;
379         SketcherCurveColorPicker *color_picker;
380         SketcherNewCurve *new_curve;
381         SketcherDelCurve *del_curve;
382         SketcherCurveUp *curve_up;
383         SketcherCurveDn *curve_dn;
384         SketcherCurveRadius *curve_radius;
385         SketcherCurveList *curve_list;
386         SketcherResetCurves *reset_curves;
387
388         SketcherResetPoints *reset_points;
389         SketcherDrag *drag;
390         SketcherPointType *point_type;
391         SketcherPointList *point_list;
392         BC_Title *title_x, *title_y;
393         SketcherPointX *point_x;
394         SketcherPointY *point_y;
395         SketcherNewPoint *new_point;
396         SketcherDelPoint *del_point;
397         SketcherPointUp *point_up;
398         SketcherPointDn *point_dn;
399         int dragging, pending_config;
400         int new_points;
401         float last_x, last_y;
402         BC_Title *notes0, *notes1, *notes2;
403 };
404 #endif
405