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 TitleWindow::~TitleWindow()
119 ungrab(client->server->mwindow->cwindow->gui);
122 for( int i=0; i<fonts.size(); ++i )
123 delete fonts[i]->get_icon();
125 sizes.remove_all_objects();
126 delete timecode_format;
132 void TitleWindow::create_objects()
135 int margin = client->get_theme()->widget_border;
136 char string[BCTEXTLEN];
140 client->build_previews(this);
142 sizes.append(new BC_ListBoxItem("8"));
143 sizes.append(new BC_ListBoxItem("9"));
144 sizes.append(new BC_ListBoxItem("10"));
145 sizes.append(new BC_ListBoxItem("11"));
146 sizes.append(new BC_ListBoxItem("12"));
147 sizes.append(new BC_ListBoxItem("13"));
148 sizes.append(new BC_ListBoxItem("14"));
149 sizes.append(new BC_ListBoxItem("16"));
150 sizes.append(new BC_ListBoxItem("18"));
151 sizes.append(new BC_ListBoxItem("20"));
152 sizes.append(new BC_ListBoxItem("22"));
153 sizes.append(new BC_ListBoxItem("24"));
154 sizes.append(new BC_ListBoxItem("26"));
155 sizes.append(new BC_ListBoxItem("28"));
156 sizes.append(new BC_ListBoxItem("32"));
157 sizes.append(new BC_ListBoxItem("36"));
158 sizes.append(new BC_ListBoxItem("40"));
159 sizes.append(new BC_ListBoxItem("48"));
160 sizes.append(new BC_ListBoxItem("56"));
161 sizes.append(new BC_ListBoxItem("64"));
162 sizes.append(new BC_ListBoxItem("72"));
163 sizes.append(new BC_ListBoxItem("100"));
164 sizes.append(new BC_ListBoxItem("128"));
165 sizes.append(new BC_ListBoxItem("256"));
166 sizes.append(new BC_ListBoxItem("512"));
167 sizes.append(new BC_ListBoxItem("1024"));
169 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(NO_MOTION)));
170 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(BOTTOM_TO_TOP)));
171 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(TOP_TO_BOTTOM)));
172 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(RIGHT_TO_LEFT)));
173 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(LEFT_TO_RIGHT)));
177 // Construct font list
178 ArrayList<BC_FontEntry*> *fontlist = get_resources()->fontlist;
180 for( int i=0; i<fontlist->size(); ++i ) {
182 for( int j=0; j<fonts.size(); ++j ) {
183 if( !strcasecmp(fonts.get(j)->get_text(),
184 fontlist->get(i)->displayname) ) {
190 BC_ListBoxItem *item = 0;
192 fonts.append(item = new
193 BC_ListBoxItem(fontlist->get(i)->displayname));
194 if( !strcmp(client->config.font, item->get_text()) )
195 item->set_selected(1);
196 if( fontlist->values[i]->image ) {
197 VFrame *vframe = fontlist->get(i)->image;
198 BC_Pixmap *icon = new BC_Pixmap(this, vframe, PIXMAP_ALPHA);
199 item->set_icon(icon);
200 item->set_icon_vframe(vframe);
209 for( int i=0; i<fonts.size()-1; ++i ) {
210 if( strcmp(fonts.values[i]->get_text(),
211 fonts.values[i + 1]->get_text()) > 0 ) {
212 BC_ListBoxItem *temp = fonts.values[i + 1];
213 fonts.values[i + 1] = fonts.values[i];
214 fonts.values[i] = temp;
220 add_tool(font_title = new BC_Title(x, y, _("Font:")));
221 font = new TitleFont(client, this, x, y + font_title->get_h());
222 font->create_objects();
224 add_subwindow(font_tumbler = new TitleFontTumble(client, this, x, y+margin));
225 x += font_tumbler->get_w() + margin;
228 add_tool(size_title = new BC_Title(x1, y1+margin, _("Size:")));
229 sprintf(string, "%.2f", client->config.size);
230 x1 += size_title->get_w() + margin;
231 size = new TitleSize(client, this, x1, y1+margin, string);
232 size->create_objects();
233 int x2 = x1 + size->get_w(), y2 = y1 + size->get_h() + margin;
234 add_subwindow(size_tumbler = new TitleSizeTumble(client, this, x2, y1+margin));
236 add_tool(pitch_title = new BC_Title(x-5, y2+margin, _("Pitch:")));
237 pitch = new TitlePitch(client, this, x1, y2+margin, &client->config.line_pitch);
238 pitch->create_objects();
240 int x3 = x2 + size_tumbler->get_w() + 50;
241 int y3 = pitch->get_y() + pitch->get_h();
243 add_tool(style_title = new BC_Title(x=x3, y, _("Style:")));
244 add_tool(italic = new TitleItalic(client, this, x, y + 20));
245 int w1 = italic->get_w();
246 add_tool(bold = new TitleBold(client, this, x, y + 50));
247 if( bold->get_w() > w1 ) w1 = bold->get_w();
248 add_tool(drag = new TitleDrag(client, this, x, y + 80));
249 if( drag->get_w() > w1 ) w1 = drag->get_w();
250 if( client->config.drag )
251 grab(client->server->mwindow->cwindow->gui);
254 add_tool(justify_title = new BC_Title(x, y, _("Justify:")));
255 add_tool(left = new TitleLeft(client, this, x, y + 20));
257 add_tool(center = new TitleCenter(client, this, x, y + 50));
258 if( center->get_w() > w1 ) w1 = center->get_w();
259 add_tool(right = new TitleRight(client, this, x, y + 80));
260 if( right->get_w() > w1 ) w1 = right->get_w();
263 add_tool(top = new TitleTop(client, this, x, y + 20));
264 add_tool(mid = new TitleMid(client, this, x, y + 50));
265 add_tool(bottom= new TitleBottom(client, this, x, y + 80));
270 w1 = BC_Title::calculate_w(this, _("X:"));
271 if( (x1 = BC_Title::calculate_w(this, _("Y:"))) > w1 ) w1 = x1;
272 if( (x1 = BC_Title::calculate_w(this, _("W:"))) > w1 ) w1 = x1;
273 if( (x1 = BC_Title::calculate_w(this, _("H:"))) > w1 ) w1 = x1;
274 add_tool(x_title = new BC_Title(x1=x, y, _("X:")));
276 title_x = new TitleX(client, this, x1, y);
277 title_x->create_objects();
278 x1 += title_x->get_w()+margin;
279 add_tool(y_title = new BC_Title(x1, y, _("Y:")));
281 title_y = new TitleY(client, this, x1, y);
282 title_y->create_objects();
283 x1 += title_y->get_w();
284 y1 = y + title_y->get_h();
286 add_tool(w_title = new BC_Title(x1=x, y1, _("W:")));
288 title_w = new TitleW(client, this, x1, y1);
289 title_w->create_objects();
290 x1 += title_w->get_w()+margin;
291 add_tool(h_title = new BC_Title(x1, y1, _("H:")));
293 title_h = new TitleH(client, this, x1, y1);
294 title_h->create_objects();
295 x1 += title_h->get_w();
298 add_tool(motion_title = new BC_Title(x1=x, y, _("Motion:")));
299 x1 += motion_title->get_w()+margin;
300 motion = new TitleMotion(client, this, x1, y);
301 motion->create_objects();
302 add_tool(loop = new TitleLoop(client, x, y1));
303 x = margin; y = y1 + loop->get_h()+20;
305 add_tool(dropshadow_title = new BC_Title(x, y, _("Drop shadow:")));
306 w1 = dropshadow_title->get_w();
307 dropshadow = new TitleDropShadow(client, this, x, y + 20);
308 dropshadow->create_objects();
309 if( dropshadow->get_w() > w1 ) w1 = dropshadow->get_w();
312 add_tool(fadein_title = new BC_Title(x, y, _("Fade in (sec):")));
313 w1 = fadein_title->get_w();
314 add_tool(fade_in = new TitleFade(client, this, &client->config.fade_in, x, y + 20));
315 if( fade_in->get_w() > w1 ) w1 = fade_in->get_w();
318 add_tool(fadeout_title = new BC_Title(x, y, _("Fade out (sec):")));
319 w1 = fadeout_title->get_w();
320 add_tool(fade_out = new TitleFade(client, this, &client->config.fade_out, x, y + 20));
321 if( fade_out->get_w() > w1 ) w1 = fade_out->get_w();
324 add_tool(speed_title = new BC_Title(x, y1=y, _("Speed:")));
325 w1 = speed_title->get_w();
326 y += speed_title->get_h() + 5;
327 speed = new TitleSpeed(client, this, x, y);
328 speed->create_objects();
329 if( speed->get_w() > w1 ) w1 = speed->get_w();
331 y2 = y + speed->get_h() + 10;
333 color_x = x3; color_y = y = y1;
334 color_thread = new TitleColorThread(client, this, 0);
335 x1 = color_x + COLOR_W + 2*margin;
337 add_tool(color_button = new TitleColorButton(client, this, x1, y1));
339 outline_color_x = x3; outline_color_y = y;
340 outline_color_thread = new TitleColorThread(client, this, 1);
341 y1 = outline_color_y + 5;
342 add_tool(outline_color_button = new TitleOutlineColorButton(client, this, x1, y1));
345 add_tool(outline_title = new BC_Title(x, y, _("Outline:")));
346 y1 = y + outline_title->get_h() + margin;
347 outline = new TitleOutline(client, this, x, y1);
348 outline->create_objects();
349 x += outline->get_w() + 2*margin;
351 // to different to be used
352 add_tool(stroker_title = new BC_Title(x, y, _("Stroker:")));
353 stroker = new TitleStroker(client, this, x, y1);
354 stroker->create_objects();
355 x += stroker->get_w() + margin;
357 y += outline_title->get_h() + margin;
358 add_tool(timecode = new TitleTimecode(client, x1=x, y));
359 x += timecode->get_w() + margin;
360 add_tool(timecode_format = new TitleTimecodeFormat(client, x, y,
361 Units::print_time_format(client->config.timecode_format, string)));
362 timecode_format->create_objects();
363 y += timecode_format->get_h() + margin;
366 add_tool(background = new TitleBackground(client, this, x, y));
367 x += background->get_w() + margin;
368 add_tool(background_path = new TitleBackgroundPath(client, this, x, y));
369 x += background_path->get_w() + margin;
370 add_tool(background_browse = new BrowseButton(
371 client->server->mwindow->theme, this, background_path,
372 x, y, "", _("background media"), _("Select background media path")));
373 x += background_browse->get_w() + 3*margin;
374 add_tool(loop_playback = new TitleLoopPlayback(client, x, y));
375 y += loop_playback->get_h() + 10;
378 add_tool(text_title = new BC_Title(x, y, _("Text:")));
379 y += text_title->get_h() + margin;
381 text = new TitleText(client, this, x, y, get_w()-margin - x, get_h() - y - 10);
382 text->create_objects();
384 add_tool(cur_popup = new TitleCurPopup(client, this));
385 cur_popup->create_objects();
386 add_tool(fonts_popup = new TitleFontsPopup(client, this));
387 color_popup = new TitleColorPopup(client, this);
388 png_popup = new TitlePngPopup(client, this);
394 int TitleWindow::resize_event(int w, int h)
396 client->config.window_w = w;
397 client->config.window_h = h;
399 clear_box(0, 0, w, h);
400 font_title->reposition_window(font_title->get_x(), font_title->get_y());
401 font->reposition_window(font->get_x(), font->get_y());
402 font_tumbler->reposition_window(font_tumbler->get_x(), font_tumbler->get_y());
403 x_title->reposition_window(x_title->get_x(), x_title->get_y());
404 title_x->reposition_window(title_x->get_x(), title_x->get_y());
405 y_title->reposition_window(y_title->get_x(), y_title->get_y());
406 title_y->reposition_window(title_y->get_x(), title_y->get_y());
407 w_title->reposition_window(w_title->get_x(), w_title->get_y());
408 title_w->reposition_window(title_w->get_x(), title_w->get_y());
409 h_title->reposition_window(h_title->get_x(), h_title->get_y());
410 title_h->reposition_window(title_h->get_x(), title_h->get_y());
411 style_title->reposition_window(style_title->get_x(), style_title->get_y());
412 italic->reposition_window(italic->get_x(), italic->get_y());
413 bold->reposition_window(bold->get_x(), bold->get_y());
414 drag->reposition_window(drag->get_x(), drag->get_y());
415 size_title->reposition_window(size_title->get_x(), size_title->get_y());
416 size->reposition_window(size->get_x(), size->get_y());
417 size_tumbler->reposition_window(size_tumbler->get_x(), size_tumbler->get_y());
418 pitch_title->reposition_window(pitch_title->get_x(), pitch_title->get_y());
419 pitch->reposition_window(pitch->get_x(), pitch->get_y());
421 color_button->reposition_window(color_button->get_x(), color_button->get_y());
422 outline_color_button->reposition_window(outline_color_button->get_x(), outline_color_button->get_y());
423 motion_title->reposition_window(motion_title->get_x(), motion_title->get_y());
424 motion->reposition_window(motion->get_x(), motion->get_y());
425 loop->reposition_window(loop->get_x(), loop->get_y());
426 dropshadow_title->reposition_window(dropshadow_title->get_x(), dropshadow_title->get_y());
427 dropshadow->reposition_window(dropshadow->get_x(), dropshadow->get_y());
428 fadein_title->reposition_window(fadein_title->get_x(), fadein_title->get_y());
429 fade_in->reposition_window(fade_in->get_x(), fade_in->get_y());
430 fadeout_title->reposition_window(fadeout_title->get_x(), fadeout_title->get_y());
431 fade_out->reposition_window(fade_out->get_x(), fade_out->get_y());
432 text_title->reposition_window(text_title->get_x(), text_title->get_y());
433 timecode->reposition_window(timecode->get_x(), timecode->get_y());
434 text->reposition_window(text->get_x(), text->get_y(), w - text->get_x() - 10,
435 BC_TextBox::pixels_to_rows(this, MEDIUMFONT, h - text->get_y() - 10));
436 justify_title->reposition_window(justify_title->get_x(), justify_title->get_y());
437 left->reposition_window(left->get_x(), left->get_y());
438 center->reposition_window(center->get_x(), center->get_y());
439 right->reposition_window(right->get_x(), right->get_y());
440 top->reposition_window(top->get_x(), top->get_y());
441 mid->reposition_window(mid->get_x(), mid->get_y());
442 bottom->reposition_window(bottom->get_x(), bottom->get_y());
443 speed_title->reposition_window(speed_title->get_x(), speed_title->get_y());
444 speed->reposition_window(speed->get_x(), speed->get_y());
451 int TitleWindow::grab_event(XEvent *event)
453 switch( event->type ) {
455 if( !dragging ) break;
458 if( !dragging ) return 0;
462 if( dragging ) break;
466 MWindow *mwindow = client->server->mwindow;
467 CWindowGUI *cwindow_gui = mwindow->cwindow->gui;
468 CWindowCanvas *canvas = cwindow_gui->canvas;
469 float cursor_x = canvas->get_canvas()->get_relative_cursor_x();
470 float cursor_y = canvas->get_canvas()->get_relative_cursor_y();
471 canvas->canvas_to_output(mwindow->edl, 0, cursor_x, cursor_y);
472 int64_t position = client->get_source_position();
473 float projector_x, projector_y, projector_z;
474 Track *track = client->server->plugin->track;
475 int track_w = track->track_w, track_h = track->track_h;
476 track->automation->get_projector(
477 &projector_x, &projector_y, &projector_z,
478 position, PLAY_FORWARD);
479 projector_x += mwindow->edl->session->output_w / 2;
480 projector_y += mwindow->edl->session->output_h / 2;
481 cursor_x = (cursor_x - projector_x) / projector_z + track_w / 2;
482 cursor_y = (cursor_y - projector_y) / projector_z + track_h / 2;
483 int title_x = client->config.title_x, title_y = client->config.title_y;
484 int title_w = client->config.title_w, title_h = client->config.title_h;
485 if( !title_w ) title_w = track_w;
486 if( !title_h ) title_h = track_h;
487 int r = MIN(track_w, track_h)/100 + 2;
488 int x0 = title_x, x1 = title_x+(title_w+1)/2, x2 = title_x+title_w;
489 int y0 = title_y, y1 = title_y+(title_h+1)/2, y2 = title_y+title_h;
490 int drag_dx = 0, drag_dy = 0;
491 if( !dragging ) { // clockwise
492 if( abs(drag_dx = cursor_x-x0) < r && // x0,y0
493 abs(drag_dy = cursor_y-y0) < r ) dragging = 1;
494 else if( abs(drag_dx = cursor_x-x1) < r && // x1,y0
495 abs(drag_dy = cursor_y-y0) < r ) dragging = 2;
496 else if( abs(drag_dx = cursor_x-x2) < r && // x2,y0
497 abs(drag_dy = cursor_y-y0) < r ) dragging = 3;
498 else if( abs(drag_dx = cursor_x-x2) < r && // x2,y1
499 abs(drag_dy = cursor_y-y1) < r ) dragging = 4;
500 else if( abs(drag_dx = cursor_x-x2) < r && // x2,y2
501 abs(drag_dy = cursor_y-y2) < r ) dragging = 5;
502 else if( abs(drag_dx = cursor_x-x1) < r && // x1,y2
503 abs(drag_dy = cursor_y-y2) < r ) dragging = 6;
504 else if( abs(drag_dx = cursor_x-x0) < r && // x0,y2
505 abs(drag_dy = cursor_y-y2) < r ) dragging = 7;
506 else if( abs(drag_dx = cursor_x-x0) < r && // x0,y1
507 abs(drag_dy = cursor_y-y1) < r ) dragging = 8;
508 else if( abs(drag_dx = cursor_x-x1) < r && // x1,y1
509 abs(drag_dy = cursor_y-y1) < r ) dragging = 9;
514 int cur_x = cursor_x - drag_dx, dx = cur_x - x0;
515 int cur_y = cursor_y - drag_dy, dy = cur_y - y0;
516 if( !dx && !dy ) return 1;
517 int cur_w = title_w - dx; if( cur_w < 1 ) cur_w = 1;
518 int cur_h = title_h - dy; if( cur_h < 1 ) cur_h = 1;
519 this->title_x->update((int64_t)(client->config.title_x = cur_x));
520 this->title_y->update((int64_t)(client->config.title_y = cur_y));
521 this->title_w->update((int64_t)(client->config.title_w = cur_w));
522 this->title_h->update((int64_t)(client->config.title_h = cur_h));
525 int cur_y = cursor_y - drag_dy, dy = cur_y - y0;
527 int cur_h = title_h - dy; if( cur_h < 1 ) cur_h = 1;
528 this->title_y->update((int64_t)(client->config.title_y = cur_y));
529 this->title_h->update((int64_t)(client->config.title_h = cur_h));
532 int cur_x = cursor_x - drag_dx, dx = cur_x - x2;
533 int cur_y = cursor_y - drag_dy, dy = cur_y - y0;
534 int cur_w = title_w + dx; if( cur_w < 1 ) cur_w = 1;
535 int cur_h = title_h - dy; if( cur_h < 1 ) cur_h = 1;
536 this->title_w->update((int64_t)(client->config.title_w = cur_w));
537 this->title_y->update((int64_t)(client->config.title_y = cur_y));
538 this->title_h->update((int64_t)(client->config.title_h = cur_h));
541 int cur_x = cursor_x - drag_dx, dx = cur_x - x2;
543 int cur_w = title_w + dx; if( cur_w < 1 ) cur_w = 1;
544 this->title_w->update((int64_t)(client->config.title_w = cur_w));
547 int cur_x = cursor_x - drag_dx, dx = cur_x - x2;
548 int cur_y = cursor_y - drag_dy, dy = cur_y - y2;
549 int cur_w = title_w + dx; if( cur_w < 1 ) cur_w = 1;
550 int cur_h = title_h + dy; if( cur_h < 1 ) cur_h = 1;
551 this->title_w->update((int64_t)(client->config.title_w = cur_w));
552 this->title_h->update((int64_t)(client->config.title_h = cur_h));
555 int cur_y = cursor_y - drag_dy, dy = cur_y - y2;
556 if( client->config.title_h == cur_y ) return 1;
557 int cur_h = title_h + dy; if( cur_h < 1 ) cur_h = 1;
558 this->title_h->update((int64_t)(client->config.title_h = cur_h));
561 int cur_x = cursor_x - drag_dx, dx = cur_x - x0;
562 int cur_y = cursor_y - drag_dy, dy = cur_y - y2;
563 int cur_w = title_w - dx; if( cur_w < 1 ) cur_w = 1;
564 int cur_h = title_h + dy; if( cur_h < 1 ) cur_h = 1;
565 this->title_x->update((int64_t)(client->config.title_x = cur_x));
566 this->title_w->update((int64_t)(client->config.title_w = cur_w));
567 this->title_h->update((int64_t)(client->config.title_h = cur_h));
570 int cur_x = cursor_x - drag_dx, dx = cur_x - x0;
572 int cur_w = title_w - dx; if( cur_w < 1 ) cur_w = 1;
573 this->title_x->update((int64_t)(client->config.title_x = cur_x));
574 this->title_w->update((int64_t)(client->config.title_w = cur_w));
577 int cur_x = cursor_x - drag_dx, dx = cur_x - x1;
578 int cur_y = cursor_y - drag_dy, dy = cur_y - y1;
579 if( title_x == cur_x && title_y == cur_y ) return 1;
580 this->title_x->update((int64_t)(client->config.title_x += dx));
581 this->title_y->update((int64_t)(client->config.title_y += dy));
584 client->send_configure_change();
588 void TitleWindow::previous_font()
590 int current_font = font->get_number();
592 if( current_font < 0 ) current_font = fonts.total - 1;
594 if( current_font < 0 || current_font >= fonts.total ) return;
596 for( int i=0; i<fonts.total; ++i ) {
597 fonts.values[i]->set_selected(i == current_font);
600 font->update(fonts.values[current_font]->get_text());
601 strcpy(client->config.font, fonts.values[current_font]->get_text());
602 client->send_configure_change();
605 void TitleWindow::next_font()
607 int current_font = font->get_number();
609 if( current_font >= fonts.total ) current_font = 0;
611 if( current_font < 0 || current_font >= fonts.total ) return;
613 for( int i=0; i<fonts.total; ++i ) {
614 fonts.values[i]->set_selected(i == current_font);
617 font->update(fonts.values[current_font]->get_text());
618 strcpy(client->config.font, fonts.values[current_font]->get_text());
619 client->send_configure_change();
622 int TitleWindow::insert_ibeam(const char *txt, int adv)
624 int ibeam = cur_ibeam;
625 client->insert_text(txt, ibeam);
626 if( (ibeam += adv) >= client->config.wlen)
627 ibeam = client->config.wlen;
628 text->wset_selection(-1, -1, ibeam);
629 text->update(client->config.wtext);
630 client->send_configure_change();
634 void TitleWindow::update_color()
636 //printf("TitleWindow::update_color %x\n", client->config.color);
637 set_color(client->config.color);
638 draw_box(color_x, color_y, COLOR_W, COLOR_H);
639 flash(color_x, color_y, COLOR_W, COLOR_H);
640 set_color(client->config.outline_color);
641 draw_box(outline_color_x, outline_color_y, COLOR_W, COLOR_H);
643 draw_rectangle(color_x, color_y, COLOR_W, COLOR_H);
644 draw_rectangle(outline_color_x, outline_color_y, COLOR_W, COLOR_H);
645 flash(outline_color_x, outline_color_y, COLOR_W, COLOR_H);
648 void TitleWindow::update_justification()
650 left->update(client->config.hjustification == JUSTIFY_LEFT);
651 center->update(client->config.hjustification == JUSTIFY_CENTER);
652 right->update(client->config.hjustification == JUSTIFY_RIGHT);
653 top->update(client->config.vjustification == JUSTIFY_TOP);
654 mid->update(client->config.vjustification == JUSTIFY_MID);
655 bottom->update(client->config.vjustification == JUSTIFY_BOTTOM);
658 void TitleWindow::update()
660 title_x->update((int64_t)client->config.title_x);
661 title_y->update((int64_t)client->config.title_y);
662 title_w->update((int64_t)client->config.title_w);
663 title_h->update((int64_t)client->config.title_h);
664 italic->update(client->config.style & BC_FONT_ITALIC);
665 bold->update(client->config.style & BC_FONT_BOLD);
666 size->update(client->config.size);
667 motion->update(TitleMain::motion_to_text(client->config.motion_strategy));
668 loop->update(client->config.loop);
669 dropshadow->update((int64_t)client->config.dropshadow);
670 fade_in->update((float)client->config.fade_in);
671 fade_out->update((float)client->config.fade_out);
672 font->update(client->config.font);
673 text->update(&client->config.wtext[0]);
674 speed->update(client->config.pixels_per_second);
675 outline->update((int64_t)client->config.outline_size);
677 stroker->update((int64_t)client->config.stroke_width);
679 timecode->update(client->config.timecode);
680 timecode_format->update(client->config.timecode_format);
681 background->update(client->config.background);
682 background_path->update(client->config.background_path);
683 loop_playback->update((int64_t)client->config.loop_playback);
685 char string[BCTEXTLEN];
686 for( int i=0; i<lengthof(timeunit_formats); ++i ) {
687 if( timeunit_formats[i] == client->config.timecode_format ) {
688 timecode_format->set_text(
689 Units::print_time_format(timeunit_formats[i], string));
693 update_justification();
698 TitleFontTumble::TitleFontTumble(TitleMain *client, TitleWindow *window, int x, int y)
701 this->client = client;
702 this->window = window;
704 int TitleFontTumble::handle_up_event()
706 window->previous_font();
710 int TitleFontTumble::handle_down_event()
718 TitleSizeTumble::TitleSizeTumble(TitleMain *client, TitleWindow *window, int x, int y)
721 this->client = client;
722 this->window = window;
725 int TitleSizeTumble::handle_up_event()
727 int current_index = -1;
728 int current_difference = -1;
729 for( int i=0; i<window->sizes.size(); ++i ) {
730 int size = atoi(window->sizes.get(i)->get_text());
731 if( current_index < 0 ||
732 abs(size - client->config.size) < current_difference ) {
734 current_difference = abs(size - client->config.size);
739 if( current_index >= window->sizes.size() ) current_index = 0;
742 client->config.size = atoi(window->sizes.get(current_index)->get_text());
743 window->size->update(client->config.size);
744 client->send_configure_change();
748 int TitleSizeTumble::handle_down_event()
750 int current_index = -1;
751 int current_difference = -1;
752 for( int i=0; i<window->sizes.size(); ++i ) {
753 int size = atoi(window->sizes.get(i)->get_text());
754 if( current_index < 0 ||
755 abs(size - client->config.size) < current_difference ) {
757 current_difference = abs(size - client->config.size);
762 if( current_index < 0 ) current_index = window->sizes.size() - 1;
765 client->config.size = atoi(window->sizes.get(current_index)->get_text());
766 window->size->update(client->config.size);
767 client->send_configure_change();
771 TitleBold::TitleBold(TitleMain *client, TitleWindow *window, int x, int y)
772 : BC_CheckBox(x, y, client->config.style & BC_FONT_BOLD, _("Bold"))
774 this->client = client;
775 this->window = window;
778 int TitleBold::handle_event()
780 client->config.style =
781 (client->config.style & ~BC_FONT_BOLD) |
782 (get_value() ? BC_FONT_BOLD : 0);
783 client->send_configure_change();
787 TitleItalic::TitleItalic(TitleMain *client, TitleWindow *window, int x, int y)
788 : BC_CheckBox(x, y, client->config.style & BC_FONT_ITALIC, _("Italic"))
790 this->client = client;
791 this->window = window;
793 int TitleItalic::handle_event()
795 client->config.style =
796 (client->config.style & ~BC_FONT_ITALIC) |
797 (get_value() ? BC_FONT_ITALIC : 0);
798 client->send_configure_change();
804 TitleSize::TitleSize(TitleMain *client, TitleWindow *window, int x, int y, char *text)
805 : BC_PopupTextBox(window,
813 this->client = client;
814 this->window = window;
816 TitleSize::~TitleSize()
819 int TitleSize::handle_event()
821 client->config.size = atol(get_text());
822 //printf("TitleSize::handle_event 1 %s\n", get_text());
823 client->send_configure_change();
826 void TitleSize::update(int size)
828 char string[BCTEXTLEN];
829 sprintf(string, "%d", size);
830 BC_PopupTextBox::update(string);
834 TitlePitch(TitleMain *client, TitleWindow *window, int x, int y, int *value)
835 : BC_TumbleTextBox(window, *value, 0, INT_MAX, x, y, 64)
837 this->client = client;
838 this->window = window;
847 int TitlePitch::handle_event()
849 *value = atol(get_text());
850 client->send_configure_change();
854 TitleColorButton::TitleColorButton(TitleMain *client, TitleWindow *window, int x, int y)
855 : BC_GenericButton(x, y, _("Color..."))
857 this->client = client;
858 this->window = window;
860 int TitleColorButton::handle_event()
862 window->color_thread->start_window(client->config.color,
863 client->config.alpha);
866 TitleOutlineColorButton::TitleOutlineColorButton(TitleMain *client, TitleWindow *window, int x, int y)
867 : BC_GenericButton(x, y, _("Outline color..."))
869 this->client = client;
870 this->window = window;
872 int TitleOutlineColorButton::handle_event()
874 window->outline_color_thread->start_window(client->config.outline_color,
875 client->config.outline_alpha);
880 TitleMotion::TitleMotion(TitleMain *client, TitleWindow *window, int x, int y)
881 : BC_PopupTextBox(window, &window->paths,
882 client->motion_to_text(client->config.motion_strategy),
885 this->client = client;
886 this->window = window;
888 int TitleMotion::handle_event()
890 client->config.motion_strategy = client->text_to_motion(get_text());
891 client->send_configure_change();
895 TitleLoop::TitleLoop(TitleMain *client, int x, int y)
896 : BC_CheckBox(x, y, client->config.loop, _("Loop"))
898 this->client = client;
900 int TitleLoop::handle_event()
902 client->config.loop = get_value();
903 client->send_configure_change();
906 TitleTimecode::TitleTimecode(TitleMain *client, int x, int y)
907 : BC_CheckBox(x, y, client->config.timecode, _("Stamp timecode"))
909 this->client = client;
911 int TitleTimecode::handle_event()
913 client->config.timecode = get_value();
914 client->send_configure_change();
918 TitleTimecodeFormat::TitleTimecodeFormat(TitleMain *client, int x, int y, const char *text)
919 : BC_PopupMenu(x, y, 100, text, 1)
921 this->client = client;
924 int TitleTimecodeFormat::handle_event()
926 client->config.timecode_format = Units::text_to_format(get_text());
927 client->send_configure_change();
931 void TitleTimecodeFormat::create_objects()
933 char string[BCTEXTLEN];
934 for( int i=0; i<lengthof(timeunit_formats); ++i ) {
935 add_item(new BC_MenuItem(
936 Units::print_time_format(timeunit_formats[i], string)));
941 int TitleTimecodeFormat::update(int timecode_format)
943 char string[BCTEXTLEN];
944 for( int i=0; i<lengthof(timeunit_formats); ++i ) {
945 if( timeunit_formats[i] == timecode_format ) {
946 set_text(Units::print_time_format(timeunit_formats[i], string));
953 TitleFade::TitleFade(TitleMain *client, TitleWindow *window,
954 double *value, int x, int y)
955 : BC_TextBox(x, y, 80, 1, (float)*value)
957 this->client = client;
958 this->window = window;
963 int TitleFade::handle_event()
965 *value = atof(get_text());
966 client->send_configure_change();
970 TitleFont::TitleFont(TitleMain *client, TitleWindow *window, int x, int y)
971 : BC_PopupTextBox(window, &window->fonts, client->config.font,
972 x, y, 200, 500, LISTBOX_ICON_LIST)
974 this->client = client;
975 this->window = window;
977 int TitleFont::handle_event()
979 strcpy(client->config.font, get_text());
980 client->send_configure_change();
984 TitleText::TitleText(TitleMain *client, TitleWindow *window,
985 int x, int y, int w, int h)
986 : BC_ScrollTextBox(window, x, y, w,
987 BC_TextBox::pixels_to_rows(window, MEDIUMFONT, h),
988 client->config.wtext, 8192)
990 this->client = client;
991 this->window = window;
992 //printf("TitleText::TitleText %s\n", client->config.text);
995 int TitleText::button_press_event()
997 if( get_buttonpress() == 3 ) {
998 window->cur_ibeam = get_ibeam_letter();
999 window->cur_popup->activate_menu();
1002 return BC_ScrollTextBox::button_press_event();
1005 int TitleText::handle_event()
1007 window->fonts_popup->deactivate();
1008 int len = sizeof(client->config.wtext) / sizeof(wchar_t);
1009 wcsncpy(client->config.wtext, get_wtext(), len);
1010 client->config.wtext[len-1] = 0;
1011 client->config.wlen = wcslen(client->config.wtext);
1012 client->send_configure_change();
1017 TitleDropShadow::TitleDropShadow(TitleMain *client, TitleWindow *window, int x, int y)
1018 : BC_TumbleTextBox(window, (int64_t)client->config.dropshadow,
1019 (int64_t)-1000, (int64_t)1000, x, y, 70)
1021 this->client = client;
1022 this->window = window;
1024 int TitleDropShadow::handle_event()
1026 client->config.dropshadow = atol(get_text());
1027 client->send_configure_change();
1032 TitleOutline::TitleOutline(TitleMain *client, TitleWindow *window, int x, int y)
1033 : BC_TumbleTextBox(window, (int64_t)client->config.outline_size,
1034 (int64_t)0, (int64_t)1000, x, y, 70)
1036 this->client = client;
1037 this->window = window;
1039 int TitleOutline::handle_event()
1041 client->config.outline_size = atol(get_text());
1042 client->send_configure_change();
1046 TitleStroker::TitleStroker(TitleMain *client, TitleWindow *window, int x, int y)
1047 : BC_TumbleTextBox(window, (int64_t)client->config.stroke_width,
1048 (int64_t)0, (int64_t)1000, x, y, 70)
1050 this->client = client;
1051 this->window = window;
1053 int TitleStroker::handle_event()
1055 client->config.stroke_width = atol(get_text());
1056 if( client->config.stroke_width > 1 )
1057 client->config.style |= BC_FONT_OUTLINE;
1059 client->config.style &= ~BC_FONT_OUTLINE;
1060 client->send_configure_change();
1065 TitleX::TitleX(TitleMain *client, TitleWindow *window, int x, int y)
1066 : BC_TumbleTextBox(window, (int64_t)client->config.title_x,
1067 (int64_t)-32767, (int64_t)32767, x, y, 50)
1069 this->client = client;
1070 this->window = window;
1072 int TitleX::handle_event()
1074 client->config.title_x = atol(get_text());
1075 client->send_configure_change();
1079 TitleY::TitleY(TitleMain *client, TitleWindow *window, int x, int y)
1080 : BC_TumbleTextBox(window, (int64_t)client->config.title_y,
1081 (int64_t)-32767, (int64_t)32767, x, y, 50)
1083 this->client = client;
1084 this->window = window;
1086 int TitleY::handle_event()
1088 client->config.title_y = atol(get_text());
1089 client->send_configure_change();
1093 TitleW::TitleW(TitleMain *client, TitleWindow *window, int x, int y)
1094 : BC_TumbleTextBox(window, (int64_t)client->config.title_w,
1095 (int64_t)0, (int64_t)32767, x, y, 50)
1097 this->client = client;
1098 this->window = window;
1100 int TitleW::handle_event()
1102 client->config.title_w = atol(get_text());
1103 client->send_configure_change();
1107 TitleH::TitleH(TitleMain *client, TitleWindow *window, int x, int y)
1108 : BC_TumbleTextBox(window, (int64_t)client->config.title_h,
1109 (int64_t)0, (int64_t)32767, x, y, 50)
1111 this->client = client;
1112 this->window = window;
1114 int TitleH::handle_event()
1116 client->config.title_h = atol(get_text());
1117 client->send_configure_change();
1121 TitleSpeed::TitleSpeed(TitleMain *client, TitleWindow *window, int x, int y)
1122 : BC_TumbleTextBox(window, (float)client->config.pixels_per_second,
1123 (float)0, (float)1000, x, y, 100)
1125 this->client = client;
1131 int TitleSpeed::handle_event()
1133 client->config.pixels_per_second = atof(get_text());
1134 client->send_configure_change();
1139 TitleLeft::TitleLeft(TitleMain *client, TitleWindow *window, int x, int y)
1140 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_LEFT, _("Left"))
1142 this->client = client;
1143 this->window = window;
1145 int TitleLeft::handle_event()
1147 client->config.hjustification = JUSTIFY_LEFT;
1148 window->update_justification();
1149 client->send_configure_change();
1153 TitleCenter::TitleCenter(TitleMain *client, TitleWindow *window, int x, int y)
1154 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_CENTER, _("Center"))
1156 this->client = client;
1157 this->window = window;
1159 int TitleCenter::handle_event()
1161 client->config.hjustification = JUSTIFY_CENTER;
1162 window->update_justification();
1163 client->send_configure_change();
1167 TitleRight::TitleRight(TitleMain *client, TitleWindow *window, int x, int y)
1168 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_RIGHT, _("Right"))
1170 this->client = client;
1171 this->window = window;
1173 int TitleRight::handle_event()
1175 client->config.hjustification = JUSTIFY_RIGHT;
1176 window->update_justification();
1177 client->send_configure_change();
1183 TitleTop::TitleTop(TitleMain *client, TitleWindow *window, int x, int y)
1184 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_TOP, _("Top"))
1186 this->client = client;
1187 this->window = window;
1189 int TitleTop::handle_event()
1191 client->config.vjustification = JUSTIFY_TOP;
1192 window->update_justification();
1193 client->send_configure_change();
1197 TitleMid::TitleMid(TitleMain *client, TitleWindow *window, int x, int y)
1198 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_MID, _("Mid"))
1200 this->client = client;
1201 this->window = window;
1203 int TitleMid::handle_event()
1205 client->config.vjustification = JUSTIFY_MID;
1206 window->update_justification();
1207 client->send_configure_change();
1211 TitleBottom::TitleBottom(TitleMain *client, TitleWindow *window, int x, int y)
1212 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_BOTTOM, _("Bottom"))
1214 this->client = client;
1215 this->window = window;
1217 int TitleBottom::handle_event()
1219 client->config.vjustification = JUSTIFY_BOTTOM;
1220 window->update_justification();
1221 client->send_configure_change();
1227 TitleColorThread::TitleColorThread(TitleMain *client, TitleWindow *window, int is_outline)
1228 : ColorThread(1, _("Text Color"))
1230 this->client = client;
1231 this->window = window;
1232 this->is_outline = is_outline;
1235 int TitleColorThread::handle_new_color(int output, int alpha)
1238 client->config.outline_color = output;
1239 client->config.outline_alpha = alpha;
1242 client->config.color = output;
1243 client->config.alpha = alpha;
1246 window->lock_window("TitleColorThread::handle_new_color");
1247 window->update_color();
1249 window->unlock_window();
1251 client->send_configure_change();
1255 TitleDrag::TitleDrag(TitleMain *client, TitleWindow *window, int x, int y)
1256 : BC_CheckBox(x, y, client->config.drag, _("Drag"))
1258 this->client = client;
1259 this->window = window;
1262 int TitleDrag::handle_event()
1264 int value = get_value();
1265 client->config.drag = value;
1267 window->grab(client->server->mwindow->cwindow->gui);
1269 window->ungrab(client->server->mwindow->cwindow->gui);
1270 client->send_configure_change();
1274 TitleBackground::TitleBackground(TitleMain *client, TitleWindow *window, int x, int y)
1275 : BC_CheckBox(x, y, client->config.background, _("Background:"))
1277 this->client = client;
1278 this->window = window;
1281 int TitleBackground::handle_event()
1283 client->config.background = get_value();
1284 client->send_configure_change();
1288 TitleBackgroundPath::TitleBackgroundPath(TitleMain *client, TitleWindow *window, int x, int y)
1289 : BC_TextBox(x, y, 240, 1, client->config.background_path)
1291 this->client = client;
1292 this->window = window;
1295 int TitleBackgroundPath::handle_event()
1297 strncpy(client->config.background_path, get_text(), sizeof(client->config.background_path));
1298 client->send_configure_change();
1302 TitleLoopPlayback::TitleLoopPlayback(TitleMain *client, int x, int y)
1303 : BC_CheckBox(x, y, client->config.loop_playback, _("Loop playback"))
1305 this->client = client;
1307 int TitleLoopPlayback::handle_event()
1309 client->config.loop_playback = get_value();
1310 client->send_configure_change();
1315 TitleCurPopup::TitleCurPopup(TitleMain *client, TitleWindow *window)
1316 : BC_PopupMenu(0, 0, 0, "", 0)
1318 this->client = client;
1319 this->window = window;
1321 int TitleCurPopup::handle_event()
1325 void TitleCurPopup::create_objects()
1327 TitleCurItem *cur_item;
1328 TitleCurSubMenu *sub_menu;
1329 add_item(cur_item = new TitleCurItem(this, _("nudge")));
1330 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1331 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("nudge dx,dy")));
1332 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("/nudge")));
1333 add_item(cur_item = new TitleCurItem(this, _("color")));
1334 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1335 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("color #")));
1336 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("color ")));
1337 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("/color")));
1338 add_item(cur_item = new TitleCurItem(this, _("alpha")));
1339 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1340 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("alpha ")));
1341 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("alpha 0.")));
1342 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("alpha .5")));
1343 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("alpha 1.")));
1344 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("/alpha")));
1345 add_item(cur_item = new TitleCurItem(this, _("font")));
1346 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1347 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("font name")));
1348 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("font ")));
1349 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("/font")));
1350 add_item(cur_item = new TitleCurItem(this, _("size")));
1351 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1352 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("size +")));
1353 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("size -")));
1354 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("size ")));
1355 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("/size")));
1356 add_item(cur_item = new TitleCurItem(this, _("bold")));
1357 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1358 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("bold 1")));
1359 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("bold 0")));
1360 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("/bold")));
1361 add_item(cur_item = new TitleCurItem(this, _("italic")));
1362 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1363 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("italic 1")));
1364 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("italic 0")));
1365 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("/italic")));
1366 add_item(cur_item = new TitleCurItem(this, _("caps")));
1367 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1368 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("caps 1")));
1369 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("caps 0")));
1370 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("caps -1")));
1371 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("/caps")));
1372 add_item(cur_item = new TitleCurItem(this, _("ul")));
1373 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1374 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("ul 1")));
1375 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("ul 0")));
1376 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("/ul")));
1377 add_item(cur_item = new TitleCurItem(this, _("blink")));
1378 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1379 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("blink 1")));
1380 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("blink -1")));
1381 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("blink ")));
1382 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("blink 0")));
1383 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("/blink")));
1384 add_item(cur_item = new TitleCurItem(this, _("fixed")));
1385 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1386 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("fixed ")));
1387 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("fixed 20")));
1388 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("fixed 10")));
1389 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("fixed 0")));
1390 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("/fixed")));
1391 add_item(cur_item = new TitleCurItem(this, _("sup")));
1392 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1393 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("sup 1")));
1394 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("sup 0")));
1395 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("sup -1")));
1396 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("/sup")));
1397 add_item(cur_item = new TitleCurItem(this, _("png")));
1398 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1399 sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("png file")));
1402 TitleCurItem::TitleCurItem(TitleCurPopup *popup, const char *text)
1405 this->popup = popup;
1407 int TitleCurItem::handle_event()
1412 TitleCurSubMenu::TitleCurSubMenu(TitleCurItem *cur_item)
1414 this->cur_item = cur_item;
1416 TitleCurSubMenu::~TitleCurSubMenu()
1420 TitleCurSubMenuItem::TitleCurSubMenuItem(TitleCurSubMenu *submenu, const char *text)
1423 this->submenu = submenu;
1425 TitleCurSubMenuItem::~TitleCurSubMenuItem()
1428 int TitleCurSubMenuItem::handle_event()
1430 TitleCurPopup *popup = submenu->cur_item->popup;
1431 TitleWindow *window = popup->window;
1432 const char *item_text = get_text();
1433 if( !strcmp(item_text, _("font name")) ) {
1435 window->get_pop_cursor_xy(px ,py);
1436 window->fonts_popup->activate(px, py, 300,200);
1439 if( !strcmp(item_text, _("color #")) ) {
1440 window->color_popup->activate();
1443 if( !strcmp(item_text, _("png file")) ) {
1444 window->png_popup->activate();
1448 sprintf(txt, "<%s>", item_text);
1449 int adv = strlen(txt);
1450 if( adv > 1 && (txt[1] != '/' && strcmp(txt,_("font"))) ) --adv;
1451 return window->insert_ibeam(txt,adv);
1454 TitleFontsPopup::TitleFontsPopup(TitleMain *client, TitleWindow *window)
1455 : BC_ListBox(-1, -1, 1, 1, LISTBOX_ICON_LIST,
1456 &window->fonts, 0, 0, 1, 0, 1)
1458 this->client = client;
1459 this->window = window;
1462 TitleFontsPopup::~TitleFontsPopup()
1466 int TitleFontsPopup::handle_event()
1469 BC_ListBoxItem *item = get_selection(0, 0);
1470 if( !item ) return 1;
1471 const char *item_text = item->get_text();
1472 char txt[BCTEXTLEN]; sprintf(txt, "<font %s>",item_text);
1473 return window->insert_ibeam(txt, strlen(txt));
1476 TitleColorPopup::TitleColorPopup(TitleMain *client, TitleWindow *window)
1477 : ColorThread(0, _("Text Color"))
1479 this->client = client;
1480 this->window = window;
1481 this->color_value = client->config.color;
1483 TitleColorPopup::~TitleColorPopup()
1486 int TitleColorPopup::handle_new_color(int output, int alpha)
1488 color_value = output;
1491 int TitleColorPopup::activate()
1493 start_window(client->config.color, 255, 1);
1496 void TitleColorPopup::handle_done_event(int result)
1498 if( result ) return;
1499 char txt[BCSTRLEN]; sprintf(txt, "<color #%06x>",color_value);
1500 window->insert_ibeam(txt, strlen(txt));
1503 TitlePngPopup::TitlePngPopup(TitleMain *client, TitleWindow *window)
1506 this->client = client;
1507 this->window = window;
1510 TitlePngPopup::~TitlePngPopup()
1515 void TitlePngPopup::handle_done_event(int result)
1517 if( result ) return;
1518 BrowseButtonWindow *gui = (BrowseButtonWindow *)get_gui();
1519 const char *path = gui->get_submitted_path();
1520 char txt[BCSTRLEN]; sprintf(txt, "<png %s>",path);
1521 window->insert_ibeam(txt, strlen(txt));
1524 BC_Window *TitlePngPopup::new_gui()
1526 BC_DisplayInfo display_info;
1527 int x = display_info.get_abs_cursor_x();
1528 int y = display_info.get_abs_cursor_y();
1530 BC_Window *gui = new BrowseButtonWindow(client->server->mwindow->theme,
1531 x-25, y-100, window, "", _("Png file"), _("Png path"), 0);
1532 gui->create_objects();
1536 int TitlePngPopup::activate()
1538 BC_DialogThread::start();