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