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 ) {
470 if( !dragging ) break;
473 if( !dragging ) return 0;
477 if( dragging ) break;
481 MWindow *mwindow = client->server->mwindow;
482 CWindowGUI *cwindow_gui = mwindow->cwindow->gui;
483 CWindowCanvas *canvas = cwindow_gui->canvas;
484 float cursor_x = canvas->get_canvas()->get_relative_cursor_x();
485 float cursor_y = canvas->get_canvas()->get_relative_cursor_y();
486 canvas->canvas_to_output(mwindow->edl, 0, cursor_x, cursor_y);
487 int64_t position = client->get_source_position();
488 float projector_x, projector_y, projector_z;
489 Track *track = client->server->plugin->track;
490 int track_w = track->track_w, track_h = track->track_h;
491 track->automation->get_projector(
492 &projector_x, &projector_y, &projector_z,
493 position, PLAY_FORWARD);
494 projector_x += mwindow->edl->session->output_w / 2;
495 projector_y += mwindow->edl->session->output_h / 2;
496 cursor_x = (cursor_x - projector_x) / projector_z + track_w / 2;
497 cursor_y = (cursor_y - projector_y) / projector_z + track_h / 2;
498 int title_x = client->config.title_x, title_y = client->config.title_y;
499 int title_w = client->config.title_w, title_h = client->config.title_h;
500 if( !title_w ) title_w = track_w;
501 if( !title_h ) title_h = track_h;
502 int r = MIN(track_w, track_h)/100 + 2;
503 int x0 = title_x, x1 = title_x+(title_w+1)/2, x2 = title_x+title_w;
504 int y0 = title_y, y1 = title_y+(title_h+1)/2, y2 = title_y+title_h;
505 int drag_dx = 0, drag_dy = 0;
506 if( !dragging ) { // clockwise
507 if( abs(drag_dx = cursor_x-x0) < r && // x0,y0
508 abs(drag_dy = cursor_y-y0) < r ) dragging = 1;
509 else if( abs(drag_dx = cursor_x-x1) < r && // x1,y0
510 abs(drag_dy = cursor_y-y0) < r ) dragging = 2;
511 else if( abs(drag_dx = cursor_x-x2) < r && // x2,y0
512 abs(drag_dy = cursor_y-y0) < r ) dragging = 3;
513 else if( abs(drag_dx = cursor_x-x2) < r && // x2,y1
514 abs(drag_dy = cursor_y-y1) < r ) dragging = 4;
515 else if( abs(drag_dx = cursor_x-x2) < r && // x2,y2
516 abs(drag_dy = cursor_y-y2) < r ) dragging = 5;
517 else if( abs(drag_dx = cursor_x-x1) < r && // x1,y2
518 abs(drag_dy = cursor_y-y2) < r ) dragging = 6;
519 else if( abs(drag_dx = cursor_x-x0) < r && // x0,y2
520 abs(drag_dy = cursor_y-y2) < r ) dragging = 7;
521 else if( abs(drag_dx = cursor_x-x0) < r && // x0,y1
522 abs(drag_dy = cursor_y-y1) < r ) dragging = 8;
523 else if( abs(drag_dx = cursor_x-x1) < r && // x1,y1
524 abs(drag_dy = cursor_y-y1) < r ) dragging = 9;
529 int cur_x = cursor_x - drag_dx, dx = cur_x - x0;
530 int cur_y = cursor_y - drag_dy, dy = cur_y - y0;
531 if( !dx && !dy ) return 1;
532 int cur_w = title_w - dx; if( cur_w < 1 ) cur_w = 1;
533 int cur_h = title_h - dy; if( cur_h < 1 ) cur_h = 1;
534 this->title_x->update((int64_t)(client->config.title_x = cur_x));
535 this->title_y->update((int64_t)(client->config.title_y = cur_y));
536 this->title_w->update((int64_t)(client->config.title_w = cur_w));
537 this->title_h->update((int64_t)(client->config.title_h = cur_h));
540 int cur_y = cursor_y - drag_dy, dy = cur_y - y0;
542 int cur_h = title_h - dy; if( cur_h < 1 ) cur_h = 1;
543 this->title_y->update((int64_t)(client->config.title_y = cur_y));
544 this->title_h->update((int64_t)(client->config.title_h = cur_h));
547 int cur_x = cursor_x - drag_dx, dx = cur_x - x2;
548 int cur_y = cursor_y - drag_dy, dy = cur_y - y0;
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_y->update((int64_t)(client->config.title_y = cur_y));
553 this->title_h->update((int64_t)(client->config.title_h = cur_h));
556 int cur_x = cursor_x - drag_dx, dx = cur_x - x2;
558 int cur_w = title_w + dx; if( cur_w < 1 ) cur_w = 1;
559 this->title_w->update((int64_t)(client->config.title_w = cur_w));
562 int cur_x = cursor_x - drag_dx, dx = cur_x - x2;
563 int cur_y = cursor_y - drag_dy, dy = cur_y - y2;
564 int cur_w = title_w + dx; if( cur_w < 1 ) cur_w = 1;
565 int cur_h = title_h + dy; if( cur_h < 1 ) cur_h = 1;
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_y = cursor_y - drag_dy, dy = cur_y - y2;
571 if( client->config.title_h == cur_y ) return 1;
572 int cur_h = title_h + dy; if( cur_h < 1 ) cur_h = 1;
573 this->title_h->update((int64_t)(client->config.title_h = cur_h));
576 int cur_x = cursor_x - drag_dx, dx = cur_x - x0;
577 int cur_y = cursor_y - drag_dy, dy = cur_y - y2;
578 int cur_w = title_w - dx; if( cur_w < 1 ) cur_w = 1;
579 int cur_h = title_h + dy; if( cur_h < 1 ) cur_h = 1;
580 this->title_x->update((int64_t)(client->config.title_x = cur_x));
581 this->title_w->update((int64_t)(client->config.title_w = cur_w));
582 this->title_h->update((int64_t)(client->config.title_h = cur_h));
585 int cur_x = cursor_x - drag_dx, dx = cur_x - x0;
587 int cur_w = title_w - dx; if( cur_w < 1 ) cur_w = 1;
588 this->title_x->update((int64_t)(client->config.title_x = cur_x));
589 this->title_w->update((int64_t)(client->config.title_w = cur_w));
592 int cur_x = cursor_x - drag_dx, dx = cur_x - x1;
593 int cur_y = cursor_y - drag_dy, dy = cur_y - y1;
594 if( title_x == cur_x && title_y == cur_y ) return 1;
595 this->title_x->update((int64_t)(client->config.title_x += dx));
596 this->title_y->update((int64_t)(client->config.title_y += dy));
599 client->send_configure_change();
603 void TitleWindow::previous_font()
605 int current_font = font->get_number();
607 if( current_font < 0 ) current_font = fonts.total - 1;
609 if( current_font < 0 || current_font >= fonts.total ) return;
611 for( int i=0; i<fonts.total; ++i ) {
612 fonts.values[i]->set_selected(i == current_font);
615 font->update(fonts.values[current_font]->get_text());
616 strcpy(client->config.font, fonts.values[current_font]->get_text());
617 check_style(client->config.font,1);
618 client->send_configure_change();
621 void TitleWindow::next_font()
623 int current_font = font->get_number();
625 if( current_font >= fonts.total ) current_font = 0;
627 if( current_font < 0 || current_font >= fonts.total ) return;
629 for( int i=0; i<fonts.total; ++i ) {
630 fonts.values[i]->set_selected(i == current_font);
633 font->update(fonts.values[current_font]->get_text());
634 strcpy(client->config.font, fonts.values[current_font]->get_text());
635 check_style(client->config.font,1);
636 client->send_configure_change();
639 int TitleWindow::insert_ibeam(const char *txt, int ofs)
641 int ibeam = cur_ibeam;
642 int ilen = strlen(txt)+1;
644 int len = BC_Resources::encode(client->config.encoding, BC_Resources::wide_encoding,
645 (char*)txt,ilen, (char *)wtxt,ilen*sizeof(wtxt[0])) / sizeof(wchar_t);
646 client->insert_text(wtxt, ibeam);
647 while( len > 0 && !wtxt[len] ) --len;
648 int adv = len+1 + ofs;
649 if( (ibeam += adv) >= client->config.wlen)
650 ibeam = client->config.wlen;
651 text->wset_selection(-1, -1, ibeam);
652 text->update(client->config.wtext);
653 client->send_configure_change();
657 void TitleWindow::update_color()
659 //printf("TitleWindow::update_color %x\n", client->config.color);
660 set_color(client->config.color);
661 draw_box(color_x, color_y, COLOR_W, COLOR_H);
662 flash(color_x, color_y, COLOR_W, COLOR_H);
663 set_color(client->config.outline_color);
664 draw_box(outline_color_x, outline_color_y, COLOR_W, COLOR_H);
666 draw_rectangle(color_x, color_y, COLOR_W, COLOR_H);
667 draw_rectangle(outline_color_x, outline_color_y, COLOR_W, COLOR_H);
668 flash(outline_color_x, outline_color_y, COLOR_W, COLOR_H);
671 void TitleWindow::update_justification()
673 left->update(client->config.hjustification == JUSTIFY_LEFT);
674 center->update(client->config.hjustification == JUSTIFY_CENTER);
675 right->update(client->config.hjustification == JUSTIFY_RIGHT);
676 top->update(client->config.vjustification == JUSTIFY_TOP);
677 mid->update(client->config.vjustification == JUSTIFY_MID);
678 bottom->update(client->config.vjustification == JUSTIFY_BOTTOM);
681 void TitleWindow::update_stats()
683 text_chars->update(client->config.wlen);
684 int len = MESSAGESIZE-16 - strlen(text->get_text());
685 if( len < 0 ) len = 0;
686 text_bfrsz->update(len);
689 void TitleWindow::update()
691 title_x->update((int64_t)client->config.title_x);
692 title_y->update((int64_t)client->config.title_y);
693 title_w->update((int64_t)client->config.title_w);
694 title_h->update((int64_t)client->config.title_h);
695 italic->update(client->config.style & BC_FONT_ITALIC);
696 bold->update(client->config.style & BC_FONT_BOLD);
697 size->update(client->config.size);
698 motion->update(TitleMain::motion_to_text(client->config.motion_strategy));
699 loop->update(client->config.loop);
700 dropshadow->update((int64_t)client->config.dropshadow);
701 fade_in->update((float)client->config.fade_in);
702 fade_out->update((float)client->config.fade_out);
703 font->update(client->config.font);
704 check_style(client->config.font,0);
705 text->update(&client->config.wtext[0]);
706 speed->update(client->config.pixels_per_second);
707 outline->update((int64_t)client->config.outline_size);
709 stroker->update((int64_t)client->config.stroke_width);
711 timecode->update(client->config.timecode);
712 timecode_format->update(client->config.timecode_format);
713 background->update(client->config.background);
714 background_path->update(client->config.background_path);
715 loop_playback->update((int64_t)client->config.loop_playback);
717 char string[BCTEXTLEN];
718 for( int i=0; i<lengthof(timeunit_formats); ++i ) {
719 if( timeunit_formats[i] == client->config.timecode_format ) {
720 timecode_format->set_text(
721 Units::print_time_format(timeunit_formats[i], string));
725 update_justification();
731 TitleFontTumble::TitleFontTumble(TitleMain *client, TitleWindow *window, int x, int y)
734 this->client = client;
735 this->window = window;
737 int TitleFontTumble::handle_up_event()
739 window->previous_font();
743 int TitleFontTumble::handle_down_event()
751 TitleSizeTumble::TitleSizeTumble(TitleMain *client, TitleWindow *window, int x, int y)
754 this->client = client;
755 this->window = window;
758 int TitleSizeTumble::handle_up_event()
760 int current_index = -1;
761 int current_difference = -1;
762 for( int i=0; i<window->sizes.size(); ++i ) {
763 int size = atoi(window->sizes.get(i)->get_text());
764 if( current_index < 0 ||
765 abs(size - client->config.size) < current_difference ) {
767 current_difference = abs(size - client->config.size);
772 if( current_index >= window->sizes.size() ) current_index = 0;
775 client->config.size = atoi(window->sizes.get(current_index)->get_text());
776 window->size->update(client->config.size);
777 client->send_configure_change();
781 int TitleSizeTumble::handle_down_event()
783 int current_index = -1;
784 int current_difference = -1;
785 for( int i=0; i<window->sizes.size(); ++i ) {
786 int size = atoi(window->sizes.get(i)->get_text());
787 if( current_index < 0 ||
788 abs(size - client->config.size) < current_difference ) {
790 current_difference = abs(size - client->config.size);
795 if( current_index < 0 ) current_index = window->sizes.size() - 1;
798 client->config.size = atoi(window->sizes.get(current_index)->get_text());
799 window->size->update(client->config.size);
800 client->send_configure_change();
804 TitleBold::TitleBold(TitleMain *client, TitleWindow *window, int x, int y)
805 : BC_CheckBox(x, y, client->config.style & BC_FONT_BOLD, _("Bold"))
807 this->client = client;
808 this->window = window;
811 int TitleBold::handle_event()
813 client->config.style =
814 (client->config.style & ~BC_FONT_BOLD) |
815 (get_value() ? BC_FONT_BOLD : 0);
816 client->send_configure_change();
820 TitleItalic::TitleItalic(TitleMain *client, TitleWindow *window, int x, int y)
821 : BC_CheckBox(x, y, client->config.style & BC_FONT_ITALIC, _("Italic"))
823 this->client = client;
824 this->window = window;
826 int TitleItalic::handle_event()
828 client->config.style =
829 (client->config.style & ~BC_FONT_ITALIC) |
830 (get_value() ? BC_FONT_ITALIC : 0);
831 client->send_configure_change();
837 TitleSize::TitleSize(TitleMain *client, TitleWindow *window, int x, int y, char *text)
838 : BC_PopupTextBox(window, &window->sizes, text, x, y, 64, 300)
840 this->client = client;
841 this->window = window;
843 TitleSize::~TitleSize()
846 int TitleSize::handle_event()
848 client->config.size = atol(get_text());
849 //printf("TitleSize::handle_event 1 %s\n", get_text());
850 client->send_configure_change();
853 void TitleSize::update(int size)
855 char string[BCTEXTLEN];
856 sprintf(string, "%d", size);
857 BC_PopupTextBox::update(string);
861 TitlePitch(TitleMain *client, TitleWindow *window, int x, int y, int *value)
862 : BC_TumbleTextBox(window, *value, 0, INT_MAX, x, y, 64)
864 this->client = client;
865 this->window = window;
874 int TitlePitch::handle_event()
876 *value = atol(get_text());
877 client->send_configure_change();
881 TitleColorButton::TitleColorButton(TitleMain *client, TitleWindow *window, int x, int y)
882 : BC_GenericButton(x, y, _("Text Color..."))
884 this->client = client;
885 this->window = window;
887 int TitleColorButton::handle_event()
889 window->color_thread->start_window(client->config.color,
890 client->config.alpha);
893 TitleOutlineColorButton::TitleOutlineColorButton(TitleMain *client, TitleWindow *window, int x, int y)
894 : BC_GenericButton(x, y, _("Outline color..."))
896 this->client = client;
897 this->window = window;
899 int TitleOutlineColorButton::handle_event()
901 window->outline_color_thread->start_window(client->config.outline_color,
902 client->config.outline_alpha);
907 TitleMotion::TitleMotion(TitleMain *client, TitleWindow *window, int x, int y)
908 : BC_PopupTextBox(window, &window->paths,
909 client->motion_to_text(client->config.motion_strategy),
912 this->client = client;
913 this->window = window;
915 int TitleMotion::handle_event()
917 client->config.motion_strategy = client->text_to_motion(get_text());
918 client->send_configure_change();
922 TitleLoop::TitleLoop(TitleMain *client, int x, int y)
923 : BC_CheckBox(x, y, client->config.loop, _("Loop"))
925 this->client = client;
927 int TitleLoop::handle_event()
929 client->config.loop = get_value();
930 client->send_configure_change();
933 TitleTimecode::TitleTimecode(TitleMain *client, int x, int y)
934 : BC_CheckBox(x, y, client->config.timecode, _("Stamp timecode"))
936 this->client = client;
938 int TitleTimecode::handle_event()
940 client->config.timecode = get_value();
941 client->send_configure_change();
945 TitleTimecodeFormat::TitleTimecodeFormat(TitleMain *client, int x, int y, const char *text)
946 : BC_PopupMenu(x, y, 100, text, 1)
948 this->client = client;
951 int TitleTimecodeFormat::handle_event()
953 client->config.timecode_format = Units::text_to_format(get_text());
954 client->send_configure_change();
958 void TitleTimecodeFormat::create_objects()
960 char string[BCTEXTLEN];
961 for( int i=0; i<lengthof(timeunit_formats); ++i ) {
962 add_item(new BC_MenuItem(
963 Units::print_time_format(timeunit_formats[i], string)));
968 int TitleTimecodeFormat::update(int timecode_format)
970 char string[BCTEXTLEN];
971 for( int i=0; i<lengthof(timeunit_formats); ++i ) {
972 if( timeunit_formats[i] == timecode_format ) {
973 set_text(Units::print_time_format(timeunit_formats[i], string));
980 TitleFade::TitleFade(TitleMain *client, TitleWindow *window,
981 double *value, int x, int y)
982 : BC_TextBox(x, y, 80, 1, (float)*value)
984 this->client = client;
985 this->window = window;
990 int TitleFade::handle_event()
992 *value = atof(get_text());
993 client->send_configure_change();
997 void TitleWindow::check_style(const char *font_name, int update)
999 BC_FontEntry *font_nrm = TitleMain::get_font(font_name, 0);
1000 BC_FontEntry *font_itl = TitleMain::get_font(font_name, BC_FONT_ITALIC);
1001 BC_FontEntry *font_bld = TitleMain::get_font(font_name, BC_FONT_BOLD);
1002 BC_FontEntry *font_bit = TitleMain::get_font(font_name, BC_FONT_ITALIC | BC_FONT_BOLD);
1003 int has_norm = font_nrm != 0 ? 1 : 0;
1004 int has_ital = font_itl != 0 || font_bit != 0 ? 1 : 0;
1005 int has_bold = font_bld != 0 || font_bit != 0 ? 1 : 0;
1006 if( bold->get_value() ) {
1007 if( !has_bold ) bold->update(0);
1010 if( !has_norm && has_bold ) bold->update(1);
1012 if( italic->get_value() ) {
1013 if( !has_ital ) italic->update(0);
1016 if( !has_norm && has_ital ) italic->update(1);
1018 if( has_norm && has_bold ) bold->enable(); else bold->disable();
1019 if( has_norm && has_ital ) italic->enable(); else italic->disable();
1021 int style = stroker && atof(stroker->get_text()) ? BC_FONT_OUTLINE : 0;
1022 if( bold->get_value() ) style |= BC_FONT_BOLD;
1023 if( italic->get_value() ) style |= BC_FONT_ITALIC;
1024 client->config.style = style;
1028 TitleFont::TitleFont(TitleMain *client, TitleWindow *window, int x, int y)
1029 : BC_PopupTextBox(window, &window->fonts, client->config.font,
1030 x, y, 240, 300, LISTBOX_ICON_LIST)
1032 this->client = client;
1033 this->window = window;
1035 int TitleFont::handle_event()
1037 strcpy(client->config.font, get_text());
1038 window->check_style(client->config.font, 1);
1039 client->send_configure_change();
1043 TitleText::TitleText(TitleMain *client, TitleWindow *window,
1044 int x, int y, int w, int h)
1045 : BC_ScrollTextBox(window, x, y, w,
1046 BC_TextBox::pixels_to_rows(window, MEDIUMFONT, h),
1047 client->config.wtext, 8192)
1049 this->client = client;
1050 this->window = window;
1051 //printf("TitleText::TitleText %s\n", client->config.text);
1054 int TitleText::button_press_event()
1056 if( get_buttonpress() == 3 ) {
1057 window->cur_ibeam = get_ibeam_letter();
1058 window->cur_popup->activate_menu();
1061 return BC_ScrollTextBox::button_press_event();
1064 int TitleText::handle_event()
1066 window->fonts_popup->deactivate();
1067 int len = sizeof(client->config.wtext) / sizeof(wchar_t);
1068 wcsncpy(client->config.wtext, get_wtext(), len);
1069 client->config.wtext[len-1] = 0;
1070 client->config.wlen = wcslen(client->config.wtext);
1071 window->update_stats();
1072 client->send_configure_change();
1075 TitleTextChars::TitleTextChars(int x, int y, int w)
1076 : BC_Title(x, y, "", MEDIUMFONT, -1, 0, w)
1079 TitleTextChars::~TitleTextChars()
1082 int TitleTextChars::update(int n)
1084 char text[BCSTRLEN];
1085 sprintf(text, _("chars: %d "),n);
1086 return BC_Title::update(text, 0);
1089 TitleTextBfrSz::TitleTextBfrSz(int x, int y, int w)
1090 : BC_Title(x, y, "", MEDIUMFONT, -1, 0, w)
1093 TitleTextBfrSz::~TitleTextBfrSz()
1096 int TitleTextBfrSz::update(int n)
1098 char text[BCSTRLEN];
1099 sprintf(text, _("bfrsz: %d "),n);
1100 return BC_Title::update(text, 0);
1104 TitleDropShadow::TitleDropShadow(TitleMain *client, TitleWindow *window, int x, int y)
1105 : BC_TumbleTextBox(window, (int64_t)client->config.dropshadow,
1106 (int64_t)-1000, (int64_t)1000, x, y, 70)
1108 this->client = client;
1109 this->window = window;
1111 int TitleDropShadow::handle_event()
1113 client->config.dropshadow = atol(get_text());
1114 client->send_configure_change();
1119 TitleOutline::TitleOutline(TitleMain *client, TitleWindow *window, int x, int y)
1120 : BC_TumbleTextBox(window, (int64_t)client->config.outline_size,
1121 (int64_t)0, (int64_t)1000, x, y, 70)
1123 this->client = client;
1124 this->window = window;
1126 int TitleOutline::handle_event()
1128 client->config.outline_size = atol(get_text());
1129 client->send_configure_change();
1134 TitleStroker::TitleStroker(TitleMain *client, TitleWindow *window, int x, int y)
1135 : BC_TumbleTextBox(window, (int64_t)client->config.stroke_width,
1136 (int64_t)0, (int64_t)1000, x, y, 70)
1138 this->client = client;
1139 this->window = window;
1141 int TitleStroker::handle_event()
1143 client->config.stroke_width = atof(get_text());
1144 if( client->config.stroke_width )
1145 client->config.style |= BC_FONT_OUTLINE;
1147 client->config.style &= ~BC_FONT_OUTLINE;
1148 client->send_configure_change();
1153 TitleX::TitleX(TitleMain *client, TitleWindow *window, int x, int y)
1154 : BC_TumbleTextBox(window, (int64_t)client->config.title_x,
1155 (int64_t)-32767, (int64_t)32767, x, y, 50)
1157 this->client = client;
1158 this->window = window;
1160 int TitleX::handle_event()
1162 client->config.title_x = atol(get_text());
1163 client->send_configure_change();
1167 TitleY::TitleY(TitleMain *client, TitleWindow *window, int x, int y)
1168 : BC_TumbleTextBox(window, (int64_t)client->config.title_y,
1169 (int64_t)-32767, (int64_t)32767, x, y, 50)
1171 this->client = client;
1172 this->window = window;
1174 int TitleY::handle_event()
1176 client->config.title_y = atol(get_text());
1177 client->send_configure_change();
1181 TitleW::TitleW(TitleMain *client, TitleWindow *window, int x, int y)
1182 : BC_TumbleTextBox(window, (int64_t)client->config.title_w,
1183 (int64_t)0, (int64_t)32767, x, y, 50)
1185 this->client = client;
1186 this->window = window;
1188 int TitleW::handle_event()
1190 client->config.title_w = atol(get_text());
1191 client->send_configure_change();
1195 TitleH::TitleH(TitleMain *client, TitleWindow *window, int x, int y)
1196 : BC_TumbleTextBox(window, (int64_t)client->config.title_h,
1197 (int64_t)0, (int64_t)32767, x, y, 50)
1199 this->client = client;
1200 this->window = window;
1202 int TitleH::handle_event()
1204 client->config.title_h = atol(get_text());
1205 client->send_configure_change();
1209 TitleSpeed::TitleSpeed(TitleMain *client, TitleWindow *window, int x, int y)
1210 : BC_TumbleTextBox(window, (float)client->config.pixels_per_second,
1211 (float)0, (float)1000, x, y, 100)
1213 this->client = client;
1219 int TitleSpeed::handle_event()
1221 client->config.pixels_per_second = atof(get_text());
1222 client->send_configure_change();
1227 TitleLeft::TitleLeft(TitleMain *client, TitleWindow *window, int x, int y)
1228 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_LEFT, _("Left"))
1230 this->client = client;
1231 this->window = window;
1233 int TitleLeft::handle_event()
1235 client->config.hjustification = JUSTIFY_LEFT;
1236 window->update_justification();
1237 client->send_configure_change();
1241 TitleCenter::TitleCenter(TitleMain *client, TitleWindow *window, int x, int y)
1242 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_CENTER, _("Center"))
1244 this->client = client;
1245 this->window = window;
1247 int TitleCenter::handle_event()
1249 client->config.hjustification = JUSTIFY_CENTER;
1250 window->update_justification();
1251 client->send_configure_change();
1255 TitleRight::TitleRight(TitleMain *client, TitleWindow *window, int x, int y)
1256 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_RIGHT, _("Right"))
1258 this->client = client;
1259 this->window = window;
1261 int TitleRight::handle_event()
1263 client->config.hjustification = JUSTIFY_RIGHT;
1264 window->update_justification();
1265 client->send_configure_change();
1271 TitleTop::TitleTop(TitleMain *client, TitleWindow *window, int x, int y)
1272 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_TOP, _("Top"))
1274 this->client = client;
1275 this->window = window;
1277 int TitleTop::handle_event()
1279 client->config.vjustification = JUSTIFY_TOP;
1280 window->update_justification();
1281 client->send_configure_change();
1285 TitleMid::TitleMid(TitleMain *client, TitleWindow *window, int x, int y)
1286 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_MID, _("Mid"))
1288 this->client = client;
1289 this->window = window;
1291 int TitleMid::handle_event()
1293 client->config.vjustification = JUSTIFY_MID;
1294 window->update_justification();
1295 client->send_configure_change();
1299 TitleBottom::TitleBottom(TitleMain *client, TitleWindow *window, int x, int y)
1300 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_BOTTOM, _("Bottom"))
1302 this->client = client;
1303 this->window = window;
1305 int TitleBottom::handle_event()
1307 client->config.vjustification = JUSTIFY_BOTTOM;
1308 window->update_justification();
1309 client->send_configure_change();
1315 TitleColorThread::TitleColorThread(TitleMain *client, TitleWindow *window, int is_outline)
1316 : ColorPicker(1, is_outline? _("Outline Color") : _("Text Color"))
1318 this->client = client;
1319 this->window = window;
1320 this->is_outline = is_outline;
1323 int TitleColorThread::handle_new_color(int output, int alpha)
1326 client->config.outline_color = output;
1327 client->config.outline_alpha = alpha;
1330 client->config.color = output;
1331 client->config.alpha = alpha;
1334 window->lock_window("TitleColorThread::handle_new_color");
1335 window->update_color();
1337 window->unlock_window();
1339 client->send_configure_change();
1343 TitleDrag::TitleDrag(TitleMain *client, TitleWindow *window, int x, int y)
1344 : BC_CheckBox(x, y, client->config.drag, _("Drag"))
1346 this->client = client;
1347 this->window = window;
1350 int TitleDrag::handle_event()
1352 int value = get_value();
1353 client->config.drag = value;
1355 window->grab(client->server->mwindow->cwindow->gui);
1357 window->ungrab(client->server->mwindow->cwindow->gui);
1358 client->send_configure_change();
1362 TitleBackground::TitleBackground(TitleMain *client, TitleWindow *window, int x, int y)
1363 : BC_CheckBox(x, y, client->config.background, _("Background:"))
1365 this->client = client;
1366 this->window = window;
1369 int TitleBackground::handle_event()
1371 client->config.background = get_value();
1372 client->send_configure_change();
1376 TitleBackgroundPath::TitleBackgroundPath(TitleMain *client, TitleWindow *window, int x, int y)
1377 : BC_TextBox(x, y, 240, 1, client->config.background_path)
1379 this->client = client;
1380 this->window = window;
1383 int TitleBackgroundPath::handle_event()
1385 strncpy(client->config.background_path, get_text(), sizeof(client->config.background_path));
1386 client->send_configure_change();
1390 TitleLoopPlayback::TitleLoopPlayback(TitleMain *client, int x, int y)
1391 : BC_CheckBox(x, y, client->config.loop_playback, _("Loop playback"))
1393 this->client = client;
1395 int TitleLoopPlayback::handle_event()
1397 client->config.loop_playback = get_value();
1398 client->send_configure_change();
1403 TitleCurPopup::TitleCurPopup(TitleMain *client, TitleWindow *window)
1404 : BC_PopupMenu(0, 0, 0, "", 0)
1406 this->client = client;
1407 this->window = window;
1409 int TitleCurPopup::handle_event()
1414 void TitleCurSubMenu::add_subitem(int popup_type, va_list ap, const char *fmt)
1416 char item[BCSTRLEN];
1417 vsnprintf(item, sizeof(item)-1, fmt, ap);
1418 item[sizeof(item)-1] = 0;
1419 add_submenuitem(new TitleCurSubMenuItem(this, item, popup_type));
1422 void TitleCurPopup::create_objects()
1424 TitleCurItem *cur_item;
1425 TitleCurSubMenu *sub_menu;
1427 add_item(cur_item = new TitleCurItem(this, item = KW_NUDGE));
1428 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1429 sub_menu->add_subitem("%s dx,dy",item);
1430 sub_menu->add_subitem("/%s",item);
1431 add_item(cur_item = new TitleCurItem(this, item = KW_COLOR));
1432 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1433 sub_menu->add_subitem(POPUP_COLOR,"%s %s",item,_("#"));
1434 sub_menu->add_subitem("%s ",item);
1435 sub_menu->add_subitem("/%s",item);
1436 add_item(cur_item = new TitleCurItem(this, item = KW_ALPHA));
1437 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1438 sub_menu->add_subitem("%s ",item);
1439 sub_menu->add_subitem("%s 0.",item);
1440 sub_menu->add_subitem("%s .5",item);
1441 sub_menu->add_subitem("%s 1.",item);
1442 sub_menu->add_subitem("/%s",item);
1443 add_item(cur_item = new TitleCurItem(this, item = KW_FONT));
1444 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1445 sub_menu->add_subitem(POPUP_FONT,"%s %s",item, _("name"));
1446 sub_menu->add_subitem(POPUP_OFFSET, "%s ",item);
1447 sub_menu->add_subitem("/%s",item);
1448 add_item(cur_item = new TitleCurItem(this, item = KW_SIZE));
1449 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1450 sub_menu->add_subitem("%s +",item);
1451 sub_menu->add_subitem("%s -",item);
1452 sub_menu->add_subitem("%s ",item);
1453 sub_menu->add_subitem("/%s",item);
1454 add_item(cur_item = new TitleCurItem(this, item = KW_BOLD));
1455 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1456 sub_menu->add_subitem("%s 1",item);
1457 sub_menu->add_subitem("%s 0",item);
1458 sub_menu->add_subitem("/%s",item);
1459 add_item(cur_item = new TitleCurItem(this, item = KW_ITALIC));
1460 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1461 sub_menu->add_subitem("%s 1",item);
1462 sub_menu->add_subitem("%s 0",item);
1463 sub_menu->add_subitem("/%s",item);
1464 add_item(cur_item = new TitleCurItem(this, item = KW_CAPS));
1465 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1466 sub_menu->add_subitem("%s 1",item);
1467 sub_menu->add_subitem("%s 0",item);
1468 sub_menu->add_subitem("%s -1",item);
1469 sub_menu->add_subitem("/%s",item);
1470 add_item(cur_item = new TitleCurItem(this, item = KW_UL));
1471 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1472 sub_menu->add_subitem("%s 1",item);
1473 sub_menu->add_subitem("%s 0",item);
1474 sub_menu->add_subitem("/%s",item);
1475 add_item(cur_item = new TitleCurItem(this, item = KW_BLINK));
1476 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1477 sub_menu->add_subitem("%s 1",item);
1478 sub_menu->add_subitem("%s -1",item);
1479 sub_menu->add_subitem("%s ",item);
1480 sub_menu->add_subitem("%s 0",item);
1481 sub_menu->add_subitem("/%s",item);
1482 add_item(cur_item = new TitleCurItem(this, item = KW_FIXED));
1483 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1484 sub_menu->add_subitem("%s ",item);
1485 sub_menu->add_subitem("%s 20",item);
1486 sub_menu->add_subitem("%s 10",item);
1487 sub_menu->add_subitem("%s 0",item);
1488 sub_menu->add_subitem("/%s",item);
1489 add_item(cur_item = new TitleCurItem(this, item = KW_SUP));
1490 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1491 sub_menu->add_subitem("%s 1",item);
1492 sub_menu->add_subitem("%s 0",item);
1493 sub_menu->add_subitem("%s -1",item);
1494 sub_menu->add_subitem("/%s",item);
1495 add_item(cur_item = new TitleCurItem(this, item = KW_PNG));
1496 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1497 sub_menu->add_subitem(POPUP_PNG,"%s %s", item, _("file"));
1500 TitleCurItem::TitleCurItem(TitleCurPopup *popup, const char *text)
1503 this->popup = popup;
1505 int TitleCurItem::handle_event()
1510 TitleCurSubMenu::TitleCurSubMenu(TitleCurItem *cur_item)
1512 this->cur_item = cur_item;
1514 TitleCurSubMenu::~TitleCurSubMenu()
1518 TitleCurSubMenuItem::TitleCurSubMenuItem(TitleCurSubMenu *submenu, const char *text, int popup_type)
1521 this->submenu = submenu;
1522 this->popup_type = popup_type;
1524 TitleCurSubMenuItem::~TitleCurSubMenuItem()
1527 int TitleCurSubMenuItem::handle_event()
1529 TitleCurPopup *popup = submenu->cur_item->popup;
1530 TitleWindow *window = popup->window;
1531 const char *item_text = get_text();
1532 int ofs = *item_text == '/' ? 0 : -1;
1533 switch( popup_type ) {
1536 window->get_pop_cursor_xy(px ,py);
1537 window->fonts_popup->activate(px, py, 300,200);
1540 window->color_popup->activate();
1543 window->png_popup->activate();
1550 sprintf(txt, "<%s>", item_text);
1551 return window->insert_ibeam(txt, ofs);
1554 TitleFontsPopup::TitleFontsPopup(TitleMain *client, TitleWindow *window)
1555 : BC_ListBox(-1, -1, 1, 1, LISTBOX_ICON_LIST,
1556 &window->fonts, 0, 0, 1, 0, 1)
1558 this->client = client;
1559 this->window = window;
1563 TitleFontsPopup::~TitleFontsPopup()
1566 int TitleFontsPopup::keypress_event()
1568 switch( get_keypress() ) {
1576 return BC_ListBox::keypress_event();
1579 int TitleFontsPopup::handle_event()
1582 BC_ListBoxItem *item = get_selection(0, 0);
1583 if( !item ) return 1;
1584 const char *item_text = item->get_text();
1585 char txt[BCTEXTLEN]; sprintf(txt, "<%s %s>", KW_FONT, item_text);
1586 return window->insert_ibeam(txt);
1589 TitleColorPopup::TitleColorPopup(TitleMain *client, TitleWindow *window)
1590 : ColorPicker(0, _("Color"))
1592 this->client = client;
1593 this->window = window;
1594 this->color_value = client->config.color;
1596 TitleColorPopup::~TitleColorPopup()
1599 int TitleColorPopup::handle_new_color(int output, int alpha)
1601 color_value = output;
1604 int TitleColorPopup::activate()
1606 start_window(client->config.color, 255, 1);
1609 void TitleColorPopup::handle_done_event(int result)
1611 if( result ) return;
1612 char txt[BCSTRLEN]; sprintf(txt, "<%s #%06x>", KW_COLOR, color_value);
1613 window->insert_ibeam(txt);
1616 TitlePngPopup::TitlePngPopup(TitleMain *client, TitleWindow *window)
1619 this->client = client;
1620 this->window = window;
1623 TitlePngPopup::~TitlePngPopup()
1628 void TitlePngPopup::handle_done_event(int result)
1630 if( result ) return;
1631 BrowseButtonWindow *gui = (BrowseButtonWindow *)get_gui();
1632 const char *path = gui->get_submitted_path();
1633 char txt[BCSTRLEN]; sprintf(txt, "<%s %s>", KW_PNG, path);
1634 window->insert_ibeam(txt);
1637 BC_Window *TitlePngPopup::new_gui()
1639 BC_DisplayInfo display_info;
1640 int x = display_info.get_abs_cursor_x();
1641 int y = display_info.get_abs_cursor_y();
1643 BC_Window *gui = new BrowseButtonWindow(client->server->mwindow->theme,
1644 x-25, y-100, window, "", _("Png file"), _("Png path"), 0);
1645 gui->create_objects();
1649 int TitlePngPopup::activate()
1651 BC_DialogThread::start();