4 * Copyright (C) 1997-2014 Adam Williams <broadcast at earthling dot net>
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.
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.
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
22 #include "bcdisplayinfo.h"
24 #include "bcsignals.h"
25 #include "browsebutton.h"
28 #include "automation.h"
30 #include "cwindowgui.h"
31 #include "dragcheckbox.h"
33 #include "edlsession.h"
36 #include "mainerror.h"
38 #include "mwindowgui.h"
40 #include "pluginserver.h"
44 #include "titlerwindow.h"
45 #include "bcfontentry.h"
47 static const int timeunit_formats[] =
58 TitleWindow::TitleWindow(TitleMain *client)
59 : PluginClientWindow(client,
60 client->config.window_w, client->config.window_h,
63 //printf("TitleWindow::TitleWindow %d %d %d\n", __LINE__, client->config.window_w, client->config.window_h);
64 this->client = client;
69 x_title = 0; title_x = 0;
70 y_title = 0; title_y = 0;
71 w_title = 0; title_w = 0;
72 h_title = 0; title_h = 0;
73 dropshadow_title = 0; dropshadow = 0;
74 outline_title = 0; outline = 0;
75 stroker_title = 0; stroker = 0;
84 drag_dx = drag_dy = dragging = 0;
109 left = 0; center = 0; right = 0;
110 top = 0; mid = 0; bottom = 0;
121 void TitleWindow::done_event(int result)
123 color_button->close_picker();
124 outline_button->close_picker();
125 drag->drag_deactivate();
126 delete color_popup; color_popup = 0;
127 delete png_popup; png_popup = 0;
131 TitleWindow::~TitleWindow()
135 for( int i=0; i<fonts.size(); ++i )
136 delete fonts[i]->get_icon();
138 sizes.remove_all_objects();
139 delete timecode_format;
146 void TitleWindow::create_objects()
148 int x = xS(10), y = yS(10);
149 int margin = client->get_theme()->widget_border;
150 char string[BCTEXTLEN];
152 #define COLOR_W xS(50)
153 #define COLOR_H yS(30)
154 client->build_previews(this);
156 sizes.append(new BC_ListBoxItem("8"));
157 sizes.append(new BC_ListBoxItem("9"));
158 sizes.append(new BC_ListBoxItem("10"));
159 sizes.append(new BC_ListBoxItem("11"));
160 sizes.append(new BC_ListBoxItem("12"));
161 sizes.append(new BC_ListBoxItem("13"));
162 sizes.append(new BC_ListBoxItem("14"));
163 sizes.append(new BC_ListBoxItem("16"));
164 sizes.append(new BC_ListBoxItem("18"));
165 sizes.append(new BC_ListBoxItem("20"));
166 sizes.append(new BC_ListBoxItem("22"));
167 sizes.append(new BC_ListBoxItem("24"));
168 sizes.append(new BC_ListBoxItem("26"));
169 sizes.append(new BC_ListBoxItem("28"));
170 sizes.append(new BC_ListBoxItem("32"));
171 sizes.append(new BC_ListBoxItem("36"));
172 sizes.append(new BC_ListBoxItem("40"));
173 sizes.append(new BC_ListBoxItem("48"));
174 sizes.append(new BC_ListBoxItem("56"));
175 sizes.append(new BC_ListBoxItem("64"));
176 sizes.append(new BC_ListBoxItem("72"));
177 sizes.append(new BC_ListBoxItem("100"));
178 sizes.append(new BC_ListBoxItem("128"));
179 sizes.append(new BC_ListBoxItem("256"));
180 sizes.append(new BC_ListBoxItem("512"));
181 sizes.append(new BC_ListBoxItem("1024"));
183 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(NO_MOTION)));
184 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(BOTTOM_TO_TOP)));
185 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(TOP_TO_BOTTOM)));
186 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(RIGHT_TO_LEFT)));
187 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(LEFT_TO_RIGHT)));
191 // Construct font list
192 ArrayList<BC_FontEntry*> *fontlist = get_resources()->fontlist;
194 for( int i=0; i<fontlist->size(); ++i ) {
196 for( int j=0; j<fonts.size(); ++j ) {
197 if( !strcasecmp(fonts.get(j)->get_text(),
198 fontlist->get(i)->displayname) ) {
204 BC_ListBoxItem *item = 0;
206 fonts.append(item = new
207 BC_ListBoxItem(fontlist->get(i)->displayname));
208 if( !strcmp(client->config.font, item->get_text()) )
209 item->set_selected(1);
210 if( fontlist->values[i]->image ) {
211 VFrame *vframe = fontlist->get(i)->image;
212 BC_Pixmap *icon = new BC_Pixmap(this, vframe, PIXMAP_ALPHA);
213 item->set_icon(icon);
214 item->set_icon_vframe(vframe);
223 for( int i=0; i<fonts.size()-1; ++i ) {
224 if( strcmp(fonts.values[i]->get_text(),
225 fonts.values[i + 1]->get_text()) > 0 ) {
226 BC_ListBoxItem *temp = fonts.values[i + 1];
227 fonts.values[i + 1] = fonts.values[i];
228 fonts.values[i] = temp;
234 add_tool(font_title = new BC_Title(x, y, _("Font:")));
235 font = new TitleFont(client, this, x, y + font_title->get_h());
236 font->create_objects();
237 font->set_show_query(1);
239 add_subwindow(font_tumbler = new TitleFontTumble(client, this, x, y+margin));
240 x += font_tumbler->get_w() + margin;
242 int x1 = x+xS(20), y1 = y;
243 add_tool(size_title = new BC_Title(x1, y1+margin, _("Size:")));
244 sprintf(string, "%.2f", client->config.size);
245 x1 += size_title->get_w() + margin;
246 size = new TitleSize(client, this, x1, y1+margin, string);
247 size->create_objects();
248 int x2 = x1 + size->get_w(), y2 = y1 + size->get_h() + margin;
249 add_subwindow(size_tumbler = new TitleSizeTumble(client, this, x2, y1+margin));
251 add_tool(pitch_title = new BC_Title(x-xS(16), y2+margin, _("Line Pitch:")));
252 pitch = new TitlePitch(client, this, x1, y2+margin, &client->config.line_pitch);
253 pitch->create_objects();
255 int x3 = x2 + size_tumbler->get_w() + xS(50);
256 int y3 = pitch->get_y() + pitch->get_h();
258 add_tool(style_title = new BC_Title(x=x3, y, _("Style:")));
259 add_tool(italic = new TitleItalic(client, this, x, y + yS(20)));
260 int w1 = italic->get_w();
261 add_tool(bold = new TitleBold(client, this, x, y + yS(50)));
262 if( bold->get_w() > w1 ) w1 = bold->get_w();
264 add_tool(drag = new TitleDrag(client, this, x, y + yS(80)));
265 drag->create_objects();
266 if( drag->get_w() > w1 ) w1 = drag->get_w();
267 if( client->config.drag && drag->drag_activate() )
268 eprintf("drag enabled, but compositor already grabbed\n");
270 add_tool(alias = new TitleAlias(client, this, x, y+yS(110)));
271 if( alias->get_w() > w1 ) w1 = drag->get_w();
274 add_tool(justify_title = new BC_Title(x+xS(50), y, _("Justify:")));
275 add_tool(left = new TitleLeft(client, this, x, y + yS(20)));
277 add_tool(center = new TitleCenter(client, this, x, y + yS(50)));
278 if( center->get_w() > w1 ) w1 = center->get_w();
279 add_tool(right = new TitleRight(client, this, x, y + yS(80)));
280 if( right->get_w() > w1 ) w1 = right->get_w();
283 add_tool(top = new TitleTop(client, this, x, y + yS(20)));
284 add_tool(mid = new TitleMid(client, this, x, y + yS(50)));
285 add_tool(bottom= new TitleBottom(client, this, x, y + yS(80)));
290 w1 = BC_Title::calculate_w(this, _("X:"));
291 if( (x1 = BC_Title::calculate_w(this, _("Y:"))) > w1 ) w1 = x1;
292 if( (x1 = BC_Title::calculate_w(this, _("W:"))) > w1 ) w1 = x1;
293 if( (x1 = BC_Title::calculate_w(this, _("H:"))) > w1 ) w1 = x1;
294 add_tool(x_title = new BC_Title(x1=x, y, _("X:")));
296 title_x = new TitleX(client, this, x1, y);
297 title_x->create_objects();
298 x1 += title_x->get_w()+margin;
299 add_tool(y_title = new BC_Title(x1, y, _("Y:")));
301 title_y = new TitleY(client, this, x1, y);
302 title_y->create_objects();
303 x1 += title_y->get_w();
304 y1 = y + title_y->get_h();
306 add_tool(w_title = new BC_Title(x1=x, y1, _("W:")));
308 title_w = new TitleW(client, this, x1, y1);
309 title_w->create_objects();
310 x1 += title_w->get_w()+margin;
311 add_tool(h_title = new BC_Title(x1, y1, _("H:")));
313 title_h = new TitleH(client, this, x1, y1);
314 title_h->create_objects();
315 x1 += title_h->get_w();
318 add_tool(motion_title = new BC_Title(x1=x, y, _("Motion:")));
319 x1 += motion_title->get_w()+margin;
320 motion = new TitleMotion(client, this, x1, y);
321 motion->create_objects();
322 add_tool(loop = new TitleLoop(client, this, x, y1));
323 x = margin; y = y1 + loop->get_h()+yS(20);
325 add_tool(dropshadow_title = new BC_Title(x, y, _("Drop shadow:")));
326 w1 = dropshadow_title->get_w();
327 dropshadow = new TitleDropShadow(client, this, x, y + yS(20));
328 dropshadow->create_objects();
329 if( dropshadow->get_w() > w1 ) w1 = dropshadow->get_w();
332 add_tool(fadein_title = new BC_Title(x, y, _("Fade in (sec):")));
333 w1 = fadein_title->get_w();
334 add_tool(fade_in = new TitleFade(client, this, &client->config.fade_in, x, y + yS(20)));
335 if( fade_in->get_w() > w1 ) w1 = fade_in->get_w();
338 add_tool(fadeout_title = new BC_Title(x, y, _("Fade out (sec):")));
339 w1 = fadeout_title->get_w();
340 add_tool(fade_out = new TitleFade(client, this, &client->config.fade_out, x, y + yS(20)));
341 if( fade_out->get_w() > w1 ) w1 = fade_out->get_w();
344 add_tool(speed_title = new BC_Title(x, y, _("Speed:")));
345 w1 = speed_title->get_w();
346 y += speed_title->get_h() + yS(5); y1 = y;
347 speed = new TitleSpeed(client, this, x, y);
348 speed->create_objects();
349 if( speed->get_w() > w1 ) w1 = speed->get_w();
351 y2 = y + speed->get_h() + yS(10);
353 add_tool(color_button_title = new BC_Title(x3, y1+yS(10), _("Color:")));
354 x1 = x3 + color_button_title->get_w() + xS(30);
355 add_tool(color_button = new TitleColorButton(client, this, x1, y1));
356 y1 += color_button->get_h() + yS(10);
357 add_tool(outline_button_title = new BC_Title(x3, y1+yS(10), _("Outline:")));
358 add_tool(outline_button = new TitleOutlineColorButton(client, this, x1, y1));
361 add_tool(outline_title = new BC_Title(x, y, _("Outline:")));
362 y1 = y + outline_title->get_h() + margin;
363 outline = new TitleOutline(client, this, x, y1);
364 outline->create_objects();
365 x += outline->get_w() + xS(2)*margin;
367 add_tool(stroker_title = new BC_Title(x, y, _("Stroker:")));
368 stroker = new TitleStroker(client, this, x, y1);
369 stroker->create_objects();
370 x += stroker->get_w() + margin;
372 add_tool(timecode = new TitleTimecode(client, this, x, y));
373 y += timecode->get_h() + margin;
375 for( int i=0; i<lengthof(timeunit_formats); ++i ) {
377 Units::print_time_format(timeunit_formats[i], text);
378 int w = get_text_width(MEDIUMFONT, text);
381 add_tool(timecode_format = new TitleTimecodeFormat(client, this, x, y, tw,
382 Units::print_time_format(client->config.timecode_format, string)));
383 timecode_format->create_objects();
384 y += timecode_format->get_h() + margin;
387 add_tool(background = new TitleBackground(client, this, x, y));
388 x += background->get_w() + margin;
389 add_tool(background_path = new TitleBackgroundPath(client, this, x, y));
390 x += background_path->get_w() + margin;
391 add_tool(background_browse = new BrowseButton(
392 client->server->mwindow->theme, this, background_path,
393 x, y, "", _("background media"), _("Select background media path")));
394 x += background_browse->get_w() + xS(3)*margin;
395 add_tool(loop_playback = new TitleLoopPlayback(client, this, x, y));
396 y += loop_playback->get_h() + yS(10);
399 add_tool(text_title = new BC_Title(x, y, _("Text:")));
400 x += text_title->get_w() + xS(20);
401 int wid = BC_Title::calculate_w(this,"0")*xS(10);
402 add_tool(text_chars = new TitleTextChars(x,y,wid));
404 y += text_title->get_h() + margin;
406 text = new TitleText(client, this, x, y, get_w()-margin - x, get_h() - y - yS(10));
407 text->create_objects();
409 add_tool(cur_popup = new TitleCurPopup(client, this));
410 cur_popup->create_objects();
411 add_tool(fonts_popup = new TitleFontsPopup(client, this));
412 color_popup = new TitleColorPopup(client, this);
413 png_popup = new TitlePngPopup(client, this);
419 int TitleWindow::resize_event(int w, int h)
421 client->config.window_w = w;
422 client->config.window_h = h;
424 clear_box(0, 0, w, h);
425 font_title->reposition_window(font_title->get_x(), font_title->get_y());
426 font->reposition_window(font->get_x(), font->get_y());
427 font_tumbler->reposition_window(font_tumbler->get_x(), font_tumbler->get_y());
428 x_title->reposition_window(x_title->get_x(), x_title->get_y());
429 title_x->reposition_window(title_x->get_x(), title_x->get_y());
430 y_title->reposition_window(y_title->get_x(), y_title->get_y());
431 title_y->reposition_window(title_y->get_x(), title_y->get_y());
432 w_title->reposition_window(w_title->get_x(), w_title->get_y());
433 title_w->reposition_window(title_w->get_x(), title_w->get_y());
434 h_title->reposition_window(h_title->get_x(), h_title->get_y());
435 title_h->reposition_window(title_h->get_x(), title_h->get_y());
436 style_title->reposition_window(style_title->get_x(), style_title->get_y());
437 italic->reposition_window(italic->get_x(), italic->get_y());
438 bold->reposition_window(bold->get_x(), bold->get_y());
439 drag->reposition_window(drag->get_x(), drag->get_y());
440 alias->reposition_window(alias->get_x(), alias->get_y());
441 size_title->reposition_window(size_title->get_x(), size_title->get_y());
442 size->reposition_window(size->get_x(), size->get_y());
443 size_tumbler->reposition_window(size_tumbler->get_x(), size_tumbler->get_y());
444 pitch_title->reposition_window(pitch_title->get_x(), pitch_title->get_y());
445 pitch->reposition_window(pitch->get_x(), pitch->get_y());
447 color_button_title->reposition_window(color_button_title->get_x(), color_button_title->get_y());
448 color_button->reposition_window(color_button->get_x(), color_button->get_y());
449 outline_button_title->reposition_window(outline_button_title->get_x(), outline_button_title->get_y());
450 outline_button->reposition_window(outline_button->get_x(), outline_button->get_y());
451 motion_title->reposition_window(motion_title->get_x(), motion_title->get_y());
452 motion->reposition_window(motion->get_x(), motion->get_y());
453 loop->reposition_window(loop->get_x(), loop->get_y());
454 dropshadow_title->reposition_window(dropshadow_title->get_x(), dropshadow_title->get_y());
455 dropshadow->reposition_window(dropshadow->get_x(), dropshadow->get_y());
456 fadein_title->reposition_window(fadein_title->get_x(), fadein_title->get_y());
457 fade_in->reposition_window(fade_in->get_x(), fade_in->get_y());
458 fadeout_title->reposition_window(fadeout_title->get_x(), fadeout_title->get_y());
459 fade_out->reposition_window(fade_out->get_x(), fade_out->get_y());
460 text_title->reposition_window(text_title->get_x(), text_title->get_y());
461 timecode->reposition_window(timecode->get_x(), timecode->get_y());
462 text->reposition_window(text->get_x(), text->get_y(), w - text->get_x() - xS(10),
463 BC_TextBox::pixels_to_rows(this, MEDIUMFONT, h - text->get_y() - yS(10)));
464 justify_title->reposition_window(justify_title->get_x(), justify_title->get_y());
465 left->reposition_window(left->get_x(), left->get_y());
466 center->reposition_window(center->get_x(), center->get_y());
467 right->reposition_window(right->get_x(), right->get_y());
468 top->reposition_window(top->get_x(), top->get_y());
469 mid->reposition_window(mid->get_x(), mid->get_y());
470 bottom->reposition_window(bottom->get_x(), bottom->get_y());
471 speed_title->reposition_window(speed_title->get_x(), speed_title->get_y());
472 speed->reposition_window(speed->get_x(), speed->get_y());
479 void TitleWindow::update_drag()
481 drag->drag_x = client->config.title_x;
482 drag->drag_y = client->config.title_y;
483 drag->drag_w = client->config.title_w;
484 drag->drag_h = client->config.title_h;
485 send_configure_change();
487 void TitleWindow::send_configure_change()
489 client->send_configure_change();
492 void TitleWindow::previous_font()
494 int current_font = font->get_number();
495 if( !fonts.total ) current_font = -1;
496 else if( --current_font < 0 ) current_font = fonts.total - 1;
497 font->set_number(current_font);
499 if( current_font < 0 || current_font >= fonts.total ) return;
501 for( int i=0; i<fonts.total; ++i ) {
502 fonts.values[i]->set_selected(i == current_font);
505 font->update(fonts.values[current_font]->get_text());
506 strcpy(client->config.font, fonts.values[current_font]->get_text());
507 check_style(client->config.font,1);
508 send_configure_change();
511 void TitleWindow::next_font()
513 int current_font = font->get_number();
514 if( !fonts.total ) current_font = -1;
515 else if( ++current_font >= fonts.total ) current_font = 0;
516 font->set_number(current_font);
518 if( current_font < 0 || current_font >= fonts.total ) return;
520 for( int i=0; i<fonts.total; ++i ) {
521 fonts.values[i]->set_selected(i == current_font);
524 font->update(fonts.values[current_font]->get_text());
525 strcpy(client->config.font, fonts.values[current_font]->get_text());
526 check_style(client->config.font,1);
527 send_configure_change();
530 int TitleWindow::insert_ibeam(const char *txt, int ofs)
532 int ibeam = cur_ibeam;
533 int ilen = strlen(txt)+1;
535 int len = BC_Resources::encode(client->config.encoding, BC_Resources::wide_encoding,
536 (char*)txt,ilen, (char *)wtxt,ilen*sizeof(wtxt[0])) / sizeof(wchr_t);
537 client->insert_text(wtxt, ibeam);
538 while( len > 0 && !wtxt[len] ) --len;
539 int adv = len+1 + ofs;
540 if( (ibeam += adv) >= client->config.wlen)
541 ibeam = client->config.wlen;
542 text->wset_selection(-1, -1, ibeam);
543 text->update(client->config.wtext);
544 send_configure_change();
548 void TitleWindow::update_color()
550 color_button->update_gui(client->config.color);
551 outline_button->update_gui(client->config.outline_color);
554 void TitleWindow::update_justification()
556 left->update(client->config.hjustification == JUSTIFY_LEFT);
557 center->update(client->config.hjustification == JUSTIFY_CENTER);
558 right->update(client->config.hjustification == JUSTIFY_RIGHT);
559 top->update(client->config.vjustification == JUSTIFY_TOP);
560 mid->update(client->config.vjustification == JUSTIFY_MID);
561 bottom->update(client->config.vjustification == JUSTIFY_BOTTOM);
564 void TitleWindow::update_stats()
566 text_chars->update(client->config.wlen);
569 void TitleWindow::update_gui()
571 title_x->update((int64_t)client->config.title_x);
572 title_y->update((int64_t)client->config.title_y);
573 title_w->update((int64_t)client->config.title_w);
574 title_h->update((int64_t)client->config.title_h);
575 drag->drag_x = client->config.title_x;
576 drag->drag_y = client->config.title_y;
577 drag->drag_w = client->config.title_w;
578 drag->drag_h = client->config.title_h;
579 italic->update(client->config.style & BC_FONT_ITALIC);
580 bold->update(client->config.style & BC_FONT_BOLD);
581 alias->update(client->config.style & FONT_ALIAS);
582 size->update(client->config.size);
583 motion->update(TitleMain::motion_to_text(client->config.motion_strategy));
584 loop->update(client->config.loop);
585 dropshadow->update((int64_t)client->config.dropshadow);
586 fade_in->update((float)client->config.fade_in);
587 fade_out->update((float)client->config.fade_out);
588 font->update(client->config.font);
589 check_style(client->config.font,0);
590 wchr_t wz[1] = { 0 };
591 text->update(client->config.wtext ? &client->config.wtext[0] : wz);
592 speed->update(client->config.pixels_per_second);
593 outline->update((int64_t)client->config.outline_size);
595 stroker->update((int64_t)client->config.stroke_width);
597 timecode->update(client->config.timecode);
598 timecode_format->update(client->config.timecode_format);
599 background->update(client->config.background);
600 background_path->update(client->config.background_path);
601 loop_playback->update((int64_t)client->config.loop_playback);
603 char string[BCTEXTLEN];
604 for( int i=0; i<lengthof(timeunit_formats); ++i ) {
605 if( timeunit_formats[i] == client->config.timecode_format ) {
606 timecode_format->set_text(
607 Units::print_time_format(timeunit_formats[i], string));
611 update_justification();
617 TitleFontTumble::TitleFontTumble(TitleMain *client, TitleWindow *window, int x, int y)
620 this->client = client;
621 this->window = window;
623 int TitleFontTumble::handle_up_event()
625 window->previous_font();
629 int TitleFontTumble::handle_down_event()
636 TitleSizeTumble::TitleSizeTumble(TitleMain *client, TitleWindow *window, int x, int y)
639 this->client = client;
640 this->window = window;
643 int TitleSizeTumble::handle_up_event()
645 int current_index = -1;
646 int current_difference = -1;
647 for( int i=0; i<window->sizes.size(); ++i ) {
648 int size = atoi(window->sizes.get(i)->get_text());
649 if( current_index < 0 ||
650 abs(size - client->config.size) < current_difference ) {
652 current_difference = abs(size - client->config.size);
657 if( current_index >= window->sizes.size() ) current_index = 0;
660 client->config.size = atoi(window->sizes.get(current_index)->get_text());
661 window->size->update(client->config.size);
662 window->send_configure_change();
666 int TitleSizeTumble::handle_down_event()
668 int current_index = -1;
669 int current_difference = -1;
670 for( int i=0; i<window->sizes.size(); ++i ) {
671 int size = atoi(window->sizes.get(i)->get_text());
672 if( current_index < 0 ||
673 abs(size - client->config.size) < current_difference ) {
675 current_difference = abs(size - client->config.size);
680 if( current_index < 0 ) current_index = window->sizes.size() - 1;
683 client->config.size = atoi(window->sizes.get(current_index)->get_text());
684 window->size->update(client->config.size);
685 window->send_configure_change();
689 TitleAlias::TitleAlias(TitleMain *client, TitleWindow *window, int x, int y)
690 : BC_CheckBox(x, y, client->config.style & FONT_ALIAS, _("Smooth"))
692 this->client = client;
693 this->window = window;
696 int TitleAlias::handle_event()
698 client->config.style =
699 (client->config.style & ~FONT_ALIAS) |
700 (get_value() ? FONT_ALIAS : 0);
701 window->send_configure_change();
705 TitleBold::TitleBold(TitleMain *client, TitleWindow *window, int x, int y)
706 : BC_CheckBox(x, y, client->config.style & BC_FONT_BOLD, _("Bold"))
708 this->client = client;
709 this->window = window;
712 int TitleBold::handle_event()
714 client->config.style =
715 (client->config.style & ~BC_FONT_BOLD) |
716 (get_value() ? BC_FONT_BOLD : 0);
717 window->send_configure_change();
721 TitleItalic::TitleItalic(TitleMain *client, TitleWindow *window, int x, int y)
722 : BC_CheckBox(x, y, client->config.style & BC_FONT_ITALIC, _("Italic"))
724 this->client = client;
725 this->window = window;
727 int TitleItalic::handle_event()
729 client->config.style =
730 (client->config.style & ~BC_FONT_ITALIC) |
731 (get_value() ? BC_FONT_ITALIC : 0);
732 window->send_configure_change();
738 TitleSize::TitleSize(TitleMain *client, TitleWindow *window, int x, int y, char *text)
739 : BC_PopupTextBox(window, &window->sizes, text, x, y, xS(64), yS(300))
741 this->client = client;
742 this->window = window;
744 TitleSize::~TitleSize()
747 int TitleSize::handle_event()
749 client->config.size = atol(get_text());
750 //printf("TitleSize::handle_event 1 %s\n", get_text());
751 window->send_configure_change();
754 void TitleSize::update(int size)
756 char string[BCTEXTLEN];
757 sprintf(string, "%d", size);
758 BC_PopupTextBox::update(string);
762 TitlePitch(TitleMain *client, TitleWindow *window, int x, int y, int *value)
763 : BC_TumbleTextBox(window, *value, 0, INT_MAX, x, y, xS(64))
765 this->client = client;
766 this->window = window;
775 int TitlePitch::handle_event()
777 *value = atol(get_text());
778 window->send_configure_change();
782 TitleColorButton::TitleColorButton(TitleMain *client, TitleWindow *window, int x, int y)
783 : ColorCircleButton(_("Text Color"), x, y, COLOR_W, COLOR_H,
784 client->config.color, client->config.alpha, 1)
786 this->client = client;
787 this->window = window;
789 int TitleColorButton::handle_new_color(int output, int alpha)
791 client->config.color = output;
792 client->config.alpha = alpha;
793 window->send_configure_change();
796 void TitleColorButton::handle_done_event(int result)
799 handle_new_color(orig_color, orig_alpha);
800 window->lock_window("TitleColorButton::handle_done_event");
801 update_gui(orig_color);
802 window->unlock_window();
806 TitleOutlineColorButton::TitleOutlineColorButton(TitleMain *client, TitleWindow *window, int x, int y)
807 : ColorCircleButton(_("Outline Color"), x, y, COLOR_W, COLOR_H,
808 client->config.outline_color, client->config.outline_alpha, 1)
810 this->client = client;
811 this->window = window;
813 int TitleOutlineColorButton::handle_new_color(int output, int alpha)
815 client->config.outline_color = output;
816 client->config.outline_alpha = alpha;
817 window->send_configure_change();
820 void TitleOutlineColorButton::handle_done_event(int result)
823 handle_new_color(orig_color, orig_alpha);
824 window->lock_window("TitleColorButton::handle_done_event");
825 update_gui(orig_color);
826 window->unlock_window();
831 TitleMotion::TitleMotion(TitleMain *client, TitleWindow *window, int x, int y)
832 : BC_PopupTextBox(window, &window->paths,
833 client->motion_to_text(client->config.motion_strategy),
834 x, y, xS(120), yS(100))
836 this->client = client;
837 this->window = window;
839 int TitleMotion::handle_event()
841 client->config.motion_strategy = client->text_to_motion(get_text());
842 window->send_configure_change();
846 TitleLoop::TitleLoop(TitleMain *client, TitleWindow *window, int x, int y)
847 : BC_CheckBox(x, y, client->config.loop, _("Loop"))
849 this->client = client;
850 this->window = window;
852 int TitleLoop::handle_event()
854 client->config.loop = get_value();
855 window->send_configure_change();
858 TitleTimecode::TitleTimecode(TitleMain *client, TitleWindow *window, int x, int y)
859 : BC_CheckBox(x, y, client->config.timecode, _("Stamp timecode"))
861 this->client = client;
862 this->window = window;
864 int TitleTimecode::handle_event()
866 client->config.timecode = get_value();
867 client->send_configure_change();
871 TitleTimecodeFormat::TitleTimecodeFormat(TitleMain *client, TitleWindow *window,
872 int x, int y, int tw, const char *text)
873 : BC_PopupMenu(x, y, BC_PopupMenu::calculate_w(tw)+xS(10), text, 1)
875 this->client = client;
876 this->window = window;
879 int TitleTimecodeFormat::handle_event()
881 client->config.timecode_format = Units::text_to_format(get_text());
882 window->send_configure_change();
886 void TitleTimecodeFormat::create_objects()
888 char string[BCTEXTLEN];
889 for( int i=0; i<lengthof(timeunit_formats); ++i ) {
890 add_item(new BC_MenuItem(
891 Units::print_time_format(timeunit_formats[i], string)));
896 int TitleTimecodeFormat::update(int timecode_format)
898 char string[BCTEXTLEN];
899 for( int i=0; i<lengthof(timeunit_formats); ++i ) {
900 if( timeunit_formats[i] == timecode_format ) {
901 set_text(Units::print_time_format(timeunit_formats[i], string));
908 TitleFade::TitleFade(TitleMain *client, TitleWindow *window,
909 double *value, int x, int y)
910 : BC_TextBox(x, y, xS(80), 1, (float)*value)
912 this->client = client;
913 this->window = window;
918 int TitleFade::handle_event()
920 *value = atof(get_text());
921 window->send_configure_change();
925 void TitleWindow::check_style(const char *font_name, int update)
927 BC_FontEntry *font_nrm = TitleMain::get_font(font_name, 0);
928 BC_FontEntry *font_itl = TitleMain::get_font(font_name, BC_FONT_ITALIC);
929 BC_FontEntry *font_bld = TitleMain::get_font(font_name, BC_FONT_BOLD);
930 BC_FontEntry *font_bit = TitleMain::get_font(font_name, BC_FONT_ITALIC | BC_FONT_BOLD);
931 int has_norm = font_nrm != 0 ? 1 : 0;
932 int has_ital = font_itl != 0 || font_bit != 0 ? 1 : 0;
933 int has_bold = font_bld != 0 || font_bit != 0 ? 1 : 0;
934 if( bold->get_value() ) {
935 if( !has_bold ) bold->update(0);
938 if( !has_norm && has_bold ) bold->update(1);
940 if( italic->get_value() ) {
941 if( !has_ital ) italic->update(0);
944 if( !has_norm && has_ital ) italic->update(1);
946 if( has_norm && has_bold ) bold->enable(); else bold->disable();
947 if( has_norm && has_ital ) italic->enable(); else italic->disable();
949 int style = stroker && atof(stroker->get_text()) ? BC_FONT_OUTLINE : 0;
950 if( bold->get_value() ) style |= BC_FONT_BOLD;
951 if( italic->get_value() ) style |= BC_FONT_ITALIC;
952 if( alias->get_value() ) style |= FONT_ALIAS;
953 client->config.style = style;
957 TitleFont::TitleFont(TitleMain *client, TitleWindow *window, int x, int y)
958 : BC_PopupTextBox(window, &window->fonts, client->config.font,
959 x, y, xS(340), yS(300), LISTBOX_ICON_LIST)
961 this->client = client;
962 this->window = window;
964 int TitleFont::handle_event()
966 strcpy(client->config.font, get_text());
967 window->check_style(client->config.font, 1);
968 window->send_configure_change();
972 TitleText::TitleText(TitleMain *client, TitleWindow *window,
973 int x, int y, int w, int h)
974 : BC_ScrollTextBox(window, x, y, w,
975 BC_TextBox::pixels_to_rows(window, MEDIUMFONT, h),
976 client->config.wtext, 0)
978 this->client = client;
979 this->window = window;
980 //printf("TitleText::TitleText %s\n", client->config.text);
983 int TitleText::button_press_event()
985 if( get_buttonpress() == 3 ) {
986 window->cur_ibeam = get_ibeam_letter();
987 window->cur_popup->activate_menu();
990 return BC_ScrollTextBox::button_press_event();
993 int TitleText::handle_event()
995 window->fonts_popup->deactivate();
996 const wchr_t *wtext = get_wtext();
997 long wlen = wstrlen(wtext);
998 client->config.demand(wlen);
999 wstrncpy(client->config.wtext, wtext, client->config.wsize);
1000 client->config.wlen = wlen;
1001 window->update_stats();
1002 window->send_configure_change();
1005 TitleTextChars::TitleTextChars(int x, int y, int w)
1006 : BC_Title(x, y, "", MEDIUMFONT, -1, 0, w)
1009 TitleTextChars::~TitleTextChars()
1012 int TitleTextChars::update(int n)
1014 char text[BCSTRLEN];
1015 sprintf(text, _("chars: %d "),n);
1016 return BC_Title::update(text, 0);
1020 TitleDropShadow::TitleDropShadow(TitleMain *client, TitleWindow *window, int x, int y)
1021 : BC_TumbleTextBox(window, client->config.dropshadow,
1022 -1000, 1000, x, y, xS(70))
1024 this->client = client;
1025 this->window = window;
1027 int TitleDropShadow::handle_event()
1029 client->config.dropshadow = atol(get_text());
1030 window->send_configure_change();
1035 TitleOutline::TitleOutline(TitleMain *client, TitleWindow *window, int x, int y)
1036 : BC_TumbleTextBox(window, client->config.outline_size,
1037 0.f, 1000.f, x, y, xS(70))
1039 this->client = client;
1040 this->window = window;
1043 int TitleOutline::handle_event()
1045 client->config.outline_size = atof(get_text());
1046 window->send_configure_change();
1051 TitleStroker::TitleStroker(TitleMain *client, TitleWindow *window, int x, int y)
1052 : BC_TumbleTextBox(window, client->config.stroke_width,
1053 0.f, 1000.f, x, y, xS(70))
1055 this->client = client;
1056 this->window = window;
1059 int TitleStroker::handle_event()
1061 client->config.stroke_width = atof(get_text());
1062 if( client->config.stroke_width )
1063 client->config.style |= BC_FONT_OUTLINE;
1065 client->config.style &= ~BC_FONT_OUTLINE;
1066 window->send_configure_change();
1071 TitleX::TitleX(TitleMain *client, TitleWindow *window, int x, int y)
1072 : BC_TumbleTextBox(window, client->config.title_x,
1073 -32767.f, 32767.f, x, y, xS(50))
1075 this->client = client;
1076 this->window = window;
1079 int TitleX::handle_event()
1081 client->config.title_x = atof(get_text());
1082 window->update_drag();
1086 TitleY::TitleY(TitleMain *client, TitleWindow *window, int x, int y)
1087 : BC_TumbleTextBox(window, client->config.title_y,
1088 -32767.f, 32767.f, x, y, xS(50))
1090 this->client = client;
1091 this->window = window;
1094 int TitleY::handle_event()
1096 client->config.title_y = atof(get_text());
1097 window->update_drag();
1101 TitleW::TitleW(TitleMain *client, TitleWindow *window, int x, int y)
1102 : BC_TumbleTextBox(window, client->config.title_w,
1103 0, 32767, x, y, xS(50))
1105 this->client = client;
1106 this->window = window;
1108 int TitleW::handle_event()
1110 client->config.title_w = atol(get_text());
1111 window->update_drag();
1115 TitleH::TitleH(TitleMain *client, TitleWindow *window, int x, int y)
1116 : BC_TumbleTextBox(window, client->config.title_h,
1117 0, 32767, x, y, xS(50))
1119 this->client = client;
1120 this->window = window;
1122 int TitleH::handle_event()
1124 client->config.title_h = atol(get_text());
1125 window->update_drag();
1129 TitleSpeed::TitleSpeed(TitleMain *client, TitleWindow *window, int x, int y)
1130 : BC_TumbleTextBox(window, client->config.pixels_per_second,
1131 0.f, 1000.f, x, y, xS(100))
1133 this->client = client;
1134 this->window = window;
1140 int TitleSpeed::handle_event()
1142 client->config.pixels_per_second = atof(get_text());
1143 window->send_configure_change();
1148 TitleLeft::TitleLeft(TitleMain *client, TitleWindow *window, int x, int y)
1149 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_LEFT, _("Left"))
1151 this->client = client;
1152 this->window = window;
1154 int TitleLeft::handle_event()
1156 client->config.hjustification = JUSTIFY_LEFT;
1157 window->update_justification();
1158 window->send_configure_change();
1162 TitleCenter::TitleCenter(TitleMain *client, TitleWindow *window, int x, int y)
1163 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_CENTER, _("Center"))
1165 this->client = client;
1166 this->window = window;
1168 int TitleCenter::handle_event()
1170 client->config.hjustification = JUSTIFY_CENTER;
1171 window->update_justification();
1172 window->send_configure_change();
1176 TitleRight::TitleRight(TitleMain *client, TitleWindow *window, int x, int y)
1177 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_RIGHT, _("Right"))
1179 this->client = client;
1180 this->window = window;
1182 int TitleRight::handle_event()
1184 client->config.hjustification = JUSTIFY_RIGHT;
1185 window->update_justification();
1186 window->send_configure_change();
1192 TitleTop::TitleTop(TitleMain *client, TitleWindow *window, int x, int y)
1193 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_TOP, _("Top"))
1195 this->client = client;
1196 this->window = window;
1198 int TitleTop::handle_event()
1200 client->config.vjustification = JUSTIFY_TOP;
1201 window->update_justification();
1202 window->send_configure_change();
1206 TitleMid::TitleMid(TitleMain *client, TitleWindow *window, int x, int y)
1207 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_MID, _("Mid"))
1209 this->client = client;
1210 this->window = window;
1212 int TitleMid::handle_event()
1214 client->config.vjustification = JUSTIFY_MID;
1215 window->update_justification();
1216 window->send_configure_change();
1220 TitleBottom::TitleBottom(TitleMain *client, TitleWindow *window, int x, int y)
1221 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_BOTTOM, _("Bottom"))
1223 this->client = client;
1224 this->window = window;
1226 int TitleBottom::handle_event()
1228 client->config.vjustification = JUSTIFY_BOTTOM;
1229 window->update_justification();
1230 window->send_configure_change();
1234 TitleDrag::TitleDrag(TitleMain *client, TitleWindow *window, int x, int y)
1235 : DragCheckBox(client->server->mwindow, x, y, _("Drag"), &client->config.drag,
1236 client->config.title_x, client->config.title_y,
1237 client->config.title_w, client->config.title_h)
1239 this->client = client;
1240 this->window = window;
1243 Track *TitleDrag::get_drag_track()
1245 PluginServer *server = client->server;
1246 int plugin_id = server->plugin_id;
1247 Plugin *plugin = server->edl->tracks->plugin_exists(plugin_id);
1248 return !plugin ? 0 : plugin->track;
1250 int64_t TitleDrag::get_drag_position()
1252 return client->get_source_position();
1255 void TitleDrag::update_gui()
1257 client->config.drag = get_value();
1258 client->config.title_x = drag_x;
1259 client->config.title_y = drag_y;
1260 client->config.title_w = drag_w+0.5;
1261 client->config.title_h = drag_h+0.5;
1262 window->title_x->update((float)client->config.title_x);
1263 window->title_y->update((float)client->config.title_y);
1264 window->title_w->update((int64_t)client->config.title_w);
1265 window->title_h->update((int64_t)client->config.title_h);
1266 window->send_configure_change();
1269 int TitleDrag::handle_event()
1271 int ret = DragCheckBox::handle_event();
1272 window->send_configure_change();
1276 TitleBackground::TitleBackground(TitleMain *client, TitleWindow *window, int x, int y)
1277 : BC_CheckBox(x, y, client->config.background, _("Background:"))
1279 this->client = client;
1280 this->window = window;
1283 int TitleBackground::handle_event()
1285 client->config.background = get_value();
1286 window->send_configure_change();
1290 TitleBackgroundPath::TitleBackgroundPath(TitleMain *client, TitleWindow *window, int x, int y)
1291 : BC_TextBox(x, y, xS(240), 1, client->config.background_path)
1293 this->client = client;
1294 this->window = window;
1297 int TitleBackgroundPath::handle_event()
1299 strncpy(client->config.background_path, get_text(), sizeof(client->config.background_path));
1300 window->send_configure_change();
1304 TitleLoopPlayback::TitleLoopPlayback(TitleMain *client, TitleWindow *window, int x, int y)
1305 : BC_CheckBox(x, y, client->config.loop_playback, _("Loop playback"))
1307 this->client = client;
1308 this->window = window;
1310 int TitleLoopPlayback::handle_event()
1312 client->config.loop_playback = get_value();
1313 window->send_configure_change();
1318 TitleCurPopup::TitleCurPopup(TitleMain *client, TitleWindow *window)
1319 : BC_PopupMenu(0, 0, 0, "", 0)
1321 this->client = client;
1322 this->window = window;
1324 int TitleCurPopup::handle_event()
1329 void TitleCurSubMenu::add_subitemx(int popup_type, va_list ap, const char *fmt)
1331 char item[BCSTRLEN];
1332 vsnprintf(item, sizeof(item)-1, fmt, ap);
1333 item[sizeof(item)-1] = 0;
1334 add_submenuitem(new TitleCurSubMenuItem(this, item, popup_type));
1337 void TitleCurPopup::create_objects()
1339 TitleCurItem *cur_item;
1340 TitleCurSubMenu *sub_menu;
1342 add_item(cur_item = new TitleCurItem(this, item = _(KW_NUDGE)));
1343 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1344 sub_menu->add_subitem("%s dx,dy",item);
1345 sub_menu->add_subitem("/%s",item);
1346 add_item(cur_item = new TitleCurItem(this, item = _(KW_COLOR)));
1347 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1348 sub_menu->add_subitem(POPUP_COLOR,"%s %s",item,_("#"));
1349 sub_menu->add_subitem("%s ",item);
1350 sub_menu->add_subitem("/%s",item);
1351 add_item(cur_item = new TitleCurItem(this, item = _(KW_ALPHA)));
1352 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1353 sub_menu->add_subitem("%s ",item);
1354 sub_menu->add_subitem("%s 0.",item);
1355 sub_menu->add_subitem("%s .5",item);
1356 sub_menu->add_subitem("%s 1.",item);
1357 sub_menu->add_subitem("/%s",item);
1358 add_item(cur_item = new TitleCurItem(this, item = _(KW_FONT)));
1359 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1360 sub_menu->add_subitem(POPUP_FONT,"%s %s",item, _("name"));
1361 sub_menu->add_subitem(POPUP_OFFSET, "%s ",item);
1362 sub_menu->add_subitem("/%s",item);
1363 add_item(cur_item = new TitleCurItem(this, item = _(KW_SIZE)));
1364 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1365 sub_menu->add_subitem("%s +",item);
1366 sub_menu->add_subitem("%s -",item);
1367 sub_menu->add_subitem("%s ",item);
1368 sub_menu->add_subitem("/%s",item);
1369 add_item(cur_item = new TitleCurItem(this, item = _(KW_BOLD)));
1370 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1371 sub_menu->add_subitem("%s 1",item);
1372 sub_menu->add_subitem("%s 0",item);
1373 sub_menu->add_subitem("/%s",item);
1374 add_item(cur_item = new TitleCurItem(this, item = _(KW_ITALIC)));
1375 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1376 sub_menu->add_subitem("%s 1",item);
1377 sub_menu->add_subitem("%s 0",item);
1378 sub_menu->add_subitem("/%s",item);
1379 add_item(cur_item = new TitleCurItem(this, item = _(KW_CAPS)));
1380 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1381 sub_menu->add_subitem("%s 1",item);
1382 sub_menu->add_subitem("%s 0",item);
1383 sub_menu->add_subitem("%s -1",item);
1384 sub_menu->add_subitem("/%s",item);
1385 add_item(cur_item = new TitleCurItem(this, item = _(KW_UL)));
1386 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1387 sub_menu->add_subitem("%s 1",item);
1388 sub_menu->add_subitem("%s 0",item);
1389 sub_menu->add_subitem("/%s",item);
1390 add_item(cur_item = new TitleCurItem(this, item = _(KW_BLINK)));
1391 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1392 sub_menu->add_subitem("%s 1",item);
1393 sub_menu->add_subitem("%s -1",item);
1394 sub_menu->add_subitem("%s ",item);
1395 sub_menu->add_subitem("%s 0",item);
1396 sub_menu->add_subitem("/%s",item);
1397 add_item(cur_item = new TitleCurItem(this, item = _(KW_FIXED)));
1398 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1399 sub_menu->add_subitem("%s ",item);
1400 sub_menu->add_subitem("%s 20",item);
1401 sub_menu->add_subitem("%s 10",item);
1402 sub_menu->add_subitem("%s 0",item);
1403 sub_menu->add_subitem("/%s",item);
1404 add_item(cur_item = new TitleCurItem(this, item = _(KW_ALIAS)));
1405 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1406 sub_menu->add_subitem("%s 1",item);
1407 sub_menu->add_subitem("%s 0",item);
1408 sub_menu->add_subitem("/%s",item);
1409 add_item(cur_item = new TitleCurItem(this, item = _(KW_SUP)));
1410 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1411 sub_menu->add_subitem("%s 1",item);
1412 sub_menu->add_subitem("%s 0",item);
1413 sub_menu->add_subitem("%s -1",item);
1414 sub_menu->add_subitem("/%s",item);
1415 add_item(cur_item = new TitleCurItem(this, item = _(KW_PNG)));
1416 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1417 sub_menu->add_subitem(POPUP_PNG,"%s %s", item, _("file"));
1420 TitleCurItem::TitleCurItem(TitleCurPopup *popup, const char *text)
1423 this->popup = popup;
1425 int TitleCurItem::handle_event()
1430 TitleCurSubMenu::TitleCurSubMenu(TitleCurItem *cur_item)
1432 this->cur_item = cur_item;
1434 TitleCurSubMenu::~TitleCurSubMenu()
1438 TitleCurSubMenuItem::TitleCurSubMenuItem(TitleCurSubMenu *submenu, const char *text, int popup_type)
1441 this->submenu = submenu;
1442 this->popup_type = popup_type;
1444 TitleCurSubMenuItem::~TitleCurSubMenuItem()
1447 int TitleCurSubMenuItem::handle_event()
1449 TitleCurPopup *popup = submenu->cur_item->popup;
1450 TitleWindow *window = popup->window;
1451 const char *item_text = get_text();
1452 int ofs = *item_text == '/' ? 0 : -1;
1453 switch( popup_type ) {
1456 window->get_pop_cursor(px ,py);
1457 window->fonts_popup->activate(px, py, xS(300),yS(200));
1460 window->color_popup->activate();
1463 window->png_popup->activate();
1470 sprintf(txt, "<%s>", item_text);
1471 return window->insert_ibeam(txt, ofs);
1474 TitleFontsPopup::TitleFontsPopup(TitleMain *client, TitleWindow *window)
1475 : BC_ListBox(-1, -1, 1, 1, LISTBOX_ICON_LIST,
1476 &window->fonts, 0, 0, 1, 0, 1)
1478 this->client = client;
1479 this->window = window;
1483 TitleFontsPopup::~TitleFontsPopup()
1486 int TitleFontsPopup::keypress_event()
1488 switch( get_keypress() ) {
1496 return BC_ListBox::keypress_event();
1499 int TitleFontsPopup::handle_event()
1502 BC_ListBoxItem *item = get_selection(0, 0);
1503 if( !item ) return 1;
1504 const char *item_text = item->get_text();
1505 char txt[BCTEXTLEN]; sprintf(txt, "<%s %s>", _(KW_FONT), item_text);
1506 return window->insert_ibeam(txt);
1509 TitleColorPopup::TitleColorPopup(TitleMain *client, TitleWindow *window)
1510 : ColorPicker(0, _("Color"))
1512 this->client = client;
1513 this->window = window;
1514 this->color_value = client->config.color;
1516 TitleColorPopup::~TitleColorPopup()
1519 int TitleColorPopup::handle_new_color(int output, int alpha)
1521 color_value = output;
1524 int TitleColorPopup::activate()
1526 start_window(client->config.color, 255, 1);
1529 void TitleColorPopup::handle_done_event(int result)
1532 char txt[BCSTRLEN]; sprintf(txt, "<%s #%06x>", _(KW_COLOR), color_value);
1533 window->lock_window("TitleColorPopup::handle_done_event");
1534 window->insert_ibeam(txt);
1535 window->unlock_window();
1539 TitlePngPopup::TitlePngPopup(TitleMain *client, TitleWindow *window)
1542 this->client = client;
1543 this->window = window;
1546 TitlePngPopup::~TitlePngPopup()
1551 void TitlePngPopup::handle_done_event(int result)
1553 if( result ) return;
1554 BrowseButtonWindow *gui = (BrowseButtonWindow *)get_gui();
1555 const char *path = gui->get_submitted_path();
1556 char txt[BCTEXTLEN]; sprintf(txt, "<%s %s>", _(KW_PNG), path);
1557 window->lock_window("TitlePngPopup::handle_done_event");
1558 window->insert_ibeam(txt);
1559 window->unlock_window();
1562 BC_Window *TitlePngPopup::new_gui()
1564 MWindow *mwindow = client->server->mwindow;
1565 int x, y; mwindow->gui->get_abs_cursor(x, y);
1567 BC_Window *gui = new BrowseButtonWindow(mwindow->theme,
1568 x-xS(25), y-yS(100), window, "", _("Png file"), _("Png path"), 0);
1569 gui->create_objects();
1573 int TitlePngPopup::activate()
1575 BC_DialogThread::start();