1 #include "bcdisplayinfo.h"
2 #include "titlewindow.h"
6 #define _(String) gettext(String)
7 #define gettext_noop(String) String
8 #define N_(String) gettext_noop (String)
18 PLUGIN_THREAD_OBJECT(TitleMain, TitleThread, TitleWindow)
29 TitleWindow::TitleWindow(TitleMain *client, int x, int y)
30 : BC_Window(client->gui_string,
41 this->client = client;
44 TitleWindow::~TitleWindow()
46 sizes.remove_all_objects();
47 encodings.remove_all_objects();
50 delete color_stroke_thread;
56 int TitleWindow::create_objects()
60 encodings.append(new BC_ListBoxItem("ISO8859-1"));
61 encodings.append(new BC_ListBoxItem("ISO8859-2"));
62 encodings.append(new BC_ListBoxItem("ISO8859-3"));
63 encodings.append(new BC_ListBoxItem("ISO8859-4"));
64 encodings.append(new BC_ListBoxItem("ISO8859-5"));
65 encodings.append(new BC_ListBoxItem("ISO8859-6"));
66 encodings.append(new BC_ListBoxItem("ISO8859-7"));
67 encodings.append(new BC_ListBoxItem("ISO8859-8"));
68 encodings.append(new BC_ListBoxItem("ISO8859-9"));
69 encodings.append(new BC_ListBoxItem("ISO8859-10"));
70 encodings.append(new BC_ListBoxItem("ISO8859-11"));
71 encodings.append(new BC_ListBoxItem("ISO8859-12"));
72 encodings.append(new BC_ListBoxItem("ISO8859-13"));
73 encodings.append(new BC_ListBoxItem("ISO8859-14"));
74 encodings.append(new BC_ListBoxItem("ISO8859-15"));
75 encodings.append(new BC_ListBoxItem("KOI8"));
79 sizes.append(new BC_ListBoxItem("8"));
80 sizes.append(new BC_ListBoxItem("9"));
81 sizes.append(new BC_ListBoxItem("10"));
82 sizes.append(new BC_ListBoxItem("11"));
83 sizes.append(new BC_ListBoxItem("12"));
84 sizes.append(new BC_ListBoxItem("13"));
85 sizes.append(new BC_ListBoxItem("14"));
86 sizes.append(new BC_ListBoxItem("16"));
87 sizes.append(new BC_ListBoxItem("18"));
88 sizes.append(new BC_ListBoxItem("20"));
89 sizes.append(new BC_ListBoxItem("22"));
90 sizes.append(new BC_ListBoxItem("24"));
91 sizes.append(new BC_ListBoxItem("26"));
92 sizes.append(new BC_ListBoxItem("28"));
93 sizes.append(new BC_ListBoxItem("32"));
94 sizes.append(new BC_ListBoxItem("36"));
95 sizes.append(new BC_ListBoxItem("40"));
96 sizes.append(new BC_ListBoxItem("48"));
97 sizes.append(new BC_ListBoxItem("56"));
98 sizes.append(new BC_ListBoxItem("64"));
99 sizes.append(new BC_ListBoxItem("72"));
100 sizes.append(new BC_ListBoxItem("100"));
101 sizes.append(new BC_ListBoxItem("128"));
103 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(NO_MOTION)));
104 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(BOTTOM_TO_TOP)));
105 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(TOP_TO_BOTTOM)));
106 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(RIGHT_TO_LEFT)));
107 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(LEFT_TO_RIGHT)));
111 // Construct font list
112 for(int i = 0; i < client->fonts->total; i++)
115 for(int j = 0; j < fonts.total; j++)
117 if(!strcasecmp(fonts.values[j]->get_text(),
118 client->fonts->values[i]->fixed_title))
125 if(!exists) fonts.append(new
126 BC_ListBoxItem(client->fonts->values[i]->fixed_title));
134 for(int i = 0; i < fonts.total - 1; i++)
136 if(strcmp(fonts.values[i]->get_text(), fonts.values[i + 1]->get_text()) > 0)
138 BC_ListBoxItem *temp = fonts.values[i + 1];
139 fonts.values[i + 1] = fonts.values[i];
140 fonts.values[i] = temp;
157 add_tool(font_title = new BC_Title(x, y, _("Font:")));
158 font = new TitleFont(client, this, x, y + 20);
159 font->create_objects();
161 add_subwindow(font_tumbler = new TitleFontTumble(client, this, x, y + 20));
163 char string[BCTEXTLEN];
164 add_tool(size_title = new BC_Title(x, y, _("Size:")));
165 sprintf(string, "%d", client->config.size);
166 size = new TitleSize(client, this, x, y + 20, string);
167 size->create_objects();
170 add_tool(style_title = new BC_Title(x, y, _("Style:")));
171 add_tool(italic = new TitleItalic(client, this, x, y + 20));
172 add_tool(bold = new TitleBold(client, this, x, y + 50));
174 add_tool(stroke = new TitleStroke(client, this, x, y + 80));
177 add_tool(justify_title = new BC_Title(x, y, _("Justify:")));
178 add_tool(left = new TitleLeft(client, this, x, y + 20));
179 add_tool(center = new TitleCenter(client, this, x, y + 50));
180 add_tool(right = new TitleRight(client, this, x, y + 80));
183 add_tool(top = new TitleTop(client, this, x, y + 20));
184 add_tool(mid = new TitleMid(client, this, x, y + 50));
185 add_tool(bottom= new TitleBottom(client, this, x, y + 80));
192 add_tool(x_title = new BC_Title(x, y, _("X:")));
193 title_x = new TitleX(client, this, x, y + 20);
194 title_x->create_objects();
197 add_tool(y_title = new BC_Title(x, y, _("Y:")));
198 title_y = new TitleY(client, this, x, y + 20);
199 title_y->create_objects();
202 add_tool(motion_title = new BC_Title(x, y, _("Motion type:")));
204 motion = new TitleMotion(client, this, x, y + 20);
205 motion->create_objects();
208 add_tool(loop = new TitleLoop(client, x, y + 20));
214 add_tool(dropshadow_title = new BC_Title(x, y, _("Drop shadow:")));
215 dropshadow = new TitleDropShadow(client, this, x, y + 20);
216 dropshadow->create_objects();
219 add_tool(fadein_title = new BC_Title(x, y, _("Fade in (sec):")));
220 add_tool(fade_in = new TitleFade(client, this, &client->config.fade_in, x, y + 20));
223 add_tool(fadeout_title = new BC_Title(x, y, _("Fade out (sec):")));
224 add_tool(fade_out = new TitleFade(client, this, &client->config.fade_out, x, y + 20));
227 add_tool(speed_title = new BC_Title(x, y, _("Speed:")));
228 speed = new TitleSpeed(client, this, x, y + 20);
229 speed->create_objects();
232 add_tool(color_button = new TitleColorButton(client, this, x, y + 20));
236 color_thread = new TitleColorThread(client, this);
240 add_tool(encoding_title = new BC_Title(x, y + 3, _("Encoding:")));
241 encoding = new TitleEncoding(client, this, x, y + 20);
242 encoding->create_objects();
246 add_tool(strokewidth_title = new BC_Title(x, y, _("Outline width:")));
247 stroke_width = new TitleStrokeW(client,
251 stroke_width->create_objects();
254 add_tool(color_stroke_button = new TitleColorStrokeButton(client,
258 color_stroke_x = color_x;
259 color_stroke_y = y + 20;
260 color_stroke_thread = new TitleColorStrokeThread(client, this);
267 add_tool(text_title = new BC_Title(x, y + 3, _("Text:")));
270 add_tool(timecode = new TitleTimecode(client, x, y));
276 text = new TitleText(client,
281 get_h() - y - 20 - 10);
282 text->create_objects();
291 int TitleWindow::resize_event(int w, int h)
293 client->window_w = w;
294 client->window_h = h;
296 clear_box(0, 0, w, h);
297 font_title->reposition_window(font_title->get_x(), font_title->get_y());
298 font->reposition_window(font->get_x(), font->get_y());
299 font_tumbler->reposition_window(font_tumbler->get_x(), font_tumbler->get_y());
300 x_title->reposition_window(x_title->get_x(), x_title->get_y());
301 title_x->reposition_window(title_x->get_x(), title_x->get_y());
302 y_title->reposition_window(y_title->get_x(), y_title->get_y());
303 title_y->reposition_window(title_y->get_x(), title_y->get_y());
304 style_title->reposition_window(style_title->get_x(), style_title->get_y());
305 italic->reposition_window(italic->get_x(), italic->get_y());
306 bold->reposition_window(bold->get_x(), bold->get_y());
308 stroke->reposition_window(stroke->get_x(), stroke->get_y());
310 size_title->reposition_window(size_title->get_x(), size_title->get_y());
311 size->reposition_window(size->get_x(), size->get_y());
312 encoding_title->reposition_window(encoding_title->get_x(), encoding_title->get_y());
313 encoding->reposition_window(encoding->get_x(), encoding->get_y());
314 color_button->reposition_window(color_button->get_x(), color_button->get_y());
316 color_stroke_button->reposition_window(color_stroke_button->get_x(), color_stroke_button->get_y());
318 motion_title->reposition_window(motion_title->get_x(), motion_title->get_y());
319 motion->reposition_window(motion->get_x(), motion->get_y());
320 loop->reposition_window(loop->get_x(), loop->get_y());
321 dropshadow_title->reposition_window(dropshadow_title->get_x(), dropshadow_title->get_y());
322 dropshadow->reposition_window(dropshadow->get_x(), dropshadow->get_y());
323 fadein_title->reposition_window(fadein_title->get_x(), fadein_title->get_y());
324 fade_in->reposition_window(fade_in->get_x(), fade_in->get_y());
325 fadeout_title->reposition_window(fadeout_title->get_x(), fadeout_title->get_y());
326 fade_out->reposition_window(fade_out->get_x(), fade_out->get_y());
327 text_title->reposition_window(text_title->get_x(), text_title->get_y());
329 stroke_width->reposition_window(stroke_width->get_x(), stroke_width->get_y());
330 strokewidth_title->reposition_window(strokewidth_title->get_x(), strokewidth_title->get_y());
332 timecode->reposition_window(timecode->get_x(), timecode->get_y());
334 text->reposition_window(text->get_x(),
336 w - text->get_x() - 10,
337 BC_TextBox::pixels_to_rows(this, MEDIUMFONT, h - text->get_y() - 10));
341 justify_title->reposition_window(justify_title->get_x(), justify_title->get_y());
342 left->reposition_window(left->get_x(), left->get_y());
343 center->reposition_window(center->get_x(), center->get_y());
344 right->reposition_window(right->get_x(), right->get_y());
345 top->reposition_window(top->get_x(), top->get_y());
346 mid->reposition_window(mid->get_x(), mid->get_y());
347 bottom->reposition_window(bottom->get_x(), bottom->get_y());
348 speed_title->reposition_window(speed_title->get_x(), speed_title->get_y());
349 speed->reposition_window(speed->get_x(), speed->get_y());
357 void TitleWindow::previous_font()
359 int current_font = font->get_number();
361 if(current_font < 0) current_font = fonts.total - 1;
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();
375 void TitleWindow::next_font()
377 int current_font = font->get_number();
379 if(current_font >= fonts.total) current_font = 0;
381 if(current_font < 0 || current_font >= fonts.total) return;
383 for(int i = 0; i < fonts.total; i++)
385 fonts.values[i]->set_selected(i == current_font);
388 font->update(fonts.values[current_font]->get_text());
389 strcpy(client->config.font, fonts.values[current_font]->get_text());
390 client->send_configure_change();
394 int TitleWindow::close_event()
396 // Set result to 1 to indicate a client side close
401 void TitleWindow::update_color()
403 //printf("TitleWindow::update_color %x\n", client->config.color);
404 set_color(client->config.color);
405 draw_box(color_x, color_y, 100, 30);
406 flash(color_x, color_y, 100, 30);
408 set_color(client->config.color_stroke);
409 draw_box(color_stroke_x, color_stroke_y, 100, 30);
410 flash(color_stroke_x, color_stroke_y, 100, 30);
414 void TitleWindow::update_justification()
416 left->update(client->config.hjustification == JUSTIFY_LEFT);
417 center->update(client->config.hjustification == JUSTIFY_CENTER);
418 right->update(client->config.hjustification == JUSTIFY_RIGHT);
419 top->update(client->config.vjustification == JUSTIFY_TOP);
420 mid->update(client->config.vjustification == JUSTIFY_MID);
421 bottom->update(client->config.vjustification == JUSTIFY_BOTTOM);
424 void TitleWindow::update()
426 title_x->update((int64_t)client->config.x);
427 title_y->update((int64_t)client->config.y);
428 italic->update(client->config.style & FONT_ITALIC);
429 bold->update(client->config.style & FONT_BOLD);
431 stroke->update(client->config.style & FONT_OUTLINE);
433 size->update(client->config.size);
434 encoding->update(client->config.encoding);
435 motion->update(TitleMain::motion_to_text(client->config.motion_strategy));
436 loop->update(client->config.loop);
437 dropshadow->update((float)client->config.dropshadow);
438 fade_in->update((float)client->config.fade_in);
439 fade_out->update((float)client->config.fade_out);
441 stroke_width->update((float)client->config.stroke_width);
443 font->update(client->config.font);
444 text->update(client->config.text);
445 speed->update(client->config.pixels_per_second);
446 update_justification();
451 TitleFontTumble::TitleFontTumble(TitleMain *client, TitleWindow *window, int x, int y)
454 this->client = client;
455 this->window = window;
457 int TitleFontTumble::handle_up_event()
459 window->previous_font();
463 int TitleFontTumble::handle_down_event()
469 TitleBold::TitleBold(TitleMain *client, TitleWindow *window, int x, int y)
470 : BC_CheckBox(x, y, client->config.style & FONT_BOLD, _("Bold"))
472 this->client = client;
473 this->window = window;
476 int TitleBold::handle_event()
478 client->config.style = (client->config.style & ~FONT_BOLD) | (get_value() ? FONT_BOLD : 0);
479 client->send_configure_change();
483 TitleItalic::TitleItalic(TitleMain *client, TitleWindow *window, int x, int y)
484 : BC_CheckBox(x, y, client->config.style & FONT_ITALIC, _("Italic"))
486 this->client = client;
487 this->window = window;
489 int TitleItalic::handle_event()
491 client->config.style = (client->config.style & ~FONT_ITALIC) | (get_value() ? FONT_ITALIC : 0);
492 client->send_configure_change();
496 TitleStroke::TitleStroke(TitleMain *client, TitleWindow *window, int x, int y)
497 : BC_CheckBox(x, y, client->config.style & FONT_OUTLINE, _("Outline"))
499 this->client = client;
500 this->window = window;
503 int TitleStroke::handle_event()
505 client->config.style =
506 (client->config.style & ~FONT_OUTLINE) |
507 (get_value() ? FONT_OUTLINE : 0);
508 client->send_configure_change();
514 TitleSize::TitleSize(TitleMain *client, TitleWindow *window, int x, int y, char *text)
515 : BC_PopupTextBox(window,
523 this->client = client;
524 this->window = window;
526 TitleSize::~TitleSize()
529 int TitleSize::handle_event()
531 client->config.size = atol(get_text());
532 //printf("TitleSize::handle_event 1 %s\n", get_text());
533 client->send_configure_change();
536 void TitleSize::update(int size)
538 char string[BCTEXTLEN];
539 sprintf(string, "%d", size);
540 BC_PopupTextBox::update(string);
542 TitleEncoding::TitleEncoding(TitleMain *client, TitleWindow *window, int x, int y)
543 : BC_PopupTextBox(window,
545 client->config.encoding,
551 this->client = client;
552 this->window = window;
555 TitleEncoding::~TitleEncoding()
558 int TitleEncoding::handle_event()
560 strcpy(client->config.encoding, get_text());
561 client->send_configure_change();
565 TitleColorButton::TitleColorButton(TitleMain *client, TitleWindow *window, int x, int y)
566 : BC_GenericButton(x, y, _("Color..."))
568 this->client = client;
569 this->window = window;
571 int TitleColorButton::handle_event()
573 window->color_thread->start_window(client->config.color, 0);
577 TitleColorStrokeButton::TitleColorStrokeButton(TitleMain *client, TitleWindow *window, int x, int y)
578 : BC_GenericButton(x, y, _("Outline color..."))
580 this->client = client;
581 this->window = window;
583 int TitleColorStrokeButton::handle_event()
586 window->color_stroke_thread->start_window(client->config.color_stroke, 0);
591 TitleMotion::TitleMotion(TitleMain *client, TitleWindow *window, int x, int y)
592 : BC_PopupTextBox(window,
594 client->motion_to_text(client->config.motion_strategy),
600 this->client = client;
601 this->window = window;
603 int TitleMotion::handle_event()
605 client->config.motion_strategy = client->text_to_motion(get_text());
606 client->send_configure_change();
610 TitleLoop::TitleLoop(TitleMain *client, int x, int y)
611 : BC_CheckBox(x, y, client->config.loop, _("Loop"))
613 this->client = client;
615 int TitleLoop::handle_event()
617 client->config.loop = get_value();
618 client->send_configure_change();
622 TitleTimecode::TitleTimecode(TitleMain *client, int x, int y)
623 : BC_CheckBox(x, y, client->config.timecode, _("Stamp timecode"))
625 this->client = client;
627 int TitleTimecode::handle_event()
629 client->config.timecode = get_value();
630 client->send_configure_change();
634 TitleFade::TitleFade(TitleMain *client,
639 : BC_TextBox(x, y, 90, 1, (float)*value)
641 this->client = client;
642 this->window = window;
646 int TitleFade::handle_event()
648 *value = atof(get_text());
649 client->send_configure_change();
653 TitleFont::TitleFont(TitleMain *client, TitleWindow *window, int x, int y)
654 : BC_PopupTextBox(window,
662 this->client = client;
663 this->window = window;
665 int TitleFont::handle_event()
667 strcpy(client->config.font, get_text());
668 client->send_configure_change();
672 TitleText::TitleText(TitleMain *client,
678 : BC_ScrollTextBox(window,
682 BC_TextBox::pixels_to_rows(window, MEDIUMFONT, h),
685 this->client = client;
686 this->window = window;
687 //printf("TitleText::TitleText %s\n", client->config.text);
690 int TitleText::handle_event()
692 strcpy(client->config.text, get_text());
693 client->send_configure_change();
698 TitleDropShadow::TitleDropShadow(TitleMain *client, TitleWindow *window, int x, int y)
699 : BC_TumbleTextBox(window,
700 (int64_t)client->config.dropshadow,
707 this->client = client;
708 this->window = window;
710 int TitleDropShadow::handle_event()
712 client->config.dropshadow = atol(get_text());
713 client->send_configure_change();
718 TitleX::TitleX(TitleMain *client, TitleWindow *window, int x, int y)
719 : BC_TumbleTextBox(window,
720 (int64_t)client->config.x,
727 this->client = client;
728 this->window = window;
730 int TitleX::handle_event()
732 client->config.x = atol(get_text());
733 client->send_configure_change();
737 TitleY::TitleY(TitleMain *client, TitleWindow *window, int x, int y)
738 : BC_TumbleTextBox(window,
739 (int64_t)client->config.y,
746 this->client = client;
747 this->window = window;
749 int TitleY::handle_event()
751 client->config.y = atol(get_text());
752 client->send_configure_change();
756 TitleSpeed::TitleSpeed(TitleMain *client, TitleWindow *window, int x, int y)
757 : BC_TumbleTextBox(window,
758 (float)client->config.pixels_per_second,
765 this->client = client;
769 int TitleSpeed::handle_event()
771 client->config.pixels_per_second = atof(get_text());
772 client->send_configure_change();
782 TitleLeft::TitleLeft(TitleMain *client, TitleWindow *window, int x, int y)
783 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_LEFT, _("Left"))
785 this->client = client;
786 this->window = window;
788 int TitleLeft::handle_event()
790 client->config.hjustification = JUSTIFY_LEFT;
791 window->update_justification();
792 client->send_configure_change();
796 TitleCenter::TitleCenter(TitleMain *client, TitleWindow *window, int x, int y)
797 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_CENTER, _("Center"))
799 this->client = client;
800 this->window = window;
802 int TitleCenter::handle_event()
804 client->config.hjustification = JUSTIFY_CENTER;
805 window->update_justification();
806 client->send_configure_change();
810 TitleRight::TitleRight(TitleMain *client, TitleWindow *window, int x, int y)
811 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_RIGHT, _("Right"))
813 this->client = client;
814 this->window = window;
816 int TitleRight::handle_event()
818 client->config.hjustification = JUSTIFY_RIGHT;
819 window->update_justification();
820 client->send_configure_change();
826 TitleTop::TitleTop(TitleMain *client, TitleWindow *window, int x, int y)
827 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_TOP, _("Top"))
829 this->client = client;
830 this->window = window;
832 int TitleTop::handle_event()
834 client->config.vjustification = JUSTIFY_TOP;
835 window->update_justification();
836 client->send_configure_change();
840 TitleMid::TitleMid(TitleMain *client, TitleWindow *window, int x, int y)
841 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_MID, _("Mid"))
843 this->client = client;
844 this->window = window;
846 int TitleMid::handle_event()
848 client->config.vjustification = JUSTIFY_MID;
849 window->update_justification();
850 client->send_configure_change();
854 TitleBottom::TitleBottom(TitleMain *client, TitleWindow *window, int x, int y)
855 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_BOTTOM, _("Bottom"))
857 this->client = client;
858 this->window = window;
860 int TitleBottom::handle_event()
862 client->config.vjustification = JUSTIFY_BOTTOM;
863 window->update_justification();
864 client->send_configure_change();
870 TitleColorThread::TitleColorThread(TitleMain *client, TitleWindow *window)
873 this->client = client;
874 this->window = window;
877 int TitleColorThread::handle_event(int output)
879 client->config.color = output;
880 window->update_color();
882 client->send_configure_change();