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;
144 void TitleWindow::create_objects()
146 int x = xS(10), y = yS(10);
147 int margin = client->get_theme()->widget_border;
148 char string[BCTEXTLEN];
150 #define COLOR_W xS(50)
151 #define COLOR_H yS(30)
152 client->build_previews(this);
154 sizes.append(new BC_ListBoxItem("8"));
155 sizes.append(new BC_ListBoxItem("9"));
156 sizes.append(new BC_ListBoxItem("10"));
157 sizes.append(new BC_ListBoxItem("11"));
158 sizes.append(new BC_ListBoxItem("12"));
159 sizes.append(new BC_ListBoxItem("13"));
160 sizes.append(new BC_ListBoxItem("14"));
161 sizes.append(new BC_ListBoxItem("16"));
162 sizes.append(new BC_ListBoxItem("18"));
163 sizes.append(new BC_ListBoxItem("20"));
164 sizes.append(new BC_ListBoxItem("22"));
165 sizes.append(new BC_ListBoxItem("24"));
166 sizes.append(new BC_ListBoxItem("26"));
167 sizes.append(new BC_ListBoxItem("28"));
168 sizes.append(new BC_ListBoxItem("32"));
169 sizes.append(new BC_ListBoxItem("36"));
170 sizes.append(new BC_ListBoxItem("40"));
171 sizes.append(new BC_ListBoxItem("48"));
172 sizes.append(new BC_ListBoxItem("56"));
173 sizes.append(new BC_ListBoxItem("64"));
174 sizes.append(new BC_ListBoxItem("72"));
175 sizes.append(new BC_ListBoxItem("100"));
176 sizes.append(new BC_ListBoxItem("128"));
177 sizes.append(new BC_ListBoxItem("256"));
178 sizes.append(new BC_ListBoxItem("512"));
179 sizes.append(new BC_ListBoxItem("1024"));
181 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(NO_MOTION)));
182 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(BOTTOM_TO_TOP)));
183 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(TOP_TO_BOTTOM)));
184 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(RIGHT_TO_LEFT)));
185 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(LEFT_TO_RIGHT)));
189 // Construct font list
190 ArrayList<BC_FontEntry*> *fontlist = get_resources()->fontlist;
192 for( int i=0; i<fontlist->size(); ++i ) {
194 for( int j=0; j<fonts.size(); ++j ) {
195 if( !strcasecmp(fonts.get(j)->get_text(),
196 fontlist->get(i)->displayname) ) {
202 BC_ListBoxItem *item = 0;
204 fonts.append(item = new
205 BC_ListBoxItem(fontlist->get(i)->displayname));
206 if( !strcmp(client->config.font, item->get_text()) )
207 item->set_selected(1);
208 if( fontlist->values[i]->image ) {
209 VFrame *vframe = fontlist->get(i)->image;
210 BC_Pixmap *icon = new BC_Pixmap(this, vframe, PIXMAP_ALPHA);
211 item->set_icon(icon);
212 item->set_icon_vframe(vframe);
221 for( int i=0; i<fonts.size()-1; ++i ) {
222 if( strcmp(fonts.values[i]->get_text(),
223 fonts.values[i + 1]->get_text()) > 0 ) {
224 BC_ListBoxItem *temp = fonts.values[i + 1];
225 fonts.values[i + 1] = fonts.values[i];
226 fonts.values[i] = temp;
232 add_tool(font_title = new BC_Title(x, y, _("Font:")));
233 font = new TitleFont(client, this, x, y + font_title->get_h());
234 font->create_objects();
235 font->set_show_query(1);
237 add_subwindow(font_tumbler = new TitleFontTumble(client, this, x, y+margin));
238 x += font_tumbler->get_w() + margin;
240 int x1 = x+xS(20), y1 = y;
241 add_tool(size_title = new BC_Title(x1, y1+margin, _("Size:")));
242 sprintf(string, "%.2f", client->config.size);
243 x1 += size_title->get_w() + margin;
244 size = new TitleSize(client, this, x1, y1+margin, string);
245 size->create_objects();
246 int x2 = x1 + size->get_w(), y2 = y1 + size->get_h() + margin;
247 add_subwindow(size_tumbler = new TitleSizeTumble(client, this, x2, y1+margin));
249 add_tool(pitch_title = new BC_Title(x-xS(16), y2+margin, _("Line Pitch:")));
250 pitch = new TitlePitch(client, this, x1, y2+margin, &client->config.line_pitch);
251 pitch->create_objects();
253 int x3 = x2 + size_tumbler->get_w() + xS(50);
254 int y3 = pitch->get_y() + pitch->get_h();
256 add_tool(style_title = new BC_Title(x=x3, y, _("Style:")));
257 add_tool(italic = new TitleItalic(client, this, x, y + yS(20)));
258 int w1 = italic->get_w();
259 add_tool(bold = new TitleBold(client, this, x, y + yS(50)));
260 if( bold->get_w() > w1 ) w1 = bold->get_w();
262 add_tool(drag = new TitleDrag(client, this, x, y + yS(80)));
263 drag->create_objects();
264 if( drag->get_w() > w1 ) w1 = drag->get_w();
265 if( client->config.drag ) {
266 if( drag->drag_activate() )
267 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 italic->update(client->config.style & BC_FONT_ITALIC);
576 bold->update(client->config.style & BC_FONT_BOLD);
577 alias->update(client->config.style & FONT_ALIAS);
578 size->update(client->config.size);
579 motion->update(TitleMain::motion_to_text(client->config.motion_strategy));
580 loop->update(client->config.loop);
581 dropshadow->update((int64_t)client->config.dropshadow);
582 fade_in->update((float)client->config.fade_in);
583 fade_out->update((float)client->config.fade_out);
584 font->update(client->config.font);
585 check_style(client->config.font,0);
586 wchr_t wz[1] = { 0 };
587 text->update(client->config.wtext ? &client->config.wtext[0] : wz);
588 speed->update(client->config.pixels_per_second);
589 outline->update((int64_t)client->config.outline_size);
591 stroker->update((int64_t)client->config.stroke_width);
593 timecode->update(client->config.timecode);
594 timecode_format->update(client->config.timecode_format);
595 background->update(client->config.background);
596 background_path->update(client->config.background_path);
597 loop_playback->update((int64_t)client->config.loop_playback);
599 char string[BCTEXTLEN];
600 for( int i=0; i<lengthof(timeunit_formats); ++i ) {
601 if( timeunit_formats[i] == client->config.timecode_format ) {
602 timecode_format->set_text(
603 Units::print_time_format(timeunit_formats[i], string));
607 update_justification();
613 TitleFontTumble::TitleFontTumble(TitleMain *client, TitleWindow *window, int x, int y)
616 this->client = client;
617 this->window = window;
619 int TitleFontTumble::handle_up_event()
621 window->previous_font();
625 int TitleFontTumble::handle_down_event()
632 TitleSizeTumble::TitleSizeTumble(TitleMain *client, TitleWindow *window, int x, int y)
635 this->client = client;
636 this->window = window;
639 int TitleSizeTumble::handle_up_event()
641 int current_index = -1;
642 int current_difference = -1;
643 for( int i=0; i<window->sizes.size(); ++i ) {
644 int size = atoi(window->sizes.get(i)->get_text());
645 if( current_index < 0 ||
646 abs(size - client->config.size) < current_difference ) {
648 current_difference = abs(size - client->config.size);
653 if( current_index >= window->sizes.size() ) current_index = 0;
656 client->config.size = atoi(window->sizes.get(current_index)->get_text());
657 window->size->update(client->config.size);
658 window->send_configure_change();
662 int TitleSizeTumble::handle_down_event()
664 int current_index = -1;
665 int current_difference = -1;
666 for( int i=0; i<window->sizes.size(); ++i ) {
667 int size = atoi(window->sizes.get(i)->get_text());
668 if( current_index < 0 ||
669 abs(size - client->config.size) < current_difference ) {
671 current_difference = abs(size - client->config.size);
676 if( current_index < 0 ) current_index = window->sizes.size() - 1;
679 client->config.size = atoi(window->sizes.get(current_index)->get_text());
680 window->size->update(client->config.size);
681 window->send_configure_change();
685 TitleAlias::TitleAlias(TitleMain *client, TitleWindow *window, int x, int y)
686 : BC_CheckBox(x, y, client->config.style & FONT_ALIAS, _("Smooth"))
688 this->client = client;
689 this->window = window;
692 int TitleAlias::handle_event()
694 client->config.style =
695 (client->config.style & ~FONT_ALIAS) |
696 (get_value() ? FONT_ALIAS : 0);
697 window->send_configure_change();
701 TitleBold::TitleBold(TitleMain *client, TitleWindow *window, int x, int y)
702 : BC_CheckBox(x, y, client->config.style & BC_FONT_BOLD, _("Bold"))
704 this->client = client;
705 this->window = window;
708 int TitleBold::handle_event()
710 client->config.style =
711 (client->config.style & ~BC_FONT_BOLD) |
712 (get_value() ? BC_FONT_BOLD : 0);
713 window->send_configure_change();
717 TitleItalic::TitleItalic(TitleMain *client, TitleWindow *window, int x, int y)
718 : BC_CheckBox(x, y, client->config.style & BC_FONT_ITALIC, _("Italic"))
720 this->client = client;
721 this->window = window;
723 int TitleItalic::handle_event()
725 client->config.style =
726 (client->config.style & ~BC_FONT_ITALIC) |
727 (get_value() ? BC_FONT_ITALIC : 0);
728 window->send_configure_change();
734 TitleSize::TitleSize(TitleMain *client, TitleWindow *window, int x, int y, char *text)
735 : BC_PopupTextBox(window, &window->sizes, text, x, y, xS(64), yS(300))
737 this->client = client;
738 this->window = window;
740 TitleSize::~TitleSize()
743 int TitleSize::handle_event()
745 client->config.size = atol(get_text());
746 //printf("TitleSize::handle_event 1 %s\n", get_text());
747 window->send_configure_change();
750 void TitleSize::update(int size)
752 char string[BCTEXTLEN];
753 sprintf(string, "%d", size);
754 BC_PopupTextBox::update(string);
758 TitlePitch(TitleMain *client, TitleWindow *window, int x, int y, int *value)
759 : BC_TumbleTextBox(window, *value, 0, INT_MAX, x, y, xS(64))
761 this->client = client;
762 this->window = window;
771 int TitlePitch::handle_event()
773 *value = atol(get_text());
774 window->send_configure_change();
778 TitleColorButton::TitleColorButton(TitleMain *client, TitleWindow *window, int x, int y)
779 : ColorCircleButton(_("Text Color"), x, y, COLOR_W, COLOR_H,
780 client->config.color, client->config.alpha, 1)
782 this->client = client;
783 this->window = window;
785 int TitleColorButton::handle_new_color(int output, int alpha)
787 client->config.color = output;
788 client->config.alpha = alpha;
789 window->send_configure_change();
792 void TitleColorButton::handle_done_event(int result)
795 handle_new_color(orig_color, orig_alpha);
796 window->lock_window("TitleColorButton::handle_done_event");
797 update_gui(orig_color);
798 window->unlock_window();
802 TitleOutlineColorButton::TitleOutlineColorButton(TitleMain *client, TitleWindow *window, int x, int y)
803 : ColorCircleButton(_("Outline Color"), x, y, COLOR_W, COLOR_H,
804 client->config.outline_color, client->config.outline_alpha, 1)
806 this->client = client;
807 this->window = window;
809 int TitleOutlineColorButton::handle_new_color(int output, int alpha)
811 client->config.outline_color = output;
812 client->config.outline_alpha = alpha;
813 window->send_configure_change();
816 void TitleOutlineColorButton::handle_done_event(int result)
819 handle_new_color(orig_color, orig_alpha);
820 window->lock_window("TitleColorButton::handle_done_event");
821 update_gui(orig_color);
822 window->unlock_window();
827 TitleMotion::TitleMotion(TitleMain *client, TitleWindow *window, int x, int y)
828 : BC_PopupTextBox(window, &window->paths,
829 client->motion_to_text(client->config.motion_strategy),
830 x, y, xS(120), yS(100))
832 this->client = client;
833 this->window = window;
835 int TitleMotion::handle_event()
837 client->config.motion_strategy = client->text_to_motion(get_text());
838 window->send_configure_change();
842 TitleLoop::TitleLoop(TitleMain *client, TitleWindow *window, int x, int y)
843 : BC_CheckBox(x, y, client->config.loop, _("Loop"))
845 this->client = client;
846 this->window = window;
848 int TitleLoop::handle_event()
850 client->config.loop = get_value();
851 window->send_configure_change();
854 TitleTimecode::TitleTimecode(TitleMain *client, TitleWindow *window, int x, int y)
855 : BC_CheckBox(x, y, client->config.timecode, _("Stamp timecode"))
857 this->client = client;
858 this->window = window;
860 int TitleTimecode::handle_event()
862 client->config.timecode = get_value();
863 client->send_configure_change();
867 TitleTimecodeFormat::TitleTimecodeFormat(TitleMain *client, TitleWindow *window,
868 int x, int y, int tw, const char *text)
869 : BC_PopupMenu(x, y, BC_PopupMenu::calculate_w(tw)+xS(10), text, 1)
871 this->client = client;
872 this->window = window;
875 int TitleTimecodeFormat::handle_event()
877 client->config.timecode_format = Units::text_to_format(get_text());
878 window->send_configure_change();
882 void TitleTimecodeFormat::create_objects()
884 char string[BCTEXTLEN];
885 for( int i=0; i<lengthof(timeunit_formats); ++i ) {
886 add_item(new BC_MenuItem(
887 Units::print_time_format(timeunit_formats[i], string)));
892 int TitleTimecodeFormat::update(int timecode_format)
894 char string[BCTEXTLEN];
895 for( int i=0; i<lengthof(timeunit_formats); ++i ) {
896 if( timeunit_formats[i] == timecode_format ) {
897 set_text(Units::print_time_format(timeunit_formats[i], string));
904 TitleFade::TitleFade(TitleMain *client, TitleWindow *window,
905 double *value, int x, int y)
906 : BC_TextBox(x, y, xS(80), 1, (float)*value)
908 this->client = client;
909 this->window = window;
914 int TitleFade::handle_event()
916 *value = atof(get_text());
917 window->send_configure_change();
921 void TitleWindow::check_style(const char *font_name, int update)
923 BC_FontEntry *font_nrm = TitleMain::get_font(font_name, 0);
924 BC_FontEntry *font_itl = TitleMain::get_font(font_name, BC_FONT_ITALIC);
925 BC_FontEntry *font_bld = TitleMain::get_font(font_name, BC_FONT_BOLD);
926 BC_FontEntry *font_bit = TitleMain::get_font(font_name, BC_FONT_ITALIC | BC_FONT_BOLD);
927 int has_norm = font_nrm != 0 ? 1 : 0;
928 int has_ital = font_itl != 0 || font_bit != 0 ? 1 : 0;
929 int has_bold = font_bld != 0 || font_bit != 0 ? 1 : 0;
930 if( bold->get_value() ) {
931 if( !has_bold ) bold->update(0);
934 if( !has_norm && has_bold ) bold->update(1);
936 if( italic->get_value() ) {
937 if( !has_ital ) italic->update(0);
940 if( !has_norm && has_ital ) italic->update(1);
942 if( has_norm && has_bold ) bold->enable(); else bold->disable();
943 if( has_norm && has_ital ) italic->enable(); else italic->disable();
945 int style = stroker && atof(stroker->get_text()) ? BC_FONT_OUTLINE : 0;
946 if( bold->get_value() ) style |= BC_FONT_BOLD;
947 if( italic->get_value() ) style |= BC_FONT_ITALIC;
948 if( alias->get_value() ) style |= FONT_ALIAS;
949 client->config.style = style;
953 TitleFont::TitleFont(TitleMain *client, TitleWindow *window, int x, int y)
954 : BC_PopupTextBox(window, &window->fonts, client->config.font,
955 x, y, xS(340), yS(300), LISTBOX_ICON_LIST)
957 this->client = client;
958 this->window = window;
960 int TitleFont::handle_event()
962 strcpy(client->config.font, get_text());
963 window->check_style(client->config.font, 1);
964 window->send_configure_change();
968 TitleText::TitleText(TitleMain *client, TitleWindow *window,
969 int x, int y, int w, int h)
970 : BC_ScrollTextBox(window, x, y, w,
971 BC_TextBox::pixels_to_rows(window, MEDIUMFONT, h),
972 client->config.wtext, 0)
974 this->client = client;
975 this->window = window;
976 //printf("TitleText::TitleText %s\n", client->config.text);
979 int TitleText::button_press_event()
981 if( get_buttonpress() == 3 ) {
982 window->cur_ibeam = get_ibeam_letter();
983 window->cur_popup->activate_menu();
986 return BC_ScrollTextBox::button_press_event();
989 int TitleText::handle_event()
991 window->fonts_popup->deactivate();
992 const wchr_t *wtext = get_wtext();
993 long wlen = wstrlen(wtext);
994 client->config.demand(wlen);
995 wstrncpy(client->config.wtext, wtext, client->config.wsize);
996 client->config.wlen = wlen;
997 window->update_stats();
998 window->send_configure_change();
1001 TitleTextChars::TitleTextChars(int x, int y, int w)
1002 : BC_Title(x, y, "", MEDIUMFONT, -1, 0, w)
1005 TitleTextChars::~TitleTextChars()
1008 int TitleTextChars::update(int n)
1010 char text[BCSTRLEN];
1011 sprintf(text, _("chars: %d "),n);
1012 return BC_Title::update(text, 0);
1016 TitleDropShadow::TitleDropShadow(TitleMain *client, TitleWindow *window, int x, int y)
1017 : BC_TumbleTextBox(window, client->config.dropshadow,
1018 -1000, 1000, x, y, xS(70))
1020 this->client = client;
1021 this->window = window;
1023 int TitleDropShadow::handle_event()
1025 client->config.dropshadow = atol(get_text());
1026 window->send_configure_change();
1031 TitleOutline::TitleOutline(TitleMain *client, TitleWindow *window, int x, int y)
1032 : BC_TumbleTextBox(window, client->config.outline_size,
1033 0.f, 1000.f, x, y, xS(70))
1035 this->client = client;
1036 this->window = window;
1039 int TitleOutline::handle_event()
1041 client->config.outline_size = atof(get_text());
1042 window->send_configure_change();
1047 TitleStroker::TitleStroker(TitleMain *client, TitleWindow *window, int x, int y)
1048 : BC_TumbleTextBox(window, client->config.stroke_width,
1049 0.f, 1000.f, x, y, xS(70))
1051 this->client = client;
1052 this->window = window;
1055 int TitleStroker::handle_event()
1057 client->config.stroke_width = atof(get_text());
1058 if( client->config.stroke_width )
1059 client->config.style |= BC_FONT_OUTLINE;
1061 client->config.style &= ~BC_FONT_OUTLINE;
1062 window->send_configure_change();
1067 TitleX::TitleX(TitleMain *client, TitleWindow *window, int x, int y)
1068 : BC_TumbleTextBox(window, client->config.title_x,
1069 -32767.f, 32767.f, x, y, xS(50))
1071 this->client = client;
1072 this->window = window;
1075 int TitleX::handle_event()
1077 client->config.title_x = atof(get_text());
1078 window->update_drag();
1082 TitleY::TitleY(TitleMain *client, TitleWindow *window, int x, int y)
1083 : BC_TumbleTextBox(window, client->config.title_y,
1084 -32767.f, 32767.f, x, y, xS(50))
1086 this->client = client;
1087 this->window = window;
1090 int TitleY::handle_event()
1092 client->config.title_y = atof(get_text());
1093 window->update_drag();
1097 TitleW::TitleW(TitleMain *client, TitleWindow *window, int x, int y)
1098 : BC_TumbleTextBox(window, client->config.title_w,
1099 0, 32767, x, y, xS(50))
1101 this->client = client;
1102 this->window = window;
1104 int TitleW::handle_event()
1106 client->config.title_w = atol(get_text());
1107 window->update_drag();
1111 TitleH::TitleH(TitleMain *client, TitleWindow *window, int x, int y)
1112 : BC_TumbleTextBox(window, client->config.title_h,
1113 0, 32767, x, y, xS(50))
1115 this->client = client;
1116 this->window = window;
1118 int TitleH::handle_event()
1120 client->config.title_h = atol(get_text());
1121 window->update_drag();
1125 TitleSpeed::TitleSpeed(TitleMain *client, TitleWindow *window, int x, int y)
1126 : BC_TumbleTextBox(window, client->config.pixels_per_second,
1127 0.f, 1000.f, x, y, xS(100))
1129 this->client = client;
1130 this->window = window;
1136 int TitleSpeed::handle_event()
1138 client->config.pixels_per_second = atof(get_text());
1139 window->send_configure_change();
1144 TitleLeft::TitleLeft(TitleMain *client, TitleWindow *window, int x, int y)
1145 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_LEFT, _("Left"))
1147 this->client = client;
1148 this->window = window;
1150 int TitleLeft::handle_event()
1152 client->config.hjustification = JUSTIFY_LEFT;
1153 window->update_justification();
1154 window->send_configure_change();
1158 TitleCenter::TitleCenter(TitleMain *client, TitleWindow *window, int x, int y)
1159 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_CENTER, _("Center"))
1161 this->client = client;
1162 this->window = window;
1164 int TitleCenter::handle_event()
1166 client->config.hjustification = JUSTIFY_CENTER;
1167 window->update_justification();
1168 window->send_configure_change();
1172 TitleRight::TitleRight(TitleMain *client, TitleWindow *window, int x, int y)
1173 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_RIGHT, _("Right"))
1175 this->client = client;
1176 this->window = window;
1178 int TitleRight::handle_event()
1180 client->config.hjustification = JUSTIFY_RIGHT;
1181 window->update_justification();
1182 window->send_configure_change();
1188 TitleTop::TitleTop(TitleMain *client, TitleWindow *window, int x, int y)
1189 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_TOP, _("Top"))
1191 this->client = client;
1192 this->window = window;
1194 int TitleTop::handle_event()
1196 client->config.vjustification = JUSTIFY_TOP;
1197 window->update_justification();
1198 window->send_configure_change();
1202 TitleMid::TitleMid(TitleMain *client, TitleWindow *window, int x, int y)
1203 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_MID, _("Mid"))
1205 this->client = client;
1206 this->window = window;
1208 int TitleMid::handle_event()
1210 client->config.vjustification = JUSTIFY_MID;
1211 window->update_justification();
1212 window->send_configure_change();
1216 TitleBottom::TitleBottom(TitleMain *client, TitleWindow *window, int x, int y)
1217 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_BOTTOM, _("Bottom"))
1219 this->client = client;
1220 this->window = window;
1222 int TitleBottom::handle_event()
1224 client->config.vjustification = JUSTIFY_BOTTOM;
1225 window->update_justification();
1226 window->send_configure_change();
1230 TitleDrag::TitleDrag(TitleMain *client, TitleWindow *window, int x, int y)
1231 : DragCheckBox(client->server->mwindow, x, y, _("Drag"), &client->config.drag,
1232 client->config.title_x, client->config.title_y,
1233 client->config.title_w, client->config.title_h)
1235 this->client = client;
1236 this->window = window;
1239 Track *TitleDrag::get_drag_track()
1241 PluginServer *server = client->server;
1242 int plugin_id = server->plugin_id;
1243 Plugin *plugin = server->edl->tracks->plugin_exists(plugin_id);
1244 return !plugin ? 0 : plugin->track;
1246 int64_t TitleDrag::get_drag_position()
1248 return client->get_source_position();
1251 void TitleDrag::update_gui()
1253 client->config.drag = get_value();
1254 client->config.title_x = drag_x;
1255 client->config.title_y = drag_y;
1256 client->config.title_w = drag_w+0.5;
1257 client->config.title_h = drag_h+0.5;
1258 window->title_x->update((float)client->config.title_x);
1259 window->title_y->update((float)client->config.title_y);
1260 window->title_w->update((int64_t)client->config.title_w);
1261 window->title_h->update((int64_t)client->config.title_h);
1262 window->send_configure_change();
1265 int TitleDrag::handle_event()
1267 int ret = DragCheckBox::handle_event();
1268 window->send_configure_change();
1272 TitleBackground::TitleBackground(TitleMain *client, TitleWindow *window, int x, int y)
1273 : BC_CheckBox(x, y, client->config.background, _("Background:"))
1275 this->client = client;
1276 this->window = window;
1279 int TitleBackground::handle_event()
1281 client->config.background = get_value();
1282 window->send_configure_change();
1286 TitleBackgroundPath::TitleBackgroundPath(TitleMain *client, TitleWindow *window, int x, int y)
1287 : BC_TextBox(x, y, xS(240), 1, client->config.background_path)
1289 this->client = client;
1290 this->window = window;
1293 int TitleBackgroundPath::handle_event()
1295 strncpy(client->config.background_path, get_text(), sizeof(client->config.background_path));
1296 window->send_configure_change();
1300 TitleLoopPlayback::TitleLoopPlayback(TitleMain *client, TitleWindow *window, int x, int y)
1301 : BC_CheckBox(x, y, client->config.loop_playback, _("Loop playback"))
1303 this->client = client;
1304 this->window = window;
1306 int TitleLoopPlayback::handle_event()
1308 client->config.loop_playback = get_value();
1309 window->send_configure_change();
1314 TitleCurPopup::TitleCurPopup(TitleMain *client, TitleWindow *window)
1315 : BC_PopupMenu(0, 0, 0, "", 0)
1317 this->client = client;
1318 this->window = window;
1320 int TitleCurPopup::handle_event()
1325 void TitleCurSubMenu::add_subitemx(int popup_type, va_list ap, const char *fmt)
1327 char item[BCSTRLEN];
1328 vsnprintf(item, sizeof(item)-1, fmt, ap);
1329 item[sizeof(item)-1] = 0;
1330 add_submenuitem(new TitleCurSubMenuItem(this, item, popup_type));
1333 void TitleCurPopup::create_objects()
1335 TitleCurItem *cur_item;
1336 TitleCurSubMenu *sub_menu;
1338 add_item(cur_item = new TitleCurItem(this, item = _(KW_NUDGE)));
1339 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1340 sub_menu->add_subitem("%s dx,dy",item);
1341 sub_menu->add_subitem("/%s",item);
1342 add_item(cur_item = new TitleCurItem(this, item = _(KW_COLOR)));
1343 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1344 sub_menu->add_subitem(POPUP_COLOR,"%s %s",item,_("#"));
1345 sub_menu->add_subitem("%s ",item);
1346 sub_menu->add_subitem("/%s",item);
1347 add_item(cur_item = new TitleCurItem(this, item = _(KW_ALPHA)));
1348 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1349 sub_menu->add_subitem("%s ",item);
1350 sub_menu->add_subitem("%s 0.",item);
1351 sub_menu->add_subitem("%s .5",item);
1352 sub_menu->add_subitem("%s 1.",item);
1353 sub_menu->add_subitem("/%s",item);
1354 add_item(cur_item = new TitleCurItem(this, item = _(KW_FONT)));
1355 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1356 sub_menu->add_subitem(POPUP_FONT,"%s %s",item, _("name"));
1357 sub_menu->add_subitem(POPUP_OFFSET, "%s ",item);
1358 sub_menu->add_subitem("/%s",item);
1359 add_item(cur_item = new TitleCurItem(this, item = _(KW_SIZE)));
1360 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1361 sub_menu->add_subitem("%s +",item);
1362 sub_menu->add_subitem("%s -",item);
1363 sub_menu->add_subitem("%s ",item);
1364 sub_menu->add_subitem("/%s",item);
1365 add_item(cur_item = new TitleCurItem(this, item = _(KW_BOLD)));
1366 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1367 sub_menu->add_subitem("%s 1",item);
1368 sub_menu->add_subitem("%s 0",item);
1369 sub_menu->add_subitem("/%s",item);
1370 add_item(cur_item = new TitleCurItem(this, item = _(KW_ITALIC)));
1371 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1372 sub_menu->add_subitem("%s 1",item);
1373 sub_menu->add_subitem("%s 0",item);
1374 sub_menu->add_subitem("/%s",item);
1375 add_item(cur_item = new TitleCurItem(this, item = _(KW_CAPS)));
1376 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1377 sub_menu->add_subitem("%s 1",item);
1378 sub_menu->add_subitem("%s 0",item);
1379 sub_menu->add_subitem("%s -1",item);
1380 sub_menu->add_subitem("/%s",item);
1381 add_item(cur_item = new TitleCurItem(this, item = _(KW_UL)));
1382 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1383 sub_menu->add_subitem("%s 1",item);
1384 sub_menu->add_subitem("%s 0",item);
1385 sub_menu->add_subitem("/%s",item);
1386 add_item(cur_item = new TitleCurItem(this, item = _(KW_BLINK)));
1387 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1388 sub_menu->add_subitem("%s 1",item);
1389 sub_menu->add_subitem("%s -1",item);
1390 sub_menu->add_subitem("%s ",item);
1391 sub_menu->add_subitem("%s 0",item);
1392 sub_menu->add_subitem("/%s",item);
1393 add_item(cur_item = new TitleCurItem(this, item = _(KW_FIXED)));
1394 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1395 sub_menu->add_subitem("%s ",item);
1396 sub_menu->add_subitem("%s 20",item);
1397 sub_menu->add_subitem("%s 10",item);
1398 sub_menu->add_subitem("%s 0",item);
1399 sub_menu->add_subitem("/%s",item);
1400 add_item(cur_item = new TitleCurItem(this, item = _(KW_ALIAS)));
1401 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1402 sub_menu->add_subitem("%s 1",item);
1403 sub_menu->add_subitem("%s 0",item);
1404 sub_menu->add_subitem("/%s",item);
1405 add_item(cur_item = new TitleCurItem(this, item = _(KW_SUP)));
1406 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1407 sub_menu->add_subitem("%s 1",item);
1408 sub_menu->add_subitem("%s 0",item);
1409 sub_menu->add_subitem("%s -1",item);
1410 sub_menu->add_subitem("/%s",item);
1411 add_item(cur_item = new TitleCurItem(this, item = _(KW_PNG)));
1412 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1413 sub_menu->add_subitem(POPUP_PNG,"%s %s", item, _("file"));
1416 TitleCurItem::TitleCurItem(TitleCurPopup *popup, const char *text)
1419 this->popup = popup;
1421 int TitleCurItem::handle_event()
1426 TitleCurSubMenu::TitleCurSubMenu(TitleCurItem *cur_item)
1428 this->cur_item = cur_item;
1430 TitleCurSubMenu::~TitleCurSubMenu()
1434 TitleCurSubMenuItem::TitleCurSubMenuItem(TitleCurSubMenu *submenu, const char *text, int popup_type)
1437 this->submenu = submenu;
1438 this->popup_type = popup_type;
1440 TitleCurSubMenuItem::~TitleCurSubMenuItem()
1443 int TitleCurSubMenuItem::handle_event()
1445 TitleCurPopup *popup = submenu->cur_item->popup;
1446 TitleWindow *window = popup->window;
1447 const char *item_text = get_text();
1448 int ofs = *item_text == '/' ? 0 : -1;
1449 switch( popup_type ) {
1452 window->get_pop_cursor(px ,py);
1453 window->fonts_popup->activate(px, py, xS(300),yS(200));
1456 window->color_popup->activate();
1459 window->png_popup->activate();
1466 sprintf(txt, "<%s>", item_text);
1467 return window->insert_ibeam(txt, ofs);
1470 TitleFontsPopup::TitleFontsPopup(TitleMain *client, TitleWindow *window)
1471 : BC_ListBox(-1, -1, 1, 1, LISTBOX_ICON_LIST,
1472 &window->fonts, 0, 0, 1, 0, 1)
1474 this->client = client;
1475 this->window = window;
1479 TitleFontsPopup::~TitleFontsPopup()
1482 int TitleFontsPopup::keypress_event()
1484 switch( get_keypress() ) {
1492 return BC_ListBox::keypress_event();
1495 int TitleFontsPopup::handle_event()
1498 BC_ListBoxItem *item = get_selection(0, 0);
1499 if( !item ) return 1;
1500 const char *item_text = item->get_text();
1501 char txt[BCTEXTLEN]; sprintf(txt, "<%s %s>", _(KW_FONT), item_text);
1502 return window->insert_ibeam(txt);
1505 TitleColorPopup::TitleColorPopup(TitleMain *client, TitleWindow *window)
1506 : ColorPicker(0, _("Color"))
1508 this->client = client;
1509 this->window = window;
1510 this->color_value = client->config.color;
1512 TitleColorPopup::~TitleColorPopup()
1515 int TitleColorPopup::handle_new_color(int output, int alpha)
1517 color_value = output;
1520 int TitleColorPopup::activate()
1522 start_window(client->config.color, 255, 1);
1525 void TitleColorPopup::handle_done_event(int result)
1528 char txt[BCSTRLEN]; sprintf(txt, "<%s #%06x>", _(KW_COLOR), color_value);
1529 window->lock_window("TitleColorPopup::handle_done_event");
1530 window->insert_ibeam(txt);
1531 window->unlock_window();
1535 TitlePngPopup::TitlePngPopup(TitleMain *client, TitleWindow *window)
1538 this->client = client;
1539 this->window = window;
1542 TitlePngPopup::~TitlePngPopup()
1547 void TitlePngPopup::handle_done_event(int result)
1549 if( result ) return;
1550 BrowseButtonWindow *gui = (BrowseButtonWindow *)get_gui();
1551 const char *path = gui->get_submitted_path();
1552 char txt[BCSTRLEN]; sprintf(txt, "<%s %s>", _(KW_PNG), path);
1553 window->lock_window("TitlePngPopup::handle_done_event");
1554 window->insert_ibeam(txt);
1555 window->unlock_window();
1558 BC_Window *TitlePngPopup::new_gui()
1560 MWindow *mwindow = client->server->mwindow;
1561 int x, y; mwindow->gui->get_abs_cursor(x, y);
1563 BC_Window *gui = new BrowseButtonWindow(mwindow->theme,
1564 x-xS(25), y-yS(100), window, "", _("Png file"), _("Png path"), 0);
1565 gui->create_objects();
1569 int TitlePngPopup::activate()
1571 BC_DialogThread::start();