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"
37 #include "pluginserver.h"
40 #include "titlerwindow.h"
41 #include "bcfontentry.h"
43 static const int timeunit_formats[] =
54 TitleWindow::TitleWindow(TitleMain *client)
55 : PluginClientWindow(client,
56 client->config.window_w, client->config.window_h, 100, 100, 1)
58 //printf("TitleWindow::TitleWindow %d %d %d\n", __LINE__, client->config.window_w, client->config.window_h);
59 this->client = client;
64 x_title = 0; title_x = 0;
65 y_title = 0; title_y = 0;
66 w_title = 0; title_w = 0;
67 h_title = 0; title_h = 0;
68 dropshadow_title = 0; dropshadow = 0;
69 outline_title = 0; outline = 0;
70 stroker_title = 0; stroker = 0;
78 color_x = color_y = 0;
79 outline_color_x = outline_color_y = 0;
80 drag_dx = drag_dy = dragging = 0;
92 outline_color_button = 0;
93 outline_color_thread = 0;
107 left = 0; center = 0; right = 0;
108 top = 0; mid = 0; bottom = 0;
118 void TitleWindow::done_event(int result)
120 ungrab(client->server->mwindow->cwindow->gui);
121 color_thread->close_window();
122 outline_color_thread->close_window();
123 color_popup->close_window();
124 png_popup->close_window();
127 TitleWindow::~TitleWindow()
131 for( int i=0; i<fonts.size(); ++i )
132 delete fonts[i]->get_icon();
134 sizes.remove_all_objects();
135 delete timecode_format;
141 void TitleWindow::create_objects()
144 int margin = client->get_theme()->widget_border;
145 char string[BCTEXTLEN];
149 client->build_previews(this);
151 sizes.append(new BC_ListBoxItem("8"));
152 sizes.append(new BC_ListBoxItem("9"));
153 sizes.append(new BC_ListBoxItem("10"));
154 sizes.append(new BC_ListBoxItem("11"));
155 sizes.append(new BC_ListBoxItem("12"));
156 sizes.append(new BC_ListBoxItem("13"));
157 sizes.append(new BC_ListBoxItem("14"));
158 sizes.append(new BC_ListBoxItem("16"));
159 sizes.append(new BC_ListBoxItem("18"));
160 sizes.append(new BC_ListBoxItem("20"));
161 sizes.append(new BC_ListBoxItem("22"));
162 sizes.append(new BC_ListBoxItem("24"));
163 sizes.append(new BC_ListBoxItem("26"));
164 sizes.append(new BC_ListBoxItem("28"));
165 sizes.append(new BC_ListBoxItem("32"));
166 sizes.append(new BC_ListBoxItem("36"));
167 sizes.append(new BC_ListBoxItem("40"));
168 sizes.append(new BC_ListBoxItem("48"));
169 sizes.append(new BC_ListBoxItem("56"));
170 sizes.append(new BC_ListBoxItem("64"));
171 sizes.append(new BC_ListBoxItem("72"));
172 sizes.append(new BC_ListBoxItem("100"));
173 sizes.append(new BC_ListBoxItem("128"));
174 sizes.append(new BC_ListBoxItem("256"));
175 sizes.append(new BC_ListBoxItem("512"));
176 sizes.append(new BC_ListBoxItem("1024"));
178 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(NO_MOTION)));
179 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(BOTTOM_TO_TOP)));
180 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(TOP_TO_BOTTOM)));
181 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(RIGHT_TO_LEFT)));
182 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(LEFT_TO_RIGHT)));
186 // Construct font list
187 ArrayList<BC_FontEntry*> *fontlist = get_resources()->fontlist;
189 for( int i=0; i<fontlist->size(); ++i ) {
191 for( int j=0; j<fonts.size(); ++j ) {
192 if( !strcasecmp(fonts.get(j)->get_text(),
193 fontlist->get(i)->displayname) ) {
199 BC_ListBoxItem *item = 0;
201 fonts.append(item = new
202 BC_ListBoxItem(fontlist->get(i)->displayname));
203 if( !strcmp(client->config.font, item->get_text()) )
204 item->set_selected(1);
205 if( fontlist->values[i]->image ) {
206 VFrame *vframe = fontlist->get(i)->image;
207 BC_Pixmap *icon = new BC_Pixmap(this, vframe, PIXMAP_ALPHA);
208 item->set_icon(icon);
209 item->set_icon_vframe(vframe);
218 for( int i=0; i<fonts.size()-1; ++i ) {
219 if( strcmp(fonts.values[i]->get_text(),
220 fonts.values[i + 1]->get_text()) > 0 ) {
221 BC_ListBoxItem *temp = fonts.values[i + 1];
222 fonts.values[i + 1] = fonts.values[i];
223 fonts.values[i] = temp;
229 add_tool(font_title = new BC_Title(x, y, _("Font:")));
230 font = new TitleFont(client, this, x, y + font_title->get_h());
231 font->create_objects();
232 font->set_show_query(1);
234 add_subwindow(font_tumbler = new TitleFontTumble(client, this, x, y+margin));
235 x += font_tumbler->get_w() + margin;
238 add_tool(size_title = new BC_Title(x1, y1+margin, _("Size:")));
239 sprintf(string, "%.2f", client->config.size);
240 x1 += size_title->get_w() + margin;
241 size = new TitleSize(client, this, x1, y1+margin, string);
242 size->create_objects();
243 int x2 = x1 + size->get_w(), y2 = y1 + size->get_h() + margin;
244 add_subwindow(size_tumbler = new TitleSizeTumble(client, this, x2, y1+margin));
246 add_tool(pitch_title = new BC_Title(x-5, y2+margin, _("Pitch:")));
247 pitch = new TitlePitch(client, this, x1, y2+margin, &client->config.line_pitch);
248 pitch->create_objects();
250 int x3 = x2 + size_tumbler->get_w() + 50;
251 int y3 = pitch->get_y() + pitch->get_h();
253 add_tool(style_title = new BC_Title(x=x3, y, _("Style:")));
254 add_tool(italic = new TitleItalic(client, this, x, y + 20));
255 int w1 = italic->get_w();
256 add_tool(bold = new TitleBold(client, this, x, y + 50));
257 if( bold->get_w() > w1 ) w1 = bold->get_w();
258 add_tool(drag = new TitleDrag(client, this, x, y + 80));
259 if( drag->get_w() > w1 ) w1 = drag->get_w();
260 if( client->config.drag )
261 grab(client->server->mwindow->cwindow->gui);
264 add_tool(justify_title = new BC_Title(x, y, _("Justify:")));
265 add_tool(left = new TitleLeft(client, this, x, y + 20));
267 add_tool(center = new TitleCenter(client, this, x, y + 50));
268 if( center->get_w() > w1 ) w1 = center->get_w();
269 add_tool(right = new TitleRight(client, this, x, y + 80));
270 if( right->get_w() > w1 ) w1 = right->get_w();
273 add_tool(top = new TitleTop(client, this, x, y + 20));
274 add_tool(mid = new TitleMid(client, this, x, y + 50));
275 add_tool(bottom= new TitleBottom(client, this, x, y + 80));
280 w1 = BC_Title::calculate_w(this, _("X:"));
281 if( (x1 = BC_Title::calculate_w(this, _("Y:"))) > w1 ) w1 = x1;
282 if( (x1 = BC_Title::calculate_w(this, _("W:"))) > w1 ) w1 = x1;
283 if( (x1 = BC_Title::calculate_w(this, _("H:"))) > w1 ) w1 = x1;
284 add_tool(x_title = new BC_Title(x1=x, y, _("X:")));
286 title_x = new TitleX(client, this, x1, y);
287 title_x->create_objects();
288 x1 += title_x->get_w()+margin;
289 add_tool(y_title = new BC_Title(x1, y, _("Y:")));
291 title_y = new TitleY(client, this, x1, y);
292 title_y->create_objects();
293 x1 += title_y->get_w();
294 y1 = y + title_y->get_h();
296 add_tool(w_title = new BC_Title(x1=x, y1, _("W:")));
298 title_w = new TitleW(client, this, x1, y1);
299 title_w->create_objects();
300 x1 += title_w->get_w()+margin;
301 add_tool(h_title = new BC_Title(x1, y1, _("H:")));
303 title_h = new TitleH(client, this, x1, y1);
304 title_h->create_objects();
305 x1 += title_h->get_w();
308 add_tool(motion_title = new BC_Title(x1=x, y, _("Motion:")));
309 x1 += motion_title->get_w()+margin;
310 motion = new TitleMotion(client, this, x1, y);
311 motion->create_objects();
312 add_tool(loop = new TitleLoop(client, x, y1));
313 x = margin; y = y1 + loop->get_h()+20;
315 add_tool(dropshadow_title = new BC_Title(x, y, _("Drop shadow:")));
316 w1 = dropshadow_title->get_w();
317 dropshadow = new TitleDropShadow(client, this, x, y + 20);
318 dropshadow->create_objects();
319 if( dropshadow->get_w() > w1 ) w1 = dropshadow->get_w();
322 add_tool(fadein_title = new BC_Title(x, y, _("Fade in (sec):")));
323 w1 = fadein_title->get_w();
324 add_tool(fade_in = new TitleFade(client, this, &client->config.fade_in, x, y + 20));
325 if( fade_in->get_w() > w1 ) w1 = fade_in->get_w();
328 add_tool(fadeout_title = new BC_Title(x, y, _("Fade out (sec):")));
329 w1 = fadeout_title->get_w();
330 add_tool(fade_out = new TitleFade(client, this, &client->config.fade_out, x, y + 20));
331 if( fade_out->get_w() > w1 ) w1 = fade_out->get_w();
334 add_tool(speed_title = new BC_Title(x, y1=y, _("Speed:")));
335 w1 = speed_title->get_w();
336 y += speed_title->get_h() + 5;
337 speed = new TitleSpeed(client, this, x, y);
338 speed->create_objects();
339 if( speed->get_w() > w1 ) w1 = speed->get_w();
341 y2 = y + speed->get_h() + 10;
343 color_x = x3; color_y = y = y1;
344 color_thread = new TitleColorThread(client, this, 0);
345 x1 = color_x + COLOR_W + 2*margin;
347 add_tool(color_button = new TitleColorButton(client, this, x1, y1));
349 outline_color_x = x3; outline_color_y = y;
350 outline_color_thread = new TitleColorThread(client, this, 1);
351 y1 = outline_color_y + 5;
352 add_tool(outline_color_button = new TitleOutlineColorButton(client, this, x1, y1));
355 add_tool(outline_title = new BC_Title(x, y, _("Outline:")));
356 y1 = y + outline_title->get_h() + margin;
357 outline = new TitleOutline(client, this, x, y1);
358 outline->create_objects();
359 x += outline->get_w() + 2*margin;
361 add_tool(stroker_title = new BC_Title(x, y, _("Stroker:")));
362 stroker = new TitleStroker(client, this, x, y1);
363 stroker->create_objects();
364 x += stroker->get_w() + margin;
366 y += outline_title->get_h() + margin;
367 add_tool(timecode = new TitleTimecode(client, x1=x, y));
368 x += timecode->get_w() + margin;
369 add_tool(timecode_format = new TitleTimecodeFormat(client, x, y,
370 Units::print_time_format(client->config.timecode_format, string)));
371 timecode_format->create_objects();
372 y += timecode_format->get_h() + margin;
375 add_tool(background = new TitleBackground(client, this, x, y));
376 x += background->get_w() + margin;
377 add_tool(background_path = new TitleBackgroundPath(client, this, x, y));
378 x += background_path->get_w() + margin;
379 add_tool(background_browse = new BrowseButton(
380 client->server->mwindow->theme, this, background_path,
381 x, y, "", _("background media"), _("Select background media path")));
382 x += background_browse->get_w() + 3*margin;
383 add_tool(loop_playback = new TitleLoopPlayback(client, x, y));
384 y += loop_playback->get_h() + 10;
387 add_tool(text_title = new BC_Title(x, y, _("Text:")));
388 x += text_title->get_w() + 20;
389 int wid = BC_Title::calculate_w(this,"0")*10;
390 add_tool(text_chars = new TitleTextChars(x,y,wid));
391 x += text_chars->get_w() + 20;
392 add_tool(text_bfrsz = new TitleTextBfrSz(x,y,wid));
394 y += text_title->get_h() + margin;
396 text = new TitleText(client, this, x, y, get_w()-margin - x, get_h() - y - 10);
397 text->create_objects();
399 add_tool(cur_popup = new TitleCurPopup(client, this));
400 cur_popup->create_objects();
401 add_tool(fonts_popup = new TitleFontsPopup(client, this));
402 color_popup = new TitleColorPopup(client, this);
403 png_popup = new TitlePngPopup(client, this);
409 int TitleWindow::resize_event(int w, int h)
411 client->config.window_w = w;
412 client->config.window_h = h;
414 clear_box(0, 0, w, h);
415 font_title->reposition_window(font_title->get_x(), font_title->get_y());
416 font->reposition_window(font->get_x(), font->get_y());
417 font_tumbler->reposition_window(font_tumbler->get_x(), font_tumbler->get_y());
418 x_title->reposition_window(x_title->get_x(), x_title->get_y());
419 title_x->reposition_window(title_x->get_x(), title_x->get_y());
420 y_title->reposition_window(y_title->get_x(), y_title->get_y());
421 title_y->reposition_window(title_y->get_x(), title_y->get_y());
422 w_title->reposition_window(w_title->get_x(), w_title->get_y());
423 title_w->reposition_window(title_w->get_x(), title_w->get_y());
424 h_title->reposition_window(h_title->get_x(), h_title->get_y());
425 title_h->reposition_window(title_h->get_x(), title_h->get_y());
426 style_title->reposition_window(style_title->get_x(), style_title->get_y());
427 italic->reposition_window(italic->get_x(), italic->get_y());
428 bold->reposition_window(bold->get_x(), bold->get_y());
429 drag->reposition_window(drag->get_x(), drag->get_y());
430 size_title->reposition_window(size_title->get_x(), size_title->get_y());
431 size->reposition_window(size->get_x(), size->get_y());
432 size_tumbler->reposition_window(size_tumbler->get_x(), size_tumbler->get_y());
433 pitch_title->reposition_window(pitch_title->get_x(), pitch_title->get_y());
434 pitch->reposition_window(pitch->get_x(), pitch->get_y());
436 color_button->reposition_window(color_button->get_x(), color_button->get_y());
437 outline_color_button->reposition_window(outline_color_button->get_x(), outline_color_button->get_y());
438 motion_title->reposition_window(motion_title->get_x(), motion_title->get_y());
439 motion->reposition_window(motion->get_x(), motion->get_y());
440 loop->reposition_window(loop->get_x(), loop->get_y());
441 dropshadow_title->reposition_window(dropshadow_title->get_x(), dropshadow_title->get_y());
442 dropshadow->reposition_window(dropshadow->get_x(), dropshadow->get_y());
443 fadein_title->reposition_window(fadein_title->get_x(), fadein_title->get_y());
444 fade_in->reposition_window(fade_in->get_x(), fade_in->get_y());
445 fadeout_title->reposition_window(fadeout_title->get_x(), fadeout_title->get_y());
446 fade_out->reposition_window(fade_out->get_x(), fade_out->get_y());
447 text_title->reposition_window(text_title->get_x(), text_title->get_y());
448 timecode->reposition_window(timecode->get_x(), timecode->get_y());
449 text->reposition_window(text->get_x(), text->get_y(), w - text->get_x() - 10,
450 BC_TextBox::pixels_to_rows(this, MEDIUMFONT, h - text->get_y() - 10));
451 justify_title->reposition_window(justify_title->get_x(), justify_title->get_y());
452 left->reposition_window(left->get_x(), left->get_y());
453 center->reposition_window(center->get_x(), center->get_y());
454 right->reposition_window(right->get_x(), right->get_y());
455 top->reposition_window(top->get_x(), top->get_y());
456 mid->reposition_window(mid->get_x(), mid->get_y());
457 bottom->reposition_window(bottom->get_x(), bottom->get_y());
458 speed_title->reposition_window(speed_title->get_x(), speed_title->get_y());
459 speed->reposition_window(speed->get_x(), speed->get_y());
466 int TitleWindow::grab_event(XEvent *event)
468 switch( event->type ) {
469 case ButtonPress: break;
470 case ButtonRelease: break;
471 case MotionNotify: break;
475 MWindow *mwindow = client->server->mwindow;
476 CWindowGUI *cwindow_gui = mwindow->cwindow->gui;
477 CWindowCanvas *canvas = cwindow_gui->canvas;
478 int cx, cy; cwindow_gui->get_relative_cursor_xy(cx, cy);
479 cx -= mwindow->theme->ccanvas_x;
480 cy -= mwindow->theme->ccanvas_y;
483 if( cx < 0 || cx >= mwindow->theme->ccanvas_w ) return 0;
484 if( cy < 0 || cy >= mwindow->theme->ccanvas_h ) return 0;
487 switch( event->type ) {
489 if( !dragging ) break;
492 if( !dragging ) return 0;
496 if( !dragging ) return 0;
502 float cursor_x = cx, cursor_y = cy;
503 canvas->canvas_to_output(mwindow->edl, 0, cursor_x, cursor_y);
504 int64_t position = client->get_source_position();
505 float projector_x, projector_y, projector_z;
506 Track *track = client->server->plugin->track;
507 int track_w = track->track_w, track_h = track->track_h;
508 track->automation->get_projector(
509 &projector_x, &projector_y, &projector_z,
510 position, PLAY_FORWARD);
511 projector_x += mwindow->edl->session->output_w / 2;
512 projector_y += mwindow->edl->session->output_h / 2;
513 cursor_x = (cursor_x - projector_x) / projector_z + track_w / 2;
514 cursor_y = (cursor_y - projector_y) / projector_z + track_h / 2;
515 int title_x = client->config.title_x, title_y = client->config.title_y;
516 int title_w = client->config.title_w, title_h = client->config.title_h;
517 if( !title_w ) title_w = track_w;
518 if( !title_h ) title_h = track_h;
519 int r = MIN(track_w, track_h)/100 + 2;
520 int x0 = title_x, x1 = title_x+(title_w+1)/2, x2 = title_x+title_w;
521 int y0 = title_y, y1 = title_y+(title_h+1)/2, y2 = title_y+title_h;
522 int drag_dx = 0, drag_dy = 0;
523 if( !dragging ) { // clockwise
524 if( abs(drag_dx = cursor_x-x0) < r && // x0,y0
525 abs(drag_dy = cursor_y-y0) < r ) dragging = 1;
526 else if( abs(drag_dx = cursor_x-x1) < r && // x1,y0
527 abs(drag_dy = cursor_y-y0) < r ) dragging = 2;
528 else if( abs(drag_dx = cursor_x-x2) < r && // x2,y0
529 abs(drag_dy = cursor_y-y0) < r ) dragging = 3;
530 else if( abs(drag_dx = cursor_x-x2) < r && // x2,y1
531 abs(drag_dy = cursor_y-y1) < r ) dragging = 4;
532 else if( abs(drag_dx = cursor_x-x2) < r && // x2,y2
533 abs(drag_dy = cursor_y-y2) < r ) dragging = 5;
534 else if( abs(drag_dx = cursor_x-x1) < r && // x1,y2
535 abs(drag_dy = cursor_y-y2) < r ) dragging = 6;
536 else if( abs(drag_dx = cursor_x-x0) < r && // x0,y2
537 abs(drag_dy = cursor_y-y2) < r ) dragging = 7;
538 else if( abs(drag_dx = cursor_x-x0) < r && // x0,y1
539 abs(drag_dy = cursor_y-y1) < r ) dragging = 8;
540 else if( abs(drag_dx = cursor_x-x1) < r && // x1,y1
541 abs(drag_dy = cursor_y-y1) < r ) dragging = 9;
546 int cur_x = cursor_x - drag_dx, dx = cur_x - x0;
547 int cur_y = cursor_y - drag_dy, dy = cur_y - y0;
548 if( !dx && !dy ) return 1;
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_x->update((int64_t)(client->config.title_x = cur_x));
552 this->title_y->update((int64_t)(client->config.title_y = cur_y));
553 this->title_w->update((int64_t)(client->config.title_w = cur_w));
554 this->title_h->update((int64_t)(client->config.title_h = cur_h));
557 int cur_y = cursor_y - drag_dy, dy = cur_y - y0;
559 int cur_h = title_h - dy; if( cur_h < 1 ) cur_h = 1;
560 this->title_y->update((int64_t)(client->config.title_y = cur_y));
561 this->title_h->update((int64_t)(client->config.title_h = cur_h));
564 int cur_x = cursor_x - drag_dx, dx = cur_x - x2;
565 int cur_y = cursor_y - drag_dy, dy = cur_y - y0;
566 int cur_w = title_w + dx; if( cur_w < 1 ) cur_w = 1;
567 int cur_h = title_h - dy; if( cur_h < 1 ) cur_h = 1;
568 this->title_w->update((int64_t)(client->config.title_w = cur_w));
569 this->title_y->update((int64_t)(client->config.title_y = cur_y));
570 this->title_h->update((int64_t)(client->config.title_h = cur_h));
573 int cur_x = cursor_x - drag_dx, dx = cur_x - x2;
575 int cur_w = title_w + dx; if( cur_w < 1 ) cur_w = 1;
576 this->title_w->update((int64_t)(client->config.title_w = cur_w));
579 int cur_x = cursor_x - drag_dx, dx = cur_x - x2;
580 int cur_y = cursor_y - drag_dy, dy = cur_y - y2;
581 int cur_w = title_w + dx; if( cur_w < 1 ) cur_w = 1;
582 int cur_h = title_h + dy; if( cur_h < 1 ) cur_h = 1;
583 this->title_w->update((int64_t)(client->config.title_w = cur_w));
584 this->title_h->update((int64_t)(client->config.title_h = cur_h));
587 int cur_y = cursor_y - drag_dy, dy = cur_y - y2;
588 if( client->config.title_h == cur_y ) return 1;
589 int cur_h = title_h + dy; if( cur_h < 1 ) cur_h = 1;
590 this->title_h->update((int64_t)(client->config.title_h = cur_h));
593 int cur_x = cursor_x - drag_dx, dx = cur_x - x0;
594 int cur_y = cursor_y - drag_dy, dy = cur_y - y2;
595 int cur_w = title_w - dx; if( cur_w < 1 ) cur_w = 1;
596 int cur_h = title_h + dy; if( cur_h < 1 ) cur_h = 1;
597 this->title_x->update((int64_t)(client->config.title_x = cur_x));
598 this->title_w->update((int64_t)(client->config.title_w = cur_w));
599 this->title_h->update((int64_t)(client->config.title_h = cur_h));
602 int cur_x = cursor_x - drag_dx, dx = cur_x - x0;
604 int cur_w = title_w - dx; if( cur_w < 1 ) cur_w = 1;
605 this->title_x->update((int64_t)(client->config.title_x = cur_x));
606 this->title_w->update((int64_t)(client->config.title_w = cur_w));
609 int cur_x = cursor_x - drag_dx, dx = cur_x - x1;
610 int cur_y = cursor_y - drag_dy, dy = cur_y - y1;
611 if( title_x == cur_x && title_y == cur_y ) return 1;
612 this->title_x->update((int64_t)(client->config.title_x += dx));
613 this->title_y->update((int64_t)(client->config.title_y += dy));
616 client->send_configure_change();
620 void TitleWindow::previous_font()
622 int current_font = font->get_number();
624 if( current_font < 0 ) current_font = fonts.total - 1;
626 if( current_font < 0 || current_font >= fonts.total ) return;
628 for( int i=0; i<fonts.total; ++i ) {
629 fonts.values[i]->set_selected(i == current_font);
632 font->update(fonts.values[current_font]->get_text());
633 strcpy(client->config.font, fonts.values[current_font]->get_text());
634 check_style(client->config.font,1);
635 client->send_configure_change();
638 void TitleWindow::next_font()
640 int current_font = font->get_number();
642 if( current_font >= fonts.total ) current_font = 0;
644 if( current_font < 0 || current_font >= fonts.total ) return;
646 for( int i=0; i<fonts.total; ++i ) {
647 fonts.values[i]->set_selected(i == current_font);
650 font->update(fonts.values[current_font]->get_text());
651 strcpy(client->config.font, fonts.values[current_font]->get_text());
652 check_style(client->config.font,1);
653 client->send_configure_change();
656 int TitleWindow::insert_ibeam(const char *txt, int ofs)
658 int ibeam = cur_ibeam;
659 int ilen = strlen(txt)+1;
661 int len = BC_Resources::encode(client->config.encoding, BC_Resources::wide_encoding,
662 (char*)txt,ilen, (char *)wtxt,ilen*sizeof(wtxt[0])) / sizeof(wchar_t);
663 client->insert_text(wtxt, ibeam);
664 while( len > 0 && !wtxt[len] ) --len;
665 int adv = len+1 + ofs;
666 if( (ibeam += adv) >= client->config.wlen)
667 ibeam = client->config.wlen;
668 text->wset_selection(-1, -1, ibeam);
669 text->update(client->config.wtext);
670 client->send_configure_change();
674 void TitleWindow::update_color()
676 //printf("TitleWindow::update_color %x\n", client->config.color);
677 set_color(client->config.color);
678 draw_box(color_x, color_y, COLOR_W, COLOR_H);
679 flash(color_x, color_y, COLOR_W, COLOR_H);
680 set_color(client->config.outline_color);
681 draw_box(outline_color_x, outline_color_y, COLOR_W, COLOR_H);
683 draw_rectangle(color_x, color_y, COLOR_W, COLOR_H);
684 draw_rectangle(outline_color_x, outline_color_y, COLOR_W, COLOR_H);
685 flash(outline_color_x, outline_color_y, COLOR_W, COLOR_H);
688 void TitleWindow::update_justification()
690 left->update(client->config.hjustification == JUSTIFY_LEFT);
691 center->update(client->config.hjustification == JUSTIFY_CENTER);
692 right->update(client->config.hjustification == JUSTIFY_RIGHT);
693 top->update(client->config.vjustification == JUSTIFY_TOP);
694 mid->update(client->config.vjustification == JUSTIFY_MID);
695 bottom->update(client->config.vjustification == JUSTIFY_BOTTOM);
698 void TitleWindow::update_stats()
700 text_chars->update(client->config.wlen);
701 int len = MESSAGESIZE - BCTEXTLEN - strlen(text->get_text()) - 1;
702 if( len < 0 ) len = 0;
703 text_bfrsz->update(len);
706 void TitleWindow::update()
708 title_x->update((int64_t)client->config.title_x);
709 title_y->update((int64_t)client->config.title_y);
710 title_w->update((int64_t)client->config.title_w);
711 title_h->update((int64_t)client->config.title_h);
712 italic->update(client->config.style & BC_FONT_ITALIC);
713 bold->update(client->config.style & BC_FONT_BOLD);
714 size->update(client->config.size);
715 motion->update(TitleMain::motion_to_text(client->config.motion_strategy));
716 loop->update(client->config.loop);
717 dropshadow->update((int64_t)client->config.dropshadow);
718 fade_in->update((float)client->config.fade_in);
719 fade_out->update((float)client->config.fade_out);
720 font->update(client->config.font);
721 check_style(client->config.font,0);
722 text->update(&client->config.wtext[0]);
723 speed->update(client->config.pixels_per_second);
724 outline->update((int64_t)client->config.outline_size);
726 stroker->update((int64_t)client->config.stroke_width);
728 timecode->update(client->config.timecode);
729 timecode_format->update(client->config.timecode_format);
730 background->update(client->config.background);
731 background_path->update(client->config.background_path);
732 loop_playback->update((int64_t)client->config.loop_playback);
734 char string[BCTEXTLEN];
735 for( int i=0; i<lengthof(timeunit_formats); ++i ) {
736 if( timeunit_formats[i] == client->config.timecode_format ) {
737 timecode_format->set_text(
738 Units::print_time_format(timeunit_formats[i], string));
742 update_justification();
748 TitleFontTumble::TitleFontTumble(TitleMain *client, TitleWindow *window, int x, int y)
751 this->client = client;
752 this->window = window;
754 int TitleFontTumble::handle_up_event()
756 window->previous_font();
760 int TitleFontTumble::handle_down_event()
768 TitleSizeTumble::TitleSizeTumble(TitleMain *client, TitleWindow *window, int x, int y)
771 this->client = client;
772 this->window = window;
775 int TitleSizeTumble::handle_up_event()
777 int current_index = -1;
778 int current_difference = -1;
779 for( int i=0; i<window->sizes.size(); ++i ) {
780 int size = atoi(window->sizes.get(i)->get_text());
781 if( current_index < 0 ||
782 abs(size - client->config.size) < current_difference ) {
784 current_difference = abs(size - client->config.size);
789 if( current_index >= window->sizes.size() ) current_index = 0;
792 client->config.size = atoi(window->sizes.get(current_index)->get_text());
793 window->size->update(client->config.size);
794 client->send_configure_change();
798 int TitleSizeTumble::handle_down_event()
800 int current_index = -1;
801 int current_difference = -1;
802 for( int i=0; i<window->sizes.size(); ++i ) {
803 int size = atoi(window->sizes.get(i)->get_text());
804 if( current_index < 0 ||
805 abs(size - client->config.size) < current_difference ) {
807 current_difference = abs(size - client->config.size);
812 if( current_index < 0 ) current_index = window->sizes.size() - 1;
815 client->config.size = atoi(window->sizes.get(current_index)->get_text());
816 window->size->update(client->config.size);
817 client->send_configure_change();
821 TitleBold::TitleBold(TitleMain *client, TitleWindow *window, int x, int y)
822 : BC_CheckBox(x, y, client->config.style & BC_FONT_BOLD, _("Bold"))
824 this->client = client;
825 this->window = window;
828 int TitleBold::handle_event()
830 client->config.style =
831 (client->config.style & ~BC_FONT_BOLD) |
832 (get_value() ? BC_FONT_BOLD : 0);
833 client->send_configure_change();
837 TitleItalic::TitleItalic(TitleMain *client, TitleWindow *window, int x, int y)
838 : BC_CheckBox(x, y, client->config.style & BC_FONT_ITALIC, _("Italic"))
840 this->client = client;
841 this->window = window;
843 int TitleItalic::handle_event()
845 client->config.style =
846 (client->config.style & ~BC_FONT_ITALIC) |
847 (get_value() ? BC_FONT_ITALIC : 0);
848 client->send_configure_change();
854 TitleSize::TitleSize(TitleMain *client, TitleWindow *window, int x, int y, char *text)
855 : BC_PopupTextBox(window, &window->sizes, text, x, y, 64, 300)
857 this->client = client;
858 this->window = window;
860 TitleSize::~TitleSize()
863 int TitleSize::handle_event()
865 client->config.size = atol(get_text());
866 //printf("TitleSize::handle_event 1 %s\n", get_text());
867 client->send_configure_change();
870 void TitleSize::update(int size)
872 char string[BCTEXTLEN];
873 sprintf(string, "%d", size);
874 BC_PopupTextBox::update(string);
878 TitlePitch(TitleMain *client, TitleWindow *window, int x, int y, int *value)
879 : BC_TumbleTextBox(window, *value, 0, INT_MAX, x, y, 64)
881 this->client = client;
882 this->window = window;
891 int TitlePitch::handle_event()
893 *value = atol(get_text());
894 client->send_configure_change();
898 TitleColorButton::TitleColorButton(TitleMain *client, TitleWindow *window, int x, int y)
899 : BC_GenericButton(x, y, _("Text Color..."))
901 this->client = client;
902 this->window = window;
904 int TitleColorButton::handle_event()
906 window->color_thread->start_window(client->config.color,
907 client->config.alpha);
910 TitleOutlineColorButton::TitleOutlineColorButton(TitleMain *client, TitleWindow *window, int x, int y)
911 : BC_GenericButton(x, y, _("Outline color..."))
913 this->client = client;
914 this->window = window;
916 int TitleOutlineColorButton::handle_event()
918 window->outline_color_thread->start_window(client->config.outline_color,
919 client->config.outline_alpha);
924 TitleMotion::TitleMotion(TitleMain *client, TitleWindow *window, int x, int y)
925 : BC_PopupTextBox(window, &window->paths,
926 client->motion_to_text(client->config.motion_strategy),
929 this->client = client;
930 this->window = window;
932 int TitleMotion::handle_event()
934 client->config.motion_strategy = client->text_to_motion(get_text());
935 client->send_configure_change();
939 TitleLoop::TitleLoop(TitleMain *client, int x, int y)
940 : BC_CheckBox(x, y, client->config.loop, _("Loop"))
942 this->client = client;
944 int TitleLoop::handle_event()
946 client->config.loop = get_value();
947 client->send_configure_change();
950 TitleTimecode::TitleTimecode(TitleMain *client, int x, int y)
951 : BC_CheckBox(x, y, client->config.timecode, _("Stamp timecode"))
953 this->client = client;
955 int TitleTimecode::handle_event()
957 client->config.timecode = get_value();
958 client->send_configure_change();
962 TitleTimecodeFormat::TitleTimecodeFormat(TitleMain *client, int x, int y, const char *text)
963 : BC_PopupMenu(x, y, 100, text, 1)
965 this->client = client;
968 int TitleTimecodeFormat::handle_event()
970 client->config.timecode_format = Units::text_to_format(get_text());
971 client->send_configure_change();
975 void TitleTimecodeFormat::create_objects()
977 char string[BCTEXTLEN];
978 for( int i=0; i<lengthof(timeunit_formats); ++i ) {
979 add_item(new BC_MenuItem(
980 Units::print_time_format(timeunit_formats[i], string)));
985 int TitleTimecodeFormat::update(int timecode_format)
987 char string[BCTEXTLEN];
988 for( int i=0; i<lengthof(timeunit_formats); ++i ) {
989 if( timeunit_formats[i] == timecode_format ) {
990 set_text(Units::print_time_format(timeunit_formats[i], string));
997 TitleFade::TitleFade(TitleMain *client, TitleWindow *window,
998 double *value, int x, int y)
999 : BC_TextBox(x, y, 80, 1, (float)*value)
1001 this->client = client;
1002 this->window = window;
1003 this->value = value;
1007 int TitleFade::handle_event()
1009 *value = atof(get_text());
1010 client->send_configure_change();
1014 void TitleWindow::check_style(const char *font_name, int update)
1016 BC_FontEntry *font_nrm = TitleMain::get_font(font_name, 0);
1017 BC_FontEntry *font_itl = TitleMain::get_font(font_name, BC_FONT_ITALIC);
1018 BC_FontEntry *font_bld = TitleMain::get_font(font_name, BC_FONT_BOLD);
1019 BC_FontEntry *font_bit = TitleMain::get_font(font_name, BC_FONT_ITALIC | BC_FONT_BOLD);
1020 int has_norm = font_nrm != 0 ? 1 : 0;
1021 int has_ital = font_itl != 0 || font_bit != 0 ? 1 : 0;
1022 int has_bold = font_bld != 0 || font_bit != 0 ? 1 : 0;
1023 if( bold->get_value() ) {
1024 if( !has_bold ) bold->update(0);
1027 if( !has_norm && has_bold ) bold->update(1);
1029 if( italic->get_value() ) {
1030 if( !has_ital ) italic->update(0);
1033 if( !has_norm && has_ital ) italic->update(1);
1035 if( has_norm && has_bold ) bold->enable(); else bold->disable();
1036 if( has_norm && has_ital ) italic->enable(); else italic->disable();
1038 int style = stroker && atof(stroker->get_text()) ? BC_FONT_OUTLINE : 0;
1039 if( bold->get_value() ) style |= BC_FONT_BOLD;
1040 if( italic->get_value() ) style |= BC_FONT_ITALIC;
1041 client->config.style = style;
1045 TitleFont::TitleFont(TitleMain *client, TitleWindow *window, int x, int y)
1046 : BC_PopupTextBox(window, &window->fonts, client->config.font,
1047 x, y, 240, 300, LISTBOX_ICON_LIST)
1049 this->client = client;
1050 this->window = window;
1052 int TitleFont::handle_event()
1054 strcpy(client->config.font, get_text());
1055 window->check_style(client->config.font, 1);
1056 client->send_configure_change();
1060 TitleText::TitleText(TitleMain *client, TitleWindow *window,
1061 int x, int y, int w, int h)
1062 : BC_ScrollTextBox(window, x, y, w,
1063 BC_TextBox::pixels_to_rows(window, MEDIUMFONT, h),
1064 client->config.wtext, 8192)
1066 this->client = client;
1067 this->window = window;
1068 //printf("TitleText::TitleText %s\n", client->config.text);
1071 int TitleText::button_press_event()
1073 if( get_buttonpress() == 3 ) {
1074 window->cur_ibeam = get_ibeam_letter();
1075 window->cur_popup->activate_menu();
1078 return BC_ScrollTextBox::button_press_event();
1081 int TitleText::handle_event()
1083 window->fonts_popup->deactivate();
1084 int text_len = strlen(get_text());
1085 int avail = MESSAGESIZE - BCTEXTLEN;
1086 if( text_len >= avail ) { // back off last utf8 char
1087 char text[2*sizeof(client->config.wtext)];
1088 strcpy(text, get_text());
1090 while( text_len > 0 && (text[text_len-1] & 0xc0) == 0x80 )
1091 text[--text_len] = 0;
1093 text[--text_len] = 0;
1096 int len = sizeof(client->config.wtext) / sizeof(wchar_t);
1097 wcsncpy(client->config.wtext, get_wtext(), len);
1098 client->config.wtext[len-1] = 0;
1099 client->config.wlen = wcslen(client->config.wtext);
1100 window->update_stats();
1101 client->send_configure_change();
1104 TitleTextChars::TitleTextChars(int x, int y, int w)
1105 : BC_Title(x, y, "", MEDIUMFONT, -1, 0, w)
1108 TitleTextChars::~TitleTextChars()
1111 int TitleTextChars::update(int n)
1113 char text[BCSTRLEN];
1114 sprintf(text, _("chars: %d "),n);
1115 return BC_Title::update(text, 0);
1118 TitleTextBfrSz::TitleTextBfrSz(int x, int y, int w)
1119 : BC_Title(x, y, "", MEDIUMFONT, -1, 0, w)
1122 TitleTextBfrSz::~TitleTextBfrSz()
1125 int TitleTextBfrSz::update(int n)
1127 char text[BCSTRLEN];
1128 sprintf(text, _("bfrsz: %d "),n);
1129 return BC_Title::update(text, 0);
1133 TitleDropShadow::TitleDropShadow(TitleMain *client, TitleWindow *window, int x, int y)
1134 : BC_TumbleTextBox(window, (int64_t)client->config.dropshadow,
1135 (int64_t)-1000, (int64_t)1000, x, y, 70)
1137 this->client = client;
1138 this->window = window;
1140 int TitleDropShadow::handle_event()
1142 client->config.dropshadow = atol(get_text());
1143 client->send_configure_change();
1148 TitleOutline::TitleOutline(TitleMain *client, TitleWindow *window, int x, int y)
1149 : BC_TumbleTextBox(window, (int64_t)client->config.outline_size,
1150 (int64_t)0, (int64_t)1000, x, y, 70)
1152 this->client = client;
1153 this->window = window;
1155 int TitleOutline::handle_event()
1157 client->config.outline_size = atol(get_text());
1158 client->send_configure_change();
1163 TitleStroker::TitleStroker(TitleMain *client, TitleWindow *window, int x, int y)
1164 : BC_TumbleTextBox(window, (int64_t)client->config.stroke_width,
1165 (int64_t)0, (int64_t)1000, x, y, 70)
1167 this->client = client;
1168 this->window = window;
1170 int TitleStroker::handle_event()
1172 client->config.stroke_width = atof(get_text());
1173 if( client->config.stroke_width )
1174 client->config.style |= BC_FONT_OUTLINE;
1176 client->config.style &= ~BC_FONT_OUTLINE;
1177 client->send_configure_change();
1182 TitleX::TitleX(TitleMain *client, TitleWindow *window, int x, int y)
1183 : BC_TumbleTextBox(window, (int64_t)client->config.title_x,
1184 (int64_t)-32767, (int64_t)32767, x, y, 50)
1186 this->client = client;
1187 this->window = window;
1189 int TitleX::handle_event()
1191 client->config.title_x = atol(get_text());
1192 client->send_configure_change();
1196 TitleY::TitleY(TitleMain *client, TitleWindow *window, int x, int y)
1197 : BC_TumbleTextBox(window, (int64_t)client->config.title_y,
1198 (int64_t)-32767, (int64_t)32767, x, y, 50)
1200 this->client = client;
1201 this->window = window;
1203 int TitleY::handle_event()
1205 client->config.title_y = atol(get_text());
1206 client->send_configure_change();
1210 TitleW::TitleW(TitleMain *client, TitleWindow *window, int x, int y)
1211 : BC_TumbleTextBox(window, (int64_t)client->config.title_w,
1212 (int64_t)0, (int64_t)32767, x, y, 50)
1214 this->client = client;
1215 this->window = window;
1217 int TitleW::handle_event()
1219 client->config.title_w = atol(get_text());
1220 client->send_configure_change();
1224 TitleH::TitleH(TitleMain *client, TitleWindow *window, int x, int y)
1225 : BC_TumbleTextBox(window, (int64_t)client->config.title_h,
1226 (int64_t)0, (int64_t)32767, x, y, 50)
1228 this->client = client;
1229 this->window = window;
1231 int TitleH::handle_event()
1233 client->config.title_h = atol(get_text());
1234 client->send_configure_change();
1238 TitleSpeed::TitleSpeed(TitleMain *client, TitleWindow *window, int x, int y)
1239 : BC_TumbleTextBox(window, (float)client->config.pixels_per_second,
1240 (float)0, (float)1000, x, y, 100)
1242 this->client = client;
1248 int TitleSpeed::handle_event()
1250 client->config.pixels_per_second = atof(get_text());
1251 client->send_configure_change();
1256 TitleLeft::TitleLeft(TitleMain *client, TitleWindow *window, int x, int y)
1257 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_LEFT, _("Left"))
1259 this->client = client;
1260 this->window = window;
1262 int TitleLeft::handle_event()
1264 client->config.hjustification = JUSTIFY_LEFT;
1265 window->update_justification();
1266 client->send_configure_change();
1270 TitleCenter::TitleCenter(TitleMain *client, TitleWindow *window, int x, int y)
1271 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_CENTER, _("Center"))
1273 this->client = client;
1274 this->window = window;
1276 int TitleCenter::handle_event()
1278 client->config.hjustification = JUSTIFY_CENTER;
1279 window->update_justification();
1280 client->send_configure_change();
1284 TitleRight::TitleRight(TitleMain *client, TitleWindow *window, int x, int y)
1285 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_RIGHT, _("Right"))
1287 this->client = client;
1288 this->window = window;
1290 int TitleRight::handle_event()
1292 client->config.hjustification = JUSTIFY_RIGHT;
1293 window->update_justification();
1294 client->send_configure_change();
1300 TitleTop::TitleTop(TitleMain *client, TitleWindow *window, int x, int y)
1301 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_TOP, _("Top"))
1303 this->client = client;
1304 this->window = window;
1306 int TitleTop::handle_event()
1308 client->config.vjustification = JUSTIFY_TOP;
1309 window->update_justification();
1310 client->send_configure_change();
1314 TitleMid::TitleMid(TitleMain *client, TitleWindow *window, int x, int y)
1315 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_MID, _("Mid"))
1317 this->client = client;
1318 this->window = window;
1320 int TitleMid::handle_event()
1322 client->config.vjustification = JUSTIFY_MID;
1323 window->update_justification();
1324 client->send_configure_change();
1328 TitleBottom::TitleBottom(TitleMain *client, TitleWindow *window, int x, int y)
1329 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_BOTTOM, _("Bottom"))
1331 this->client = client;
1332 this->window = window;
1334 int TitleBottom::handle_event()
1336 client->config.vjustification = JUSTIFY_BOTTOM;
1337 window->update_justification();
1338 client->send_configure_change();
1344 TitleColorThread::TitleColorThread(TitleMain *client, TitleWindow *window, int is_outline)
1345 : ColorPicker(1, is_outline? _("Outline Color") : _("Text Color"))
1347 this->client = client;
1348 this->window = window;
1349 this->is_outline = is_outline;
1352 int TitleColorThread::handle_new_color(int output, int alpha)
1355 client->config.outline_color = output;
1356 client->config.outline_alpha = alpha;
1359 client->config.color = output;
1360 client->config.alpha = alpha;
1363 window->lock_window("TitleColorThread::handle_new_color");
1364 window->update_color();
1366 window->unlock_window();
1368 client->send_configure_change();
1372 TitleDrag::TitleDrag(TitleMain *client, TitleWindow *window, int x, int y)
1373 : BC_CheckBox(x, y, client->config.drag, _("Drag"))
1375 this->client = client;
1376 this->window = window;
1379 int TitleDrag::handle_event()
1381 int value = get_value();
1382 client->config.drag = value;
1384 window->grab(client->server->mwindow->cwindow->gui);
1386 window->ungrab(client->server->mwindow->cwindow->gui);
1387 client->send_configure_change();
1391 TitleBackground::TitleBackground(TitleMain *client, TitleWindow *window, int x, int y)
1392 : BC_CheckBox(x, y, client->config.background, _("Background:"))
1394 this->client = client;
1395 this->window = window;
1398 int TitleBackground::handle_event()
1400 client->config.background = get_value();
1401 client->send_configure_change();
1405 TitleBackgroundPath::TitleBackgroundPath(TitleMain *client, TitleWindow *window, int x, int y)
1406 : BC_TextBox(x, y, 240, 1, client->config.background_path)
1408 this->client = client;
1409 this->window = window;
1412 int TitleBackgroundPath::handle_event()
1414 strncpy(client->config.background_path, get_text(), sizeof(client->config.background_path));
1415 client->send_configure_change();
1419 TitleLoopPlayback::TitleLoopPlayback(TitleMain *client, int x, int y)
1420 : BC_CheckBox(x, y, client->config.loop_playback, _("Loop playback"))
1422 this->client = client;
1424 int TitleLoopPlayback::handle_event()
1426 client->config.loop_playback = get_value();
1427 client->send_configure_change();
1432 TitleCurPopup::TitleCurPopup(TitleMain *client, TitleWindow *window)
1433 : BC_PopupMenu(0, 0, 0, "", 0)
1435 this->client = client;
1436 this->window = window;
1438 int TitleCurPopup::handle_event()
1443 void TitleCurSubMenu::add_subitemx(int popup_type, va_list ap, const char *fmt)
1445 char item[BCSTRLEN];
1446 vsnprintf(item, sizeof(item)-1, fmt, ap);
1447 item[sizeof(item)-1] = 0;
1448 add_submenuitem(new TitleCurSubMenuItem(this, item, popup_type));
1451 void TitleCurPopup::create_objects()
1453 TitleCurItem *cur_item;
1454 TitleCurSubMenu *sub_menu;
1456 add_item(cur_item = new TitleCurItem(this, item = KW_NUDGE));
1457 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1458 sub_menu->add_subitem("%s dx,dy",item);
1459 sub_menu->add_subitem("/%s",item);
1460 add_item(cur_item = new TitleCurItem(this, item = KW_COLOR));
1461 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1462 sub_menu->add_subitem(POPUP_COLOR,"%s %s",item,_("#"));
1463 sub_menu->add_subitem("%s ",item);
1464 sub_menu->add_subitem("/%s",item);
1465 add_item(cur_item = new TitleCurItem(this, item = KW_ALPHA));
1466 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1467 sub_menu->add_subitem("%s ",item);
1468 sub_menu->add_subitem("%s 0.",item);
1469 sub_menu->add_subitem("%s .5",item);
1470 sub_menu->add_subitem("%s 1.",item);
1471 sub_menu->add_subitem("/%s",item);
1472 add_item(cur_item = new TitleCurItem(this, item = KW_FONT));
1473 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1474 sub_menu->add_subitem(POPUP_FONT,"%s %s",item, _("name"));
1475 sub_menu->add_subitem(POPUP_OFFSET, "%s ",item);
1476 sub_menu->add_subitem("/%s",item);
1477 add_item(cur_item = new TitleCurItem(this, item = KW_SIZE));
1478 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1479 sub_menu->add_subitem("%s +",item);
1480 sub_menu->add_subitem("%s -",item);
1481 sub_menu->add_subitem("%s ",item);
1482 sub_menu->add_subitem("/%s",item);
1483 add_item(cur_item = new TitleCurItem(this, item = KW_BOLD));
1484 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1485 sub_menu->add_subitem("%s 1",item);
1486 sub_menu->add_subitem("%s 0",item);
1487 sub_menu->add_subitem("/%s",item);
1488 add_item(cur_item = new TitleCurItem(this, item = KW_ITALIC));
1489 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1490 sub_menu->add_subitem("%s 1",item);
1491 sub_menu->add_subitem("%s 0",item);
1492 sub_menu->add_subitem("/%s",item);
1493 add_item(cur_item = new TitleCurItem(this, item = KW_CAPS));
1494 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1495 sub_menu->add_subitem("%s 1",item);
1496 sub_menu->add_subitem("%s 0",item);
1497 sub_menu->add_subitem("%s -1",item);
1498 sub_menu->add_subitem("/%s",item);
1499 add_item(cur_item = new TitleCurItem(this, item = KW_UL));
1500 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1501 sub_menu->add_subitem("%s 1",item);
1502 sub_menu->add_subitem("%s 0",item);
1503 sub_menu->add_subitem("/%s",item);
1504 add_item(cur_item = new TitleCurItem(this, item = KW_BLINK));
1505 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1506 sub_menu->add_subitem("%s 1",item);
1507 sub_menu->add_subitem("%s -1",item);
1508 sub_menu->add_subitem("%s ",item);
1509 sub_menu->add_subitem("%s 0",item);
1510 sub_menu->add_subitem("/%s",item);
1511 add_item(cur_item = new TitleCurItem(this, item = KW_FIXED));
1512 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1513 sub_menu->add_subitem("%s ",item);
1514 sub_menu->add_subitem("%s 20",item);
1515 sub_menu->add_subitem("%s 10",item);
1516 sub_menu->add_subitem("%s 0",item);
1517 sub_menu->add_subitem("/%s",item);
1518 add_item(cur_item = new TitleCurItem(this, item = KW_SUP));
1519 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1520 sub_menu->add_subitem("%s 1",item);
1521 sub_menu->add_subitem("%s 0",item);
1522 sub_menu->add_subitem("%s -1",item);
1523 sub_menu->add_subitem("/%s",item);
1524 add_item(cur_item = new TitleCurItem(this, item = KW_PNG));
1525 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1526 sub_menu->add_subitem(POPUP_PNG,"%s %s", item, _("file"));
1529 TitleCurItem::TitleCurItem(TitleCurPopup *popup, const char *text)
1532 this->popup = popup;
1534 int TitleCurItem::handle_event()
1539 TitleCurSubMenu::TitleCurSubMenu(TitleCurItem *cur_item)
1541 this->cur_item = cur_item;
1543 TitleCurSubMenu::~TitleCurSubMenu()
1547 TitleCurSubMenuItem::TitleCurSubMenuItem(TitleCurSubMenu *submenu, const char *text, int popup_type)
1550 this->submenu = submenu;
1551 this->popup_type = popup_type;
1553 TitleCurSubMenuItem::~TitleCurSubMenuItem()
1556 int TitleCurSubMenuItem::handle_event()
1558 TitleCurPopup *popup = submenu->cur_item->popup;
1559 TitleWindow *window = popup->window;
1560 const char *item_text = get_text();
1561 int ofs = *item_text == '/' ? 0 : -1;
1562 switch( popup_type ) {
1565 window->get_pop_cursor_xy(px ,py);
1566 window->fonts_popup->activate(px, py, 300,200);
1569 window->color_popup->activate();
1572 window->png_popup->activate();
1579 sprintf(txt, "<%s>", item_text);
1580 return window->insert_ibeam(txt, ofs);
1583 TitleFontsPopup::TitleFontsPopup(TitleMain *client, TitleWindow *window)
1584 : BC_ListBox(-1, -1, 1, 1, LISTBOX_ICON_LIST,
1585 &window->fonts, 0, 0, 1, 0, 1)
1587 this->client = client;
1588 this->window = window;
1592 TitleFontsPopup::~TitleFontsPopup()
1595 int TitleFontsPopup::keypress_event()
1597 switch( get_keypress() ) {
1605 return BC_ListBox::keypress_event();
1608 int TitleFontsPopup::handle_event()
1611 BC_ListBoxItem *item = get_selection(0, 0);
1612 if( !item ) return 1;
1613 const char *item_text = item->get_text();
1614 char txt[BCTEXTLEN]; sprintf(txt, "<%s %s>", KW_FONT, item_text);
1615 return window->insert_ibeam(txt);
1618 TitleColorPopup::TitleColorPopup(TitleMain *client, TitleWindow *window)
1619 : ColorPicker(0, _("Color"))
1621 this->client = client;
1622 this->window = window;
1623 this->color_value = client->config.color;
1625 TitleColorPopup::~TitleColorPopup()
1628 int TitleColorPopup::handle_new_color(int output, int alpha)
1630 color_value = output;
1633 int TitleColorPopup::activate()
1635 start_window(client->config.color, 255, 1);
1638 void TitleColorPopup::handle_done_event(int result)
1640 if( result ) return;
1641 char txt[BCSTRLEN]; sprintf(txt, "<%s #%06x>", KW_COLOR, color_value);
1642 window->insert_ibeam(txt);
1645 TitlePngPopup::TitlePngPopup(TitleMain *client, TitleWindow *window)
1648 this->client = client;
1649 this->window = window;
1652 TitlePngPopup::~TitlePngPopup()
1657 void TitlePngPopup::handle_done_event(int result)
1659 if( result ) return;
1660 BrowseButtonWindow *gui = (BrowseButtonWindow *)get_gui();
1661 const char *path = gui->get_submitted_path();
1662 char txt[BCSTRLEN]; sprintf(txt, "<%s %s>", KW_PNG, path);
1663 window->insert_ibeam(txt);
1666 BC_Window *TitlePngPopup::new_gui()
1668 BC_DisplayInfo display_info;
1669 int x = display_info.get_abs_cursor_x();
1670 int y = display_info.get_abs_cursor_y();
1672 BC_Window *gui = new BrowseButtonWindow(client->server->mwindow->theme,
1673 x-25, y-100, window, "", _("Png file"), _("Png path"), 0);
1674 gui->create_objects();
1678 int TitlePngPopup::activate()
1680 BC_DialogThread::start();