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