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 ) {
268 if( drag->drag_activate() )
269 eprintf("drag enabled, but compositor already grabbed\n");
272 add_tool(alias = new TitleAlias(client, this, x, y+yS(110)));
273 if( alias->get_w() > w1 ) w1 = drag->get_w();
276 add_tool(justify_title = new BC_Title(x+xS(50), y, _("Justify:")));
277 add_tool(left = new TitleLeft(client, this, x, y + yS(20)));
279 add_tool(center = new TitleCenter(client, this, x, y + yS(50)));
280 if( center->get_w() > w1 ) w1 = center->get_w();
281 add_tool(right = new TitleRight(client, this, x, y + yS(80)));
282 if( right->get_w() > w1 ) w1 = right->get_w();
285 add_tool(top = new TitleTop(client, this, x, y + yS(20)));
286 add_tool(mid = new TitleMid(client, this, x, y + yS(50)));
287 add_tool(bottom= new TitleBottom(client, this, x, y + yS(80)));
292 w1 = BC_Title::calculate_w(this, _("X:"));
293 if( (x1 = BC_Title::calculate_w(this, _("Y:"))) > w1 ) w1 = x1;
294 if( (x1 = BC_Title::calculate_w(this, _("W:"))) > w1 ) w1 = x1;
295 if( (x1 = BC_Title::calculate_w(this, _("H:"))) > w1 ) w1 = x1;
296 add_tool(x_title = new BC_Title(x1=x, y, _("X:")));
298 title_x = new TitleX(client, this, x1, y);
299 title_x->create_objects();
300 x1 += title_x->get_w()+margin;
301 add_tool(y_title = new BC_Title(x1, y, _("Y:")));
303 title_y = new TitleY(client, this, x1, y);
304 title_y->create_objects();
305 x1 += title_y->get_w();
306 y1 = y + title_y->get_h();
308 add_tool(w_title = new BC_Title(x1=x, y1, _("W:")));
310 title_w = new TitleW(client, this, x1, y1);
311 title_w->create_objects();
312 x1 += title_w->get_w()+margin;
313 add_tool(h_title = new BC_Title(x1, y1, _("H:")));
315 title_h = new TitleH(client, this, x1, y1);
316 title_h->create_objects();
317 x1 += title_h->get_w();
320 add_tool(motion_title = new BC_Title(x1=x, y, _("Motion:")));
321 x1 += motion_title->get_w()+margin;
322 motion = new TitleMotion(client, this, x1, y);
323 motion->create_objects();
324 add_tool(loop = new TitleLoop(client, this, x, y1));
325 x = margin; y = y1 + loop->get_h()+yS(20);
327 add_tool(dropshadow_title = new BC_Title(x, y, _("Drop shadow:")));
328 w1 = dropshadow_title->get_w();
329 dropshadow = new TitleDropShadow(client, this, x, y + yS(20));
330 dropshadow->create_objects();
331 if( dropshadow->get_w() > w1 ) w1 = dropshadow->get_w();
334 add_tool(fadein_title = new BC_Title(x, y, _("Fade in (sec):")));
335 w1 = fadein_title->get_w();
336 add_tool(fade_in = new TitleFade(client, this, &client->config.fade_in, x, y + yS(20)));
337 if( fade_in->get_w() > w1 ) w1 = fade_in->get_w();
340 add_tool(fadeout_title = new BC_Title(x, y, _("Fade out (sec):")));
341 w1 = fadeout_title->get_w();
342 add_tool(fade_out = new TitleFade(client, this, &client->config.fade_out, x, y + yS(20)));
343 if( fade_out->get_w() > w1 ) w1 = fade_out->get_w();
346 add_tool(speed_title = new BC_Title(x, y, _("Speed:")));
347 w1 = speed_title->get_w();
348 y += speed_title->get_h() + yS(5); y1 = y;
349 speed = new TitleSpeed(client, this, x, y);
350 speed->create_objects();
351 if( speed->get_w() > w1 ) w1 = speed->get_w();
353 y2 = y + speed->get_h() + yS(10);
355 add_tool(color_button_title = new BC_Title(x3, y1+yS(10), _("Color:")));
356 x1 = x3 + color_button_title->get_w() + xS(30);
357 add_tool(color_button = new TitleColorButton(client, this, x1, y1));
358 y1 += color_button->get_h() + yS(10);
359 add_tool(outline_button_title = new BC_Title(x3, y1+yS(10), _("Outline:")));
360 add_tool(outline_button = new TitleOutlineColorButton(client, this, x1, y1));
363 add_tool(outline_title = new BC_Title(x, y, _("Outline:")));
364 y1 = y + outline_title->get_h() + margin;
365 outline = new TitleOutline(client, this, x, y1);
366 outline->create_objects();
367 x += outline->get_w() + xS(2)*margin;
369 add_tool(stroker_title = new BC_Title(x, y, _("Stroker:")));
370 stroker = new TitleStroker(client, this, x, y1);
371 stroker->create_objects();
372 x += stroker->get_w() + margin;
374 add_tool(timecode = new TitleTimecode(client, this, x, y));
375 y += timecode->get_h() + margin;
377 for( int i=0; i<lengthof(timeunit_formats); ++i ) {
379 Units::print_time_format(timeunit_formats[i], text);
380 int w = get_text_width(MEDIUMFONT, text);
383 add_tool(timecode_format = new TitleTimecodeFormat(client, this, x, y, tw,
384 Units::print_time_format(client->config.timecode_format, string)));
385 timecode_format->create_objects();
386 y += timecode_format->get_h() + margin;
389 add_tool(background = new TitleBackground(client, this, x, y));
390 x += background->get_w() + margin;
391 add_tool(background_path = new TitleBackgroundPath(client, this, x, y));
392 x += background_path->get_w() + margin;
393 add_tool(background_browse = new BrowseButton(
394 client->server->mwindow->theme, this, background_path,
395 x, y, "", _("background media"), _("Select background media path")));
396 x += background_browse->get_w() + xS(3)*margin;
397 add_tool(loop_playback = new TitleLoopPlayback(client, this, x, y));
398 y += loop_playback->get_h() + yS(10);
401 add_tool(text_title = new BC_Title(x, y, _("Text:")));
402 x += text_title->get_w() + xS(20);
403 int wid = BC_Title::calculate_w(this,"0")*xS(10);
404 add_tool(text_chars = new TitleTextChars(x,y,wid));
406 y += text_title->get_h() + margin;
408 text = new TitleText(client, this, x, y, get_w()-margin - x, get_h() - y - yS(10));
409 text->create_objects();
411 add_tool(cur_popup = new TitleCurPopup(client, this));
412 cur_popup->create_objects();
413 add_tool(fonts_popup = new TitleFontsPopup(client, this));
414 color_popup = new TitleColorPopup(client, this);
415 png_popup = new TitlePngPopup(client, this);
421 int TitleWindow::resize_event(int w, int h)
423 client->config.window_w = w;
424 client->config.window_h = h;
426 clear_box(0, 0, w, h);
427 font_title->reposition_window(font_title->get_x(), font_title->get_y());
428 font->reposition_window(font->get_x(), font->get_y());
429 font_tumbler->reposition_window(font_tumbler->get_x(), font_tumbler->get_y());
430 x_title->reposition_window(x_title->get_x(), x_title->get_y());
431 title_x->reposition_window(title_x->get_x(), title_x->get_y());
432 y_title->reposition_window(y_title->get_x(), y_title->get_y());
433 title_y->reposition_window(title_y->get_x(), title_y->get_y());
434 w_title->reposition_window(w_title->get_x(), w_title->get_y());
435 title_w->reposition_window(title_w->get_x(), title_w->get_y());
436 h_title->reposition_window(h_title->get_x(), h_title->get_y());
437 title_h->reposition_window(title_h->get_x(), title_h->get_y());
438 style_title->reposition_window(style_title->get_x(), style_title->get_y());
439 italic->reposition_window(italic->get_x(), italic->get_y());
440 bold->reposition_window(bold->get_x(), bold->get_y());
441 drag->reposition_window(drag->get_x(), drag->get_y());
442 alias->reposition_window(alias->get_x(), alias->get_y());
443 size_title->reposition_window(size_title->get_x(), size_title->get_y());
444 size->reposition_window(size->get_x(), size->get_y());
445 size_tumbler->reposition_window(size_tumbler->get_x(), size_tumbler->get_y());
446 pitch_title->reposition_window(pitch_title->get_x(), pitch_title->get_y());
447 pitch->reposition_window(pitch->get_x(), pitch->get_y());
449 color_button_title->reposition_window(color_button_title->get_x(), color_button_title->get_y());
450 color_button->reposition_window(color_button->get_x(), color_button->get_y());
451 outline_button_title->reposition_window(outline_button_title->get_x(), outline_button_title->get_y());
452 outline_button->reposition_window(outline_button->get_x(), outline_button->get_y());
453 motion_title->reposition_window(motion_title->get_x(), motion_title->get_y());
454 motion->reposition_window(motion->get_x(), motion->get_y());
455 loop->reposition_window(loop->get_x(), loop->get_y());
456 dropshadow_title->reposition_window(dropshadow_title->get_x(), dropshadow_title->get_y());
457 dropshadow->reposition_window(dropshadow->get_x(), dropshadow->get_y());
458 fadein_title->reposition_window(fadein_title->get_x(), fadein_title->get_y());
459 fade_in->reposition_window(fade_in->get_x(), fade_in->get_y());
460 fadeout_title->reposition_window(fadeout_title->get_x(), fadeout_title->get_y());
461 fade_out->reposition_window(fade_out->get_x(), fade_out->get_y());
462 text_title->reposition_window(text_title->get_x(), text_title->get_y());
463 timecode->reposition_window(timecode->get_x(), timecode->get_y());
464 text->reposition_window(text->get_x(), text->get_y(), w - text->get_x() - xS(10),
465 BC_TextBox::pixels_to_rows(this, MEDIUMFONT, h - text->get_y() - yS(10)));
466 justify_title->reposition_window(justify_title->get_x(), justify_title->get_y());
467 left->reposition_window(left->get_x(), left->get_y());
468 center->reposition_window(center->get_x(), center->get_y());
469 right->reposition_window(right->get_x(), right->get_y());
470 top->reposition_window(top->get_x(), top->get_y());
471 mid->reposition_window(mid->get_x(), mid->get_y());
472 bottom->reposition_window(bottom->get_x(), bottom->get_y());
473 speed_title->reposition_window(speed_title->get_x(), speed_title->get_y());
474 speed->reposition_window(speed->get_x(), speed->get_y());
481 void TitleWindow::update_drag()
483 drag->drag_x = client->config.title_x;
484 drag->drag_y = client->config.title_y;
485 drag->drag_w = client->config.title_w;
486 drag->drag_h = client->config.title_h;
487 send_configure_change();
489 void TitleWindow::send_configure_change()
491 client->send_configure_change();
494 void TitleWindow::previous_font()
496 int current_font = font->get_number();
497 if( !fonts.total ) current_font = -1;
498 else if( --current_font < 0 ) current_font = fonts.total - 1;
499 font->set_number(current_font);
501 if( current_font < 0 || current_font >= fonts.total ) return;
503 for( int i=0; i<fonts.total; ++i ) {
504 fonts.values[i]->set_selected(i == current_font);
507 font->update(fonts.values[current_font]->get_text());
508 strcpy(client->config.font, fonts.values[current_font]->get_text());
509 check_style(client->config.font,1);
510 send_configure_change();
513 void TitleWindow::next_font()
515 int current_font = font->get_number();
516 if( !fonts.total ) current_font = -1;
517 else if( ++current_font >= fonts.total ) current_font = 0;
518 font->set_number(current_font);
520 if( current_font < 0 || current_font >= fonts.total ) return;
522 for( int i=0; i<fonts.total; ++i ) {
523 fonts.values[i]->set_selected(i == current_font);
526 font->update(fonts.values[current_font]->get_text());
527 strcpy(client->config.font, fonts.values[current_font]->get_text());
528 check_style(client->config.font,1);
529 send_configure_change();
532 int TitleWindow::insert_ibeam(const char *txt, int ofs)
534 int ibeam = cur_ibeam;
535 int ilen = strlen(txt)+1;
537 int len = BC_Resources::encode(client->config.encoding, BC_Resources::wide_encoding,
538 (char*)txt,ilen, (char *)wtxt,ilen*sizeof(wtxt[0])) / sizeof(wchr_t);
539 client->insert_text(wtxt, ibeam);
540 while( len > 0 && !wtxt[len] ) --len;
541 int adv = len+1 + ofs;
542 if( (ibeam += adv) >= client->config.wlen)
543 ibeam = client->config.wlen;
544 text->wset_selection(-1, -1, ibeam);
545 text->update(client->config.wtext);
546 send_configure_change();
550 void TitleWindow::update_color()
552 color_button->update_gui(client->config.color);
553 outline_button->update_gui(client->config.outline_color);
556 void TitleWindow::update_justification()
558 left->update(client->config.hjustification == JUSTIFY_LEFT);
559 center->update(client->config.hjustification == JUSTIFY_CENTER);
560 right->update(client->config.hjustification == JUSTIFY_RIGHT);
561 top->update(client->config.vjustification == JUSTIFY_TOP);
562 mid->update(client->config.vjustification == JUSTIFY_MID);
563 bottom->update(client->config.vjustification == JUSTIFY_BOTTOM);
566 void TitleWindow::update_stats()
568 text_chars->update(client->config.wlen);
571 void TitleWindow::update_gui()
573 title_x->update((int64_t)client->config.title_x);
574 title_y->update((int64_t)client->config.title_y);
575 title_w->update((int64_t)client->config.title_w);
576 title_h->update((int64_t)client->config.title_h);
577 italic->update(client->config.style & BC_FONT_ITALIC);
578 bold->update(client->config.style & BC_FONT_BOLD);
579 alias->update(client->config.style & FONT_ALIAS);
580 size->update(client->config.size);
581 motion->update(TitleMain::motion_to_text(client->config.motion_strategy));
582 loop->update(client->config.loop);
583 dropshadow->update((int64_t)client->config.dropshadow);
584 fade_in->update((float)client->config.fade_in);
585 fade_out->update((float)client->config.fade_out);
586 font->update(client->config.font);
587 check_style(client->config.font,0);
588 wchr_t wz[1] = { 0 };
589 text->update(client->config.wtext ? &client->config.wtext[0] : wz);
590 speed->update(client->config.pixels_per_second);
591 outline->update((int64_t)client->config.outline_size);
593 stroker->update((int64_t)client->config.stroke_width);
595 timecode->update(client->config.timecode);
596 timecode_format->update(client->config.timecode_format);
597 background->update(client->config.background);
598 background_path->update(client->config.background_path);
599 loop_playback->update((int64_t)client->config.loop_playback);
601 char string[BCTEXTLEN];
602 for( int i=0; i<lengthof(timeunit_formats); ++i ) {
603 if( timeunit_formats[i] == client->config.timecode_format ) {
604 timecode_format->set_text(
605 Units::print_time_format(timeunit_formats[i], string));
609 update_justification();
615 TitleFontTumble::TitleFontTumble(TitleMain *client, TitleWindow *window, int x, int y)
618 this->client = client;
619 this->window = window;
621 int TitleFontTumble::handle_up_event()
623 window->previous_font();
627 int TitleFontTumble::handle_down_event()
634 TitleSizeTumble::TitleSizeTumble(TitleMain *client, TitleWindow *window, int x, int y)
637 this->client = client;
638 this->window = window;
641 int TitleSizeTumble::handle_up_event()
643 int current_index = -1;
644 int current_difference = -1;
645 for( int i=0; i<window->sizes.size(); ++i ) {
646 int size = atoi(window->sizes.get(i)->get_text());
647 if( current_index < 0 ||
648 abs(size - client->config.size) < current_difference ) {
650 current_difference = abs(size - client->config.size);
655 if( current_index >= window->sizes.size() ) current_index = 0;
658 client->config.size = atoi(window->sizes.get(current_index)->get_text());
659 window->size->update(client->config.size);
660 window->send_configure_change();
664 int TitleSizeTumble::handle_down_event()
666 int current_index = -1;
667 int current_difference = -1;
668 for( int i=0; i<window->sizes.size(); ++i ) {
669 int size = atoi(window->sizes.get(i)->get_text());
670 if( current_index < 0 ||
671 abs(size - client->config.size) < current_difference ) {
673 current_difference = abs(size - client->config.size);
678 if( current_index < 0 ) current_index = window->sizes.size() - 1;
681 client->config.size = atoi(window->sizes.get(current_index)->get_text());
682 window->size->update(client->config.size);
683 window->send_configure_change();
687 TitleAlias::TitleAlias(TitleMain *client, TitleWindow *window, int x, int y)
688 : BC_CheckBox(x, y, client->config.style & FONT_ALIAS, _("Smooth"))
690 this->client = client;
691 this->window = window;
694 int TitleAlias::handle_event()
696 client->config.style =
697 (client->config.style & ~FONT_ALIAS) |
698 (get_value() ? FONT_ALIAS : 0);
699 window->send_configure_change();
703 TitleBold::TitleBold(TitleMain *client, TitleWindow *window, int x, int y)
704 : BC_CheckBox(x, y, client->config.style & BC_FONT_BOLD, _("Bold"))
706 this->client = client;
707 this->window = window;
710 int TitleBold::handle_event()
712 client->config.style =
713 (client->config.style & ~BC_FONT_BOLD) |
714 (get_value() ? BC_FONT_BOLD : 0);
715 window->send_configure_change();
719 TitleItalic::TitleItalic(TitleMain *client, TitleWindow *window, int x, int y)
720 : BC_CheckBox(x, y, client->config.style & BC_FONT_ITALIC, _("Italic"))
722 this->client = client;
723 this->window = window;
725 int TitleItalic::handle_event()
727 client->config.style =
728 (client->config.style & ~BC_FONT_ITALIC) |
729 (get_value() ? BC_FONT_ITALIC : 0);
730 window->send_configure_change();
736 TitleSize::TitleSize(TitleMain *client, TitleWindow *window, int x, int y, char *text)
737 : BC_PopupTextBox(window, &window->sizes, text, x, y, xS(64), yS(300))
739 this->client = client;
740 this->window = window;
742 TitleSize::~TitleSize()
745 int TitleSize::handle_event()
747 client->config.size = atol(get_text());
748 //printf("TitleSize::handle_event 1 %s\n", get_text());
749 window->send_configure_change();
752 void TitleSize::update(int size)
754 char string[BCTEXTLEN];
755 sprintf(string, "%d", size);
756 BC_PopupTextBox::update(string);
760 TitlePitch(TitleMain *client, TitleWindow *window, int x, int y, int *value)
761 : BC_TumbleTextBox(window, *value, 0, INT_MAX, x, y, xS(64))
763 this->client = client;
764 this->window = window;
773 int TitlePitch::handle_event()
775 *value = atol(get_text());
776 window->send_configure_change();
780 TitleColorButton::TitleColorButton(TitleMain *client, TitleWindow *window, int x, int y)
781 : ColorCircleButton(_("Text Color"), x, y, COLOR_W, COLOR_H,
782 client->config.color, client->config.alpha, 1)
784 this->client = client;
785 this->window = window;
787 int TitleColorButton::handle_new_color(int output, int alpha)
789 client->config.color = output;
790 client->config.alpha = alpha;
791 window->send_configure_change();
794 void TitleColorButton::handle_done_event(int result)
797 handle_new_color(orig_color, orig_alpha);
798 window->lock_window("TitleColorButton::handle_done_event");
799 update_gui(orig_color);
800 window->unlock_window();
804 TitleOutlineColorButton::TitleOutlineColorButton(TitleMain *client, TitleWindow *window, int x, int y)
805 : ColorCircleButton(_("Outline Color"), x, y, COLOR_W, COLOR_H,
806 client->config.outline_color, client->config.outline_alpha, 1)
808 this->client = client;
809 this->window = window;
811 int TitleOutlineColorButton::handle_new_color(int output, int alpha)
813 client->config.outline_color = output;
814 client->config.outline_alpha = alpha;
815 window->send_configure_change();
818 void TitleOutlineColorButton::handle_done_event(int result)
821 handle_new_color(orig_color, orig_alpha);
822 window->lock_window("TitleColorButton::handle_done_event");
823 update_gui(orig_color);
824 window->unlock_window();
829 TitleMotion::TitleMotion(TitleMain *client, TitleWindow *window, int x, int y)
830 : BC_PopupTextBox(window, &window->paths,
831 client->motion_to_text(client->config.motion_strategy),
832 x, y, xS(120), yS(100))
834 this->client = client;
835 this->window = window;
837 int TitleMotion::handle_event()
839 client->config.motion_strategy = client->text_to_motion(get_text());
840 window->send_configure_change();
844 TitleLoop::TitleLoop(TitleMain *client, TitleWindow *window, int x, int y)
845 : BC_CheckBox(x, y, client->config.loop, _("Loop"))
847 this->client = client;
848 this->window = window;
850 int TitleLoop::handle_event()
852 client->config.loop = get_value();
853 window->send_configure_change();
856 TitleTimecode::TitleTimecode(TitleMain *client, TitleWindow *window, int x, int y)
857 : BC_CheckBox(x, y, client->config.timecode, _("Stamp timecode"))
859 this->client = client;
860 this->window = window;
862 int TitleTimecode::handle_event()
864 client->config.timecode = get_value();
865 client->send_configure_change();
869 TitleTimecodeFormat::TitleTimecodeFormat(TitleMain *client, TitleWindow *window,
870 int x, int y, int tw, const char *text)
871 : BC_PopupMenu(x, y, BC_PopupMenu::calculate_w(tw)+xS(10), text, 1)
873 this->client = client;
874 this->window = window;
877 int TitleTimecodeFormat::handle_event()
879 client->config.timecode_format = Units::text_to_format(get_text());
880 window->send_configure_change();
884 void TitleTimecodeFormat::create_objects()
886 char string[BCTEXTLEN];
887 for( int i=0; i<lengthof(timeunit_formats); ++i ) {
888 add_item(new BC_MenuItem(
889 Units::print_time_format(timeunit_formats[i], string)));
894 int TitleTimecodeFormat::update(int timecode_format)
896 char string[BCTEXTLEN];
897 for( int i=0; i<lengthof(timeunit_formats); ++i ) {
898 if( timeunit_formats[i] == timecode_format ) {
899 set_text(Units::print_time_format(timeunit_formats[i], string));
906 TitleFade::TitleFade(TitleMain *client, TitleWindow *window,
907 double *value, int x, int y)
908 : BC_TextBox(x, y, xS(80), 1, (float)*value)
910 this->client = client;
911 this->window = window;
916 int TitleFade::handle_event()
918 *value = atof(get_text());
919 window->send_configure_change();
923 void TitleWindow::check_style(const char *font_name, int update)
925 BC_FontEntry *font_nrm = TitleMain::get_font(font_name, 0);
926 BC_FontEntry *font_itl = TitleMain::get_font(font_name, BC_FONT_ITALIC);
927 BC_FontEntry *font_bld = TitleMain::get_font(font_name, BC_FONT_BOLD);
928 BC_FontEntry *font_bit = TitleMain::get_font(font_name, BC_FONT_ITALIC | BC_FONT_BOLD);
929 int has_norm = font_nrm != 0 ? 1 : 0;
930 int has_ital = font_itl != 0 || font_bit != 0 ? 1 : 0;
931 int has_bold = font_bld != 0 || font_bit != 0 ? 1 : 0;
932 if( bold->get_value() ) {
933 if( !has_bold ) bold->update(0);
936 if( !has_norm && has_bold ) bold->update(1);
938 if( italic->get_value() ) {
939 if( !has_ital ) italic->update(0);
942 if( !has_norm && has_ital ) italic->update(1);
944 if( has_norm && has_bold ) bold->enable(); else bold->disable();
945 if( has_norm && has_ital ) italic->enable(); else italic->disable();
947 int style = stroker && atof(stroker->get_text()) ? BC_FONT_OUTLINE : 0;
948 if( bold->get_value() ) style |= BC_FONT_BOLD;
949 if( italic->get_value() ) style |= BC_FONT_ITALIC;
950 if( alias->get_value() ) style |= FONT_ALIAS;
951 client->config.style = style;
955 TitleFont::TitleFont(TitleMain *client, TitleWindow *window, int x, int y)
956 : BC_PopupTextBox(window, &window->fonts, client->config.font,
957 x, y, xS(340), yS(300), LISTBOX_ICON_LIST)
959 this->client = client;
960 this->window = window;
962 int TitleFont::handle_event()
964 strcpy(client->config.font, get_text());
965 window->check_style(client->config.font, 1);
966 window->send_configure_change();
970 TitleText::TitleText(TitleMain *client, TitleWindow *window,
971 int x, int y, int w, int h)
972 : BC_ScrollTextBox(window, x, y, w,
973 BC_TextBox::pixels_to_rows(window, MEDIUMFONT, h),
974 client->config.wtext, 0)
976 this->client = client;
977 this->window = window;
978 //printf("TitleText::TitleText %s\n", client->config.text);
981 int TitleText::button_press_event()
983 if( get_buttonpress() == 3 ) {
984 window->cur_ibeam = get_ibeam_letter();
985 window->cur_popup->activate_menu();
988 return BC_ScrollTextBox::button_press_event();
991 int TitleText::handle_event()
993 window->fonts_popup->deactivate();
994 const wchr_t *wtext = get_wtext();
995 long wlen = wstrlen(wtext);
996 client->config.demand(wlen);
997 wstrncpy(client->config.wtext, wtext, client->config.wsize);
998 client->config.wlen = wlen;
999 window->update_stats();
1000 window->send_configure_change();
1003 TitleTextChars::TitleTextChars(int x, int y, int w)
1004 : BC_Title(x, y, "", MEDIUMFONT, -1, 0, w)
1007 TitleTextChars::~TitleTextChars()
1010 int TitleTextChars::update(int n)
1012 char text[BCSTRLEN];
1013 sprintf(text, _("chars: %d "),n);
1014 return BC_Title::update(text, 0);
1018 TitleDropShadow::TitleDropShadow(TitleMain *client, TitleWindow *window, int x, int y)
1019 : BC_TumbleTextBox(window, client->config.dropshadow,
1020 -1000, 1000, x, y, xS(70))
1022 this->client = client;
1023 this->window = window;
1025 int TitleDropShadow::handle_event()
1027 client->config.dropshadow = atol(get_text());
1028 window->send_configure_change();
1033 TitleOutline::TitleOutline(TitleMain *client, TitleWindow *window, int x, int y)
1034 : BC_TumbleTextBox(window, client->config.outline_size,
1035 0.f, 1000.f, x, y, xS(70))
1037 this->client = client;
1038 this->window = window;
1041 int TitleOutline::handle_event()
1043 client->config.outline_size = atof(get_text());
1044 window->send_configure_change();
1049 TitleStroker::TitleStroker(TitleMain *client, TitleWindow *window, int x, int y)
1050 : BC_TumbleTextBox(window, client->config.stroke_width,
1051 0.f, 1000.f, x, y, xS(70))
1053 this->client = client;
1054 this->window = window;
1057 int TitleStroker::handle_event()
1059 client->config.stroke_width = atof(get_text());
1060 if( client->config.stroke_width )
1061 client->config.style |= BC_FONT_OUTLINE;
1063 client->config.style &= ~BC_FONT_OUTLINE;
1064 window->send_configure_change();
1069 TitleX::TitleX(TitleMain *client, TitleWindow *window, int x, int y)
1070 : BC_TumbleTextBox(window, client->config.title_x,
1071 -32767.f, 32767.f, x, y, xS(50))
1073 this->client = client;
1074 this->window = window;
1077 int TitleX::handle_event()
1079 client->config.title_x = atof(get_text());
1080 window->update_drag();
1084 TitleY::TitleY(TitleMain *client, TitleWindow *window, int x, int y)
1085 : BC_TumbleTextBox(window, client->config.title_y,
1086 -32767.f, 32767.f, x, y, xS(50))
1088 this->client = client;
1089 this->window = window;
1092 int TitleY::handle_event()
1094 client->config.title_y = atof(get_text());
1095 window->update_drag();
1099 TitleW::TitleW(TitleMain *client, TitleWindow *window, int x, int y)
1100 : BC_TumbleTextBox(window, client->config.title_w,
1101 0, 32767, x, y, xS(50))
1103 this->client = client;
1104 this->window = window;
1106 int TitleW::handle_event()
1108 client->config.title_w = atol(get_text());
1109 window->update_drag();
1113 TitleH::TitleH(TitleMain *client, TitleWindow *window, int x, int y)
1114 : BC_TumbleTextBox(window, client->config.title_h,
1115 0, 32767, x, y, xS(50))
1117 this->client = client;
1118 this->window = window;
1120 int TitleH::handle_event()
1122 client->config.title_h = atol(get_text());
1123 window->update_drag();
1127 TitleSpeed::TitleSpeed(TitleMain *client, TitleWindow *window, int x, int y)
1128 : BC_TumbleTextBox(window, client->config.pixels_per_second,
1129 0.f, 1000.f, x, y, xS(100))
1131 this->client = client;
1132 this->window = window;
1138 int TitleSpeed::handle_event()
1140 client->config.pixels_per_second = atof(get_text());
1141 window->send_configure_change();
1146 TitleLeft::TitleLeft(TitleMain *client, TitleWindow *window, int x, int y)
1147 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_LEFT, _("Left"))
1149 this->client = client;
1150 this->window = window;
1152 int TitleLeft::handle_event()
1154 client->config.hjustification = JUSTIFY_LEFT;
1155 window->update_justification();
1156 window->send_configure_change();
1160 TitleCenter::TitleCenter(TitleMain *client, TitleWindow *window, int x, int y)
1161 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_CENTER, _("Center"))
1163 this->client = client;
1164 this->window = window;
1166 int TitleCenter::handle_event()
1168 client->config.hjustification = JUSTIFY_CENTER;
1169 window->update_justification();
1170 window->send_configure_change();
1174 TitleRight::TitleRight(TitleMain *client, TitleWindow *window, int x, int y)
1175 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_RIGHT, _("Right"))
1177 this->client = client;
1178 this->window = window;
1180 int TitleRight::handle_event()
1182 client->config.hjustification = JUSTIFY_RIGHT;
1183 window->update_justification();
1184 window->send_configure_change();
1190 TitleTop::TitleTop(TitleMain *client, TitleWindow *window, int x, int y)
1191 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_TOP, _("Top"))
1193 this->client = client;
1194 this->window = window;
1196 int TitleTop::handle_event()
1198 client->config.vjustification = JUSTIFY_TOP;
1199 window->update_justification();
1200 window->send_configure_change();
1204 TitleMid::TitleMid(TitleMain *client, TitleWindow *window, int x, int y)
1205 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_MID, _("Mid"))
1207 this->client = client;
1208 this->window = window;
1210 int TitleMid::handle_event()
1212 client->config.vjustification = JUSTIFY_MID;
1213 window->update_justification();
1214 window->send_configure_change();
1218 TitleBottom::TitleBottom(TitleMain *client, TitleWindow *window, int x, int y)
1219 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_BOTTOM, _("Bottom"))
1221 this->client = client;
1222 this->window = window;
1224 int TitleBottom::handle_event()
1226 client->config.vjustification = JUSTIFY_BOTTOM;
1227 window->update_justification();
1228 window->send_configure_change();
1232 TitleDrag::TitleDrag(TitleMain *client, TitleWindow *window, int x, int y)
1233 : DragCheckBox(client->server->mwindow, x, y, _("Drag"), &client->config.drag,
1234 client->config.title_x, client->config.title_y,
1235 client->config.title_w, client->config.title_h)
1237 this->client = client;
1238 this->window = window;
1241 Track *TitleDrag::get_drag_track()
1243 PluginServer *server = client->server;
1244 int plugin_id = server->plugin_id;
1245 Plugin *plugin = server->edl->tracks->plugin_exists(plugin_id);
1246 return !plugin ? 0 : plugin->track;
1248 int64_t TitleDrag::get_drag_position()
1250 return client->get_source_position();
1253 void TitleDrag::update_gui()
1255 client->config.drag = get_value();
1256 client->config.title_x = drag_x;
1257 client->config.title_y = drag_y;
1258 client->config.title_w = drag_w+0.5;
1259 client->config.title_h = drag_h+0.5;
1260 window->title_x->update((float)client->config.title_x);
1261 window->title_y->update((float)client->config.title_y);
1262 window->title_w->update((int64_t)client->config.title_w);
1263 window->title_h->update((int64_t)client->config.title_h);
1264 window->send_configure_change();
1267 int TitleDrag::handle_event()
1269 int ret = DragCheckBox::handle_event();
1270 window->send_configure_change();
1274 TitleBackground::TitleBackground(TitleMain *client, TitleWindow *window, int x, int y)
1275 : BC_CheckBox(x, y, client->config.background, _("Background:"))
1277 this->client = client;
1278 this->window = window;
1281 int TitleBackground::handle_event()
1283 client->config.background = get_value();
1284 window->send_configure_change();
1288 TitleBackgroundPath::TitleBackgroundPath(TitleMain *client, TitleWindow *window, int x, int y)
1289 : BC_TextBox(x, y, xS(240), 1, client->config.background_path)
1291 this->client = client;
1292 this->window = window;
1295 int TitleBackgroundPath::handle_event()
1297 strncpy(client->config.background_path, get_text(), sizeof(client->config.background_path));
1298 window->send_configure_change();
1302 TitleLoopPlayback::TitleLoopPlayback(TitleMain *client, TitleWindow *window, int x, int y)
1303 : BC_CheckBox(x, y, client->config.loop_playback, _("Loop playback"))
1305 this->client = client;
1306 this->window = window;
1308 int TitleLoopPlayback::handle_event()
1310 client->config.loop_playback = get_value();
1311 window->send_configure_change();
1316 TitleCurPopup::TitleCurPopup(TitleMain *client, TitleWindow *window)
1317 : BC_PopupMenu(0, 0, 0, "", 0)
1319 this->client = client;
1320 this->window = window;
1322 int TitleCurPopup::handle_event()
1327 void TitleCurSubMenu::add_subitemx(int popup_type, va_list ap, const char *fmt)
1329 char item[BCSTRLEN];
1330 vsnprintf(item, sizeof(item)-1, fmt, ap);
1331 item[sizeof(item)-1] = 0;
1332 add_submenuitem(new TitleCurSubMenuItem(this, item, popup_type));
1335 void TitleCurPopup::create_objects()
1337 TitleCurItem *cur_item;
1338 TitleCurSubMenu *sub_menu;
1340 add_item(cur_item = new TitleCurItem(this, item = _(KW_NUDGE)));
1341 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1342 sub_menu->add_subitem("%s dx,dy",item);
1343 sub_menu->add_subitem("/%s",item);
1344 add_item(cur_item = new TitleCurItem(this, item = _(KW_COLOR)));
1345 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1346 sub_menu->add_subitem(POPUP_COLOR,"%s %s",item,_("#"));
1347 sub_menu->add_subitem("%s ",item);
1348 sub_menu->add_subitem("/%s",item);
1349 add_item(cur_item = new TitleCurItem(this, item = _(KW_ALPHA)));
1350 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1351 sub_menu->add_subitem("%s ",item);
1352 sub_menu->add_subitem("%s 0.",item);
1353 sub_menu->add_subitem("%s .5",item);
1354 sub_menu->add_subitem("%s 1.",item);
1355 sub_menu->add_subitem("/%s",item);
1356 add_item(cur_item = new TitleCurItem(this, item = _(KW_FONT)));
1357 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1358 sub_menu->add_subitem(POPUP_FONT,"%s %s",item, _("name"));
1359 sub_menu->add_subitem(POPUP_OFFSET, "%s ",item);
1360 sub_menu->add_subitem("/%s",item);
1361 add_item(cur_item = new TitleCurItem(this, item = _(KW_SIZE)));
1362 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1363 sub_menu->add_subitem("%s +",item);
1364 sub_menu->add_subitem("%s -",item);
1365 sub_menu->add_subitem("%s ",item);
1366 sub_menu->add_subitem("/%s",item);
1367 add_item(cur_item = new TitleCurItem(this, item = _(KW_BOLD)));
1368 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1369 sub_menu->add_subitem("%s 1",item);
1370 sub_menu->add_subitem("%s 0",item);
1371 sub_menu->add_subitem("/%s",item);
1372 add_item(cur_item = new TitleCurItem(this, item = _(KW_ITALIC)));
1373 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1374 sub_menu->add_subitem("%s 1",item);
1375 sub_menu->add_subitem("%s 0",item);
1376 sub_menu->add_subitem("/%s",item);
1377 add_item(cur_item = new TitleCurItem(this, item = _(KW_CAPS)));
1378 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1379 sub_menu->add_subitem("%s 1",item);
1380 sub_menu->add_subitem("%s 0",item);
1381 sub_menu->add_subitem("%s -1",item);
1382 sub_menu->add_subitem("/%s",item);
1383 add_item(cur_item = new TitleCurItem(this, item = _(KW_UL)));
1384 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1385 sub_menu->add_subitem("%s 1",item);
1386 sub_menu->add_subitem("%s 0",item);
1387 sub_menu->add_subitem("/%s",item);
1388 add_item(cur_item = new TitleCurItem(this, item = _(KW_BLINK)));
1389 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1390 sub_menu->add_subitem("%s 1",item);
1391 sub_menu->add_subitem("%s -1",item);
1392 sub_menu->add_subitem("%s ",item);
1393 sub_menu->add_subitem("%s 0",item);
1394 sub_menu->add_subitem("/%s",item);
1395 add_item(cur_item = new TitleCurItem(this, item = _(KW_FIXED)));
1396 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1397 sub_menu->add_subitem("%s ",item);
1398 sub_menu->add_subitem("%s 20",item);
1399 sub_menu->add_subitem("%s 10",item);
1400 sub_menu->add_subitem("%s 0",item);
1401 sub_menu->add_subitem("/%s",item);
1402 add_item(cur_item = new TitleCurItem(this, item = _(KW_ALIAS)));
1403 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1404 sub_menu->add_subitem("%s 1",item);
1405 sub_menu->add_subitem("%s 0",item);
1406 sub_menu->add_subitem("/%s",item);
1407 add_item(cur_item = new TitleCurItem(this, item = _(KW_SUP)));
1408 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1409 sub_menu->add_subitem("%s 1",item);
1410 sub_menu->add_subitem("%s 0",item);
1411 sub_menu->add_subitem("%s -1",item);
1412 sub_menu->add_subitem("/%s",item);
1413 add_item(cur_item = new TitleCurItem(this, item = _(KW_PNG)));
1414 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1415 sub_menu->add_subitem(POPUP_PNG,"%s %s", item, _("file"));
1418 TitleCurItem::TitleCurItem(TitleCurPopup *popup, const char *text)
1421 this->popup = popup;
1423 int TitleCurItem::handle_event()
1428 TitleCurSubMenu::TitleCurSubMenu(TitleCurItem *cur_item)
1430 this->cur_item = cur_item;
1432 TitleCurSubMenu::~TitleCurSubMenu()
1436 TitleCurSubMenuItem::TitleCurSubMenuItem(TitleCurSubMenu *submenu, const char *text, int popup_type)
1439 this->submenu = submenu;
1440 this->popup_type = popup_type;
1442 TitleCurSubMenuItem::~TitleCurSubMenuItem()
1445 int TitleCurSubMenuItem::handle_event()
1447 TitleCurPopup *popup = submenu->cur_item->popup;
1448 TitleWindow *window = popup->window;
1449 const char *item_text = get_text();
1450 int ofs = *item_text == '/' ? 0 : -1;
1451 switch( popup_type ) {
1454 window->get_pop_cursor(px ,py);
1455 window->fonts_popup->activate(px, py, xS(300),yS(200));
1458 window->color_popup->activate();
1461 window->png_popup->activate();
1468 sprintf(txt, "<%s>", item_text);
1469 return window->insert_ibeam(txt, ofs);
1472 TitleFontsPopup::TitleFontsPopup(TitleMain *client, TitleWindow *window)
1473 : BC_ListBox(-1, -1, 1, 1, LISTBOX_ICON_LIST,
1474 &window->fonts, 0, 0, 1, 0, 1)
1476 this->client = client;
1477 this->window = window;
1481 TitleFontsPopup::~TitleFontsPopup()
1484 int TitleFontsPopup::keypress_event()
1486 switch( get_keypress() ) {
1494 return BC_ListBox::keypress_event();
1497 int TitleFontsPopup::handle_event()
1500 BC_ListBoxItem *item = get_selection(0, 0);
1501 if( !item ) return 1;
1502 const char *item_text = item->get_text();
1503 char txt[BCTEXTLEN]; sprintf(txt, "<%s %s>", _(KW_FONT), item_text);
1504 return window->insert_ibeam(txt);
1507 TitleColorPopup::TitleColorPopup(TitleMain *client, TitleWindow *window)
1508 : ColorPicker(0, _("Color"))
1510 this->client = client;
1511 this->window = window;
1512 this->color_value = client->config.color;
1514 TitleColorPopup::~TitleColorPopup()
1517 int TitleColorPopup::handle_new_color(int output, int alpha)
1519 color_value = output;
1522 int TitleColorPopup::activate()
1524 start_window(client->config.color, 255, 1);
1527 void TitleColorPopup::handle_done_event(int result)
1530 char txt[BCSTRLEN]; sprintf(txt, "<%s #%06x>", _(KW_COLOR), color_value);
1531 window->lock_window("TitleColorPopup::handle_done_event");
1532 window->insert_ibeam(txt);
1533 window->unlock_window();
1537 TitlePngPopup::TitlePngPopup(TitleMain *client, TitleWindow *window)
1540 this->client = client;
1541 this->window = window;
1544 TitlePngPopup::~TitlePngPopup()
1549 void TitlePngPopup::handle_done_event(int result)
1551 if( result ) return;
1552 BrowseButtonWindow *gui = (BrowseButtonWindow *)get_gui();
1553 const char *path = gui->get_submitted_path();
1554 char txt[BCTEXTLEN]; sprintf(txt, "<%s %s>", _(KW_PNG), path);
1555 window->lock_window("TitlePngPopup::handle_done_event");
1556 window->insert_ibeam(txt);
1557 window->unlock_window();
1560 BC_Window *TitlePngPopup::new_gui()
1562 MWindow *mwindow = client->server->mwindow;
1563 int x, y; mwindow->gui->get_abs_cursor(x, y);
1565 BC_Window *gui = new BrowseButtonWindow(mwindow->theme,
1566 x-xS(25), y-yS(100), window, "", _("Png file"), _("Png path"), 0);
1567 gui->create_objects();
1571 int TitlePngPopup::activate()
1573 BC_DialogThread::start();