update ffmpeg to 4.1, add sketcher plugin, crikey tweaks, titler colorpicker, keyfram...
[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 SketcherPointList;
46 class SketcherNewPoint;
47 class SketcherDelPoint;
48 class SketcherPointUp;
49 class SketcherPointDn;
50 class SketcherResetCurves;
51 class SketcherResetPoints;
52 class SketcherWindow;
53
54 class SketcherNum : public BC_TumbleTextBox
55 {
56 public:
57         SketcherWindow *gui;
58
59         SketcherNum(SketcherWindow *gui, int x, int y, int output,
60                 int mn=-32767, int mx=32767);
61         ~SketcherNum();
62         int update(int v) { return BC_TumbleTextBox::update((int64_t)v); }
63 };
64
65 class SketcherCurveTypeItem : public BC_MenuItem
66 {
67 public:
68         SketcherCurveTypeItem(int ty);
69         int handle_event();
70         int ty;
71 };
72
73 class SketcherCurveType : public BC_PopupMenu
74 {
75 public:
76         SketcherCurveType(SketcherWindow *gui, int x, int y, int ty);
77         void create_objects();
78         void update(int ty);
79
80         SketcherWindow *gui;
81 };
82
83 class SketcherCurvePenItem : public BC_MenuItem
84 {
85 public:
86         SketcherCurvePenItem(int pen);
87         int handle_event();
88         int pen;
89 };
90
91 class SketcherCurvePen : public BC_PopupMenu
92 {
93 public:
94         SketcherCurvePen(SketcherWindow *gui, int x, int y, int pen);
95         void create_objects();
96         void update(int ty);
97
98         SketcherWindow *gui;
99 };
100
101 class SketcherCurveColor : public BC_Button
102 {
103 public:
104         SketcherCurveColor(SketcherWindow *gui, int x, int y, int w);
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 SketcherCurveRadius : public SketcherNum
194 {
195 public:
196         SketcherCurveRadius(SketcherWindow *gui, int x, int y, float output)
197          : SketcherNum(gui, x, y, output, 0, 255) {}
198         ~SketcherCurveRadius() {}
199
200         int handle_event();
201 };
202
203 class SketcherCurveList : public BC_ListBox
204 {
205 public:
206         SketcherCurveList(SketcherWindow *gui, Sketcher *plugin, int x, int y);
207         ~SketcherCurveList();
208
209         int handle_event();
210         int selection_changed();
211         int column_resize_event();
212         ArrayList<BC_ListBoxItem*> cols[CV_SZ];
213         void clear();
214         void add_curve(const char *id, const char *type,
215                 const char *radius, const char *pen, const char *color);
216         void del_curve(int i);
217         void set_selected(int k);
218         void update(int k);
219         void update_list(int k);
220
221         SketcherWindow *gui;
222         Sketcher *plugin;
223         const char *titles[CV_SZ];
224         int widths[CV_SZ];
225 };
226
227
228 class SketcherPointX : public SketcherNum
229 {
230 public:
231         SketcherPointX(SketcherWindow *gui, int x, int y, float output)
232          : SketcherNum(gui, x, y, output) {}
233         ~SketcherPointX() {}
234
235         int handle_event();
236 };
237 class SketcherPointY : public SketcherNum
238 {
239 public:
240         SketcherPointY(SketcherWindow *gui, int x, int y, float output)
241          : SketcherNum(gui, x, y, output) {}
242         ~SketcherPointY() {}
243
244         int handle_event();
245 };
246
247
248 class SketcherDrag : public BC_CheckBox
249 {
250 public:
251         SketcherDrag(SketcherWindow *gui, int x, int y);
252
253         int handle_event();
254         SketcherWindow *gui;
255 };
256
257
258 class SketcherPointList : public BC_ListBox
259 {
260 public:
261         SketcherPointList(SketcherWindow *gui, Sketcher *plugin, int x, int y);
262         ~SketcherPointList();
263
264         int handle_event();
265         int selection_changed();
266         int column_resize_event();
267         ArrayList<BC_ListBoxItem*> cols[PT_SZ];
268         void clear();
269         void add_point(const char *id, const char *xp, const char *yp);
270         void set_point(int i, int c, int v);
271         void set_point(int i, int c, const char *cp);
272         void set_selected(int k);
273         void update(int k);
274         void update_list(int k);
275
276
277         SketcherWindow *gui;
278         Sketcher *plugin;
279         const char *titles[PT_SZ];
280         int widths[PT_SZ];
281 };
282
283 class SketcherNewPoint : public BC_GenericButton
284 {
285 public:
286         SketcherNewPoint(SketcherWindow *gui, Sketcher *plugin, int x, int y);
287         ~SketcherNewPoint();
288
289         int handle_event();
290
291         SketcherWindow *gui;
292         Sketcher *plugin;
293 };
294
295 class SketcherDelPoint : public BC_GenericButton
296 {
297 public:
298         SketcherDelPoint(SketcherWindow *gui, Sketcher *plugin, int x, int y);
299         ~SketcherDelPoint();
300
301         int handle_event();
302
303         Sketcher *plugin;
304         SketcherWindow *gui;
305 };
306
307 class SketcherPointUp : public BC_GenericButton
308 {
309 public:
310         SketcherPointUp(SketcherWindow *gui, int x, int y);
311         ~SketcherPointUp();
312
313         int handle_event();
314
315         SketcherWindow *gui;
316 };
317
318 class SketcherPointDn : public BC_GenericButton
319 {
320 public:
321         SketcherPointDn(SketcherWindow *gui, int x, int y);
322         ~SketcherPointDn();
323
324         int handle_event();
325
326         SketcherWindow *gui;
327 };
328
329 class SketcherResetCurves : public BC_GenericButton
330 {
331 public:
332         SketcherResetCurves(SketcherWindow *gui, Sketcher *plugin, int x, int y);
333         ~SketcherResetCurves();
334
335         int handle_event();
336
337         Sketcher *plugin;
338         SketcherWindow *gui;
339 };
340
341 class SketcherResetPoints : public BC_GenericButton
342 {
343 public:
344         SketcherResetPoints(SketcherWindow *gui, Sketcher *plugin, int x, int y);
345         ~SketcherResetPoints();
346
347         int handle_event();
348
349         Sketcher *plugin;
350         SketcherWindow *gui;
351 };
352
353
354 class SketcherWindow : public PluginClientWindow
355 {
356 public:
357         SketcherWindow(Sketcher *plugin);
358         ~SketcherWindow();
359
360         void create_objects();
361         void update_gui();
362         void start_color_thread(SketcherCurveColor *curve_color);
363         int grab_event(XEvent *event);
364         int do_grab_event(XEvent *event);
365         void done_event(int result);
366         void send_configure_change();
367         int keypress_event();
368
369         Sketcher *plugin;
370
371         BC_Title *title_type, *title_pen;
372         BC_Title *title_color, *title_radius;
373         SketcherCurveType *curve_type;
374         SketcherCurvePen *curve_pen;
375         SketcherCurveColor *curve_color;
376         SketcherCurveColorPicker *color_picker;
377         SketcherNewCurve *new_curve;
378         SketcherDelCurve *del_curve;
379         SketcherCurveUp *curve_up;
380         SketcherCurveDn *curve_dn;
381         SketcherCurveRadius *curve_radius;
382         SketcherCurveList *curve_list;
383         SketcherResetCurves *reset_curves;
384
385         BC_Title *title_x, *title_y;
386         SketcherPointX *point_x;
387         SketcherPointY *point_y;
388         SketcherNewPoint *new_point;
389         SketcherDelPoint *del_point;
390         SketcherPointUp *point_up;
391         SketcherPointDn *point_dn;
392         int dragging, pending_config;
393         int new_points;
394         float last_x, last_y;
395         SketcherDrag *drag;
396         SketcherPointList *point_list;
397         SketcherResetPoints *reset_points;
398         BC_Title *notes0, *notes1, *notes2;
399 };
400 #endif
401