5654e8825cd7b181f2c76bbdb0a546800780b02d
[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 CWindowMaskSmooth : public BC_GenericButton
327 {
328 public:
329         CWindowMaskSmooth(MWindow *mwindow, CWindowMaskGUI *gui,
330                         int x, int y);
331         int handle_event();
332         MWindow *mwindow;
333         CWindowMaskGUI *gui;
334 };
335
336 class CWindowMaskGangSmooth : public BC_Button
337 {
338 public:
339         CWindowMaskGangSmooth(MWindow *mwindow, CWindowMaskGUI *gui,
340                         int x, int y);
341         int handle_event();
342         MWindow *mwindow;
343         CWindowMaskGUI *gui;
344 };
345
346 class CWindowMaskAffectedPoint : public BC_TumbleTextBox
347 {
348 public:
349         CWindowMaskAffectedPoint(MWindow *mwindow, CWindowMaskGUI *gui,
350                         int x, int y);
351         ~CWindowMaskAffectedPoint();
352         int handle_event();
353         MWindow *mwindow;
354         CWindowMaskGUI *gui;
355 };
356
357 class CWindowMaskFocus : public BC_CheckBox
358 {
359 public:
360         CWindowMaskFocus(MWindow *mwindow, CWindowMaskGUI *gui,
361                         int x, int y);
362         ~CWindowMaskFocus();
363         int handle_event();
364         MWindow *mwindow;
365         CWindowMaskGUI *gui;
366 };
367
368 class CWindowMaskHelp : public BC_CheckBox
369 {
370 public:
371         CWindowMaskHelp(MWindow *mwindow, CWindowMaskGUI *gui,
372                         int x, int y);
373         ~CWindowMaskHelp();
374         int handle_event();
375         MWindow *mwindow;
376         CWindowMaskGUI *gui;
377 };
378
379 class CWindowMaskDrawMarkers : public BC_CheckBox
380 {
381 public:
382         CWindowMaskDrawMarkers(MWindow *mwindow, CWindowMaskGUI *gui,
383                         int x, int y);
384         ~CWindowMaskDrawMarkers();
385         int handle_event();
386         MWindow *mwindow;
387         CWindowMaskGUI *gui;
388 };
389
390 class CWindowMaskDrawBoundary : public BC_CheckBox
391 {
392 public:
393         CWindowMaskDrawBoundary(MWindow *mwindow, CWindowMaskGUI *gui,
394                         int x, int y);
395         ~CWindowMaskDrawBoundary();
396         int handle_event();
397         MWindow *mwindow;
398         CWindowMaskGUI *gui;
399 };
400
401 class CWindowMaskDelPoint : public BC_GenericButton
402 {
403 public:
404         CWindowMaskDelPoint(MWindow *mwindow, CWindowMaskGUI *gui,
405                         int x, int y);
406         int handle_event();
407         int keypress_event();
408         MWindow *mwindow;
409         CWindowMaskGUI *gui;
410 };
411
412 class CWindowMaskFeather : public BC_TumbleTextBox
413 {
414 public:
415         CWindowMaskFeather(MWindow *mwindow, CWindowMaskGUI *gui,
416                         int x, int y);
417         ~CWindowMaskFeather();
418         int update(float v);
419         int update_value(float v);
420         int handle_event();
421         MWindow *mwindow;
422         CWindowMaskGUI *gui;
423 };
424
425 class CWindowMaskFeatherSlider : public BC_FSlider
426 {
427 public:
428         CWindowMaskFeatherSlider(MWindow *mwindow, CWindowMaskGUI *gui,
429                 int x, int y, int w, float v);
430         ~CWindowMaskFeatherSlider();
431         int handle_event();
432         int update(float v);
433         char *get_caption() { return 0; }
434         MWindow *mwindow;
435         CWindowMaskGUI *gui;
436         int stick;
437         float last_v;
438         Timer *timer;
439 };
440
441 class CWindowMaskGangFeather : public BC_Toggle
442 {
443 public:
444         CWindowMaskGangFeather(MWindow *mwindow, CWindowMaskGUI *gui,
445                         int x, int y);
446         ~CWindowMaskGangFeather();
447         int handle_event();
448         MWindow *mwindow;
449         CWindowMaskGUI *gui;
450 };
451
452 class CWindowMaskBeforePlugins : public BC_CheckBox
453 {
454 public:
455         CWindowMaskBeforePlugins(CWindowMaskGUI *gui,
456                         int x, int y);
457         int handle_event();
458         CWindowMaskGUI *gui;
459 };
460
461 class CWindowDisableOpenGLMasking : public BC_CheckBox
462 {
463 public:
464         CWindowDisableOpenGLMasking(CWindowMaskGUI *gui,
465                         int x, int y);
466         int handle_event();
467         CWindowMaskGUI *gui;
468 };
469
470 class CWindowMaskGUI : public CWindowToolGUI
471 {
472 public:
473         CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread);
474         ~CWindowMaskGUI();
475         void create_objects();
476         void update();
477         int close_event();
478         void done_event();
479         void handle_event();
480         void set_focused(int v, float cx, float cy);
481         void update_buttons(MaskAuto *keyframe, int k);
482         int smooth_mask(int gang);
483         void get_keyframe(Track* &track, MaskAutos* &autos, MaskAuto* &keyframe,
484                 SubMask* &mask, MaskPoint* &point, int create_it);
485
486         CWindowMaskOnTrack *mask_on_track;
487         CWindowMaskTrackTumbler *mask_track_tumbler;
488         CWindowMaskName *mask_name;
489         CWindowMaskButton *mask_buttons[SUBMASKS];
490         CWindowMaskThumbler *mask_thumbler;
491         BC_Title *mask_blabels[SUBMASKS];
492         CWindowMaskEnable *mask_enables[SUBMASKS];
493         CWindowMaskSoloTrack *mask_solo_track;
494         CWindowMaskDelMask *del_mask;
495         CWindowMaskUnclear *unclr_mask;
496         CWindowMaskClrMask *clr_mask;
497         CWindowMaskFade *fade;
498         CWindowMaskFadeSlider *fade_slider;
499         CWindowMaskGangFader *gang_fader;
500         CWindowMaskAffectedPoint *active_point;
501         CWindowMaskDelPoint *del_point;
502         CWindowCoord *x, *y;
503         CWindowMaskFocus *focus;
504         int focused;
505         CWindowMaskGangFocus *gang_focus;
506         CWindowMaskSmooth *smooth;
507         CWindowMaskGangSmooth *gang_smooth;
508         CWindowMaskHelp *help;
509         int helped, help_y, help_h;
510         CWindowMaskDrawMarkers *draw_markers;
511         int markers;
512         CWindowMaskDrawBoundary *draw_boundary;
513         int boundary;
514         CWindowCoord *focus_x, *focus_y;
515         CWindowMaskFeather *feather;
516         CWindowMaskFeatherSlider *feather_slider;
517         CWindowMaskGangFeather *gang_feather;
518         CWindowMaskBeforePlugins *apply_before_plugins;
519         CWindowDisableOpenGLMasking *disable_opengl_masking;
520 };
521
522
523 class CWindowEyedropGUI : public CWindowToolGUI
524 {
525 public:
526         CWindowEyedropGUI(MWindow *mwindow, CWindowTool *thread);
527         ~CWindowEyedropGUI();
528
529         void handle_event();
530         void create_objects();
531         void update();
532
533         BC_Title *current;
534         CWindowCoord *radius;
535         CWindowEyedropCheckBox *use_max;
536         BC_Title *red, *green, *blue, *y, *u, *v;
537         BC_Title *rgb_hex, *yuv_hex;
538         BC_SubWindow *sample;
539 };
540
541
542 class CWindowEyedropCheckBox : public BC_CheckBox
543 {
544 public:
545         CWindowEyedropCheckBox(MWindow *mwindow, 
546                 CWindowEyedropGUI *gui,
547                 int x, 
548                 int y);
549
550         int handle_event();
551         MWindow *mwindow;
552         CWindowEyedropGUI *gui;
553 };
554
555
556
557 class CWindowCameraGUI : public CWindowToolGUI
558 {
559 public:
560         CWindowCameraGUI(MWindow *mwindow, CWindowTool *thread);
561         ~CWindowCameraGUI();
562         void create_objects();
563         void update();
564
565 // Update the keyframe from text boxes
566         void handle_event();
567 //      BezierAuto* get_keyframe();
568         CWindowCoord *x, *y, *z;
569 private:
570 // Toggles for keyframe curve mode (for camera automation only)
571         CWindowCurveToggle *t_smooth, *t_linear;
572 };
573
574 class CWindowCameraLeft : public BC_Button
575 {
576 public:
577         CWindowCameraLeft(MWindow *mwindow, CWindowCameraGUI *gui,
578                         int x, int y);
579         int handle_event();
580         MWindow *mwindow;
581         CWindowCameraGUI *gui;
582 };
583
584 class CWindowCameraCenter : public BC_Button
585 {
586 public:
587         CWindowCameraCenter(MWindow *mwindow, CWindowCameraGUI *gui,
588                         int x, int y);
589         int handle_event();
590         MWindow *mwindow;
591         CWindowCameraGUI *gui;
592 };
593
594 class CWindowCameraRight : public BC_Button
595 {
596 public:
597         CWindowCameraRight(MWindow *mwindow, CWindowCameraGUI *gui,
598                         int x, int y);
599         int handle_event();
600         MWindow *mwindow;
601         CWindowCameraGUI *gui;
602 };
603
604 class CWindowCameraTop : public BC_Button
605 {
606 public:
607         CWindowCameraTop(MWindow *mwindow, CWindowCameraGUI *gui,
608                         int x, int y);
609         int handle_event();
610         MWindow *mwindow;
611         CWindowCameraGUI *gui;
612 };
613
614 class CWindowCameraMiddle : public BC_Button
615 {
616 public:
617         CWindowCameraMiddle(MWindow *mwindow, CWindowCameraGUI *gui,
618                         int x, int y);
619         int handle_event();
620         MWindow *mwindow;
621         CWindowCameraGUI *gui;
622 };
623
624 class CWindowCameraBottom : public BC_Button
625 {
626 public:
627         CWindowCameraBottom(MWindow *mwindow, CWindowCameraGUI *gui,
628                         int x, int y);
629         int handle_event();
630         MWindow *mwindow;
631         CWindowCameraGUI *gui;
632 };
633
634 class CWindowProjectorGUI : public CWindowToolGUI
635 {
636 public:
637         CWindowProjectorGUI(MWindow *mwindow, CWindowTool *thread);
638         ~CWindowProjectorGUI();
639         void create_objects();
640         void update();
641         void handle_event();
642 //      BezierAuto* get_keyframe();
643         CWindowCoord *x, *y, *z;
644 private:
645 // Toggles for keyframe curve mode (projector automation only)
646         CWindowCurveToggle *t_smooth, *t_linear;
647 };
648
649 class CWindowProjectorLeft : public BC_Button
650 {
651 public:
652         CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui,
653                         int x, int y);
654         int handle_event();
655         MWindow *mwindow;
656         CWindowProjectorGUI *gui;
657 };
658
659 class CWindowProjectorCenter : public BC_Button
660 {
661 public:
662         CWindowProjectorCenter(MWindow *mwindow, CWindowProjectorGUI *gui,
663                         int x, int y);
664         int handle_event();
665         MWindow *mwindow;
666         CWindowProjectorGUI *gui;
667 };
668
669 class CWindowProjectorRight : public BC_Button
670 {
671 public:
672         CWindowProjectorRight(MWindow *mwindow, CWindowProjectorGUI *gui,
673                         int x, int y);
674         int handle_event();
675         MWindow *mwindow;
676         CWindowProjectorGUI *gui;
677 };
678
679 class CWindowProjectorTop : public BC_Button
680 {
681 public:
682         CWindowProjectorTop(MWindow *mwindow, CWindowProjectorGUI *gui,
683                         int x, int y);
684         int handle_event();
685         MWindow *mwindow;
686         CWindowProjectorGUI *gui;
687 };
688
689 class CWindowProjectorMiddle : public BC_Button
690 {
691 public:
692         CWindowProjectorMiddle(MWindow *mwindow, CWindowProjectorGUI *gui,
693                         int x, int y);
694         int handle_event();
695         MWindow *mwindow;
696         CWindowProjectorGUI *gui;
697 };
698
699 class CWindowProjectorBottom : public BC_Button
700 {
701 public:
702         CWindowProjectorBottom(MWindow *mwindow, CWindowProjectorGUI *gui,
703                         int x, int y);
704         int handle_event();
705         MWindow *mwindow;
706         CWindowProjectorGUI *gui;
707 };
708
709
710
711
712 class CWindowRulerGUI : public CWindowToolGUI
713 {
714 public:
715         CWindowRulerGUI(MWindow *mwindow, CWindowTool *thread);
716         ~CWindowRulerGUI();
717         void create_objects();
718         void update();
719 // Update the gui
720         void handle_event();
721
722         BC_TextBox *current;
723         BC_TextBox *point1;
724         BC_TextBox *point2;
725         BC_TextBox *deltas;
726         BC_TextBox *distance;
727         BC_TextBox *angle;
728 };
729
730
731
732 #endif