mask mods- accel rotate/scale, gang rotate/scale/xlate, high-lite active mask tracks...
[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         void raise_tool();
50
51         void run();
52         void update_show_window();
53         void raise_window();
54         void update_values();
55
56         MWindow *mwindow;
57         CWindowGUI *gui;
58         CWindowToolGUI *tool_gui;
59         int done;
60         int current_tool;
61         Condition *input_lock;
62         Condition *output_lock;
63 // Lock run and update_values
64         Mutex *tool_gui_lock;
65 };
66
67 class CWindowToolGUI : public BC_Window
68 {
69 public:
70         CWindowToolGUI(MWindow *mwindow,
71                 CWindowTool *thread,
72                 const char *title,
73                 int w,
74                 int h);
75         ~CWindowToolGUI();
76
77         virtual void create_objects() {};
78 // Update the keyframe from text boxes
79         virtual void handle_event() {};
80 // Update text boxes from keyframe here
81         virtual void update() {};
82 // Update EDL and preview only
83         void update_preview(int changed_edl=0);
84         void draw_preview(int changed_edl);
85         int current_operation;
86         virtual int close_event();
87         int keypress_event();
88         int translation_event();
89
90         MWindow *mwindow;
91         CWindowTool *thread;
92         CWindowCoord *event_caller;
93 };
94
95 class CWindowCoord : public BC_TumbleTextBox
96 {
97 public:
98         CWindowCoord(CWindowToolGUI *gui, int x, int y,
99                         float value, int logincrement);
100         CWindowCoord(CWindowToolGUI *gui, int x, int y,
101                         int value);
102
103 // Calls the window's handle_event
104         int handle_event();
105
106         CWindowToolGUI *gui;
107 };
108
109 class CWindowCropOK : public BC_GenericButton
110 {
111 public:
112         CWindowCropOK(MWindow *mwindow, CWindowToolGUI *gui,
113                         int x, int y);
114 // Perform the cropping operation
115         int handle_event();
116         int keypress_event();
117         MWindow *mwindow;
118         CWindowToolGUI *gui;
119 };
120
121 class CWindowCropGUI : public CWindowToolGUI
122 {
123 public:
124         CWindowCropGUI(MWindow *mwindow, CWindowTool *thread);
125         ~CWindowCropGUI();
126         void create_objects();
127         void update();
128 // Update the gui
129         void handle_event();
130         CWindowCoord *x1, *y1, *width, *height;
131 };
132
133 class CWindowMaskItem : public BC_ListBoxItem
134 {
135 public:
136         CWindowMaskItem(const char *text, int id=-1, int color=-1)
137          : BC_ListBoxItem(text, color), id(id) {}
138         ~CWindowMaskItem() {}
139         int id;
140 };
141
142 class CWindowMaskItems : public ArrayList<BC_ListBoxItem*>
143 {
144 public:
145         CWindowMaskItems() {}
146         ~CWindowMaskItems() { remove_all_objects(); }
147 };
148
149 class CWindowMaskOnTrack : public BC_PopupTextBox
150 {
151 public:
152         CWindowMaskOnTrack(MWindow *mwindow, CWindowMaskGUI *gui,
153                         int x, int y, int w, const char *text);
154         ~CWindowMaskOnTrack();
155         MWindow *mwindow;
156         CWindowMaskGUI *gui;
157         CWindowMaskItems track_items;
158
159         int handle_event();
160         void update_items();
161 };
162
163 class CWindowMaskTrackTumbler : public BC_Tumbler
164 {
165 public:
166         CWindowMaskTrackTumbler(MWindow *mwindow, CWindowMaskGUI *gui,
167                         int x, int y);
168         ~CWindowMaskTrackTumbler();
169         int handle_up_event();
170         int handle_down_event();
171         int do_event(int dir);
172
173         MWindow *mwindow;
174         CWindowMaskGUI *gui;
175 };
176
177
178 class CWindowMaskName : public BC_PopupTextBox
179 {
180 public:
181         CWindowMaskName(MWindow *mwindow, CWindowMaskGUI *gui,
182                         int x, int y, const char *text);
183         ~CWindowMaskName();
184         MWindow *mwindow;
185         CWindowMaskGUI *gui;
186         CWindowMaskItems mask_items;
187
188         int handle_event();
189         void update_items(MaskAuto *keyframe);
190 };
191
192 class CWindowMaskUnclear : public BC_GenericButton
193 {
194 public:
195         CWindowMaskUnclear(MWindow *mwindow, CWindowMaskGUI *gui,
196                         int x, int y, int w);
197         int handle_event();
198         MWindow *mwindow;
199         CWindowMaskGUI *gui;
200 };
201
202 class CWindowMaskSoloTrack : public BC_CheckBox
203 {
204 public:
205         CWindowMaskSoloTrack(MWindow *mwindow, CWindowMaskGUI *gui,
206                         int x, int y, int v);
207         static int calculate_w(BC_WindowBase *gui);
208         int handle_event();
209         MWindow *mwindow;
210         CWindowMaskGUI *gui;
211 };
212
213 class CWindowMaskDelMask : public BC_GenericButton
214 {
215 public:
216         CWindowMaskDelMask(MWindow *mwindow, CWindowMaskGUI *gui,
217                         int x, int y);
218         int handle_event();
219         MWindow *mwindow;
220         CWindowMaskGUI *gui;
221 };
222
223 class CWindowMaskClrMask : public BC_Button
224 {
225 public:
226         CWindowMaskClrMask(MWindow *mwindow, CWindowMaskGUI *gui,
227                         int x, int y);
228         ~CWindowMaskClrMask();
229         static int calculate_w(MWindow *mwindow);
230         int handle_event();
231         MWindow *mwindow;
232         CWindowMaskGUI *gui;
233 };
234
235 class CWindowMaskButton : public BC_CheckBox
236 {
237 public:
238         CWindowMaskButton(MWindow *mwindow, CWindowMaskGUI *gui,
239                          int x, int y, int no, int v);
240         ~CWindowMaskButton();
241
242         int handle_event();
243         MWindow *mwindow;
244         CWindowMaskGUI *gui;
245         int no;
246 };
247
248 class CWindowMaskThumbler : public BC_Tumbler
249 {
250 public:
251         CWindowMaskThumbler(MWindow *mwindow, CWindowMaskGUI *gui,
252                         int x, int y);
253         ~CWindowMaskThumbler();
254         int handle_up_event();
255         int handle_down_event();
256         int do_event(int dir);
257
258         MWindow *mwindow;
259         CWindowMaskGUI *gui;
260 };
261
262 class CWindowMaskEnable : public BC_CheckBox
263 {
264 public:
265         CWindowMaskEnable(MWindow *mwindow, CWindowMaskGUI *gui,
266                          int x, int y, int no, int v);
267         ~CWindowMaskEnable();
268
269         int handle_event();
270         MWindow *mwindow;
271         CWindowMaskGUI *gui;
272         int no;
273 };
274
275 class CWindowMaskFade : public BC_TumbleTextBox
276 {
277 public:
278         CWindowMaskFade(MWindow *mwindow, CWindowMaskGUI *gui,
279                         int x, int y);
280         ~CWindowMaskFade();
281         int update(float v);
282         int update_value(float v);
283         int handle_event();
284         MWindow *mwindow;
285         CWindowMaskGUI *gui;
286 };
287
288 class CWindowMaskFadeSlider : public BC_ISlider
289 {
290 public:
291         CWindowMaskFadeSlider(MWindow *mwindow, CWindowMaskGUI *gui,
292                 int x, int y, int w);
293         ~CWindowMaskFadeSlider();
294         int handle_event();
295         int update(int64_t v);
296         char *get_caption() { return 0; }
297         MWindow *mwindow;
298         CWindowMaskGUI *gui;
299         int stick;
300         float last_v;
301         Timer *timer;
302 };
303
304 class CWindowMaskGangFader : public BC_Toggle
305 {
306 public:
307         CWindowMaskGangFader(MWindow *mwindow, CWindowMaskGUI *gui,
308                         int x, int y);
309         ~CWindowMaskGangFader();
310         int handle_event();
311         MWindow *mwindow;
312         CWindowMaskGUI *gui;
313 };
314
315 class CWindowMaskGangFocus : public BC_Toggle
316 {
317 public:
318         CWindowMaskGangFocus(MWindow *mwindow, CWindowMaskGUI *gui,
319                         int x, int y);
320         ~CWindowMaskGangFocus();
321         int handle_event();
322         MWindow *mwindow;
323         CWindowMaskGUI *gui;
324 };
325
326 class CWindowMaskAffectedPoint : public BC_TumbleTextBox
327 {
328 public:
329         CWindowMaskAffectedPoint(MWindow *mwindow, CWindowMaskGUI *gui,
330                         int x, int y);
331         ~CWindowMaskAffectedPoint();
332         int handle_event();
333         MWindow *mwindow;
334         CWindowMaskGUI *gui;
335 };
336
337 class CWindowMaskFocus : public BC_CheckBox
338 {
339 public:
340         CWindowMaskFocus(MWindow *mwindow, CWindowMaskGUI *gui,
341                         int x, int y);
342         ~CWindowMaskFocus();
343         int handle_event();
344         MWindow *mwindow;
345         CWindowMaskGUI *gui;
346 };
347
348 class CWindowMaskHelp : public BC_CheckBox
349 {
350 public:
351         CWindowMaskHelp(MWindow *mwindow, CWindowMaskGUI *gui,
352                         int x, int y);
353         ~CWindowMaskHelp();
354         int handle_event();
355         MWindow *mwindow;
356         CWindowMaskGUI *gui;
357 };
358
359 class CWindowMaskDrawMarkers : public BC_CheckBox
360 {
361 public:
362         CWindowMaskDrawMarkers(MWindow *mwindow, CWindowMaskGUI *gui,
363                         int x, int y);
364         ~CWindowMaskDrawMarkers();
365         int handle_event();
366         MWindow *mwindow;
367         CWindowMaskGUI *gui;
368 };
369
370 class CWindowMaskDrawBoundary : public BC_CheckBox
371 {
372 public:
373         CWindowMaskDrawBoundary(MWindow *mwindow, CWindowMaskGUI *gui,
374                         int x, int y);
375         ~CWindowMaskDrawBoundary();
376         int handle_event();
377         MWindow *mwindow;
378         CWindowMaskGUI *gui;
379 };
380
381 class CWindowMaskDelPoint : public BC_GenericButton
382 {
383 public:
384         CWindowMaskDelPoint(MWindow *mwindow, CWindowMaskGUI *gui,
385                         int x, int y);
386         int handle_event();
387         int keypress_event();
388         MWindow *mwindow;
389         CWindowMaskGUI *gui;
390 };
391
392 class CWindowMaskFeather : public BC_TumbleTextBox
393 {
394 public:
395         CWindowMaskFeather(MWindow *mwindow, CWindowMaskGUI *gui,
396                         int x, int y);
397         ~CWindowMaskFeather();
398         int update(float v);
399         int update_value(float v);
400         int handle_event();
401         MWindow *mwindow;
402         CWindowMaskGUI *gui;
403 };
404
405 class CWindowMaskFeatherSlider : public BC_FSlider
406 {
407 public:
408         CWindowMaskFeatherSlider(MWindow *mwindow, CWindowMaskGUI *gui,
409                 int x, int y, int w, float v);
410         ~CWindowMaskFeatherSlider();
411         int handle_event();
412         int update(float v);
413         char *get_caption() { return 0; }
414         MWindow *mwindow;
415         CWindowMaskGUI *gui;
416         int stick;
417         float last_v;
418         Timer *timer;
419 };
420
421 class CWindowMaskGangFeather : public BC_Toggle
422 {
423 public:
424         CWindowMaskGangFeather(MWindow *mwindow, CWindowMaskGUI *gui,
425                         int x, int y);
426         ~CWindowMaskGangFeather();
427         int handle_event();
428         MWindow *mwindow;
429         CWindowMaskGUI *gui;
430 };
431
432 class CWindowMaskBeforePlugins : public BC_CheckBox
433 {
434 public:
435         CWindowMaskBeforePlugins(CWindowMaskGUI *gui,
436                         int x, int y);
437         int handle_event();
438         CWindowMaskGUI *gui;
439 };
440
441 class CWindowDisableOpenGLMasking : public BC_CheckBox
442 {
443 public:
444         CWindowDisableOpenGLMasking(CWindowMaskGUI *gui,
445                         int x, int y);
446         int handle_event();
447         CWindowMaskGUI *gui;
448 };
449
450 class CWindowMaskGUI : public CWindowToolGUI
451 {
452 public:
453         CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread);
454         ~CWindowMaskGUI();
455         void create_objects();
456         void update();
457         int close_event();
458         void done_event();
459         void set_focused(int v, float cx, float cy);
460         void update_buttons(MaskAuto *keyframe, int k);
461         void handle_event();
462         void get_keyframe(Track* &track, MaskAutos* &autos, MaskAuto* &keyframe,
463                 SubMask* &mask, MaskPoint* &point, int create_it);
464
465         CWindowMaskOnTrack *mask_on_track;
466         CWindowMaskTrackTumbler *mask_track_tumbler;
467         CWindowMaskName *mask_name;
468         CWindowMaskButton *mask_buttons[SUBMASKS];
469         CWindowMaskThumbler *mask_thumbler;
470         BC_Title *mask_blabels[SUBMASKS];
471         CWindowMaskEnable *mask_enables[SUBMASKS];
472         CWindowMaskSoloTrack *mask_solo_track;
473         CWindowMaskDelMask *del_mask;
474         CWindowMaskUnclear *unclr_mask;
475         CWindowMaskClrMask *clr_mask;
476         CWindowMaskFade *fade;
477         CWindowMaskFadeSlider *fade_slider;
478         CWindowMaskGangFader *gang_fader;
479         CWindowMaskAffectedPoint *active_point;
480         CWindowMaskDelPoint *del_point;
481         CWindowCoord *x, *y;
482         CWindowMaskFocus *focus;
483         int focused;
484         CWindowMaskGangFocus *gang_focus;
485         CWindowMaskHelp *help;
486         int helped, help_y, help_h;
487         CWindowMaskDrawMarkers *draw_markers;
488         int markers;
489         CWindowMaskDrawBoundary *draw_boundary;
490         int boundary;
491         CWindowCoord *focus_x, *focus_y;
492         CWindowMaskFeather *feather;
493         CWindowMaskFeatherSlider *feather_slider;
494         CWindowMaskGangFeather *gang_feather;
495         CWindowMaskBeforePlugins *apply_before_plugins;
496         CWindowDisableOpenGLMasking *disable_opengl_masking;
497 };
498
499
500 class CWindowEyedropGUI : public CWindowToolGUI
501 {
502 public:
503         CWindowEyedropGUI(MWindow *mwindow, CWindowTool *thread);
504         ~CWindowEyedropGUI();
505
506         void handle_event();
507         void create_objects();
508         void update();
509
510         BC_Title *current;
511         CWindowCoord *radius;
512         CWindowEyedropCheckBox *use_max;
513         BC_Title *red, *green, *blue, *y, *u, *v;
514         BC_Title *rgb_hex, *yuv_hex;
515         BC_SubWindow *sample;
516 };
517
518
519 class CWindowEyedropCheckBox : public BC_CheckBox
520 {
521 public:
522         CWindowEyedropCheckBox(MWindow *mwindow, 
523                 CWindowEyedropGUI *gui,
524                 int x, 
525                 int y);
526
527         int handle_event();
528         MWindow *mwindow;
529         CWindowEyedropGUI *gui;
530 };
531
532
533
534 class CWindowCameraGUI : public CWindowToolGUI
535 {
536 public:
537         CWindowCameraGUI(MWindow *mwindow, CWindowTool *thread);
538         ~CWindowCameraGUI();
539         void create_objects();
540         void update();
541
542 // Update the keyframe from text boxes
543         void handle_event();
544 //      BezierAuto* get_keyframe();
545         CWindowCoord *x, *y, *z;
546 private:
547 // Toggles for keyframe curve mode (for camera automation only)
548         CWindowCurveToggle *t_smooth, *t_linear;
549 };
550
551 class CWindowCameraLeft : public BC_Button
552 {
553 public:
554         CWindowCameraLeft(MWindow *mwindow, CWindowCameraGUI *gui,
555                         int x, int y);
556         int handle_event();
557         MWindow *mwindow;
558         CWindowCameraGUI *gui;
559 };
560
561 class CWindowCameraCenter : public BC_Button
562 {
563 public:
564         CWindowCameraCenter(MWindow *mwindow, CWindowCameraGUI *gui,
565                         int x, int y);
566         int handle_event();
567         MWindow *mwindow;
568         CWindowCameraGUI *gui;
569 };
570
571 class CWindowCameraRight : public BC_Button
572 {
573 public:
574         CWindowCameraRight(MWindow *mwindow, CWindowCameraGUI *gui,
575                         int x, int y);
576         int handle_event();
577         MWindow *mwindow;
578         CWindowCameraGUI *gui;
579 };
580
581 class CWindowCameraTop : public BC_Button
582 {
583 public:
584         CWindowCameraTop(MWindow *mwindow, CWindowCameraGUI *gui,
585                         int x, int y);
586         int handle_event();
587         MWindow *mwindow;
588         CWindowCameraGUI *gui;
589 };
590
591 class CWindowCameraMiddle : public BC_Button
592 {
593 public:
594         CWindowCameraMiddle(MWindow *mwindow, CWindowCameraGUI *gui,
595                         int x, int y);
596         int handle_event();
597         MWindow *mwindow;
598         CWindowCameraGUI *gui;
599 };
600
601 class CWindowCameraBottom : public BC_Button
602 {
603 public:
604         CWindowCameraBottom(MWindow *mwindow, CWindowCameraGUI *gui,
605                         int x, int y);
606         int handle_event();
607         MWindow *mwindow;
608         CWindowCameraGUI *gui;
609 };
610
611 class CWindowProjectorGUI : public CWindowToolGUI
612 {
613 public:
614         CWindowProjectorGUI(MWindow *mwindow, CWindowTool *thread);
615         ~CWindowProjectorGUI();
616         void create_objects();
617         void update();
618         void handle_event();
619 //      BezierAuto* get_keyframe();
620         CWindowCoord *x, *y, *z;
621 private:
622 // Toggles for keyframe curve mode (projector automation only)
623         CWindowCurveToggle *t_smooth, *t_linear;
624 };
625
626 class CWindowProjectorLeft : public BC_Button
627 {
628 public:
629         CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui,
630                         int x, int y);
631         int handle_event();
632         MWindow *mwindow;
633         CWindowProjectorGUI *gui;
634 };
635
636 class CWindowProjectorCenter : public BC_Button
637 {
638 public:
639         CWindowProjectorCenter(MWindow *mwindow, CWindowProjectorGUI *gui,
640                         int x, int y);
641         int handle_event();
642         MWindow *mwindow;
643         CWindowProjectorGUI *gui;
644 };
645
646 class CWindowProjectorRight : public BC_Button
647 {
648 public:
649         CWindowProjectorRight(MWindow *mwindow, CWindowProjectorGUI *gui,
650                         int x, int y);
651         int handle_event();
652         MWindow *mwindow;
653         CWindowProjectorGUI *gui;
654 };
655
656 class CWindowProjectorTop : public BC_Button
657 {
658 public:
659         CWindowProjectorTop(MWindow *mwindow, CWindowProjectorGUI *gui,
660                         int x, int y);
661         int handle_event();
662         MWindow *mwindow;
663         CWindowProjectorGUI *gui;
664 };
665
666 class CWindowProjectorMiddle : public BC_Button
667 {
668 public:
669         CWindowProjectorMiddle(MWindow *mwindow, CWindowProjectorGUI *gui,
670                         int x, int y);
671         int handle_event();
672         MWindow *mwindow;
673         CWindowProjectorGUI *gui;
674 };
675
676 class CWindowProjectorBottom : public BC_Button
677 {
678 public:
679         CWindowProjectorBottom(MWindow *mwindow, CWindowProjectorGUI *gui,
680                         int x, int y);
681         int handle_event();
682         MWindow *mwindow;
683         CWindowProjectorGUI *gui;
684 };
685
686
687
688
689 class CWindowRulerGUI : public CWindowToolGUI
690 {
691 public:
692         CWindowRulerGUI(MWindow *mwindow, CWindowTool *thread);
693         ~CWindowRulerGUI();
694         void create_objects();
695         void update();
696 // Update the gui
697         void handle_event();
698
699         BC_TextBox *current;
700         BC_TextBox *point1;
701         BC_TextBox *point2;
702         BC_TextBox *deltas;
703         BC_TextBox *distance;
704         BC_TextBox *angle;
705 };
706
707
708
709 #endif