add mask selection btns
[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,
97                         float value, int logincrement);
98         CWindowCoord(CWindowToolGUI *gui, int x, int y,
99                         int value);
100
101 // Calls the window's handle_event
102         int handle_event();
103
104         CWindowToolGUI *gui;
105 };
106
107 class CWindowCropOK : public BC_GenericButton
108 {
109 public:
110         CWindowCropOK(MWindow *mwindow, CWindowToolGUI *gui,
111                         int x, int y);
112 // Perform the cropping operation
113         int handle_event();
114         int keypress_event();
115         MWindow *mwindow;
116         CWindowToolGUI *gui;
117 };
118
119 class CWindowCropGUI : public CWindowToolGUI
120 {
121 public:
122         CWindowCropGUI(MWindow *mwindow, CWindowTool *thread);
123         ~CWindowCropGUI();
124         void create_objects();
125         void update();
126 // Update the gui
127         void handle_event();
128         CWindowCoord *x1, *y1, *width, *height;
129 };
130
131 class CWindowMaskItems : public ArrayList<BC_ListBoxItem*>
132 {
133 public:
134         CWindowMaskItems() {}
135         ~CWindowMaskItems() { remove_all_objects(); }
136 };
137
138 class CWindowMaskName : public BC_PopupTextBox
139 {
140 public:
141         CWindowMaskName(MWindow *mwindow, CWindowMaskGUI *gui,
142                         int x, int y, const char *text);
143         ~CWindowMaskName();
144         MWindow *mwindow;
145         CWindowMaskGUI *gui;
146         CWindowMaskItems mask_items;
147
148         int handle_event();
149         void update_items(MaskAuto *keyframe);
150 };
151
152 class CWindowMaskDelMask : public BC_GenericButton
153 {
154 public:
155         CWindowMaskDelMask(MWindow *mwindow, CWindowToolGUI *gui,
156                         int x, int y);
157         int handle_event();
158         MWindow *mwindow;
159         CWindowToolGUI *gui;
160 };
161
162 class CWindowMaskClrMask : public BC_Button
163 {
164 public:
165         CWindowMaskClrMask(MWindow *mwindow, CWindowMaskGUI *gui,
166                         int x, int y);
167         ~CWindowMaskClrMask();
168         static int calculate_w(MWindow *mwindow);
169         int handle_event();
170         MWindow *mwindow;
171         CWindowMaskGUI *gui;
172 };
173
174 class CWindowMaskButton : public BC_CheckBox
175 {
176 public:
177         CWindowMaskButton(MWindow *mwindow, CWindowMaskGUI *gui,
178                          int x, int y, int no, int v);
179         ~CWindowMaskButton();
180
181         int handle_event();
182         MWindow *mwindow;
183         CWindowMaskGUI *gui;
184         int no;
185 };
186
187 class CWindowMaskThumbler : public BC_Tumbler
188 {
189 public:
190         CWindowMaskThumbler(MWindow *mwindow, CWindowMaskGUI *gui,
191                         int x, int y);
192         ~CWindowMaskThumbler();
193         int handle_up_event();
194         int handle_down_event();
195         int do_event(int dir);
196
197         MWindow *mwindow;
198         CWindowMaskGUI *gui;
199 };
200
201 class CWindowMaskFade : public BC_TumbleTextBox
202 {
203 public:
204         CWindowMaskFade(MWindow *mwindow, CWindowToolGUI *gui,
205                         int x, int y);
206         ~CWindowMaskFade();
207         int update(float v);
208         int update_value(float v);
209         int handle_event();
210         MWindow *mwindow;
211         CWindowToolGUI *gui;
212 };
213
214 class CWindowMaskFadeSlider : public BC_ISlider
215 {
216 public:
217         CWindowMaskFadeSlider(MWindow *mwindow, CWindowToolGUI *gui,
218                 int x, int y, int w);
219         ~CWindowMaskFadeSlider();
220         int handle_event();
221         int update(int64_t v);
222         char *get_caption() { return 0; }
223         MWindow *mwindow;
224         CWindowToolGUI *gui;
225         int stick;
226         float last_v;
227         Timer *timer;
228 };
229
230 class CWindowMaskGangFader : public BC_Toggle
231 {
232 public:
233         CWindowMaskGangFader(MWindow *mwindow, CWindowToolGUI *gui,
234                         int x, int y);
235         ~CWindowMaskGangFader();
236         int handle_event();
237         MWindow *mwindow;
238         CWindowToolGUI *gui;
239 };
240
241 class CWindowMaskAffectedPoint : public BC_TumbleTextBox
242 {
243 public:
244         CWindowMaskAffectedPoint(MWindow *mwindow, CWindowToolGUI *gui,
245                         int x, int y);
246         ~CWindowMaskAffectedPoint();
247         int handle_event();
248         MWindow *mwindow;
249         CWindowToolGUI *gui;
250 };
251
252 class CWindowMaskFocus : public BC_CheckBox
253 {
254 public:
255         CWindowMaskFocus(MWindow *mwindow, CWindowToolGUI *gui,
256                         int x, int y);
257         ~CWindowMaskFocus();
258         int handle_event();
259         MWindow *mwindow;
260         CWindowToolGUI *gui;
261 };
262
263 class CWindowMaskDrawMarkers : public BC_CheckBox
264 {
265 public:
266         CWindowMaskDrawMarkers(MWindow *mwindow, CWindowToolGUI *gui,
267                         int x, int y);
268         ~CWindowMaskDrawMarkers();
269         int handle_event();
270         MWindow *mwindow;
271         CWindowToolGUI *gui;
272 };
273
274 class CWindowMaskDrawBoundary : public BC_CheckBox
275 {
276 public:
277         CWindowMaskDrawBoundary(MWindow *mwindow, CWindowToolGUI *gui,
278                         int x, int y);
279         ~CWindowMaskDrawBoundary();
280         int handle_event();
281         MWindow *mwindow;
282         CWindowToolGUI *gui;
283 };
284
285 class CWindowMaskDelPoint : public BC_GenericButton
286 {
287 public:
288         CWindowMaskDelPoint(MWindow *mwindow, CWindowToolGUI *gui,
289                         int x, int y);
290         int handle_event();
291         int keypress_event();
292         MWindow *mwindow;
293         CWindowToolGUI *gui;
294 };
295
296 class CWindowMaskFeather : public BC_TumbleTextBox
297 {
298 public:
299         CWindowMaskFeather(MWindow *mwindow, CWindowToolGUI *gui,
300                         int x, int y);
301         ~CWindowMaskFeather();
302         int update(float v);
303         int update_value(float v);
304         int handle_event();
305         MWindow *mwindow;
306         CWindowToolGUI *gui;
307 };
308
309 class CWindowMaskFeatherSlider : public BC_FSlider
310 {
311 public:
312         CWindowMaskFeatherSlider(MWindow *mwindow, CWindowToolGUI *gui,
313                 int x, int y, int w, float v);
314         ~CWindowMaskFeatherSlider();
315         int handle_event();
316         int update(float v);
317         char *get_caption() { return 0; }
318         MWindow *mwindow;
319         CWindowToolGUI *gui;
320         int stick;
321         float last_v;
322         Timer *timer;
323 };
324
325 class CWindowMaskGangFeather : public BC_Toggle
326 {
327 public:
328         CWindowMaskGangFeather(MWindow *mwindow, CWindowToolGUI *gui,
329                         int x, int y);
330         ~CWindowMaskGangFeather();
331         int handle_event();
332         MWindow *mwindow;
333         CWindowToolGUI *gui;
334 };
335
336 class CWindowMaskBeforePlugins : public BC_CheckBox
337 {
338 public:
339         CWindowMaskBeforePlugins(CWindowToolGUI *gui,
340                         int x, int y);
341         int handle_event();
342         CWindowToolGUI *gui;
343 };
344
345 class CWindowDisableOpenGLMasking : public BC_CheckBox
346 {
347 public:
348         CWindowDisableOpenGLMasking(CWindowToolGUI *gui,
349                         int x, int y);
350         int handle_event();
351         CWindowToolGUI *gui;
352 };
353
354 class CWindowMaskGUI : public CWindowToolGUI
355 {
356 public:
357         CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread);
358         ~CWindowMaskGUI();
359         void create_objects();
360         void update();
361         void set_focused(int v, float cx, float cy);
362         void handle_event();
363         void get_keyframe(Track* &track, MaskAutos* &autos, MaskAuto* &keyframe,
364                 SubMask* &mask, MaskPoint* &point, int create_it);
365         void update_preview();
366
367         CWindowMaskName *name;
368         CWindowMaskButton *mask_buttons[SUBMASKS];
369         CWindowMaskThumbler *mask_thumbler;
370         BC_Title *mask_blabels[SUBMASKS];
371         CWindowMaskDelMask *del_mask;
372         CWindowMaskClrMask *clr_mask;
373         CWindowMaskFade *fade;
374         CWindowMaskFadeSlider *fade_slider;
375         CWindowMaskGangFader *gang_fader;
376         CWindowMaskAffectedPoint *active_point;
377         CWindowMaskDelPoint *del_point;
378         CWindowCoord *x, *y;
379         CWindowMaskFocus *focus;
380         int focused;
381         CWindowMaskDrawMarkers *draw_markers;
382         int markers;
383         CWindowMaskDrawBoundary *draw_boundary;
384         int boundary;
385         CWindowCoord *focus_x, *focus_y;
386         CWindowMaskFeather *feather;
387         CWindowMaskFeatherSlider *feather_slider;
388         CWindowMaskGangFeather *gang_feather;
389         CWindowMaskBeforePlugins *apply_before_plugins;
390         CWindowDisableOpenGLMasking *disable_opengl_masking;
391 };
392
393
394 class CWindowEyedropGUI : public CWindowToolGUI
395 {
396 public:
397         CWindowEyedropGUI(MWindow *mwindow, CWindowTool *thread);
398         ~CWindowEyedropGUI();
399
400         void handle_event();
401         void create_objects();
402         void update();
403
404         BC_Title *current;
405         CWindowCoord *radius;
406         CWindowEyedropCheckBox *use_max;
407         BC_Title *red, *green, *blue, *y, *u, *v;
408         BC_Title *rgb_hex, *yuv_hex;
409         BC_SubWindow *sample;
410 };
411
412
413 class CWindowEyedropCheckBox : public BC_CheckBox
414 {
415 public:
416         CWindowEyedropCheckBox(MWindow *mwindow, 
417                 CWindowEyedropGUI *gui,
418                 int x, 
419                 int y);
420
421         int handle_event();
422         MWindow *mwindow;
423         CWindowEyedropGUI *gui;
424 };
425
426
427
428 class CWindowCameraGUI : public CWindowToolGUI
429 {
430 public:
431         CWindowCameraGUI(MWindow *mwindow, CWindowTool *thread);
432         ~CWindowCameraGUI();
433         void create_objects();
434         void update();
435         void update_preview();
436
437 // Update the keyframe from text boxes
438         void handle_event();
439 //      BezierAuto* get_keyframe();
440         CWindowCoord *x, *y, *z;
441 private:
442 // Toggles for keyframe curve mode (for camera automation only)
443         CWindowCurveToggle *t_smooth, *t_linear;
444 };
445
446 class CWindowCameraLeft : public BC_Button
447 {
448 public:
449         CWindowCameraLeft(MWindow *mwindow, CWindowCameraGUI *gui,
450                         int x, int y);
451         int handle_event();
452         MWindow *mwindow;
453         CWindowCameraGUI *gui;
454 };
455
456 class CWindowCameraCenter : public BC_Button
457 {
458 public:
459         CWindowCameraCenter(MWindow *mwindow, CWindowCameraGUI *gui,
460                         int x, int y);
461         int handle_event();
462         MWindow *mwindow;
463         CWindowCameraGUI *gui;
464 };
465
466 class CWindowCameraRight : public BC_Button
467 {
468 public:
469         CWindowCameraRight(MWindow *mwindow, CWindowCameraGUI *gui,
470                         int x, int y);
471         int handle_event();
472         MWindow *mwindow;
473         CWindowCameraGUI *gui;
474 };
475
476 class CWindowCameraTop : public BC_Button
477 {
478 public:
479         CWindowCameraTop(MWindow *mwindow, CWindowCameraGUI *gui,
480                         int x, int y);
481         int handle_event();
482         MWindow *mwindow;
483         CWindowCameraGUI *gui;
484 };
485
486 class CWindowCameraMiddle : public BC_Button
487 {
488 public:
489         CWindowCameraMiddle(MWindow *mwindow, CWindowCameraGUI *gui,
490                         int x, int y);
491         int handle_event();
492         MWindow *mwindow;
493         CWindowCameraGUI *gui;
494 };
495
496 class CWindowCameraBottom : public BC_Button
497 {
498 public:
499         CWindowCameraBottom(MWindow *mwindow, CWindowCameraGUI *gui,
500                         int x, int y);
501         int handle_event();
502         MWindow *mwindow;
503         CWindowCameraGUI *gui;
504 };
505
506 class CWindowProjectorGUI : public CWindowToolGUI
507 {
508 public:
509         CWindowProjectorGUI(MWindow *mwindow, CWindowTool *thread);
510         ~CWindowProjectorGUI();
511         void create_objects();
512         void update();
513         void update_preview();
514         void handle_event();
515 //      BezierAuto* get_keyframe();
516         CWindowCoord *x, *y, *z;
517 private:
518 // Toggles for keyframe curve mode (projector automation only)
519         CWindowCurveToggle *t_smooth, *t_linear;
520 };
521
522 class CWindowProjectorLeft : public BC_Button
523 {
524 public:
525         CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui,
526                         int x, int y);
527         int handle_event();
528         MWindow *mwindow;
529         CWindowProjectorGUI *gui;
530 };
531
532 class CWindowProjectorCenter : public BC_Button
533 {
534 public:
535         CWindowProjectorCenter(MWindow *mwindow, CWindowProjectorGUI *gui,
536                         int x, int y);
537         int handle_event();
538         MWindow *mwindow;
539         CWindowProjectorGUI *gui;
540 };
541
542 class CWindowProjectorRight : public BC_Button
543 {
544 public:
545         CWindowProjectorRight(MWindow *mwindow, CWindowProjectorGUI *gui,
546                         int x, int y);
547         int handle_event();
548         MWindow *mwindow;
549         CWindowProjectorGUI *gui;
550 };
551
552 class CWindowProjectorTop : public BC_Button
553 {
554 public:
555         CWindowProjectorTop(MWindow *mwindow, CWindowProjectorGUI *gui,
556                         int x, int y);
557         int handle_event();
558         MWindow *mwindow;
559         CWindowProjectorGUI *gui;
560 };
561
562 class CWindowProjectorMiddle : public BC_Button
563 {
564 public:
565         CWindowProjectorMiddle(MWindow *mwindow, CWindowProjectorGUI *gui,
566                         int x, int y);
567         int handle_event();
568         MWindow *mwindow;
569         CWindowProjectorGUI *gui;
570 };
571
572 class CWindowProjectorBottom : public BC_Button
573 {
574 public:
575         CWindowProjectorBottom(MWindow *mwindow, CWindowProjectorGUI *gui,
576                         int x, int y);
577         int handle_event();
578         MWindow *mwindow;
579         CWindowProjectorGUI *gui;
580 };
581
582
583
584
585 class CWindowRulerGUI : public CWindowToolGUI
586 {
587 public:
588         CWindowRulerGUI(MWindow *mwindow, CWindowTool *thread);
589         ~CWindowRulerGUI();
590         void create_objects();
591         void update();
592 // Update the gui
593         void handle_event();
594
595         BC_TextBox *current;
596         BC_TextBox *point1;
597         BC_TextBox *point2;
598         BC_TextBox *deltas;
599         BC_TextBox *distance;
600         BC_TextBox *angle;
601 };
602
603
604
605 #endif