9752b5f943f944f2ae87682b5edac64405ab51f4
[goodguy/history.git] / cinelerra-5.1 / plugins / titler / titlerwindow.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 TITLEWINDOW_H
23 #define TITLEWINDOW_H
24
25 #include "guicast.h"
26
27 class TitleThread;
28 class TitleWindow;
29 class TitleInterlace;
30
31 #include "colorpicker.h"
32 #include "filexml.h"
33 #include "mutex.h"
34 #include "titler.h"
35
36 #include <stdarg.h>
37
38 class TitleFontTumble;
39 class TitleSizeTumble;
40 class TitleItalic;
41 class TitleBold;
42 class TitleDrag;
43 class TitleSize;
44 class TitlePitch;
45 class TitleEncoding;
46 class TitleColorButton;
47 class TitleOutlineColorButton;
48 class TitleDropShadow;
49 class TitleMotion;
50 class TitleLoop;
51 class TitleLinePitch;
52 class TitleFade;
53 class TitleFont;
54 class TitleText;
55 class TitleTextChars;
56 class TitleTextBfrSz;
57 class TitleX;
58 class TitleY;
59 class TitleW;
60 class TitleH;
61 class TitleLeft;
62 class TitleCenter;
63 class TitleRight;class TitleTop;
64 class TitleMid;
65 class TitleBottom;
66 class TitleColorThread;
67 class TitleSpeed;
68 class TitleTimecode;
69 class TitleTimecodeFormat;
70 class TitleOutline;
71 class TitleStroker;
72 class TitleBackground;
73 class TitleBackgroundPath;
74 class TitleLoopPlayback;
75 class TitleCurPopup;
76 class TitleCurItem;
77 class TitleCurSubMenu;
78 class TitleCurSubMenuItem;
79 class TitleFontsPopup;
80 class TitleColorPopup;
81 class TitlePngPopup;
82
83 class TitleWindow : public PluginClientWindow
84 {
85 public:
86         TitleWindow(TitleMain *client);
87         ~TitleWindow();
88
89         void create_objects();
90         int resize_event(int w, int h);
91         int grab_event(XEvent *event);
92         void update_color();
93         void update_justification();
94         void update_stats();
95         void update();
96         void previous_font();
97         void next_font();
98         void check_style(const char *font_name, int update);
99         int insert_ibeam(const char *txt, int ofs=0);
100         void done_event(int result);
101         void send_configure_change();
102         int check_configure_change(int ret);
103
104         TitleMain *client;
105
106         BC_Title *font_title;
107         TitleFont *font;
108         TitleFontTumble *font_tumbler;
109         BC_Title *x_title;
110         TitleX *title_x;
111         BC_Title *y_title;
112         TitleY *title_y;
113         BC_Title *w_title;
114         TitleW *title_w;
115         BC_Title *h_title;
116         TitleH *title_h;
117         BC_Title *dropshadow_title;
118         TitleDropShadow *dropshadow;
119         BC_Title *outline_title;
120         TitleOutline *outline;
121         BC_Title *stroker_title;
122         TitleStroker *stroker;
123         BC_Title *style_title;
124         TitleItalic *italic;
125         TitleBold *bold;
126         TitleDrag *drag;
127         TitleCurPopup *cur_popup;
128         TitleFontsPopup *fonts_popup;
129         TitleColorPopup *color_popup;
130         TitlePngPopup *png_popup;
131
132         int color_x, color_y;
133         int outline_color_x, outline_color_y;
134         int drag_dx, drag_dy, dragging;
135         int cur_ibeam, pending_config;
136
137         BC_Title *size_title;
138         TitleSize *size;
139         TitleSizeTumble *size_tumbler;
140         BC_Title *pitch_title;
141         TitlePitch *pitch;
142         BC_Title *encoding_title;
143         TitleEncoding *encoding;
144         TitleColorButton *color_button;
145         TitleColorThread *color_thread;
146         TitleOutlineColorButton *outline_color_button;
147         TitleColorThread *outline_color_thread;
148         BC_Title *motion_title;
149         TitleMotion *motion;
150         TitleLinePitch *line_pitch;
151         TitleLoop *loop;
152         BC_Title *fadein_title;
153         TitleFade *fade_in;
154         BC_Title *fadeout_title;
155         TitleFade *fade_out;
156         BC_Title *text_title;
157         TitleText *text;
158         TitleTextChars *text_chars;
159         TitleTextBfrSz *text_bfrsz;
160         BC_Title *justify_title;
161         TitleLeft *left;
162         TitleCenter *center;
163         TitleRight *right;
164         TitleTop *top;
165         TitleMid *mid;
166         TitleBottom *bottom;
167         BC_Title *speed_title;
168         TitleSpeed *speed;
169         TitleTimecode *timecode;
170         TitleTimecodeFormat *timecode_format;
171         TitleBackground *background;
172         TitleBackgroundPath *background_path;
173         BrowseButton *background_browse;
174         TitleLoopPlayback *loop_playback;
175
176 // Color preview
177         ArrayList<BC_ListBoxItem*> sizes;
178         ArrayList<BC_ListBoxItem*> encodings;
179         ArrayList<BC_ListBoxItem*> paths;
180         ArrayList<BC_ListBoxItem*> fonts;
181 };
182
183
184 class TitleFontTumble : public BC_Tumbler
185 {
186 public:
187         TitleFontTumble(TitleMain *client, TitleWindow *window, int x, int y);
188
189         int handle_up_event();
190         int handle_down_event();
191
192         TitleMain *client;
193         TitleWindow *window;
194 };
195
196
197 class TitleSizeTumble : public BC_Tumbler
198 {
199 public:
200         TitleSizeTumble(TitleMain *client, TitleWindow *window, int x, int y);
201
202         int handle_up_event();
203         int handle_down_event();
204
205         TitleMain *client;
206         TitleWindow *window;
207 };
208
209
210
211 class TitleItalic : public BC_CheckBox
212 {
213 public:
214         TitleItalic(TitleMain *client, TitleWindow *window, int x, int y);
215         int handle_event();
216         TitleMain *client;
217         TitleWindow *window;
218 };
219 class TitleBold : public BC_CheckBox
220 {
221 public:
222         TitleBold(TitleMain *client, TitleWindow *window, int x, int y);
223         int handle_event();
224         TitleMain *client;
225         TitleWindow *window;
226 };
227 class TitleDrag : public BC_CheckBox
228 {
229 public:
230         TitleDrag(TitleMain *client, TitleWindow *window, int x, int y);
231         int handle_event();
232         TitleMain *client;
233         TitleWindow *window;
234 };
235
236
237 class TitleSize : public BC_PopupTextBox
238 {
239 public:
240         TitleSize(TitleMain *client, TitleWindow *window, int x, int y, char *text);
241         ~TitleSize();
242         int handle_event();
243         void update(int size);
244         TitleMain *client;
245         TitleWindow *window;
246 };
247
248 class TitlePitch : public BC_TumbleTextBox
249 {
250 public:
251         TitlePitch(TitleMain *client, TitleWindow *window, int x, int y, int *value);
252         ~TitlePitch();
253         int handle_event();
254
255         int *value;
256         TitleMain *client;
257         TitleWindow *window;
258 };
259
260 class TitleEncoding : public BC_PopupTextBox
261 {
262 public:
263         TitleEncoding(TitleMain *client, TitleWindow *window, int x, int y, char *text);
264         ~TitleEncoding();
265         int handle_event();
266         TitleMain *client;
267         TitleWindow *window;
268 };
269
270 class TitleColorButton : public BC_GenericButton
271 {
272 public:
273         TitleColorButton(TitleMain *client, TitleWindow *window, int x, int y);
274         int handle_event();
275         TitleMain *client;
276         TitleWindow *window;
277 };
278 class TitleOutlineColorButton : public BC_GenericButton
279 {
280 public:
281         TitleOutlineColorButton(TitleMain *client, TitleWindow *window, int x, int y);
282         int handle_event();
283         TitleMain *client;
284         TitleWindow *window;
285 };
286
287 class TitleMotion : public BC_PopupTextBox
288 {
289 public:
290         TitleMotion(TitleMain *client, TitleWindow *window, int x, int y);
291         int handle_event();
292         TitleMain *client;
293         TitleWindow *window;
294 };
295 class TitleLoop : public BC_CheckBox
296 {
297 public:
298         TitleLoop(TitleMain *client, TitleWindow *window, int x, int y);
299         int handle_event();
300         TitleMain *client;
301         TitleWindow *window;
302 };
303 class TitleLinePitch : public BC_CheckBox
304 {
305 public:
306         TitleLinePitch(TitleMain *client, TitleWindow *window, int x, int y);
307         int handle_event();
308         TitleMain *client;
309         TitleWindow *window;
310 };
311
312 class TitleTimecode : public BC_CheckBox
313 {
314 public:
315         TitleTimecode(TitleMain *client, TitleWindow *window, int x, int y);
316         int handle_event();
317         TitleMain *client;
318         TitleWindow *window;
319 };
320
321 class TitleTimecodeFormat : public BC_PopupMenu
322 {
323 public:
324         TitleTimecodeFormat(TitleMain *client, TitleWindow *window, int x, int y, const char *text);
325         void create_objects();
326         int update(int timecode_format);
327         int handle_event();
328         TitleMain *client;
329         TitleWindow *window;
330 };
331
332 class TitleFade : public BC_TextBox
333 {
334 public:
335         TitleFade(TitleMain *client, TitleWindow *window, double *value, int x, int y);
336         int handle_event();
337         TitleMain *client;
338         TitleWindow *window;
339         double *value;
340 };
341 class TitleFont : public BC_PopupTextBox
342 {
343 public:
344         TitleFont(TitleMain *client, TitleWindow *window, int x, int y);
345         int handle_event();
346         TitleMain *client;
347         TitleWindow *window;
348 };
349 class TitleText : public BC_ScrollTextBox
350 {
351 public:
352         TitleText(TitleMain *client,
353                 TitleWindow *window,
354                 int x,
355                 int y,
356                 int w,
357                 int h);
358         int handle_event();
359         int button_press_event();
360         TitleMain *client;
361         TitleWindow *window;
362 };
363 class TitleTextChars : public BC_Title
364 {
365 public:
366         int update(int n);
367         TitleTextChars(int x, int y, int w);
368         ~TitleTextChars();
369 };
370 class TitleTextBfrSz : public BC_Title
371 {
372 public:
373         int update(int n);
374         TitleTextBfrSz(int x, int y, int w);
375         ~TitleTextBfrSz();
376 };
377
378 class TitleX : public BC_TumbleTextBox
379 {
380 public:
381         TitleX(TitleMain *client, TitleWindow *window, int x, int y);
382         int handle_event();
383         TitleMain *client;
384         TitleWindow *window;
385 };
386 class TitleY : public BC_TumbleTextBox
387 {
388 public:
389         TitleY(TitleMain *client, TitleWindow *window, int x, int y);
390         int handle_event();
391         TitleMain *client;
392         TitleWindow *window;
393 };
394 class TitleW : public BC_TumbleTextBox
395 {
396 public:
397         TitleW(TitleMain *client, TitleWindow *window, int x, int y);
398         int handle_event();
399         TitleMain *client;
400         TitleWindow *window;
401 };
402 class TitleH : public BC_TumbleTextBox
403 {
404 public:
405         TitleH(TitleMain *client, TitleWindow *window, int x, int y);
406         int handle_event();
407         TitleMain *client;
408         TitleWindow *window;
409 };
410
411 class TitleDropShadow : public BC_TumbleTextBox
412 {
413 public:
414         TitleDropShadow(TitleMain *client, TitleWindow *window, int x, int y);
415         int handle_event();
416         TitleMain *client;
417         TitleWindow *window;
418 };
419
420 class TitleOutline : public BC_TumbleTextBox
421 {
422 public:
423         TitleOutline(TitleMain *client, TitleWindow *window, int x, int y);
424         int handle_event();
425         TitleMain *client;
426         TitleWindow *window;
427 };
428
429 class TitleStroker : public BC_TumbleTextBox
430 {
431 public:
432         TitleStroker(TitleMain *client, TitleWindow *window, int x, int y);
433         int handle_event();
434         TitleMain *client;
435         TitleWindow *window;
436 };
437
438 class TitleSpeed : public BC_TumbleTextBox
439 {
440 public:
441         TitleSpeed(TitleMain *client, TitleWindow *window, int x, int y);
442         int handle_event();
443         TitleMain *client;
444         TitleWindow *window;
445 };
446
447 class TitleLeft : public BC_Radial
448 {
449 public:
450         TitleLeft(TitleMain *client, TitleWindow *window, int x, int y);
451         int handle_event();
452         TitleMain *client;
453         TitleWindow *window;
454 };
455 class TitleCenter : public BC_Radial
456 {
457 public:
458         TitleCenter(TitleMain *client, TitleWindow *window, int x, int y);
459         int handle_event();
460         TitleMain *client;
461         TitleWindow *window;
462 };
463 class TitleRight : public BC_Radial
464 {
465 public:
466         TitleRight(TitleMain *client, TitleWindow *window, int x, int y);
467         int handle_event();
468         TitleMain *client;
469         TitleWindow *window;
470 };
471
472 class TitleTop : public BC_Radial
473 {
474 public:
475         TitleTop(TitleMain *client, TitleWindow *window, int x, int y);
476         int handle_event();
477         TitleMain *client;
478         TitleWindow *window;
479 };
480 class TitleMid : public BC_Radial
481 {
482 public:
483         TitleMid(TitleMain *client, TitleWindow *window, int x, int y);
484         int handle_event();
485         TitleMain *client;
486         TitleWindow *window;
487 };
488 class TitleBottom : public BC_Radial
489 {
490 public:
491         TitleBottom(TitleMain *client, TitleWindow *window, int x, int y);
492         int handle_event();
493         TitleMain *client;
494         TitleWindow *window;
495 };
496 class TitleColorThread : public ColorPicker
497 {
498 public:
499         TitleColorThread(TitleMain *client, TitleWindow *window, int is_outline);
500         virtual int handle_new_color(int output, int alpha);
501         TitleMain *client;
502         TitleWindow *window;
503         int is_outline;
504 };
505 class TitleBackground : public BC_CheckBox
506 {
507 public:
508         TitleBackground(TitleMain *client, TitleWindow *window, int x, int y);
509         int handle_event();
510         TitleMain *client;
511         TitleWindow *window;
512 };
513 class TitleBackgroundPath : public BC_TextBox
514 {
515 public:
516         TitleBackgroundPath(TitleMain *client, TitleWindow *window, int x, int y);
517         int handle_event();
518         TitleMain *client;
519         TitleWindow *window;
520 };
521 class TitleLoopPlayback : public BC_CheckBox
522 {
523 public:
524         TitleLoopPlayback(TitleMain *client, TitleWindow *window, int x, int y);
525         int handle_event();
526         TitleMain *client;
527         TitleWindow *window;
528 };
529
530
531 class TitleCurPopup : public BC_PopupMenu
532 {
533 public:
534         TitleCurPopup(TitleMain *client, TitleWindow *window);
535
536         int handle_event();
537         void create_objects();
538
539         TitleMain *client;
540         TitleWindow *window;
541 };
542
543 class TitleCurItem : public BC_MenuItem
544 {
545 public:
546         TitleCurItem(TitleCurPopup *popup, const char *text);
547
548         int handle_event();
549         TitleCurPopup *popup;
550 };
551
552 enum { POPUP_OFFSET=-1, POPUP_NONE=0, POPUP_FONT, POPUP_COLOR, POPUP_PNG, };
553
554 class TitleCurSubMenu : public BC_SubMenu
555 {
556 public:
557         TitleCurSubMenu(TitleCurItem *cur_item);
558         ~TitleCurSubMenu();
559         void add_subitemx(int popup_type, va_list ap, const char *fmt);
560         void add_subitem(int popup_type, const char *fmt,...) { va_list ap;
561                 va_start(ap, fmt); add_subitemx(popup_type, ap, fmt); va_end(ap);
562         }
563         void add_subitem(const char *fmt,...) { va_list ap;
564                 va_start(ap, fmt); add_subitemx(POPUP_NONE, ap, fmt); va_end(ap);
565         }
566         TitleCurItem *cur_item;
567 };
568
569 class TitleCurSubMenuItem : public BC_MenuItem
570 {
571 public:
572         TitleCurSubMenuItem(TitleCurSubMenu *submenu, const char *text, int popup_type);
573         ~TitleCurSubMenuItem();
574         int handle_event();
575
576         TitleCurSubMenu *submenu;
577         int popup_type;
578 };
579
580 class TitleFontsPopup : public BC_ListBox
581 {
582 public:
583         TitleFontsPopup(TitleMain *client, TitleWindow *window);
584         ~TitleFontsPopup();
585         int keypress_event();
586         int handle_event();
587         int show_tooltip(const char *text, int x,int y, int w,int h) {
588                 return gui_tooltip(text);
589         }
590
591         TitleMain *client;
592         TitleWindow *window;
593 };
594
595 class TitleColorPopup : public ColorPicker
596 {
597 public:
598         TitleColorPopup(TitleMain *client, TitleWindow *window);
599         ~TitleColorPopup();
600         int handle_new_color(int output, int alpha);
601         void handle_done_event(int result);
602         int activate();
603
604         TitleMain *client;
605         TitleWindow *window;
606         int color_value;
607 };
608
609 class TitlePngPopup : public BC_DialogThread
610 {
611 public:
612         TitlePngPopup(TitleMain *client, TitleWindow *window);
613         ~TitlePngPopup();
614
615         void handle_done_event(int result);
616         BC_Window* new_gui();
617         int activate();
618
619         TitleMain *client;
620         TitleWindow *window;
621 };
622
623 #endif