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