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