1 #include "bcdisplayinfo.h"
3 #include "titlewindow.h"
8 PLUGIN_THREAD_OBJECT(TitleMain, TitleThread, TitleWindow)
11 TitleWindow::TitleWindow(TitleMain *client, int x, int y)
12 : BC_Window(client->gui_string,
23 this->client = client;
26 TitleWindow::~TitleWindow()
28 sizes.remove_all_objects();
29 encodings.remove_all_objects();
32 delete color_stroke_thread;
38 int TitleWindow::create_objects()
42 encodings.append(new BC_ListBoxItem("ISO8859-1"));
43 encodings.append(new BC_ListBoxItem("ISO8859-2"));
44 encodings.append(new BC_ListBoxItem("ISO8859-3"));
45 encodings.append(new BC_ListBoxItem("ISO8859-4"));
46 encodings.append(new BC_ListBoxItem("ISO8859-5"));
47 encodings.append(new BC_ListBoxItem("ISO8859-6"));
48 encodings.append(new BC_ListBoxItem("ISO8859-7"));
49 encodings.append(new BC_ListBoxItem("ISO8859-8"));
50 encodings.append(new BC_ListBoxItem("ISO8859-9"));
51 encodings.append(new BC_ListBoxItem("ISO8859-10"));
52 encodings.append(new BC_ListBoxItem("ISO8859-11"));
53 encodings.append(new BC_ListBoxItem("ISO8859-12"));
54 encodings.append(new BC_ListBoxItem("ISO8859-13"));
55 encodings.append(new BC_ListBoxItem("ISO8859-14"));
56 encodings.append(new BC_ListBoxItem("ISO8859-15"));
57 encodings.append(new BC_ListBoxItem("KOI8"));
61 sizes.append(new BC_ListBoxItem("8"));
62 sizes.append(new BC_ListBoxItem("9"));
63 sizes.append(new BC_ListBoxItem("10"));
64 sizes.append(new BC_ListBoxItem("11"));
65 sizes.append(new BC_ListBoxItem("12"));
66 sizes.append(new BC_ListBoxItem("13"));
67 sizes.append(new BC_ListBoxItem("14"));
68 sizes.append(new BC_ListBoxItem("16"));
69 sizes.append(new BC_ListBoxItem("18"));
70 sizes.append(new BC_ListBoxItem("20"));
71 sizes.append(new BC_ListBoxItem("22"));
72 sizes.append(new BC_ListBoxItem("24"));
73 sizes.append(new BC_ListBoxItem("26"));
74 sizes.append(new BC_ListBoxItem("28"));
75 sizes.append(new BC_ListBoxItem("32"));
76 sizes.append(new BC_ListBoxItem("36"));
77 sizes.append(new BC_ListBoxItem("40"));
78 sizes.append(new BC_ListBoxItem("48"));
79 sizes.append(new BC_ListBoxItem("56"));
80 sizes.append(new BC_ListBoxItem("64"));
81 sizes.append(new BC_ListBoxItem("72"));
82 sizes.append(new BC_ListBoxItem("100"));
83 sizes.append(new BC_ListBoxItem("128"));
85 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(NO_MOTION)));
86 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(BOTTOM_TO_TOP)));
87 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(TOP_TO_BOTTOM)));
88 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(RIGHT_TO_LEFT)));
89 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(LEFT_TO_RIGHT)));
93 // Construct font list
94 for(int i = 0; i < client->fonts->total; i++)
97 for(int j = 0; j < fonts.total; j++)
99 if(!strcasecmp(fonts.values[j]->get_text(),
100 client->fonts->values[i]->fixed_title))
107 if(!exists) fonts.append(new
108 BC_ListBoxItem(client->fonts->values[i]->fixed_title));
116 for(int i = 0; i < fonts.total - 1; i++)
118 if(strcmp(fonts.values[i]->get_text(), fonts.values[i + 1]->get_text()) > 0)
120 BC_ListBoxItem *temp = fonts.values[i + 1];
121 fonts.values[i + 1] = fonts.values[i];
122 fonts.values[i] = temp;
139 add_tool(font_title = new BC_Title(x, y, _("Font:")));
140 font = new TitleFont(client, this, x, y + 20);
141 font->create_objects();
143 add_subwindow(font_tumbler = new TitleFontTumble(client, this, x, y + 20));
145 char string[BCTEXTLEN];
146 add_tool(size_title = new BC_Title(x, y, _("Size:")));
147 sprintf(string, "%d", client->config.size);
148 size = new TitleSize(client, this, x, y + 20, string);
149 size->create_objects();
152 add_tool(style_title = new BC_Title(x, y, _("Style:")));
153 add_tool(italic = new TitleItalic(client, this, x, y + 20));
154 add_tool(bold = new TitleBold(client, this, x, y + 50));
156 add_tool(stroke = new TitleStroke(client, this, x, y + 80));
159 add_tool(justify_title = new BC_Title(x, y, _("Justify:")));
160 add_tool(left = new TitleLeft(client, this, x, y + 20));
161 add_tool(center = new TitleCenter(client, this, x, y + 50));
162 add_tool(right = new TitleRight(client, this, x, y + 80));
165 add_tool(top = new TitleTop(client, this, x, y + 20));
166 add_tool(mid = new TitleMid(client, this, x, y + 50));
167 add_tool(bottom= new TitleBottom(client, this, x, y + 80));
174 add_tool(x_title = new BC_Title(x, y, _("X:")));
175 title_x = new TitleX(client, this, x, y + 20);
176 title_x->create_objects();
179 add_tool(y_title = new BC_Title(x, y, _("Y:")));
180 title_y = new TitleY(client, this, x, y + 20);
181 title_y->create_objects();
184 add_tool(motion_title = new BC_Title(x, y, _("Motion type:")));
186 motion = new TitleMotion(client, this, x, y + 20);
187 motion->create_objects();
190 add_tool(loop = new TitleLoop(client, x, y + 20));
196 add_tool(dropshadow_title = new BC_Title(x, y, _("Drop shadow:")));
197 dropshadow = new TitleDropShadow(client, this, x, y + 20);
198 dropshadow->create_objects();
201 add_tool(fadein_title = new BC_Title(x, y, _("Fade in (sec):")));
202 add_tool(fade_in = new TitleFade(client, this, &client->config.fade_in, x, y + 20));
205 add_tool(fadeout_title = new BC_Title(x, y, _("Fade out (sec):")));
206 add_tool(fade_out = new TitleFade(client, this, &client->config.fade_out, x, y + 20));
209 add_tool(speed_title = new BC_Title(x, y, _("Speed:")));
210 speed = new TitleSpeed(client, this, x, y + 20);
211 speed->create_objects();
214 add_tool(color_button = new TitleColorButton(client, this, x, y + 20));
218 color_thread = new TitleColorThread(client, this);
222 add_tool(encoding_title = new BC_Title(x, y + 3, _("Encoding:")));
223 encoding = new TitleEncoding(client, this, x, y + 20);
224 encoding->create_objects();
228 add_tool(strokewidth_title = new BC_Title(x, y, _("Outline width:")));
229 stroke_width = new TitleStrokeW(client,
233 stroke_width->create_objects();
236 add_tool(color_stroke_button = new TitleColorStrokeButton(client,
240 color_stroke_x = color_x;
241 color_stroke_y = y + 20;
242 color_stroke_thread = new TitleColorStrokeThread(client, this);
249 add_tool(text_title = new BC_Title(x, y + 3, _("Text:")));
252 add_tool(timecode = new TitleTimecode(client, x, y));
258 text = new TitleText(client,
263 get_h() - y - 20 - 10);
264 text->create_objects();
273 int TitleWindow::resize_event(int w, int h)
275 client->window_w = w;
276 client->window_h = h;
278 clear_box(0, 0, w, h);
279 font_title->reposition_window(font_title->get_x(), font_title->get_y());
280 font->reposition_window(font->get_x(), font->get_y());
281 font_tumbler->reposition_window(font_tumbler->get_x(), font_tumbler->get_y());
282 x_title->reposition_window(x_title->get_x(), x_title->get_y());
283 title_x->reposition_window(title_x->get_x(), title_x->get_y());
284 y_title->reposition_window(y_title->get_x(), y_title->get_y());
285 title_y->reposition_window(title_y->get_x(), title_y->get_y());
286 style_title->reposition_window(style_title->get_x(), style_title->get_y());
287 italic->reposition_window(italic->get_x(), italic->get_y());
288 bold->reposition_window(bold->get_x(), bold->get_y());
290 stroke->reposition_window(stroke->get_x(), stroke->get_y());
292 size_title->reposition_window(size_title->get_x(), size_title->get_y());
293 size->reposition_window(size->get_x(), size->get_y());
294 encoding_title->reposition_window(encoding_title->get_x(), encoding_title->get_y());
295 encoding->reposition_window(encoding->get_x(), encoding->get_y());
296 color_button->reposition_window(color_button->get_x(), color_button->get_y());
298 color_stroke_button->reposition_window(color_stroke_button->get_x(), color_stroke_button->get_y());
300 motion_title->reposition_window(motion_title->get_x(), motion_title->get_y());
301 motion->reposition_window(motion->get_x(), motion->get_y());
302 loop->reposition_window(loop->get_x(), loop->get_y());
303 dropshadow_title->reposition_window(dropshadow_title->get_x(), dropshadow_title->get_y());
304 dropshadow->reposition_window(dropshadow->get_x(), dropshadow->get_y());
305 fadein_title->reposition_window(fadein_title->get_x(), fadein_title->get_y());
306 fade_in->reposition_window(fade_in->get_x(), fade_in->get_y());
307 fadeout_title->reposition_window(fadeout_title->get_x(), fadeout_title->get_y());
308 fade_out->reposition_window(fade_out->get_x(), fade_out->get_y());
309 text_title->reposition_window(text_title->get_x(), text_title->get_y());
311 stroke_width->reposition_window(stroke_width->get_x(), stroke_width->get_y());
312 strokewidth_title->reposition_window(strokewidth_title->get_x(), strokewidth_title->get_y());
314 timecode->reposition_window(timecode->get_x(), timecode->get_y());
316 text->reposition_window(text->get_x(),
318 w - text->get_x() - 10,
319 BC_TextBox::pixels_to_rows(this, MEDIUMFONT, h - text->get_y() - 10));
323 justify_title->reposition_window(justify_title->get_x(), justify_title->get_y());
324 left->reposition_window(left->get_x(), left->get_y());
325 center->reposition_window(center->get_x(), center->get_y());
326 right->reposition_window(right->get_x(), right->get_y());
327 top->reposition_window(top->get_x(), top->get_y());
328 mid->reposition_window(mid->get_x(), mid->get_y());
329 bottom->reposition_window(bottom->get_x(), bottom->get_y());
330 speed_title->reposition_window(speed_title->get_x(), speed_title->get_y());
331 speed->reposition_window(speed->get_x(), speed->get_y());
339 void TitleWindow::previous_font()
341 int current_font = font->get_number();
343 if(current_font < 0) current_font = fonts.total - 1;
345 if(current_font < 0 || current_font >= fonts.total) return;
347 for(int i = 0; i < fonts.total; i++)
349 fonts.values[i]->set_selected(i == current_font);
352 font->update(fonts.values[current_font]->get_text());
353 strcpy(client->config.font, fonts.values[current_font]->get_text());
354 client->send_configure_change();
357 void TitleWindow::next_font()
359 int current_font = font->get_number();
361 if(current_font >= fonts.total) current_font = 0;
363 if(current_font < 0 || current_font >= fonts.total) return;
365 for(int i = 0; i < fonts.total; i++)
367 fonts.values[i]->set_selected(i == current_font);
370 font->update(fonts.values[current_font]->get_text());
371 strcpy(client->config.font, fonts.values[current_font]->get_text());
372 client->send_configure_change();
376 int TitleWindow::close_event()
378 // Set result to 1 to indicate a client side close
383 void TitleWindow::update_color()
385 //printf("TitleWindow::update_color %x\n", client->config.color);
386 set_color(client->config.color);
387 draw_box(color_x, color_y, 100, 30);
388 flash(color_x, color_y, 100, 30);
390 set_color(client->config.color_stroke);
391 draw_box(color_stroke_x, color_stroke_y, 100, 30);
392 flash(color_stroke_x, color_stroke_y, 100, 30);
396 void TitleWindow::update_justification()
398 left->update(client->config.hjustification == JUSTIFY_LEFT);
399 center->update(client->config.hjustification == JUSTIFY_CENTER);
400 right->update(client->config.hjustification == JUSTIFY_RIGHT);
401 top->update(client->config.vjustification == JUSTIFY_TOP);
402 mid->update(client->config.vjustification == JUSTIFY_MID);
403 bottom->update(client->config.vjustification == JUSTIFY_BOTTOM);
406 void TitleWindow::update()
408 title_x->update((int64_t)client->config.x);
409 title_y->update((int64_t)client->config.y);
410 italic->update(client->config.style & FONT_ITALIC);
411 bold->update(client->config.style & FONT_BOLD);
413 stroke->update(client->config.style & FONT_OUTLINE);
415 size->update(client->config.size);
416 encoding->update(client->config.encoding);
417 motion->update(TitleMain::motion_to_text(client->config.motion_strategy));
418 loop->update(client->config.loop);
419 dropshadow->update((float)client->config.dropshadow);
420 fade_in->update((float)client->config.fade_in);
421 fade_out->update((float)client->config.fade_out);
423 stroke_width->update((float)client->config.stroke_width);
425 font->update(client->config.font);
426 text->update(client->config.text);
427 speed->update(client->config.pixels_per_second);
428 update_justification();
433 TitleFontTumble::TitleFontTumble(TitleMain *client, TitleWindow *window, int x, int y)
436 this->client = client;
437 this->window = window;
439 int TitleFontTumble::handle_up_event()
441 window->previous_font();
445 int TitleFontTumble::handle_down_event()
451 TitleBold::TitleBold(TitleMain *client, TitleWindow *window, int x, int y)
452 : BC_CheckBox(x, y, client->config.style & FONT_BOLD, _("Bold"))
454 this->client = client;
455 this->window = window;
458 int TitleBold::handle_event()
460 client->config.style = (client->config.style & ~FONT_BOLD) | (get_value() ? FONT_BOLD : 0);
461 client->send_configure_change();
465 TitleItalic::TitleItalic(TitleMain *client, TitleWindow *window, int x, int y)
466 : BC_CheckBox(x, y, client->config.style & FONT_ITALIC, _("Italic"))
468 this->client = client;
469 this->window = window;
471 int TitleItalic::handle_event()
473 client->config.style = (client->config.style & ~FONT_ITALIC) | (get_value() ? FONT_ITALIC : 0);
474 client->send_configure_change();
478 TitleStroke::TitleStroke(TitleMain *client, TitleWindow *window, int x, int y)
479 : BC_CheckBox(x, y, client->config.style & FONT_OUTLINE, _("Outline"))
481 this->client = client;
482 this->window = window;
485 int TitleStroke::handle_event()
487 client->config.style =
488 (client->config.style & ~FONT_OUTLINE) |
489 (get_value() ? FONT_OUTLINE : 0);
490 client->send_configure_change();
496 TitleSize::TitleSize(TitleMain *client, TitleWindow *window, int x, int y, char *text)
497 : BC_PopupTextBox(window,
505 this->client = client;
506 this->window = window;
508 TitleSize::~TitleSize()
511 int TitleSize::handle_event()
513 client->config.size = atol(get_text());
514 //printf("TitleSize::handle_event 1 %s\n", get_text());
515 client->send_configure_change();
518 void TitleSize::update(int size)
520 char string[BCTEXTLEN];
521 sprintf(string, "%d", size);
522 BC_PopupTextBox::update(string);
524 TitleEncoding::TitleEncoding(TitleMain *client, TitleWindow *window, int x, int y)
525 : BC_PopupTextBox(window,
527 client->config.encoding,
533 this->client = client;
534 this->window = window;
537 TitleEncoding::~TitleEncoding()
540 int TitleEncoding::handle_event()
542 strcpy(client->config.encoding, get_text());
543 client->send_configure_change();
547 TitleColorButton::TitleColorButton(TitleMain *client, TitleWindow *window, int x, int y)
548 : BC_GenericButton(x, y, _("Color..."))
550 this->client = client;
551 this->window = window;
553 int TitleColorButton::handle_event()
555 window->color_thread->start_window(client->config.color, 0);
559 TitleColorStrokeButton::TitleColorStrokeButton(TitleMain *client, TitleWindow *window, int x, int y)
560 : BC_GenericButton(x, y, _("Outline color..."))
562 this->client = client;
563 this->window = window;
565 int TitleColorStrokeButton::handle_event()
568 window->color_stroke_thread->start_window(client->config.color_stroke, 0);
573 TitleMotion::TitleMotion(TitleMain *client, TitleWindow *window, int x, int y)
574 : BC_PopupTextBox(window,
576 client->motion_to_text(client->config.motion_strategy),
582 this->client = client;
583 this->window = window;
585 int TitleMotion::handle_event()
587 client->config.motion_strategy = client->text_to_motion(get_text());
588 client->send_configure_change();
592 TitleLoop::TitleLoop(TitleMain *client, int x, int y)
593 : BC_CheckBox(x, y, client->config.loop, _("Loop"))
595 this->client = client;
597 int TitleLoop::handle_event()
599 client->config.loop = get_value();
600 client->send_configure_change();
604 TitleTimecode::TitleTimecode(TitleMain *client, int x, int y)
605 : BC_CheckBox(x, y, client->config.timecode, _("Stamp timecode"))
607 this->client = client;
609 int TitleTimecode::handle_event()
611 client->config.timecode = get_value();
612 client->send_configure_change();
616 TitleFade::TitleFade(TitleMain *client,
621 : BC_TextBox(x, y, 90, 1, (float)*value)
623 this->client = client;
624 this->window = window;
628 int TitleFade::handle_event()
630 *value = atof(get_text());
631 client->send_configure_change();
635 TitleFont::TitleFont(TitleMain *client, TitleWindow *window, int x, int y)
636 : BC_PopupTextBox(window,
644 this->client = client;
645 this->window = window;
647 int TitleFont::handle_event()
649 strcpy(client->config.font, get_text());
650 client->send_configure_change();
654 TitleText::TitleText(TitleMain *client,
660 : BC_ScrollTextBox(window,
664 BC_TextBox::pixels_to_rows(window, MEDIUMFONT, h),
667 this->client = client;
668 this->window = window;
669 //printf("TitleText::TitleText %s\n", client->config.text);
672 int TitleText::handle_event()
674 strcpy(client->config.text, get_text());
675 client->send_configure_change();
680 TitleDropShadow::TitleDropShadow(TitleMain *client, TitleWindow *window, int x, int y)
681 : BC_TumbleTextBox(window,
682 (int64_t)client->config.dropshadow,
689 this->client = client;
690 this->window = window;
692 int TitleDropShadow::handle_event()
694 client->config.dropshadow = atol(get_text());
695 client->send_configure_change();
700 TitleX::TitleX(TitleMain *client, TitleWindow *window, int x, int y)
701 : BC_TumbleTextBox(window,
702 (int64_t)client->config.x,
709 this->client = client;
710 this->window = window;
712 int TitleX::handle_event()
714 client->config.x = atol(get_text());
715 client->send_configure_change();
719 TitleY::TitleY(TitleMain *client, TitleWindow *window, int x, int y)
720 : BC_TumbleTextBox(window,
721 (int64_t)client->config.y,
728 this->client = client;
729 this->window = window;
731 int TitleY::handle_event()
733 client->config.y = atol(get_text());
734 client->send_configure_change();
738 TitleStrokeW::TitleStrokeW(TitleMain *client,
742 : BC_TumbleTextBox(window,
743 (float)client->config.stroke_width,
750 this->client = client;
751 this->window = window;
753 int TitleStrokeW::handle_event()
755 client->config.stroke_width = atof(get_text());
756 client->send_configure_change();
761 TitleSpeed::TitleSpeed(TitleMain *client, TitleWindow *window, int x, int y)
762 : BC_TumbleTextBox(window,
763 (float)client->config.pixels_per_second,
770 this->client = client;
774 int TitleSpeed::handle_event()
776 client->config.pixels_per_second = atof(get_text());
777 client->send_configure_change();
787 TitleLeft::TitleLeft(TitleMain *client, TitleWindow *window, int x, int y)
788 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_LEFT, _("Left"))
790 this->client = client;
791 this->window = window;
793 int TitleLeft::handle_event()
795 client->config.hjustification = JUSTIFY_LEFT;
796 window->update_justification();
797 client->send_configure_change();
801 TitleCenter::TitleCenter(TitleMain *client, TitleWindow *window, int x, int y)
802 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_CENTER, _("Center"))
804 this->client = client;
805 this->window = window;
807 int TitleCenter::handle_event()
809 client->config.hjustification = JUSTIFY_CENTER;
810 window->update_justification();
811 client->send_configure_change();
815 TitleRight::TitleRight(TitleMain *client, TitleWindow *window, int x, int y)
816 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_RIGHT, _("Right"))
818 this->client = client;
819 this->window = window;
821 int TitleRight::handle_event()
823 client->config.hjustification = JUSTIFY_RIGHT;
824 window->update_justification();
825 client->send_configure_change();
831 TitleTop::TitleTop(TitleMain *client, TitleWindow *window, int x, int y)
832 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_TOP, _("Top"))
834 this->client = client;
835 this->window = window;
837 int TitleTop::handle_event()
839 client->config.vjustification = JUSTIFY_TOP;
840 window->update_justification();
841 client->send_configure_change();
845 TitleMid::TitleMid(TitleMain *client, TitleWindow *window, int x, int y)
846 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_MID, _("Mid"))
848 this->client = client;
849 this->window = window;
851 int TitleMid::handle_event()
853 client->config.vjustification = JUSTIFY_MID;
854 window->update_justification();
855 client->send_configure_change();
859 TitleBottom::TitleBottom(TitleMain *client, TitleWindow *window, int x, int y)
860 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_BOTTOM, _("Bottom"))
862 this->client = client;
863 this->window = window;
865 int TitleBottom::handle_event()
867 client->config.vjustification = JUSTIFY_BOTTOM;
868 window->update_justification();
869 client->send_configure_change();
875 TitleColorThread::TitleColorThread(TitleMain *client, TitleWindow *window)
878 this->client = client;
879 this->window = window;
882 int TitleColorThread::handle_event(int output)
884 client->config.color = output;
885 window->update_color();
887 client->send_configure_change();
890 TitleColorStrokeThread::TitleColorStrokeThread(TitleMain *client, TitleWindow *window)
893 this->client = client;
894 this->window = window;
897 int TitleColorStrokeThread::handle_event(int output)
899 client->config.color_stroke = output;
900 window->update_color();
902 client->send_configure_change();