merge: mask fixes/upgrades, overlay plugin rework, popup menu tweak
[goodguy/history.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 "guicast.h"
28 #include "maskauto.inc"
29 #include "maskautos.inc"
30 #include "mwindow.inc"
31
32
33 class CWindowToolGUI;
34 class CWindowCoord;
35 class CWindowCurveToggle;
36
37
38 // This common thread supports all the tool GUI's.
39 class CWindowTool : public Thread
40 {
41 public:
42         CWindowTool(MWindow *mwindow, CWindowGUI *gui);
43         ~CWindowTool();
44
45 // Called depending on state of toggle button
46         void start_tool(int operation);
47         void stop_tool();
48
49 // Called when window is visible
50         void show_tool();
51         void hide_tool();
52
53         void run();
54         void update_show_window();
55         void raise_window();
56         void update_values();
57
58         MWindow *mwindow;
59         CWindowGUI *gui;
60         CWindowToolGUI *tool_gui;
61         int done;
62         int current_tool;
63         Condition *input_lock;
64         Condition *output_lock;
65 // Lock run and update_values
66         Mutex *tool_gui_lock;
67 };
68
69 class CWindowToolGUI : public BC_Window
70 {
71 public:
72         CWindowToolGUI(MWindow *mwindow,
73                 CWindowTool *thread,
74                 const char *title,
75                 int w,
76                 int h);
77         ~CWindowToolGUI();
78
79         virtual void create_objects() {};
80 // Update the keyframe from text boxes
81         virtual void handle_event() {};
82 // Update text boxes from keyframe here
83         virtual void update() {};
84 // Update EDL and preview only
85         virtual void update_preview() {};
86         int current_operation;
87         int close_event();
88         int keypress_event();
89         int translation_event();
90
91         MWindow *mwindow;
92         CWindowTool *thread;
93         CWindowCoord *event_caller;
94 };
95
96 class CWindowCoord : public BC_TumbleTextBox
97 {
98 public:
99         CWindowCoord(CWindowToolGUI *gui, int x, int y, float value, int logincrement);
100         CWindowCoord(CWindowToolGUI *gui, int x, int y, int value);
101
102 // Calls the window's handle_event
103         int handle_event();
104
105         CWindowToolGUI *gui;
106 };
107
108 class CWindowCropOK : public BC_GenericButton
109 {
110 public:
111         CWindowCropOK(MWindow *mwindow, CWindowToolGUI *gui, 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 CWindowMaskMode : public BC_PopupMenu
132 {
133 public:
134         CWindowMaskMode(MWindow *mwindow, CWindowToolGUI *gui, int x, int y, const char *text);
135         void create_objects();
136         int handle_event();
137         static char* mode_to_text(int mode);
138         int text_to_mode(char *text);
139         MWindow *mwindow;
140         CWindowToolGUI *gui;
141 };
142
143 class CWindowMaskDelete : public BC_GenericButton
144 {
145 public:
146         CWindowMaskDelete(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
147         int handle_event();
148         int keypress_event();
149         MWindow *mwindow;
150         CWindowToolGUI *gui;
151 };
152
153 class CWindowMaskCycleNext : public BC_GenericButton
154 {
155 public:
156         CWindowMaskCycleNext(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
157         int handle_event();
158         MWindow *mwindow;
159         CWindowToolGUI *gui;
160 };
161
162 class CWindowMaskCyclePrev : public BC_GenericButton
163 {
164 public:
165         CWindowMaskCyclePrev(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
166         int handle_event();
167         MWindow *mwindow;
168         CWindowToolGUI *gui;
169 };
170
171 class CWindowMaskNumber : public BC_TumbleTextBox
172 {
173 public:
174         CWindowMaskNumber(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
175         ~CWindowMaskNumber();
176         int handle_event();
177         MWindow *mwindow;
178         CWindowToolGUI *gui;
179 };
180
181
182 class CWindowMaskAffectedPoint : public BC_TumbleTextBox
183 {
184 public:
185         CWindowMaskAffectedPoint(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
186         ~CWindowMaskAffectedPoint();
187         int handle_event();
188         MWindow *mwindow;
189         CWindowToolGUI *gui;
190 };
191
192
193 class CWindowMaskFeather : public BC_TumbleTextBox
194 {
195 public:
196         CWindowMaskFeather(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
197         ~CWindowMaskFeather();
198         int handle_event();
199         MWindow *mwindow;
200         CWindowToolGUI *gui;
201 };
202
203 class CWindowMaskValue : public BC_ISlider
204 {
205 public:
206         CWindowMaskValue(MWindow *mwindow, CWindowToolGUI *gui, int x, int y);
207         ~CWindowMaskValue();
208         int handle_event();
209         MWindow *mwindow;
210         CWindowToolGUI *gui;
211 };
212
213 class CWindowMaskBeforePlugins : public BC_CheckBox
214 {
215 public:
216         CWindowMaskBeforePlugins(CWindowToolGUI *gui, int x, int y);
217         int handle_event();
218         CWindowToolGUI *gui;
219 };
220
221
222
223
224 class CWindowMaskGUI : public CWindowToolGUI
225 {
226 public:
227         CWindowMaskGUI(MWindow *mwindow, CWindowTool *thread);
228         ~CWindowMaskGUI();
229         void create_objects();
230         void update();
231         void handle_event();
232         void get_keyframe(Track* &track, MaskAutos* &autos, MaskAuto* &keyframe,
233                 SubMask* &mask, MaskPoint* &point, int create_it);
234         void update_preview();
235
236         CWindowCoord *x, *y;
237         CWindowMaskMode *mode;
238         CWindowMaskFeather *feather;
239         CWindowMaskDelete *delete_point;
240         CWindowMaskAffectedPoint *active_point;
241 // Not necessary if all keyframes have same points
242 //      CWindowMaskCycleNext *next_point;
243 //      CWindowMaskCyclePrev *prev_point;
244         CWindowMaskNumber *number;
245         CWindowMaskValue *value;
246         CWindowMaskBeforePlugins *apply_before_plugins;
247 };
248
249
250
251 class CWindowEyedropGUI : public CWindowToolGUI
252 {
253 public:
254         CWindowEyedropGUI(MWindow *mwindow, CWindowTool *thread);
255         ~CWindowEyedropGUI();
256
257         void handle_event();
258         void create_objects();
259         void update();
260
261         CWindowCoord *radius;
262         BC_Title *red, *green, *blue, *y, *u, *v;
263         BC_SubWindow *sample;
264 };
265
266
267
268 class CWindowCameraGUI : public CWindowToolGUI
269 {
270 public:
271         CWindowCameraGUI(MWindow *mwindow, CWindowTool *thread);
272         ~CWindowCameraGUI();
273         void create_objects();
274         void update();
275         void update_preview();
276
277 // Update the keyframe from text boxes
278         void handle_event();
279 //      BezierAuto* get_keyframe();
280         CWindowCoord *x, *y, *z;
281 private:
282 // Toggles for keyframe curve mode (for camera automation only)
283         CWindowCurveToggle *t_smooth, *t_linear;
284 };
285
286 class CWindowCameraLeft : public BC_Button
287 {
288 public:
289         CWindowCameraLeft(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y);
290         int handle_event();
291         MWindow *mwindow;
292         CWindowCameraGUI *gui;
293 };
294
295 class CWindowCameraCenter : public BC_Button
296 {
297 public:
298         CWindowCameraCenter(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y);
299         int handle_event();
300         MWindow *mwindow;
301         CWindowCameraGUI *gui;
302 };
303
304 class CWindowCameraRight : public BC_Button
305 {
306 public:
307         CWindowCameraRight(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y);
308         int handle_event();
309         MWindow *mwindow;
310         CWindowCameraGUI *gui;
311 };
312
313 class CWindowCameraTop : public BC_Button
314 {
315 public:
316         CWindowCameraTop(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y);
317         int handle_event();
318         MWindow *mwindow;
319         CWindowCameraGUI *gui;
320 };
321
322 class CWindowCameraMiddle : public BC_Button
323 {
324 public:
325         CWindowCameraMiddle(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y);
326         int handle_event();
327         MWindow *mwindow;
328         CWindowCameraGUI *gui;
329 };
330
331 class CWindowCameraBottom : public BC_Button
332 {
333 public:
334         CWindowCameraBottom(MWindow *mwindow, CWindowCameraGUI *gui, int x, int y);
335         int handle_event();
336         MWindow *mwindow;
337         CWindowCameraGUI *gui;
338 };
339
340 class CWindowProjectorGUI : public CWindowToolGUI
341 {
342 public:
343         CWindowProjectorGUI(MWindow *mwindow, CWindowTool *thread);
344         ~CWindowProjectorGUI();
345         void create_objects();
346         void update();
347         void update_preview();
348         void handle_event();
349 //      BezierAuto* get_keyframe();
350         CWindowCoord *x, *y, *z;
351 private:
352 // Toggles for keyframe curve mode (projector automation only)
353         CWindowCurveToggle *t_smooth, *t_linear;
354 };
355
356 class CWindowProjectorLeft : public BC_Button
357 {
358 public:
359         CWindowProjectorLeft(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y);
360         int handle_event();
361         MWindow *mwindow;
362         CWindowProjectorGUI *gui;
363 };
364
365 class CWindowProjectorCenter : public BC_Button
366 {
367 public:
368         CWindowProjectorCenter(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y);
369         int handle_event();
370         MWindow *mwindow;
371         CWindowProjectorGUI *gui;
372 };
373
374 class CWindowProjectorRight : public BC_Button
375 {
376 public:
377         CWindowProjectorRight(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y);
378         int handle_event();
379         MWindow *mwindow;
380         CWindowProjectorGUI *gui;
381 };
382
383 class CWindowProjectorTop : public BC_Button
384 {
385 public:
386         CWindowProjectorTop(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y);
387         int handle_event();
388         MWindow *mwindow;
389         CWindowProjectorGUI *gui;
390 };
391
392 class CWindowProjectorMiddle : public BC_Button
393 {
394 public:
395         CWindowProjectorMiddle(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y);
396         int handle_event();
397         MWindow *mwindow;
398         CWindowProjectorGUI *gui;
399 };
400
401 class CWindowProjectorBottom : public BC_Button
402 {
403 public:
404         CWindowProjectorBottom(MWindow *mwindow, CWindowProjectorGUI *gui, int x, int y);
405         int handle_event();
406         MWindow *mwindow;
407         CWindowProjectorGUI *gui;
408 };
409
410
411
412
413 class CWindowRulerGUI : public CWindowToolGUI
414 {
415 public:
416         CWindowRulerGUI(MWindow *mwindow, CWindowTool *thread);
417         ~CWindowRulerGUI();
418         void create_objects();
419         void update();
420 // Update the gui
421         void handle_event();
422
423         BC_Title *current;
424         BC_Title *point1;
425         BC_Title *point2;
426         BC_Title *distance;
427         BC_Title *angle;
428 };
429
430
431
432 #endif