1 #include "bcdisplayinfo.h"
2 #include "titlewindow.h"
7 #define _(String) gettext(String)
8 #define gettext_noop(String) String
9 #define N_(String) gettext_noop (String)
11 TitleThread::TitleThread(TitleMain *client)
14 this->client = client;
20 TitleThread::~TitleThread()
22 // Window always deleted here
26 void TitleThread::run()
29 window = new TitleWindow(client,
30 info.get_abs_cursor_x() - client->window_w / 2,
31 info.get_abs_cursor_y() - client->window_h / 2);
32 window->create_objects();
34 int result = window->run_window();
36 // Last command executed in thread
37 if(result) client->client_side_close();
48 TitleWindow::TitleWindow(TitleMain *client, int x, int y)
49 : BC_Window(client->gui_string,
60 this->client = client;
63 TitleWindow::~TitleWindow()
65 sizes.remove_all_objects();
66 encodings.remove_all_objects();
69 delete color_stroke_thread;
75 int TitleWindow::create_objects()
79 encodings.append(new BC_ListBoxItem("ISO8859-1"));
80 encodings.append(new BC_ListBoxItem("ISO8859-2"));
81 encodings.append(new BC_ListBoxItem("ISO8859-3"));
82 encodings.append(new BC_ListBoxItem("ISO8859-4"));
83 encodings.append(new BC_ListBoxItem("ISO8859-5"));
84 encodings.append(new BC_ListBoxItem("ISO8859-6"));
85 encodings.append(new BC_ListBoxItem("ISO8859-7"));
86 encodings.append(new BC_ListBoxItem("ISO8859-8"));
87 encodings.append(new BC_ListBoxItem("ISO8859-9"));
88 encodings.append(new BC_ListBoxItem("ISO8859-10"));
89 encodings.append(new BC_ListBoxItem("ISO8859-11"));
90 encodings.append(new BC_ListBoxItem("ISO8859-12"));
91 encodings.append(new BC_ListBoxItem("ISO8859-13"));
92 encodings.append(new BC_ListBoxItem("ISO8859-14"));
93 encodings.append(new BC_ListBoxItem("ISO8859-15"));
94 encodings.append(new BC_ListBoxItem("KOI8"));
98 sizes.append(new BC_ListBoxItem("8"));
99 sizes.append(new BC_ListBoxItem("9"));
100 sizes.append(new BC_ListBoxItem("10"));
101 sizes.append(new BC_ListBoxItem("11"));
102 sizes.append(new BC_ListBoxItem("12"));
103 sizes.append(new BC_ListBoxItem("13"));
104 sizes.append(new BC_ListBoxItem("14"));
105 sizes.append(new BC_ListBoxItem("16"));
106 sizes.append(new BC_ListBoxItem("18"));
107 sizes.append(new BC_ListBoxItem("20"));
108 sizes.append(new BC_ListBoxItem("22"));
109 sizes.append(new BC_ListBoxItem("24"));
110 sizes.append(new BC_ListBoxItem("26"));
111 sizes.append(new BC_ListBoxItem("28"));
112 sizes.append(new BC_ListBoxItem("32"));
113 sizes.append(new BC_ListBoxItem("36"));
114 sizes.append(new BC_ListBoxItem("40"));
115 sizes.append(new BC_ListBoxItem("48"));
116 sizes.append(new BC_ListBoxItem("56"));
117 sizes.append(new BC_ListBoxItem("64"));
118 sizes.append(new BC_ListBoxItem("72"));
119 sizes.append(new BC_ListBoxItem("100"));
120 sizes.append(new BC_ListBoxItem("128"));
122 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(NO_MOTION)));
123 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(BOTTOM_TO_TOP)));
124 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(TOP_TO_BOTTOM)));
125 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(RIGHT_TO_LEFT)));
126 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(LEFT_TO_RIGHT)));
130 // Construct font list
131 for(int i = 0; i < client->fonts->total; i++)
134 for(int j = 0; j < fonts.total; j++)
136 if(!strcasecmp(fonts.values[j]->get_text(),
137 client->fonts->values[i]->fixed_title))
144 if(!exists) fonts.append(new
145 BC_ListBoxItem(client->fonts->values[i]->fixed_title));
153 for(int i = 0; i < fonts.total - 1; i++)
155 if(strcmp(fonts.values[i]->get_text(), fonts.values[i + 1]->get_text()) > 0)
157 BC_ListBoxItem *temp = fonts.values[i + 1];
158 fonts.values[i + 1] = fonts.values[i];
159 fonts.values[i] = temp;
176 add_tool(font_title = new BC_Title(x, y, _("Font:")));
177 font = new TitleFont(client, this, x, y + 20);
178 font->create_objects();
180 add_subwindow(font_tumbler = new TitleFontTumble(client, this, x, y + 20));
182 char string[BCTEXTLEN];
183 add_tool(size_title = new BC_Title(x, y, _("Size:")));
184 sprintf(string, "%d", client->config.size);
185 size = new TitleSize(client, this, x, y + 20, string);
186 size->create_objects();
189 add_tool(style_title = new BC_Title(x, y, _("Style:")));
190 add_tool(italic = new TitleItalic(client, this, x, y + 20));
191 add_tool(bold = new TitleBold(client, this, x, y + 50));
193 add_tool(stroke = new TitleStroke(client, this, x, y + 80));
196 add_tool(justify_title = new BC_Title(x, y, _("Justify:")));
197 add_tool(left = new TitleLeft(client, this, x, y + 20));
198 add_tool(center = new TitleCenter(client, this, x, y + 50));
199 add_tool(right = new TitleRight(client, this, x, y + 80));
202 add_tool(top = new TitleTop(client, this, x, y + 20));
203 add_tool(mid = new TitleMid(client, this, x, y + 50));
204 add_tool(bottom= new TitleBottom(client, this, x, y + 80));
211 add_tool(x_title = new BC_Title(x, y, _("X:")));
212 title_x = new TitleX(client, this, x, y + 20);
213 title_x->create_objects();
216 add_tool(y_title = new BC_Title(x, y, _("Y:")));
217 title_y = new TitleY(client, this, x, y + 20);
218 title_y->create_objects();
221 add_tool(motion_title = new BC_Title(x, y, _("Motion type:")));
223 motion = new TitleMotion(client, this, x, y + 20);
224 motion->create_objects();
227 add_tool(loop = new TitleLoop(client, x, y + 20));
233 add_tool(dropshadow_title = new BC_Title(x, y, _("Drop shadow:")));
234 dropshadow = new TitleDropShadow(client, this, x, y + 20);
235 dropshadow->create_objects();
238 add_tool(fadein_title = new BC_Title(x, y, _("Fade in (sec):")));
239 add_tool(fade_in = new TitleFade(client, this, &client->config.fade_in, x, y + 20));
242 add_tool(fadeout_title = new BC_Title(x, y, _("Fade out (sec):")));
243 add_tool(fade_out = new TitleFade(client, this, &client->config.fade_out, x, y + 20));
246 add_tool(speed_title = new BC_Title(x, y, _("Speed:")));
247 speed = new TitleSpeed(client, this, x, y + 20);
248 speed->create_objects();
251 add_tool(color_button = new TitleColorButton(client, this, x, y + 20));
255 color_thread = new TitleColorThread(client, this);
259 add_tool(encoding_title = new BC_Title(x, y + 3, _("Encoding:")));
260 encoding = new TitleEncoding(client, this, x, y + 20);
261 encoding->create_objects();
265 add_tool(strokewidth_title = new BC_Title(x, y, _("Outline width:")));
266 stroke_width = new TitleStrokeW(client,
270 stroke_width->create_objects();
273 add_tool(color_stroke_button = new TitleColorStrokeButton(client,
277 color_stroke_x = color_x;
278 color_stroke_y = y + 20;
279 color_stroke_thread = new TitleColorStrokeThread(client, this);
286 add_tool(text_title = new BC_Title(x, y + 3, _("Text:")));
289 add_tool(timecode = new TitleTimecode(client, x, y));
295 text = new TitleText(client,
300 get_h() - y - 20 - 10);
301 text->create_objects();
310 int TitleWindow::resize_event(int w, int h)
312 client->window_w = w;
313 client->window_h = h;
315 clear_box(0, 0, w, h);
316 font_title->reposition_window(font_title->get_x(), font_title->get_y());
317 font->reposition_window(font->get_x(), font->get_y());
318 font_tumbler->reposition_window(font_tumbler->get_x(), font_tumbler->get_y());
319 x_title->reposition_window(x_title->get_x(), x_title->get_y());
320 title_x->reposition_window(title_x->get_x(), title_x->get_y());
321 y_title->reposition_window(y_title->get_x(), y_title->get_y());
322 title_y->reposition_window(title_y->get_x(), title_y->get_y());
323 style_title->reposition_window(style_title->get_x(), style_title->get_y());
324 italic->reposition_window(italic->get_x(), italic->get_y());
325 bold->reposition_window(bold->get_x(), bold->get_y());
327 stroke->reposition_window(stroke->get_x(), stroke->get_y());
329 size_title->reposition_window(size_title->get_x(), size_title->get_y());
330 size->reposition_window(size->get_x(), size->get_y());
331 encoding_title->reposition_window(encoding_title->get_x(), encoding_title->get_y());
332 encoding->reposition_window(encoding->get_x(), encoding->get_y());
333 color_button->reposition_window(color_button->get_x(), color_button->get_y());
335 color_stroke_button->reposition_window(color_stroke_button->get_x(), color_stroke_button->get_y());
337 motion_title->reposition_window(motion_title->get_x(), motion_title->get_y());
338 motion->reposition_window(motion->get_x(), motion->get_y());
339 loop->reposition_window(loop->get_x(), loop->get_y());
340 dropshadow_title->reposition_window(dropshadow_title->get_x(), dropshadow_title->get_y());
341 dropshadow->reposition_window(dropshadow->get_x(), dropshadow->get_y());
342 fadein_title->reposition_window(fadein_title->get_x(), fadein_title->get_y());
343 fade_in->reposition_window(fade_in->get_x(), fade_in->get_y());
344 fadeout_title->reposition_window(fadeout_title->get_x(), fadeout_title->get_y());
345 fade_out->reposition_window(fade_out->get_x(), fade_out->get_y());
346 text_title->reposition_window(text_title->get_x(), text_title->get_y());
348 stroke_width->reposition_window(stroke_width->get_x(), stroke_width->get_y());
349 strokewidth_title->reposition_window(strokewidth_title->get_x(), strokewidth_title->get_y());
351 timecode->reposition_window(timecode->get_x(), timecode->get_y());
353 text->reposition_window(text->get_x(),
355 w - text->get_x() - 10,
356 BC_TextBox::pixels_to_rows(this, MEDIUMFONT, h - text->get_y() - 10));
360 justify_title->reposition_window(justify_title->get_x(), justify_title->get_y());
361 left->reposition_window(left->get_x(), left->get_y());
362 center->reposition_window(center->get_x(), center->get_y());
363 right->reposition_window(right->get_x(), right->get_y());
364 top->reposition_window(top->get_x(), top->get_y());
365 mid->reposition_window(mid->get_x(), mid->get_y());
366 bottom->reposition_window(bottom->get_x(), bottom->get_y());
367 speed_title->reposition_window(speed_title->get_x(), speed_title->get_y());
368 speed->reposition_window(speed->get_x(), speed->get_y());
376 void TitleWindow::previous_font()
378 int current_font = font->get_number();
380 if(current_font < 0) current_font = fonts.total - 1;
382 if(current_font < 0 || current_font >= fonts.total) return;
384 for(int i = 0; i < fonts.total; i++)
386 fonts.values[i]->set_selected(i == current_font);
389 font->update(fonts.values[current_font]->get_text());
390 strcpy(client->config.font, fonts.values[current_font]->get_text());
391 client->send_configure_change();
394 void TitleWindow::next_font()
396 int current_font = font->get_number();
398 if(current_font >= fonts.total) current_font = 0;
400 if(current_font < 0 || current_font >= fonts.total) return;
402 for(int i = 0; i < fonts.total; i++)
404 fonts.values[i]->set_selected(i == current_font);
407 font->update(fonts.values[current_font]->get_text());
408 strcpy(client->config.font, fonts.values[current_font]->get_text());
409 client->send_configure_change();
413 int TitleWindow::close_event()
415 // Set result to 1 to indicate a client side close
420 void TitleWindow::update_color()
422 //printf("TitleWindow::update_color %x\n", client->config.color);
423 set_color(client->config.color);
424 draw_box(color_x, color_y, 100, 30);
425 flash(color_x, color_y, 100, 30);
427 set_color(client->config.color_stroke);
428 draw_box(color_stroke_x, color_stroke_y, 100, 30);
429 flash(color_stroke_x, color_stroke_y, 100, 30);
433 void TitleWindow::update_justification()
435 left->update(client->config.hjustification == JUSTIFY_LEFT);
436 center->update(client->config.hjustification == JUSTIFY_CENTER);
437 right->update(client->config.hjustification == JUSTIFY_RIGHT);
438 top->update(client->config.vjustification == JUSTIFY_TOP);
439 mid->update(client->config.vjustification == JUSTIFY_MID);
440 bottom->update(client->config.vjustification == JUSTIFY_BOTTOM);
443 void TitleWindow::update()
445 title_x->update((int64_t)client->config.x);
446 title_y->update((int64_t)client->config.y);
447 italic->update(client->config.style & FONT_ITALIC);
448 bold->update(client->config.style & FONT_BOLD);
450 stroke->update(client->config.style & FONT_OUTLINE);
452 size->update(client->config.size);
453 encoding->update(client->config.encoding);
454 motion->update(TitleMain::motion_to_text(client->config.motion_strategy));
455 loop->update(client->config.loop);
456 dropshadow->update((float)client->config.dropshadow);
457 fade_in->update((float)client->config.fade_in);
458 fade_out->update((float)client->config.fade_out);
460 stroke_width->update((float)client->config.stroke_width);
462 font->update(client->config.font);
463 text->update(client->config.text);
464 speed->update(client->config.pixels_per_second);
465 update_justification();
470 TitleFontTumble::TitleFontTumble(TitleMain *client, TitleWindow *window, int x, int y)
473 this->client = client;
474 this->window = window;
476 int TitleFontTumble::handle_up_event()
478 window->previous_font();
482 int TitleFontTumble::handle_down_event()
488 TitleBold::TitleBold(TitleMain *client, TitleWindow *window, int x, int y)
489 : BC_CheckBox(x, y, client->config.style & FONT_BOLD, _("Bold"))
491 this->client = client;
492 this->window = window;
495 int TitleBold::handle_event()
497 client->config.style = (client->config.style & ~FONT_BOLD) | (get_value() ? FONT_BOLD : 0);
498 client->send_configure_change();
502 TitleItalic::TitleItalic(TitleMain *client, TitleWindow *window, int x, int y)
503 : BC_CheckBox(x, y, client->config.style & FONT_ITALIC, _("Italic"))
505 this->client = client;
506 this->window = window;
508 int TitleItalic::handle_event()
510 client->config.style = (client->config.style & ~FONT_ITALIC) | (get_value() ? FONT_ITALIC : 0);
511 client->send_configure_change();
515 TitleStroke::TitleStroke(TitleMain *client, TitleWindow *window, int x, int y)
516 : BC_CheckBox(x, y, client->config.style & FONT_OUTLINE, _("Outline"))
518 this->client = client;
519 this->window = window;
522 int TitleStroke::handle_event()
524 client->config.style =
525 (client->config.style & ~FONT_OUTLINE) |
526 (get_value() ? FONT_OUTLINE : 0);
527 client->send_configure_change();
533 TitleSize::TitleSize(TitleMain *client, TitleWindow *window, int x, int y, char *text)
534 : BC_PopupTextBox(window,
542 this->client = client;
543 this->window = window;
545 TitleSize::~TitleSize()
548 int TitleSize::handle_event()
550 client->config.size = atol(get_text());
551 //printf("TitleSize::handle_event 1 %s\n", get_text());
552 client->send_configure_change();
555 void TitleSize::update(int size)
557 char string[BCTEXTLEN];
558 sprintf(string, "%d", size);
559 BC_PopupTextBox::update(string);
561 TitleEncoding::TitleEncoding(TitleMain *client, TitleWindow *window, int x, int y)
562 : BC_PopupTextBox(window,
564 client->config.encoding,
570 this->client = client;
571 this->window = window;
574 TitleEncoding::~TitleEncoding()
577 int TitleEncoding::handle_event()
579 strcpy(client->config.encoding, get_text());
580 client->send_configure_change();
584 TitleColorButton::TitleColorButton(TitleMain *client, TitleWindow *window, int x, int y)
585 : BC_GenericButton(x, y, _("Color..."))
587 this->client = client;
588 this->window = window;
590 int TitleColorButton::handle_event()
592 window->color_thread->start_window(client->config.color, 0);
596 TitleColorStrokeButton::TitleColorStrokeButton(TitleMain *client, TitleWindow *window, int x, int y)
597 : BC_GenericButton(x, y, _("Outline color..."))
599 this->client = client;
600 this->window = window;
602 int TitleColorStrokeButton::handle_event()
605 window->color_stroke_thread->start_window(client->config.color_stroke, 0);
610 TitleMotion::TitleMotion(TitleMain *client, TitleWindow *window, int x, int y)
611 : BC_PopupTextBox(window,
613 client->motion_to_text(client->config.motion_strategy),
619 this->client = client;
620 this->window = window;
622 int TitleMotion::handle_event()
624 client->config.motion_strategy = client->text_to_motion(get_text());
625 client->send_configure_change();
629 TitleLoop::TitleLoop(TitleMain *client, int x, int y)
630 : BC_CheckBox(x, y, client->config.loop, _("Loop"))
632 this->client = client;
634 int TitleLoop::handle_event()
636 client->config.loop = get_value();
637 client->send_configure_change();
641 TitleTimecode::TitleTimecode(TitleMain *client, int x, int y)
642 : BC_CheckBox(x, y, client->config.timecode, _("Stamp timecode"))
644 this->client = client;
646 int TitleTimecode::handle_event()
648 client->config.timecode = get_value();
649 client->send_configure_change();
653 TitleFade::TitleFade(TitleMain *client,
658 : BC_TextBox(x, y, 90, 1, (float)*value)
660 this->client = client;
661 this->window = window;
665 int TitleFade::handle_event()
667 *value = atof(get_text());
668 client->send_configure_change();
672 TitleFont::TitleFont(TitleMain *client, TitleWindow *window, int x, int y)
673 : BC_PopupTextBox(window,
681 this->client = client;
682 this->window = window;
684 int TitleFont::handle_event()
686 strcpy(client->config.font, get_text());
687 client->send_configure_change();
691 TitleText::TitleText(TitleMain *client,
697 : BC_ScrollTextBox(window,
701 BC_TextBox::pixels_to_rows(window, MEDIUMFONT, h),
704 this->client = client;
705 this->window = window;
706 //printf("TitleText::TitleText %s\n", client->config.text);
709 int TitleText::handle_event()
711 strcpy(client->config.text, get_text());
712 client->send_configure_change();
717 TitleDropShadow::TitleDropShadow(TitleMain *client, TitleWindow *window, int x, int y)
718 : BC_TumbleTextBox(window,
719 (int64_t)client->config.dropshadow,
726 this->client = client;
727 this->window = window;
729 int TitleDropShadow::handle_event()
731 client->config.dropshadow = atol(get_text());
732 client->send_configure_change();
737 TitleX::TitleX(TitleMain *client, TitleWindow *window, int x, int y)
738 : BC_TumbleTextBox(window,
739 (int64_t)client->config.x,
746 this->client = client;
747 this->window = window;
749 int TitleX::handle_event()
751 client->config.x = atol(get_text());
752 client->send_configure_change();
756 TitleY::TitleY(TitleMain *client, TitleWindow *window, int x, int y)
757 : BC_TumbleTextBox(window,
758 (int64_t)client->config.y,
765 this->client = client;
766 this->window = window;
768 int TitleY::handle_event()
770 client->config.y = atol(get_text());
771 client->send_configure_change();
775 TitleStrokeW::TitleStrokeW(TitleMain *client,
779 : BC_TumbleTextBox(window,
780 (float)client->config.stroke_width,
787 this->client = client;
788 this->window = window;
790 int TitleStrokeW::handle_event()
792 client->config.stroke_width = atof(get_text());
793 client->send_configure_change();
798 TitleSpeed::TitleSpeed(TitleMain *client, TitleWindow *window, int x, int y)
799 : BC_TumbleTextBox(window,
800 (float)client->config.pixels_per_second,
807 this->client = client;
811 int TitleSpeed::handle_event()
813 client->config.pixels_per_second = atof(get_text());
814 client->send_configure_change();
824 TitleLeft::TitleLeft(TitleMain *client, TitleWindow *window, int x, int y)
825 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_LEFT, _("Left"))
827 this->client = client;
828 this->window = window;
830 int TitleLeft::handle_event()
832 client->config.hjustification = JUSTIFY_LEFT;
833 window->update_justification();
834 client->send_configure_change();
838 TitleCenter::TitleCenter(TitleMain *client, TitleWindow *window, int x, int y)
839 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_CENTER, _("Center"))
841 this->client = client;
842 this->window = window;
844 int TitleCenter::handle_event()
846 client->config.hjustification = JUSTIFY_CENTER;
847 window->update_justification();
848 client->send_configure_change();
852 TitleRight::TitleRight(TitleMain *client, TitleWindow *window, int x, int y)
853 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_RIGHT, _("Right"))
855 this->client = client;
856 this->window = window;
858 int TitleRight::handle_event()
860 client->config.hjustification = JUSTIFY_RIGHT;
861 window->update_justification();
862 client->send_configure_change();
868 TitleTop::TitleTop(TitleMain *client, TitleWindow *window, int x, int y)
869 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_TOP, _("Top"))
871 this->client = client;
872 this->window = window;
874 int TitleTop::handle_event()
876 client->config.vjustification = JUSTIFY_TOP;
877 window->update_justification();
878 client->send_configure_change();
882 TitleMid::TitleMid(TitleMain *client, TitleWindow *window, int x, int y)
883 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_MID, _("Mid"))
885 this->client = client;
886 this->window = window;
888 int TitleMid::handle_event()
890 client->config.vjustification = JUSTIFY_MID;
891 window->update_justification();
892 client->send_configure_change();
896 TitleBottom::TitleBottom(TitleMain *client, TitleWindow *window, int x, int y)
897 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_BOTTOM, _("Bottom"))
899 this->client = client;
900 this->window = window;
902 int TitleBottom::handle_event()
904 client->config.vjustification = JUSTIFY_BOTTOM;
905 window->update_justification();
906 client->send_configure_change();
912 TitleColorThread::TitleColorThread(TitleMain *client, TitleWindow *window)
915 this->client = client;
916 this->window = window;
919 int TitleColorThread::handle_event(int output)
921 client->config.color = output;
922 window->update_color();
924 client->send_configure_change();
927 TitleColorStrokeThread::TitleColorStrokeThread(TitleMain *client, TitleWindow *window)
930 this->client = client;
931 this->window = window;
934 int TitleColorStrokeThread::handle_event(int output)
936 client->config.color_stroke = output;
937 window->update_color();
939 client->send_configure_change();