opengl upgrade to 4.3 for masks, mask function/layout rework, make_shader rework
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / cwindowtool.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #ifndef CWINDOWTOOL_H
23 #define CWINDOWTOOL_H
24
25 #include "condition.inc"
26 #include "cwindowgui.inc"
27 #include "cwindowtool.inc"
28 #include "guicast.h"
29 #include "keyframe.inc"
30 #include "maskauto.inc"
31 #include "maskautos.inc"
32 #include "mwindow.inc"
33
34
35 // This common thread supports all the tool GUI's.
36 class CWindowTool : public Thread
37 {
38 public:
39         CWindowTool(MWindow *mwindow, CWindowGUI *gui);
40         ~CWindowTool();
41
42 // Called depending on state of toggle button
43         void start_tool(int operation);
44         void stop_tool();
45
46 // Called when window is visible
47         void show_tool();
48         void hide_tool();
49
50         void run();
51         void update_show_window();
52         void raise_window();
53         void update_values();
54
55         MWindow *mwindow;
56         CWindowGUI *gui;
57         CWindowToolGUI *tool_gui;
58         int done;
59         int current_tool;
60         Condition *input_lock;
61         Condition *output_lock;
62 // Lock run and update_values
63         Mutex *tool_gui_lock;
64 };
65
66 class CWindowToolGUI : public BC_Window
67 {
68 public:
69         CWindowToolGUI(MWindow *mwindow,
70                 CWindowTool *thread,
71                 const char *title,
72                 int w,
73                 int h);
74         ~CWindowToolGUI();
75
76         virtual void create_objects() {};
77 // Update the keyframe from text boxes
78         virtual void handle_event() {};
79 // Update text boxes from keyframe here
80         virtual void update() {};
81 // Update EDL and preview only
82         virtual void update_preview() {};
83         int current_operation;
84         int close_event();
85         int keypress_event();
86         int translation_event();
87
88         MWindow *mwindow;
89         CWindowTool *thread;
90         CWindowCoord *event_caller;
91 };
92
93 class CWindowCoord : public BC_TumbleTextBox
94 {
95 public:
96         CWindowCoord(CWindowToolGUI *gui, int x, int y, float value, int logincrement);
97         CWindowCoord(CWindowToolGUI *gui, int x, int y, int value);
98
99 // Calls the window's handle_event
100         int handle_event();
101
102         CWindowToolGUI *gui;
103 };
104
105 class CWindowCropOK : public BC_GenericButton
106 {
107 public:
108         CWindowCropOK(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
109 // Perform the cropping operation
110         int handle_event();
111         int keypress_event();
112         MWindow *mwindow;
113         CWindowToolGUI *gui;
114 };
115
116 class CWindowCropGUI : public CWindowToolGUI
117 {
118 public:
119         CWindowCropGUI(MWindow *mwindow, CWindowTool *thread);
120         ~CWindowCropGUI();
121         void create_objects();
122         void update();
123 // Update the gui
124         void handle_event();
125         CWindowCoord *x1, *y1, *width, *height;
126 };
127
128 class CWindowMaskItems : public ArrayList<BC_ListBoxItem*>
129 {
130 public:
131         CWindowMaskItems() {}
132         ~CWindowMaskItems() { remove_all_objects(); }
133 };
134
135 class CWindowMaskName : public BC_PopupTextBox
136 {
137 public:
138         CWindowMaskName(MWindow *mwindow, CWindowToolGUI *gui, int x, int y, const char *text);
139         ~CWindowMaskName();
140         MWindow *mwindow;
141         CWindowToolGUI *gui;
142         CWindowMaskItems mask_items;
143
144         int handle_event();
145         void update_items(MaskAuto *keyframe);
146 };
147
148 class CWindowMaskDelMask : public BC_GenericButton
149 {
150 public:
151         CWindowMaskDelMask(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
152         int handle_event();
153         MWindow *mwindow;
154         CWindowToolGUI *gui;
155 };
156
157 class CWindowMaskClrMask : public BC_Button
158 {
159 public:
160         CWindowMaskClrMask(MWindow *mwindow, CWindowMaskGUI *gui, int x, int y);
161         ~CWindowMaskClrMask();
162         static int calculate_w(MWindow *mwindow);
163         int handle_event();
164         MWindow *mwindow;
165         CWindowMaskGUI *gui;
166 };
167
168 class CWindowMaskFade : public BC_TumbleTextBox
169 {
170 public:
171         CWindowMaskFade(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
172         ~CWindowMaskFade();
173         int update(float v);
174         int update_value(float v);
175         int handle_event();
176         MWindow *mwindow;
177         CWindowToolGUI *gui;
178 };
179
180 class CWindowMaskFadeSlider : public BC_ISlider
181 {
182 public:
183         CWindowMaskFadeSlider(MWindow *mwindow, CWindowToolGUI *gui,
184                 int x, int y, int w);
185         ~CWindowMaskFadeSlider();
186         int handle_event();
187         int update(int64_t v);
188         char *get_caption() { return 0; }
189         MWindow *mwindow;
190         CWindowToolGUI *gui;
191         int stick;
192         float last_v;
193         Timer *timer;
194 };
195
196 class CWindowMaskGangFader : public BC_Toggle
197 {
198 public:
199         CWindowMaskGangFader(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
200         ~CWindowMaskGangFader();
201         int handle_event();
202         MWindow *mwindow;
203         CWindowToolGUI *gui;
204 };
205
206 class CWindowMaskAffectedPoint : public BC_TumbleTextBox
207 {
208 public:
209         CWindowMaskAffectedPoint(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
210         ~CWindowMaskAffectedPoint();
211         int handle_event();
212         MWindow *mwindow;
213         CWindowToolGUI *gui;
214 };
215
216 class CWindowMaskFocus : public BC_CheckBox
217 {
218 public:
219         CWindowMaskFocus(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
220         ~CWindowMaskFocus();
221         int handle_event();
222         MWindow *mwindow;
223         CWindowToolGUI *gui;
224 };
225
226 class CWindowMaskDrawMarkers : public BC_CheckBox
227 {
228 public:
229         CWindowMaskDrawMarkers(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
230         ~CWindowMaskDrawMarkers();
231         int handle_event();
232         MWindow *mwindow;
233         CWindowToolGUI *gui;
234 };
235
236 class CWindowMaskDrawBoundary : public BC_CheckBox
237 {
238 public:
239         CWindowMaskDrawBoundary(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
240         ~CWindowMaskDrawBoundary();
241         int handle_event();
242         MWindow *mwindow;
243         CWindowToolGUI *gui;
244 };
245
246 class CWindowMaskDelPoint : public BC_GenericButton
247 {
248 public:
249         CWindowMaskDelPoint(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
250         int handle_event();
251         int keypress_event();
252         MWindow *mwindow;
253         CWindowToolGUI *gui;
254 };
255
256 class CWindowMaskFeather : public BC_TumbleTextBox
257 {
258 public:
259         CWindowMaskFeather(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
260         ~CWindowMaskFeather();
261         int update(float v);
262         int update_value(float v);
263         int handle_event();
264         MWindow *mwindow;
265         CWindowToolGUI *gui;
266 };
267
268 class CWindowMaskFeatherSlider : public BC_FSlider
269 {
270 public:
271         CWindowMaskFeatherSlider(MWindow *mwindow, CWindowToolGUI *gui,
272                 int x, int y, int w, float v);
273         ~CWindowMaskFeatherSlider();
274         int handle_event();
275         int update(float v);
276         char *get_caption() { return 0; }
277         MWindow *mwindow;
278         CWindowToolGUI *gui;
279         int stick;
280         float last_v;
281         Timer *timer;
282 };
283
284 class CWindowMaskGangFeather : public BC_Toggle
285 {
286 public:
287         CWindowMaskGangFeather(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
288         ~CWindowMaskGangFeather();
289         int handle_event();
290         MWindow *mwindow;
291         CWindowToolGUI *gui;
292 };
293
294 class CWindowMaskBeforePlugins : public BC_CheckBox
295 {
296 public:
297         CWindowMaskBeforePlugins(CWindowToolGUI *gui, int x, int y);
298         int handle_event();
299         CWindowToolGUI *gui;
300 };
301
302 class CWindowDisableOpenGLMasking : public BC_CheckBox
303 {
304 public:
305         CWindowDisableOpenGLMasking(CWindowToolGUI *gui, int x, int y);
306         int handle_event();
307         CWindowToolGUI *gui;
308 };
309
310 class CWindowMaskGUI : public CWindowToolGUI
311 {
312 public:
313         CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread);
314         ~CWindowMaskGUI();
315         void create_objects();
316         void update();
317         void set_focused(int v, float cx, float cy);
318         void handle_event();
319         void get_keyframe(Track* &track, MaskAutos* &autos, MaskAuto* &keyframe,
320                 SubMask* &mask, MaskPoint* &point, int create_it);
321         void update_preview();
322
323         CWindowMaskName *name;
324         CWindowMaskDelMask *del_mask;
325         CWindowMaskClrMask *clr_mask;
326         CWindowMaskFade *fade;
327         CWindowMaskFadeSlider *fade_slider;
328         CWindowMaskGangFader *gang_fader;
329         CWindowMaskAffectedPoint *active_point;
330         CWindowMaskDelPoint *del_point;
331         CWindowCoord *x, *y;
332         CWindowMaskFocus *focus;
333         int focused;
334         CWindowMaskDrawMarkers *draw_markers;
335         int markers;
336         CWindowMaskDrawBoundary *draw_boundary;
337         int boundary;
338         CWindowCoord *focus_x, *focus_y;
339         CWindowMaskFeather *feather;
340         CWindowMaskFeatherSlider *feather_slider;
341         CWindowMaskGangFeather *gang_feather;
342         CWindowMaskBeforePlugins *apply_before_plugins;
343         CWindowDisableOpenGLMasking *disable_opengl_masking;
344 };
345
346
347 class CWindowEyedropGUI : public CWindowToolGUI
348 {
349 public:
350         CWindowEyedropGUI(MWindow *mwindow, CWindowTool *thread);
351         ~CWindowEyedropGUI();
352
353         void handle_event();
354         void create_objects();
355         void update();
356
357         BC_Title *current;
358         CWindowCoord *radius;
359         CWindowEyedropCheckBox *use_max;
360         BC_Title *red, *green, *blue, *y, *u, *v;
361         BC_Title *rgb_hex, *yuv_hex;
362         BC_SubWindow *sample;
363 };
364
365
366 class CWindowEyedropCheckBox : public BC_CheckBox
367 {
368 public:
369         CWindowEyedropCheckBox(MWindow *mwindow, 
370                 CWindowEyedropGUI *gui,
371                 int x, 
372                 int y);
373
374         int handle_event();
375         MWindow *mwindow;
376         CWindowEyedropGUI *gui;
377 };
378
379
380
381 class CWindowCameraGUI : public CWindowToolGUI
382 {
383 public:
384         CWindowCameraGUI(MWindow *mwindow, CWindowTool *thread);
385         ~CWindowCameraGUI();
386         void create_objects();
387         void update();
388         void update_preview();
389
390 // Update the keyframe from text boxes
391         void handle_event();
392 //      BezierAuto* get_keyframe();
393         CWindowCoord *x, *y, *z;
394 private:
395 // Toggles for keyframe curve mode (for camera automation only)
396         CWindowCurveToggle *t_smooth, *t_linear;
397 };
398
399 class CWindowCameraLeft : public BC_Button
400 {
401 public:
402         CWindowCameraLeft(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y);
403         int handle_event();
404         MWindow *mwindow;
405         CWindowCameraGUI *gui;
406 };
407
408 class CWindowCameraCenter : public BC_Button
409 {
410 public:
411         CWindowCameraCenter(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y);
412         int handle_event();
413         MWindow *mwindow;
414         CWindowCameraGUI *gui;
415 };
416
417 class CWindowCameraRight : public BC_Button
418 {
419 public:
420         CWindowCameraRight(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y);
421         int handle_event();
422         MWindow *mwindow;
423         CWindowCameraGUI *gui;
424 };
425
426 class CWindowCameraTop : public BC_Button
427 {
428 public:
429         CWindowCameraTop(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y);
430         int handle_event();
431         MWindow *mwindow;
432         CWindowCameraGUI *gui;
433 };
434
435 class CWindowCameraMiddle : public BC_Button
436 {
437 public:
438         CWindowCameraMiddle(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y);
439         int handle_event();
440         MWindow *mwindow;
441         CWindowCameraGUI *gui;
442 };
443
444 class CWindowCameraBottom : public BC_Button
445 {
446 public:
447         CWindowCameraBottom(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y);
448         int handle_event();
449         MWindow *mwindow;
450         CWindowCameraGUI *gui;
451 };
452
453 class CWindowProjectorGUI : public CWindowToolGUI
454 {
455 public:
456         CWindowProjectorGUI(MWindow *mwindow, CWindowTool *thread);
457         ~CWindowProjectorGUI();
458         void create_objects();
459         void update();
460         void update_preview();
461         void handle_event();
462 //      BezierAuto* get_keyframe();
463         CWindowCoord *x, *y, *z;
464 private:
465 // Toggles for keyframe curve mode (projector automation only)
466         CWindowCurveToggle *t_smooth, *t_linear;
467 };
468
469 class CWindowProjectorLeft : public BC_Button
470 {
471 public:
472         CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y);
473         int handle_event();
474         MWindow *mwindow;
475         CWindowProjectorGUI *gui;
476 };
477
478 class CWindowProjectorCenter : public BC_Button
479 {
480 public:
481         CWindowProjectorCenter(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y);
482         int handle_event();
483         MWindow *mwindow;
484         CWindowProjectorGUI *gui;
485 };
486
487 class CWindowProjectorRight : public BC_Button
488 {
489 public:
490         CWindowProjectorRight(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y);
491         int handle_event();
492         MWindow *mwindow;
493         CWindowProjectorGUI *gui;
494 };
495
496 class CWindowProjectorTop : public BC_Button
497 {
498 public:
499         CWindowProjectorTop(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y);
500         int handle_event();
501         MWindow *mwindow;
502         CWindowProjectorGUI *gui;
503 };
504
505 class CWindowProjectorMiddle : public BC_Button
506 {
507 public:
508         CWindowProjectorMiddle(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y);
509         int handle_event();
510         MWindow *mwindow;
511         CWindowProjectorGUI *gui;
512 };
513
514 class CWindowProjectorBottom : public BC_Button
515 {
516 public:
517         CWindowProjectorBottom(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y);
518         int handle_event();
519         MWindow *mwindow;
520         CWindowProjectorGUI *gui;
521 };
522
523
524
525
526 class CWindowRulerGUI : public CWindowToolGUI
527 {
528 public:
529         CWindowRulerGUI(MWindow *mwindow, CWindowTool *thread);
530         ~CWindowRulerGUI();
531         void create_objects();
532         void update();
533 // Update the gui
534         void handle_event();
535
536         BC_TextBox *current;
537         BC_TextBox *point1;
538         BC_TextBox *point2;
539         BC_TextBox *deltas;
540         BC_TextBox *distance;
541         BC_TextBox *angle;
542 };
543
544
545
546 #endif