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"
32 #include "edlsession.h"
36 #include "pluginserver.h"
39 #include "titlerwindow.h"
40 #include "bcfontentry.h"
44 static const int timeunit_formats[] =
55 TitleWindow::TitleWindow(TitleMain *client)
56 : PluginClientWindow(client,
57 client->config.window_w, client->config.window_h, 100, 100, 1)
59 //printf("TitleWindow::TitleWindow %d %d %d\n", __LINE__, client->config.window_w, client->config.window_h);
60 this->client = client;
65 x_title = 0; title_x = 0;
66 y_title = 0; title_y = 0;
67 w_title = 0; title_w = 0;
68 h_title = 0; title_h = 0;
69 dropshadow_title = 0; dropshadow = 0;
70 outline_title = 0; outline = 0;
71 stroker_title = 0; stroker = 0;
79 color_x = color_y = 0;
80 outline_color_x = outline_color_y = 0;
81 drag_dx = drag_dy = dragging = 0;
93 outline_color_button = 0;
94 outline_color_thread = 0;
106 left = 0; center = 0; right = 0;
107 top = 0; mid = 0; bottom = 0;
117 void TitleWindow::done_event(int result)
119 ungrab(client->server->mwindow->cwindow->gui);
122 TitleWindow::~TitleWindow()
126 for( int i=0; i<fonts.size(); ++i )
127 delete fonts[i]->get_icon();
129 sizes.remove_all_objects();
130 delete timecode_format;
136 void TitleWindow::create_objects()
139 int margin = client->get_theme()->widget_border;
140 char string[BCTEXTLEN];
144 client->build_previews(this);
146 sizes.append(new BC_ListBoxItem("8"));
147 sizes.append(new BC_ListBoxItem("9"));
148 sizes.append(new BC_ListBoxItem("10"));
149 sizes.append(new BC_ListBoxItem("11"));
150 sizes.append(new BC_ListBoxItem("12"));
151 sizes.append(new BC_ListBoxItem("13"));
152 sizes.append(new BC_ListBoxItem("14"));
153 sizes.append(new BC_ListBoxItem("16"));
154 sizes.append(new BC_ListBoxItem("18"));
155 sizes.append(new BC_ListBoxItem("20"));
156 sizes.append(new BC_ListBoxItem("22"));
157 sizes.append(new BC_ListBoxItem("24"));
158 sizes.append(new BC_ListBoxItem("26"));
159 sizes.append(new BC_ListBoxItem("28"));
160 sizes.append(new BC_ListBoxItem("32"));
161 sizes.append(new BC_ListBoxItem("36"));
162 sizes.append(new BC_ListBoxItem("40"));
163 sizes.append(new BC_ListBoxItem("48"));
164 sizes.append(new BC_ListBoxItem("56"));
165 sizes.append(new BC_ListBoxItem("64"));
166 sizes.append(new BC_ListBoxItem("72"));
167 sizes.append(new BC_ListBoxItem("100"));
168 sizes.append(new BC_ListBoxItem("128"));
169 sizes.append(new BC_ListBoxItem("256"));
170 sizes.append(new BC_ListBoxItem("512"));
171 sizes.append(new BC_ListBoxItem("1024"));
173 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(NO_MOTION)));
174 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(BOTTOM_TO_TOP)));
175 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(TOP_TO_BOTTOM)));
176 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(RIGHT_TO_LEFT)));
177 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(LEFT_TO_RIGHT)));
181 // Construct font list
182 ArrayList<BC_FontEntry*> *fontlist = get_resources()->fontlist;
184 for( int i=0; i<fontlist->size(); ++i ) {
186 for( int j=0; j<fonts.size(); ++j ) {
187 if( !strcasecmp(fonts.get(j)->get_text(),
188 fontlist->get(i)->displayname) ) {
194 BC_ListBoxItem *item = 0;
196 fonts.append(item = new
197 BC_ListBoxItem(fontlist->get(i)->displayname));
198 if( !strcmp(client->config.font, item->get_text()) )
199 item->set_selected(1);
200 if( fontlist->values[i]->image ) {
201 VFrame *vframe = fontlist->get(i)->image;
202 BC_Pixmap *icon = new BC_Pixmap(this, vframe, PIXMAP_ALPHA);
203 item->set_icon(icon);
204 item->set_icon_vframe(vframe);
213 for( int i=0; i<fonts.size()-1; ++i ) {
214 if( strcmp(fonts.values[i]->get_text(),
215 fonts.values[i + 1]->get_text()) > 0 ) {
216 BC_ListBoxItem *temp = fonts.values[i + 1];
217 fonts.values[i + 1] = fonts.values[i];
218 fonts.values[i] = temp;
224 add_tool(font_title = new BC_Title(x, y, _("Font:")));
225 font = new TitleFont(client, this, x, y + font_title->get_h());
226 font->create_objects();
228 add_subwindow(font_tumbler = new TitleFontTumble(client, this, x, y+margin));
229 x += font_tumbler->get_w() + margin;
232 add_tool(size_title = new BC_Title(x1, y1+margin, _("Size:")));
233 sprintf(string, "%.2f", client->config.size);
234 x1 += size_title->get_w() + margin;
235 size = new TitleSize(client, this, x1, y1+margin, string);
236 size->create_objects();
237 int x2 = x1 + size->get_w(), y2 = y1 + size->get_h() + margin;
238 add_subwindow(size_tumbler = new TitleSizeTumble(client, this, x2, y1+margin));
240 add_tool(pitch_title = new BC_Title(x-5, y2+margin, _("Pitch:")));
241 pitch = new TitlePitch(client, this, x1, y2+margin, &client->config.line_pitch);
242 pitch->create_objects();
244 int x3 = x2 + size_tumbler->get_w() + 50;
245 int y3 = pitch->get_y() + pitch->get_h();
247 add_tool(style_title = new BC_Title(x=x3, y, _("Style:")));
248 add_tool(italic = new TitleItalic(client, this, x, y + 20));
249 int w1 = italic->get_w();
250 add_tool(bold = new TitleBold(client, this, x, y + 50));
251 if( bold->get_w() > w1 ) w1 = bold->get_w();
252 add_tool(drag = new TitleDrag(client, this, x, y + 80));
253 if( drag->get_w() > w1 ) w1 = drag->get_w();
254 if( client->config.drag )
255 grab(client->server->mwindow->cwindow->gui);
258 add_tool(justify_title = new BC_Title(x, y, _("Justify:")));
259 add_tool(left = new TitleLeft(client, this, x, y + 20));
261 add_tool(center = new TitleCenter(client, this, x, y + 50));
262 if( center->get_w() > w1 ) w1 = center->get_w();
263 add_tool(right = new TitleRight(client, this, x, y + 80));
264 if( right->get_w() > w1 ) w1 = right->get_w();
267 add_tool(top = new TitleTop(client, this, x, y + 20));
268 add_tool(mid = new TitleMid(client, this, x, y + 50));
269 add_tool(bottom= new TitleBottom(client, this, x, y + 80));
274 w1 = BC_Title::calculate_w(this, _("X:"));
275 if( (x1 = BC_Title::calculate_w(this, _("Y:"))) > w1 ) w1 = x1;
276 if( (x1 = BC_Title::calculate_w(this, _("W:"))) > w1 ) w1 = x1;
277 if( (x1 = BC_Title::calculate_w(this, _("H:"))) > w1 ) w1 = x1;
278 add_tool(x_title = new BC_Title(x1=x, y, _("X:")));
280 title_x = new TitleX(client, this, x1, y);
281 title_x->create_objects();
282 x1 += title_x->get_w()+margin;
283 add_tool(y_title = new BC_Title(x1, y, _("Y:")));
285 title_y = new TitleY(client, this, x1, y);
286 title_y->create_objects();
287 x1 += title_y->get_w();
288 y1 = y + title_y->get_h();
290 add_tool(w_title = new BC_Title(x1=x, y1, _("W:")));
292 title_w = new TitleW(client, this, x1, y1);
293 title_w->create_objects();
294 x1 += title_w->get_w()+margin;
295 add_tool(h_title = new BC_Title(x1, y1, _("H:")));
297 title_h = new TitleH(client, this, x1, y1);
298 title_h->create_objects();
299 x1 += title_h->get_w();
302 add_tool(motion_title = new BC_Title(x1=x, y, _("Motion:")));
303 x1 += motion_title->get_w()+margin;
304 motion = new TitleMotion(client, this, x1, y);
305 motion->create_objects();
306 add_tool(loop = new TitleLoop(client, x, y1));
307 x = margin; y = y1 + loop->get_h()+20;
309 add_tool(dropshadow_title = new BC_Title(x, y, _("Drop shadow:")));
310 w1 = dropshadow_title->get_w();
311 dropshadow = new TitleDropShadow(client, this, x, y + 20);
312 dropshadow->create_objects();
313 if( dropshadow->get_w() > w1 ) w1 = dropshadow->get_w();
316 add_tool(fadein_title = new BC_Title(x, y, _("Fade in (sec):")));
317 w1 = fadein_title->get_w();
318 add_tool(fade_in = new TitleFade(client, this, &client->config.fade_in, x, y + 20));
319 if( fade_in->get_w() > w1 ) w1 = fade_in->get_w();
322 add_tool(fadeout_title = new BC_Title(x, y, _("Fade out (sec):")));
323 w1 = fadeout_title->get_w();
324 add_tool(fade_out = new TitleFade(client, this, &client->config.fade_out, x, y + 20));
325 if( fade_out->get_w() > w1 ) w1 = fade_out->get_w();
328 add_tool(speed_title = new BC_Title(x, y1=y, _("Speed:")));
329 w1 = speed_title->get_w();
330 y += speed_title->get_h() + 5;
331 speed = new TitleSpeed(client, this, x, y);
332 speed->create_objects();
333 if( speed->get_w() > w1 ) w1 = speed->get_w();
335 y2 = y + speed->get_h() + 10;
337 color_x = x3; color_y = y = y1;
338 color_thread = new TitleColorThread(client, this, 0);
339 x1 = color_x + COLOR_W + 2*margin;
341 add_tool(color_button = new TitleColorButton(client, this, x1, y1));
343 outline_color_x = x3; outline_color_y = y;
344 outline_color_thread = new TitleColorThread(client, this, 1);
345 y1 = outline_color_y + 5;
346 add_tool(outline_color_button = new TitleOutlineColorButton(client, this, x1, y1));
349 add_tool(outline_title = new BC_Title(x, y, _("Outline:")));
350 y1 = y + outline_title->get_h() + margin;
351 outline = new TitleOutline(client, this, x, y1);
352 outline->create_objects();
353 x += outline->get_w() + 2*margin;
355 // to different to be used
356 add_tool(stroker_title = new BC_Title(x, y, _("Stroker:")));
357 stroker = new TitleStroker(client, this, x, y1);
358 stroker->create_objects();
359 x += stroker->get_w() + margin;
361 y += outline_title->get_h() + margin;
362 add_tool(timecode = new TitleTimecode(client, x1=x, y));
363 x += timecode->get_w() + margin;
364 add_tool(timecode_format = new TitleTimecodeFormat(client, x, y,
365 Units::print_time_format(client->config.timecode_format, string)));
366 timecode_format->create_objects();
367 y += timecode_format->get_h() + margin;
370 add_tool(background = new TitleBackground(client, this, x, y));
371 x += background->get_w() + margin;
372 add_tool(background_path = new TitleBackgroundPath(client, this, x, y));
373 x += background_path->get_w() + margin;
374 add_tool(background_browse = new BrowseButton(
375 client->server->mwindow->theme, this, background_path,
376 x, y, "", _("background media"), _("Select background media path")));
377 x += background_browse->get_w() + 3*margin;
378 add_tool(loop_playback = new TitleLoopPlayback(client, x, y));
379 y += loop_playback->get_h() + 10;
382 add_tool(text_title = new BC_Title(x, y, _("Text:")));
383 y += text_title->get_h() + margin;
385 text = new TitleText(client, this, x, y, get_w()-margin - x, get_h() - y - 10);
386 text->create_objects();
388 add_tool(cur_popup = new TitleCurPopup(client, this));
389 cur_popup->create_objects();
390 add_tool(fonts_popup = new TitleFontsPopup(client, this));
391 color_popup = new TitleColorPopup(client, this);
392 png_popup = new TitlePngPopup(client, this);
398 int TitleWindow::resize_event(int w, int h)
400 client->config.window_w = w;
401 client->config.window_h = h;
403 clear_box(0, 0, w, h);
404 font_title->reposition_window(font_title->get_x(), font_title->get_y());
405 font->reposition_window(font->get_x(), font->get_y());
406 font_tumbler->reposition_window(font_tumbler->get_x(), font_tumbler->get_y());
407 x_title->reposition_window(x_title->get_x(), x_title->get_y());
408 title_x->reposition_window(title_x->get_x(), title_x->get_y());
409 y_title->reposition_window(y_title->get_x(), y_title->get_y());
410 title_y->reposition_window(title_y->get_x(), title_y->get_y());
411 w_title->reposition_window(w_title->get_x(), w_title->get_y());
412 title_w->reposition_window(title_w->get_x(), title_w->get_y());
413 h_title->reposition_window(h_title->get_x(), h_title->get_y());
414 title_h->reposition_window(title_h->get_x(), title_h->get_y());
415 style_title->reposition_window(style_title->get_x(), style_title->get_y());
416 italic->reposition_window(italic->get_x(), italic->get_y());
417 bold->reposition_window(bold->get_x(), bold->get_y());
418 drag->reposition_window(drag->get_x(), drag->get_y());
419 size_title->reposition_window(size_title->get_x(), size_title->get_y());
420 size->reposition_window(size->get_x(), size->get_y());
421 size_tumbler->reposition_window(size_tumbler->get_x(), size_tumbler->get_y());
422 pitch_title->reposition_window(pitch_title->get_x(), pitch_title->get_y());
423 pitch->reposition_window(pitch->get_x(), pitch->get_y());
425 color_button->reposition_window(color_button->get_x(), color_button->get_y());
426 outline_color_button->reposition_window(outline_color_button->get_x(), outline_color_button->get_y());
427 motion_title->reposition_window(motion_title->get_x(), motion_title->get_y());
428 motion->reposition_window(motion->get_x(), motion->get_y());
429 loop->reposition_window(loop->get_x(), loop->get_y());
430 dropshadow_title->reposition_window(dropshadow_title->get_x(), dropshadow_title->get_y());
431 dropshadow->reposition_window(dropshadow->get_x(), dropshadow->get_y());
432 fadein_title->reposition_window(fadein_title->get_x(), fadein_title->get_y());
433 fade_in->reposition_window(fade_in->get_x(), fade_in->get_y());
434 fadeout_title->reposition_window(fadeout_title->get_x(), fadeout_title->get_y());
435 fade_out->reposition_window(fade_out->get_x(), fade_out->get_y());
436 text_title->reposition_window(text_title->get_x(), text_title->get_y());
437 timecode->reposition_window(timecode->get_x(), timecode->get_y());
438 text->reposition_window(text->get_x(), text->get_y(), w - text->get_x() - 10,
439 BC_TextBox::pixels_to_rows(this, MEDIUMFONT, h - text->get_y() - 10));
440 justify_title->reposition_window(justify_title->get_x(), justify_title->get_y());
441 left->reposition_window(left->get_x(), left->get_y());
442 center->reposition_window(center->get_x(), center->get_y());
443 right->reposition_window(right->get_x(), right->get_y());
444 top->reposition_window(top->get_x(), top->get_y());
445 mid->reposition_window(mid->get_x(), mid->get_y());
446 bottom->reposition_window(bottom->get_x(), bottom->get_y());
447 speed_title->reposition_window(speed_title->get_x(), speed_title->get_y());
448 speed->reposition_window(speed->get_x(), speed->get_y());
455 int TitleWindow::grab_event(XEvent *event)
457 switch( event->type ) {
459 if( !dragging ) break;
462 if( !dragging ) return 0;
466 if( dragging ) break;
470 MWindow *mwindow = client->server->mwindow;
471 CWindowGUI *cwindow_gui = mwindow->cwindow->gui;
472 CWindowCanvas *canvas = cwindow_gui->canvas;
473 float cursor_x = canvas->get_canvas()->get_relative_cursor_x();
474 float cursor_y = canvas->get_canvas()->get_relative_cursor_y();
475 canvas->canvas_to_output(mwindow->edl, 0, cursor_x, cursor_y);
476 int64_t position = client->get_source_position();
477 float projector_x, projector_y, projector_z;
478 Track *track = client->server->plugin->track;
479 int track_w = track->track_w, track_h = track->track_h;
480 track->automation->get_projector(
481 &projector_x, &projector_y, &projector_z,
482 position, PLAY_FORWARD);
483 projector_x += mwindow->edl->session->output_w / 2;
484 projector_y += mwindow->edl->session->output_h / 2;
485 cursor_x = (cursor_x - projector_x) / projector_z + track_w / 2;
486 cursor_y = (cursor_y - projector_y) / projector_z + track_h / 2;
487 int title_x = client->config.title_x, title_y = client->config.title_y;
488 int title_w = client->config.title_w, title_h = client->config.title_h;
489 if( !title_w ) title_w = track_w;
490 if( !title_h ) title_h = track_h;
491 int r = MIN(track_w, track_h)/100 + 2;
492 int x0 = title_x, x1 = title_x+(title_w+1)/2, x2 = title_x+title_w;
493 int y0 = title_y, y1 = title_y+(title_h+1)/2, y2 = title_y+title_h;
494 int drag_dx = 0, drag_dy = 0;
495 if( !dragging ) { // clockwise
496 if( abs(drag_dx = cursor_x-x0) < r && // x0,y0
497 abs(drag_dy = cursor_y-y0) < r ) dragging = 1;
498 else if( abs(drag_dx = cursor_x-x1) < r && // x1,y0
499 abs(drag_dy = cursor_y-y0) < r ) dragging = 2;
500 else if( abs(drag_dx = cursor_x-x2) < r && // x2,y0
501 abs(drag_dy = cursor_y-y0) < r ) dragging = 3;
502 else if( abs(drag_dx = cursor_x-x2) < r && // x2,y1
503 abs(drag_dy = cursor_y-y1) < r ) dragging = 4;
504 else if( abs(drag_dx = cursor_x-x2) < r && // x2,y2
505 abs(drag_dy = cursor_y-y2) < r ) dragging = 5;
506 else if( abs(drag_dx = cursor_x-x1) < r && // x1,y2
507 abs(drag_dy = cursor_y-y2) < r ) dragging = 6;
508 else if( abs(drag_dx = cursor_x-x0) < r && // x0,y2
509 abs(drag_dy = cursor_y-y2) < r ) dragging = 7;
510 else if( abs(drag_dx = cursor_x-x0) < r && // x0,y1
511 abs(drag_dy = cursor_y-y1) < r ) dragging = 8;
512 else if( abs(drag_dx = cursor_x-x1) < r && // x1,y1
513 abs(drag_dy = cursor_y-y1) < r ) dragging = 9;
518 int cur_x = cursor_x - drag_dx, dx = cur_x - x0;
519 int cur_y = cursor_y - drag_dy, dy = cur_y - y0;
520 if( !dx && !dy ) return 1;
521 int cur_w = title_w - dx; if( cur_w < 1 ) cur_w = 1;
522 int cur_h = title_h - dy; if( cur_h < 1 ) cur_h = 1;
523 this->title_x->update((int64_t)(client->config.title_x = cur_x));
524 this->title_y->update((int64_t)(client->config.title_y = cur_y));
525 this->title_w->update((int64_t)(client->config.title_w = cur_w));
526 this->title_h->update((int64_t)(client->config.title_h = cur_h));
529 int cur_y = cursor_y - drag_dy, dy = cur_y - y0;
531 int cur_h = title_h - dy; if( cur_h < 1 ) cur_h = 1;
532 this->title_y->update((int64_t)(client->config.title_y = cur_y));
533 this->title_h->update((int64_t)(client->config.title_h = cur_h));
536 int cur_x = cursor_x - drag_dx, dx = cur_x - x2;
537 int cur_y = cursor_y - drag_dy, dy = cur_y - y0;
538 int cur_w = title_w + dx; if( cur_w < 1 ) cur_w = 1;
539 int cur_h = title_h - dy; if( cur_h < 1 ) cur_h = 1;
540 this->title_w->update((int64_t)(client->config.title_w = cur_w));
541 this->title_y->update((int64_t)(client->config.title_y = cur_y));
542 this->title_h->update((int64_t)(client->config.title_h = cur_h));
545 int cur_x = cursor_x - drag_dx, dx = cur_x - x2;
547 int cur_w = title_w + dx; if( cur_w < 1 ) cur_w = 1;
548 this->title_w->update((int64_t)(client->config.title_w = cur_w));
551 int cur_x = cursor_x - drag_dx, dx = cur_x - x2;
552 int cur_y = cursor_y - drag_dy, dy = cur_y - y2;
553 int cur_w = title_w + dx; if( cur_w < 1 ) cur_w = 1;
554 int cur_h = title_h + dy; if( cur_h < 1 ) cur_h = 1;
555 this->title_w->update((int64_t)(client->config.title_w = cur_w));
556 this->title_h->update((int64_t)(client->config.title_h = cur_h));
559 int cur_y = cursor_y - drag_dy, dy = cur_y - y2;
560 if( client->config.title_h == cur_y ) return 1;
561 int cur_h = title_h + dy; if( cur_h < 1 ) cur_h = 1;
562 this->title_h->update((int64_t)(client->config.title_h = cur_h));
565 int cur_x = cursor_x - drag_dx, dx = cur_x - x0;
566 int cur_y = cursor_y - drag_dy, dy = cur_y - y2;
567 int cur_w = title_w - dx; if( cur_w < 1 ) cur_w = 1;
568 int cur_h = title_h + dy; if( cur_h < 1 ) cur_h = 1;
569 this->title_x->update((int64_t)(client->config.title_x = cur_x));
570 this->title_w->update((int64_t)(client->config.title_w = cur_w));
571 this->title_h->update((int64_t)(client->config.title_h = cur_h));
574 int cur_x = cursor_x - drag_dx, dx = cur_x - x0;
576 int cur_w = title_w - dx; if( cur_w < 1 ) cur_w = 1;
577 this->title_x->update((int64_t)(client->config.title_x = cur_x));
578 this->title_w->update((int64_t)(client->config.title_w = cur_w));
581 int cur_x = cursor_x - drag_dx, dx = cur_x - x1;
582 int cur_y = cursor_y - drag_dy, dy = cur_y - y1;
583 if( title_x == cur_x && title_y == cur_y ) return 1;
584 this->title_x->update((int64_t)(client->config.title_x += dx));
585 this->title_y->update((int64_t)(client->config.title_y += dy));
588 client->send_configure_change();
592 void TitleWindow::previous_font()
594 int current_font = font->get_number();
596 if( current_font < 0 ) current_font = fonts.total - 1;
598 if( current_font < 0 || current_font >= fonts.total ) return;
600 for( int i=0; i<fonts.total; ++i ) {
601 fonts.values[i]->set_selected(i == current_font);
604 font->update(fonts.values[current_font]->get_text());
605 strcpy(client->config.font, fonts.values[current_font]->get_text());
606 check_style(client->config.font);
607 client->send_configure_change();
610 void TitleWindow::next_font()
612 int current_font = font->get_number();
614 if( current_font >= fonts.total ) current_font = 0;
616 if( current_font < 0 || current_font >= fonts.total ) return;
618 for( int i=0; i<fonts.total; ++i ) {
619 fonts.values[i]->set_selected(i == current_font);
622 font->update(fonts.values[current_font]->get_text());
623 strcpy(client->config.font, fonts.values[current_font]->get_text());
624 check_style(client->config.font);
625 client->send_configure_change();
628 int TitleWindow::insert_ibeam(const char *txt, int adv)
630 int ibeam = cur_ibeam;
631 client->insert_text(txt, ibeam);
632 if( (ibeam += adv) >= client->config.wlen)
633 ibeam = client->config.wlen;
634 text->wset_selection(-1, -1, ibeam);
635 text->update(client->config.wtext);
636 client->send_configure_change();
640 void TitleWindow::update_color()
642 //printf("TitleWindow::update_color %x\n", client->config.color);
643 set_color(client->config.color);
644 draw_box(color_x, color_y, COLOR_W, COLOR_H);
645 flash(color_x, color_y, COLOR_W, COLOR_H);
646 set_color(client->config.outline_color);
647 draw_box(outline_color_x, outline_color_y, COLOR_W, COLOR_H);
649 draw_rectangle(color_x, color_y, COLOR_W, COLOR_H);
650 draw_rectangle(outline_color_x, outline_color_y, COLOR_W, COLOR_H);
651 flash(outline_color_x, outline_color_y, COLOR_W, COLOR_H);
654 void TitleWindow::update_justification()
656 left->update(client->config.hjustification == JUSTIFY_LEFT);
657 center->update(client->config.hjustification == JUSTIFY_CENTER);
658 right->update(client->config.hjustification == JUSTIFY_RIGHT);
659 top->update(client->config.vjustification == JUSTIFY_TOP);
660 mid->update(client->config.vjustification == JUSTIFY_MID);
661 bottom->update(client->config.vjustification == JUSTIFY_BOTTOM);
664 void TitleWindow::update()
666 title_x->update((int64_t)client->config.title_x);
667 title_y->update((int64_t)client->config.title_y);
668 title_w->update((int64_t)client->config.title_w);
669 title_h->update((int64_t)client->config.title_h);
670 italic->update(client->config.style & BC_FONT_ITALIC);
671 bold->update(client->config.style & BC_FONT_BOLD);
672 size->update(client->config.size);
673 motion->update(TitleMain::motion_to_text(client->config.motion_strategy));
674 loop->update(client->config.loop);
675 dropshadow->update((int64_t)client->config.dropshadow);
676 fade_in->update((float)client->config.fade_in);
677 fade_out->update((float)client->config.fade_out);
678 font->update(client->config.font);
679 check_style(client->config.font);
680 text->update(&client->config.wtext[0]);
681 speed->update(client->config.pixels_per_second);
682 outline->update((int64_t)client->config.outline_size);
684 stroker->update((int64_t)client->config.stroke_width);
686 timecode->update(client->config.timecode);
687 timecode_format->update(client->config.timecode_format);
688 background->update(client->config.background);
689 background_path->update(client->config.background_path);
690 loop_playback->update((int64_t)client->config.loop_playback);
692 char string[BCTEXTLEN];
693 for( int i=0; i<lengthof(timeunit_formats); ++i ) {
694 if( timeunit_formats[i] == client->config.timecode_format ) {
695 timecode_format->set_text(
696 Units::print_time_format(timeunit_formats[i], string));
700 update_justification();
705 TitleFontTumble::TitleFontTumble(TitleMain *client, TitleWindow *window, int x, int y)
708 this->client = client;
709 this->window = window;
711 int TitleFontTumble::handle_up_event()
713 window->previous_font();
717 int TitleFontTumble::handle_down_event()
725 TitleSizeTumble::TitleSizeTumble(TitleMain *client, TitleWindow *window, int x, int y)
728 this->client = client;
729 this->window = window;
732 int TitleSizeTumble::handle_up_event()
734 int current_index = -1;
735 int current_difference = -1;
736 for( int i=0; i<window->sizes.size(); ++i ) {
737 int size = atoi(window->sizes.get(i)->get_text());
738 if( current_index < 0 ||
739 abs(size - client->config.size) < current_difference ) {
741 current_difference = abs(size - client->config.size);
746 if( current_index >= window->sizes.size() ) current_index = 0;
749 client->config.size = atoi(window->sizes.get(current_index)->get_text());
750 window->size->update(client->config.size);
751 client->send_configure_change();
755 int TitleSizeTumble::handle_down_event()
757 int current_index = -1;
758 int current_difference = -1;
759 for( int i=0; i<window->sizes.size(); ++i ) {
760 int size = atoi(window->sizes.get(i)->get_text());
761 if( current_index < 0 ||
762 abs(size - client->config.size) < current_difference ) {
764 current_difference = abs(size - client->config.size);
769 if( current_index < 0 ) current_index = window->sizes.size() - 1;
772 client->config.size = atoi(window->sizes.get(current_index)->get_text());
773 window->size->update(client->config.size);
774 client->send_configure_change();
778 TitleBold::TitleBold(TitleMain *client, TitleWindow *window, int x, int y)
779 : BC_CheckBox(x, y, client->config.style & BC_FONT_BOLD, _("Bold"))
781 this->client = client;
782 this->window = window;
785 int TitleBold::handle_event()
787 client->config.style =
788 (client->config.style & ~BC_FONT_BOLD) |
789 (get_value() ? BC_FONT_BOLD : 0);
790 client->send_configure_change();
794 TitleItalic::TitleItalic(TitleMain *client, TitleWindow *window, int x, int y)
795 : BC_CheckBox(x, y, client->config.style & BC_FONT_ITALIC, _("Italic"))
797 this->client = client;
798 this->window = window;
800 int TitleItalic::handle_event()
802 client->config.style =
803 (client->config.style & ~BC_FONT_ITALIC) |
804 (get_value() ? BC_FONT_ITALIC : 0);
805 client->send_configure_change();
811 TitleSize::TitleSize(TitleMain *client, TitleWindow *window, int x, int y, char *text)
812 : BC_PopupTextBox(window, &window->sizes, text, x, y, 64, 300)
814 this->client = client;
815 this->window = window;
817 TitleSize::~TitleSize()
820 int TitleSize::handle_event()
822 client->config.size = atol(get_text());
823 //printf("TitleSize::handle_event 1 %s\n", get_text());
824 client->send_configure_change();
827 void TitleSize::update(int size)
829 char string[BCTEXTLEN];
830 sprintf(string, "%d", size);
831 BC_PopupTextBox::update(string);
835 TitlePitch(TitleMain *client, TitleWindow *window, int x, int y, int *value)
836 : BC_TumbleTextBox(window, *value, 0, INT_MAX, x, y, 64)
838 this->client = client;
839 this->window = window;
848 int TitlePitch::handle_event()
850 *value = atol(get_text());
851 client->send_configure_change();
855 TitleColorButton::TitleColorButton(TitleMain *client, TitleWindow *window, int x, int y)
856 : BC_GenericButton(x, y, _("Color..."))
858 this->client = client;
859 this->window = window;
861 int TitleColorButton::handle_event()
863 window->color_thread->start_window(client->config.color,
864 client->config.alpha);
867 TitleOutlineColorButton::TitleOutlineColorButton(TitleMain *client, TitleWindow *window, int x, int y)
868 : BC_GenericButton(x, y, _("Outline color..."))
870 this->client = client;
871 this->window = window;
873 int TitleOutlineColorButton::handle_event()
875 window->outline_color_thread->start_window(client->config.outline_color,
876 client->config.outline_alpha);
881 TitleMotion::TitleMotion(TitleMain *client, TitleWindow *window, int x, int y)
882 : BC_PopupTextBox(window, &window->paths,
883 client->motion_to_text(client->config.motion_strategy),
886 this->client = client;
887 this->window = window;
889 int TitleMotion::handle_event()
891 client->config.motion_strategy = client->text_to_motion(get_text());
892 client->send_configure_change();
896 TitleLoop::TitleLoop(TitleMain *client, int x, int y)
897 : BC_CheckBox(x, y, client->config.loop, _("Loop"))
899 this->client = client;
901 int TitleLoop::handle_event()
903 client->config.loop = get_value();
904 client->send_configure_change();
907 TitleTimecode::TitleTimecode(TitleMain *client, int x, int y)
908 : BC_CheckBox(x, y, client->config.timecode, _("Stamp timecode"))
910 this->client = client;
912 int TitleTimecode::handle_event()
914 client->config.timecode = get_value();
915 client->send_configure_change();
919 TitleTimecodeFormat::TitleTimecodeFormat(TitleMain *client, int x, int y, const char *text)
920 : BC_PopupMenu(x, y, 100, text, 1)
922 this->client = client;
925 int TitleTimecodeFormat::handle_event()
927 client->config.timecode_format = Units::text_to_format(get_text());
928 client->send_configure_change();
932 void TitleTimecodeFormat::create_objects()
934 char string[BCTEXTLEN];
935 for( int i=0; i<lengthof(timeunit_formats); ++i ) {
936 add_item(new BC_MenuItem(
937 Units::print_time_format(timeunit_formats[i], string)));
942 int TitleTimecodeFormat::update(int timecode_format)
944 char string[BCTEXTLEN];
945 for( int i=0; i<lengthof(timeunit_formats); ++i ) {
946 if( timeunit_formats[i] == timecode_format ) {
947 set_text(Units::print_time_format(timeunit_formats[i], string));
954 TitleFade::TitleFade(TitleMain *client, TitleWindow *window,
955 double *value, int x, int y)
956 : BC_TextBox(x, y, 80, 1, (float)*value)
958 this->client = client;
959 this->window = window;
964 int TitleFade::handle_event()
966 *value = atof(get_text());
967 client->send_configure_change();
971 void TitleWindow::check_style(const char *font_name)
974 font = TitleMain::get_font(font_name, BC_FONT_ITALIC);
975 strcmp(font_name, font->displayname) ? italic->disable() : italic->enable();
976 font = TitleMain::get_font(font_name, BC_FONT_BOLD);
977 strcmp(font_name, font->displayname) ? bold->disable() : bold->enable();
980 TitleFont::TitleFont(TitleMain *client, TitleWindow *window, int x, int y)
981 : BC_PopupTextBox(window, &window->fonts, client->config.font,
982 x, y, 240, 300, LISTBOX_ICON_LIST)
984 this->client = client;
985 this->window = window;
987 int TitleFont::handle_event()
989 strcpy(client->config.font, get_text());
990 window->check_style(client->config.font);
991 client->send_configure_change();
995 TitleText::TitleText(TitleMain *client, TitleWindow *window,
996 int x, int y, int w, int h)
997 : BC_ScrollTextBox(window, x, y, w,
998 BC_TextBox::pixels_to_rows(window, MEDIUMFONT, h),
999 client->config.wtext, 8192)
1001 this->client = client;
1002 this->window = window;
1003 //printf("TitleText::TitleText %s\n", client->config.text);
1006 int TitleText::button_press_event()
1008 if( get_buttonpress() == 3 ) {
1009 window->cur_ibeam = get_ibeam_letter();
1010 window->cur_popup->activate_menu();
1013 return BC_ScrollTextBox::button_press_event();
1016 int TitleText::handle_event()
1018 window->fonts_popup->deactivate();
1019 int len = sizeof(client->config.wtext) / sizeof(wchar_t);
1020 wcsncpy(client->config.wtext, get_wtext(), len);
1021 client->config.wtext[len-1] = 0;
1022 client->config.wlen = wcslen(client->config.wtext);
1023 client->send_configure_change();
1028 TitleDropShadow::TitleDropShadow(TitleMain *client, TitleWindow *window, int x, int y)
1029 : BC_TumbleTextBox(window, (int64_t)client->config.dropshadow,
1030 (int64_t)-1000, (int64_t)1000, x, y, 70)
1032 this->client = client;
1033 this->window = window;
1035 int TitleDropShadow::handle_event()
1037 client->config.dropshadow = atol(get_text());
1038 client->send_configure_change();
1043 TitleOutline::TitleOutline(TitleMain *client, TitleWindow *window, int x, int y)
1044 : BC_TumbleTextBox(window, (int64_t)client->config.outline_size,
1045 (int64_t)0, (int64_t)1000, x, y, 70)
1047 this->client = client;
1048 this->window = window;
1050 int TitleOutline::handle_event()
1052 client->config.outline_size = atol(get_text());
1053 client->send_configure_change();
1057 TitleStroker::TitleStroker(TitleMain *client, TitleWindow *window, int x, int y)
1058 : BC_TumbleTextBox(window, (int64_t)client->config.stroke_width,
1059 (int64_t)0, (int64_t)1000, x, y, 70)
1061 this->client = client;
1062 this->window = window;
1064 int TitleStroker::handle_event()
1066 client->config.stroke_width = atol(get_text());
1067 if( client->config.stroke_width > 1 )
1068 client->config.style |= BC_FONT_OUTLINE;
1070 client->config.style &= ~BC_FONT_OUTLINE;
1071 client->send_configure_change();
1076 TitleX::TitleX(TitleMain *client, TitleWindow *window, int x, int y)
1077 : BC_TumbleTextBox(window, (int64_t)client->config.title_x,
1078 (int64_t)-32767, (int64_t)32767, x, y, 50)
1080 this->client = client;
1081 this->window = window;
1083 int TitleX::handle_event()
1085 client->config.title_x = atol(get_text());
1086 client->send_configure_change();
1090 TitleY::TitleY(TitleMain *client, TitleWindow *window, int x, int y)
1091 : BC_TumbleTextBox(window, (int64_t)client->config.title_y,
1092 (int64_t)-32767, (int64_t)32767, x, y, 50)
1094 this->client = client;
1095 this->window = window;
1097 int TitleY::handle_event()
1099 client->config.title_y = atol(get_text());
1100 client->send_configure_change();
1104 TitleW::TitleW(TitleMain *client, TitleWindow *window, int x, int y)
1105 : BC_TumbleTextBox(window, (int64_t)client->config.title_w,
1106 (int64_t)0, (int64_t)32767, x, y, 50)
1108 this->client = client;
1109 this->window = window;
1111 int TitleW::handle_event()
1113 client->config.title_w = atol(get_text());
1114 client->send_configure_change();
1118 TitleH::TitleH(TitleMain *client, TitleWindow *window, int x, int y)
1119 : BC_TumbleTextBox(window, (int64_t)client->config.title_h,
1120 (int64_t)0, (int64_t)32767, x, y, 50)
1122 this->client = client;
1123 this->window = window;
1125 int TitleH::handle_event()
1127 client->config.title_h = atol(get_text());
1128 client->send_configure_change();
1132 TitleSpeed::TitleSpeed(TitleMain *client, TitleWindow *window, int x, int y)
1133 : BC_TumbleTextBox(window, (float)client->config.pixels_per_second,
1134 (float)0, (float)1000, x, y, 100)
1136 this->client = client;
1142 int TitleSpeed::handle_event()
1144 client->config.pixels_per_second = atof(get_text());
1145 client->send_configure_change();
1150 TitleLeft::TitleLeft(TitleMain *client, TitleWindow *window, int x, int y)
1151 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_LEFT, _("Left"))
1153 this->client = client;
1154 this->window = window;
1156 int TitleLeft::handle_event()
1158 client->config.hjustification = JUSTIFY_LEFT;
1159 window->update_justification();
1160 client->send_configure_change();
1164 TitleCenter::TitleCenter(TitleMain *client, TitleWindow *window, int x, int y)
1165 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_CENTER, _("Center"))
1167 this->client = client;
1168 this->window = window;
1170 int TitleCenter::handle_event()
1172 client->config.hjustification = JUSTIFY_CENTER;
1173 window->update_justification();
1174 client->send_configure_change();
1178 TitleRight::TitleRight(TitleMain *client, TitleWindow *window, int x, int y)
1179 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_RIGHT, _("Right"))
1181 this->client = client;
1182 this->window = window;
1184 int TitleRight::handle_event()
1186 client->config.hjustification = JUSTIFY_RIGHT;
1187 window->update_justification();
1188 client->send_configure_change();
1194 TitleTop::TitleTop(TitleMain *client, TitleWindow *window, int x, int y)
1195 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_TOP, _("Top"))
1197 this->client = client;
1198 this->window = window;
1200 int TitleTop::handle_event()
1202 client->config.vjustification = JUSTIFY_TOP;
1203 window->update_justification();
1204 client->send_configure_change();
1208 TitleMid::TitleMid(TitleMain *client, TitleWindow *window, int x, int y)
1209 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_MID, _("Mid"))
1211 this->client = client;
1212 this->window = window;
1214 int TitleMid::handle_event()
1216 client->config.vjustification = JUSTIFY_MID;
1217 window->update_justification();
1218 client->send_configure_change();
1222 TitleBottom::TitleBottom(TitleMain *client, TitleWindow *window, int x, int y)
1223 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_BOTTOM, _("Bottom"))
1225 this->client = client;
1226 this->window = window;
1228 int TitleBottom::handle_event()
1230 client->config.vjustification = JUSTIFY_BOTTOM;
1231 window->update_justification();
1232 client->send_configure_change();
1238 TitleColorThread::TitleColorThread(TitleMain *client, TitleWindow *window, int is_outline)
1239 : ColorThread(1, _("Text Color"))
1241 this->client = client;
1242 this->window = window;
1243 this->is_outline = is_outline;
1246 int TitleColorThread::handle_new_color(int output, int alpha)
1249 client->config.outline_color = output;
1250 client->config.outline_alpha = alpha;
1253 client->config.color = output;
1254 client->config.alpha = alpha;
1257 window->lock_window("TitleColorThread::handle_new_color");
1258 window->update_color();
1260 window->unlock_window();
1262 client->send_configure_change();
1266 TitleDrag::TitleDrag(TitleMain *client, TitleWindow *window, int x, int y)
1267 : BC_CheckBox(x, y, client->config.drag, _("Drag"))
1269 this->client = client;
1270 this->window = window;
1273 int TitleDrag::handle_event()
1275 int value = get_value();
1276 client->config.drag = value;
1278 window->grab(client->server->mwindow->cwindow->gui);
1280 window->ungrab(client->server->mwindow->cwindow->gui);
1281 client->send_configure_change();
1285 TitleBackground::TitleBackground(TitleMain *client, TitleWindow *window, int x, int y)
1286 : BC_CheckBox(x, y, client->config.background, _("Background:"))
1288 this->client = client;
1289 this->window = window;
1292 int TitleBackground::handle_event()
1294 client->config.background = get_value();
1295 client->send_configure_change();
1299 TitleBackgroundPath::TitleBackgroundPath(TitleMain *client, TitleWindow *window, int x, int y)
1300 : BC_TextBox(x, y, 240, 1, client->config.background_path)
1302 this->client = client;
1303 this->window = window;
1306 int TitleBackgroundPath::handle_event()
1308 strncpy(client->config.background_path, get_text(), sizeof(client->config.background_path));
1309 client->send_configure_change();
1313 TitleLoopPlayback::TitleLoopPlayback(TitleMain *client, int x, int y)
1314 : BC_CheckBox(x, y, client->config.loop_playback, _("Loop playback"))
1316 this->client = client;
1318 int TitleLoopPlayback::handle_event()
1320 client->config.loop_playback = get_value();
1321 client->send_configure_change();
1326 TitleCurPopup::TitleCurPopup(TitleMain *client, TitleWindow *window)
1327 : BC_PopupMenu(0, 0, 0, "", 0)
1329 this->client = client;
1330 this->window = window;
1332 int TitleCurPopup::handle_event()
1336 void TitleCurPopup::create_objects()
1338 TitleCurItem *cur_item;
1339 TitleCurSubMenu *sub_menu;
1340 add_item(cur_item = new TitleCurItem(this, _("nudge")));
1341 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1342 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("nudge dx,dy")));
1343 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("/nudge")));
1344 add_item(cur_item = new TitleCurItem(this, _("color")));
1345 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1346 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("color #")));
1347 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("color ")));
1348 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("/color")));
1349 add_item(cur_item = new TitleCurItem(this, _("alpha")));
1350 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1351 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("alpha ")));
1352 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("alpha 0.")));
1353 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("alpha .5")));
1354 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("alpha 1.")));
1355 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("/alpha")));
1356 add_item(cur_item = new TitleCurItem(this, _("font")));
1357 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1358 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("font name")));
1359 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("font ")));
1360 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("/font")));
1361 add_item(cur_item = new TitleCurItem(this, _("size")));
1362 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1363 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("size +")));
1364 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("size -")));
1365 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("size ")));
1366 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("/size")));
1367 add_item(cur_item = new TitleCurItem(this, _("bold")));
1368 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1369 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("bold 1")));
1370 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("bold 0")));
1371 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("/bold")));
1372 add_item(cur_item = new TitleCurItem(this, _("italic")));
1373 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1374 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("italic 1")));
1375 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("italic 0")));
1376 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("/italic")));
1377 add_item(cur_item = new TitleCurItem(this, _("caps")));
1378 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1379 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("caps 1")));
1380 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("caps 0")));
1381 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("caps -1")));
1382 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("/caps")));
1383 add_item(cur_item = new TitleCurItem(this, _("ul")));
1384 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1385 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("ul 1")));
1386 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("ul 0")));
1387 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("/ul")));
1388 add_item(cur_item = new TitleCurItem(this, _("blink")));
1389 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1390 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("blink 1")));
1391 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("blink -1")));
1392 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("blink ")));
1393 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("blink 0")));
1394 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("/blink")));
1395 add_item(cur_item = new TitleCurItem(this, _("fixed")));
1396 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1397 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("fixed ")));
1398 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("fixed 20")));
1399 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("fixed 10")));
1400 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("fixed 0")));
1401 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("/fixed")));
1402 add_item(cur_item = new TitleCurItem(this, _("sup")));
1403 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1404 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("sup 1")));
1405 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("sup 0")));
1406 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("sup -1")));
1407 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("/sup")));
1408 add_item(cur_item = new TitleCurItem(this, _("png")));
1409 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1410 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("png file")));
1413 TitleCurItem::TitleCurItem(TitleCurPopup *popup, const char *text)
1416 this->popup = popup;
1418 int TitleCurItem::handle_event()
1423 TitleCurSubMenu::TitleCurSubMenu(TitleCurItem *cur_item)
1425 this->cur_item = cur_item;
1427 TitleCurSubMenu::~TitleCurSubMenu()
1431 TitleCurSubMenuItem::TitleCurSubMenuItem(TitleCurSubMenu *submenu, const char *text)
1434 this->submenu = submenu;
1436 TitleCurSubMenuItem::~TitleCurSubMenuItem()
1439 int TitleCurSubMenuItem::handle_event()
1441 TitleCurPopup *popup = submenu->cur_item->popup;
1442 TitleWindow *window = popup->window;
1443 const char *item_text = get_text();
1444 if( !strcmp(item_text, _("font name")) ) {
1446 window->get_pop_cursor_xy(px ,py);
1447 window->fonts_popup->activate(px, py, 300,200);
1450 if( !strcmp(item_text, _("color #")) ) {
1451 window->color_popup->activate();
1454 if( !strcmp(item_text, _("png file")) ) {
1455 window->png_popup->activate();
1459 sprintf(txt, "<%s>", item_text);
1460 int adv = strlen(txt);
1461 if( adv > 1 && (txt[1] != '/' && strcmp(txt,_("font"))) ) --adv;
1462 return window->insert_ibeam(txt,adv);
1465 TitleFontsPopup::TitleFontsPopup(TitleMain *client, TitleWindow *window)
1466 : BC_ListBox(-1, -1, 1, 1, LISTBOX_ICON_LIST,
1467 &window->fonts, 0, 0, 1, 0, 1)
1469 this->client = client;
1470 this->window = window;
1473 TitleFontsPopup::~TitleFontsPopup()
1477 int TitleFontsPopup::handle_event()
1480 BC_ListBoxItem *item = get_selection(0, 0);
1481 if( !item ) return 1;
1482 const char *item_text = item->get_text();
1483 char txt[BCTEXTLEN]; sprintf(txt, "<font %s>",item_text);
1484 return window->insert_ibeam(txt, strlen(txt));
1487 TitleColorPopup::TitleColorPopup(TitleMain *client, TitleWindow *window)
1488 : ColorThread(0, _("Text Color"))
1490 this->client = client;
1491 this->window = window;
1492 this->color_value = client->config.color;
1494 TitleColorPopup::~TitleColorPopup()
1497 int TitleColorPopup::handle_new_color(int output, int alpha)
1499 color_value = output;
1502 int TitleColorPopup::activate()
1504 start_window(client->config.color, 255, 1);
1507 void TitleColorPopup::handle_done_event(int result)
1509 if( result ) return;
1510 char txt[BCSTRLEN]; sprintf(txt, "<color #%06x>",color_value);
1511 window->insert_ibeam(txt, strlen(txt));
1514 TitlePngPopup::TitlePngPopup(TitleMain *client, TitleWindow *window)
1517 this->client = client;
1518 this->window = window;
1521 TitlePngPopup::~TitlePngPopup()
1526 void TitlePngPopup::handle_done_event(int result)
1528 if( result ) return;
1529 BrowseButtonWindow *gui = (BrowseButtonWindow *)get_gui();
1530 const char *path = gui->get_submitted_path();
1531 char txt[BCSTRLEN]; sprintf(txt, "<png %s>",path);
1532 window->insert_ibeam(txt, strlen(txt));
1535 BC_Window *TitlePngPopup::new_gui()
1537 BC_DisplayInfo display_info;
1538 int x = display_info.get_abs_cursor_x();
1539 int y = display_info.get_abs_cursor_y();
1541 BC_Window *gui = new BrowseButtonWindow(client->server->mwindow->theme,
1542 x-25, y-100, window, "", _("Png file"), _("Png path"), 0);
1543 gui->create_objects();
1547 int TitlePngPopup::activate()
1549 BC_DialogThread::start();