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