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