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