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