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"
35 #include "mainerror.h"
37 #include "mwindowgui.h"
39 #include "pluginserver.h"
42 #include "titlerwindow.h"
43 #include "bcfontentry.h"
45 static const int timeunit_formats[] =
56 TitleWindow::TitleWindow(TitleMain *client)
57 : PluginClientWindow(client,
58 client->config.window_w, client->config.window_h, 100, 100, 1)
60 //printf("TitleWindow::TitleWindow %d %d %d\n", __LINE__, client->config.window_w, client->config.window_h);
61 this->client = client;
66 x_title = 0; title_x = 0;
67 y_title = 0; title_y = 0;
68 w_title = 0; title_w = 0;
69 h_title = 0; title_h = 0;
70 dropshadow_title = 0; dropshadow = 0;
71 outline_title = 0; outline = 0;
72 stroker_title = 0; stroker = 0;
80 color_x = color_y = 0;
81 outline_color_x = outline_color_y = 0;
82 drag_dx = drag_dy = dragging = 0;
94 outline_color_button = 0;
95 outline_color_thread = 0;
109 left = 0; center = 0; right = 0;
110 top = 0; mid = 0; bottom = 0;
120 void TitleWindow::done_event(int result)
122 ungrab(client->server->mwindow->cwindow->gui);
123 color_thread->close_window();
124 outline_color_thread->close_window();
125 color_popup->close_window();
126 png_popup->close_window();
129 TitleWindow::~TitleWindow()
133 for( int i=0; i<fonts.size(); ++i )
134 delete fonts[i]->get_icon();
136 sizes.remove_all_objects();
137 delete timecode_format;
143 void TitleWindow::create_objects()
146 int margin = client->get_theme()->widget_border;
147 char string[BCTEXTLEN];
151 client->build_previews(this);
153 sizes.append(new BC_ListBoxItem("8"));
154 sizes.append(new BC_ListBoxItem("9"));
155 sizes.append(new BC_ListBoxItem("10"));
156 sizes.append(new BC_ListBoxItem("11"));
157 sizes.append(new BC_ListBoxItem("12"));
158 sizes.append(new BC_ListBoxItem("13"));
159 sizes.append(new BC_ListBoxItem("14"));
160 sizes.append(new BC_ListBoxItem("16"));
161 sizes.append(new BC_ListBoxItem("18"));
162 sizes.append(new BC_ListBoxItem("20"));
163 sizes.append(new BC_ListBoxItem("22"));
164 sizes.append(new BC_ListBoxItem("24"));
165 sizes.append(new BC_ListBoxItem("26"));
166 sizes.append(new BC_ListBoxItem("28"));
167 sizes.append(new BC_ListBoxItem("32"));
168 sizes.append(new BC_ListBoxItem("36"));
169 sizes.append(new BC_ListBoxItem("40"));
170 sizes.append(new BC_ListBoxItem("48"));
171 sizes.append(new BC_ListBoxItem("56"));
172 sizes.append(new BC_ListBoxItem("64"));
173 sizes.append(new BC_ListBoxItem("72"));
174 sizes.append(new BC_ListBoxItem("100"));
175 sizes.append(new BC_ListBoxItem("128"));
176 sizes.append(new BC_ListBoxItem("256"));
177 sizes.append(new BC_ListBoxItem("512"));
178 sizes.append(new BC_ListBoxItem("1024"));
180 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(NO_MOTION)));
181 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(BOTTOM_TO_TOP)));
182 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(TOP_TO_BOTTOM)));
183 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(RIGHT_TO_LEFT)));
184 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(LEFT_TO_RIGHT)));
188 // Construct font list
189 ArrayList<BC_FontEntry*> *fontlist = get_resources()->fontlist;
191 for( int i=0; i<fontlist->size(); ++i ) {
193 for( int j=0; j<fonts.size(); ++j ) {
194 if( !strcasecmp(fonts.get(j)->get_text(),
195 fontlist->get(i)->displayname) ) {
201 BC_ListBoxItem *item = 0;
203 fonts.append(item = new
204 BC_ListBoxItem(fontlist->get(i)->displayname));
205 if( !strcmp(client->config.font, item->get_text()) )
206 item->set_selected(1);
207 if( fontlist->values[i]->image ) {
208 VFrame *vframe = fontlist->get(i)->image;
209 BC_Pixmap *icon = new BC_Pixmap(this, vframe, PIXMAP_ALPHA);
210 item->set_icon(icon);
211 item->set_icon_vframe(vframe);
220 for( int i=0; i<fonts.size()-1; ++i ) {
221 if( strcmp(fonts.values[i]->get_text(),
222 fonts.values[i + 1]->get_text()) > 0 ) {
223 BC_ListBoxItem *temp = fonts.values[i + 1];
224 fonts.values[i + 1] = fonts.values[i];
225 fonts.values[i] = temp;
231 add_tool(font_title = new BC_Title(x, y, _("Font:")));
232 font = new TitleFont(client, this, x, y + font_title->get_h());
233 font->create_objects();
234 font->set_show_query(1);
236 add_subwindow(font_tumbler = new TitleFontTumble(client, this, x, y+margin));
237 x += font_tumbler->get_w() + margin;
240 add_tool(size_title = new BC_Title(x1, y1+margin, _("Size:")));
241 sprintf(string, "%.2f", client->config.size);
242 x1 += size_title->get_w() + margin;
243 size = new TitleSize(client, this, x1, y1+margin, string);
244 size->create_objects();
245 int x2 = x1 + size->get_w(), y2 = y1 + size->get_h() + margin;
246 add_subwindow(size_tumbler = new TitleSizeTumble(client, this, x2, y1+margin));
248 add_tool(pitch_title = new BC_Title(x-5, y2+margin, _("Pitch:")));
249 pitch = new TitlePitch(client, this, x1, y2+margin, &client->config.line_pitch);
250 pitch->create_objects();
252 int x3 = x2 + size_tumbler->get_w() + 50;
253 int y3 = pitch->get_y() + pitch->get_h();
255 add_tool(style_title = new BC_Title(x=x3, y, _("Style:")));
256 add_tool(italic = new TitleItalic(client, this, x, y + 20));
257 int w1 = italic->get_w();
258 add_tool(bold = new TitleBold(client, this, x, y + 50));
259 if( bold->get_w() > w1 ) w1 = bold->get_w();
261 add_tool(drag = new TitleDrag(client, this, x, y + 80));
262 if( drag->get_w() > w1 ) w1 = drag->get_w();
263 if( client->config.drag ) {
264 if( !grab(client->server->mwindow->cwindow->gui) )
265 eprintf("drag enabled, but compositor already grabbed\n");
269 add_tool(justify_title = new BC_Title(x, y, _("Justify:")));
270 add_tool(left = new TitleLeft(client, this, x, y + 20));
272 add_tool(center = new TitleCenter(client, this, x, y + 50));
273 if( center->get_w() > w1 ) w1 = center->get_w();
274 add_tool(right = new TitleRight(client, this, x, y + 80));
275 if( right->get_w() > w1 ) w1 = right->get_w();
278 add_tool(top = new TitleTop(client, this, x, y + 20));
279 add_tool(mid = new TitleMid(client, this, x, y + 50));
280 add_tool(bottom= new TitleBottom(client, this, x, y + 80));
285 w1 = BC_Title::calculate_w(this, _("X:"));
286 if( (x1 = BC_Title::calculate_w(this, _("Y:"))) > w1 ) w1 = x1;
287 if( (x1 = BC_Title::calculate_w(this, _("W:"))) > w1 ) w1 = x1;
288 if( (x1 = BC_Title::calculate_w(this, _("H:"))) > w1 ) w1 = x1;
289 add_tool(x_title = new BC_Title(x1=x, y, _("X:")));
291 title_x = new TitleX(client, this, x1, y);
292 title_x->create_objects();
293 x1 += title_x->get_w()+margin;
294 add_tool(y_title = new BC_Title(x1, y, _("Y:")));
296 title_y = new TitleY(client, this, x1, y);
297 title_y->create_objects();
298 x1 += title_y->get_w();
299 y1 = y + title_y->get_h();
301 add_tool(w_title = new BC_Title(x1=x, y1, _("W:")));
303 title_w = new TitleW(client, this, x1, y1);
304 title_w->create_objects();
305 x1 += title_w->get_w()+margin;
306 add_tool(h_title = new BC_Title(x1, y1, _("H:")));
308 title_h = new TitleH(client, this, x1, y1);
309 title_h->create_objects();
310 x1 += title_h->get_w();
313 add_tool(motion_title = new BC_Title(x1=x, y, _("Motion:")));
314 x1 += motion_title->get_w()+margin;
315 motion = new TitleMotion(client, this, x1, y);
316 motion->create_objects();
317 add_tool(loop = new TitleLoop(client, x, y1));
318 x = margin; y = y1 + loop->get_h()+20;
320 add_tool(dropshadow_title = new BC_Title(x, y, _("Drop shadow:")));
321 w1 = dropshadow_title->get_w();
322 dropshadow = new TitleDropShadow(client, this, x, y + 20);
323 dropshadow->create_objects();
324 if( dropshadow->get_w() > w1 ) w1 = dropshadow->get_w();
327 add_tool(fadein_title = new BC_Title(x, y, _("Fade in (sec):")));
328 w1 = fadein_title->get_w();
329 add_tool(fade_in = new TitleFade(client, this, &client->config.fade_in, x, y + 20));
330 if( fade_in->get_w() > w1 ) w1 = fade_in->get_w();
333 add_tool(fadeout_title = new BC_Title(x, y, _("Fade out (sec):")));
334 w1 = fadeout_title->get_w();
335 add_tool(fade_out = new TitleFade(client, this, &client->config.fade_out, x, y + 20));
336 if( fade_out->get_w() > w1 ) w1 = fade_out->get_w();
339 add_tool(speed_title = new BC_Title(x, y1=y, _("Speed:")));
340 w1 = speed_title->get_w();
341 y += speed_title->get_h() + 5;
342 speed = new TitleSpeed(client, this, x, y);
343 speed->create_objects();
344 if( speed->get_w() > w1 ) w1 = speed->get_w();
346 y2 = y + speed->get_h() + 10;
348 color_x = x3; color_y = y = y1;
349 color_thread = new TitleColorThread(client, this, 0);
350 x1 = color_x + COLOR_W + 2*margin;
352 add_tool(color_button = new TitleColorButton(client, this, x1, y1));
354 outline_color_x = x3; outline_color_y = y;
355 outline_color_thread = new TitleColorThread(client, this, 1);
356 y1 = outline_color_y + 5;
357 add_tool(outline_color_button = new TitleOutlineColorButton(client, this, x1, y1));
360 add_tool(outline_title = new BC_Title(x, y, _("Outline:")));
361 y1 = y + outline_title->get_h() + margin;
362 outline = new TitleOutline(client, this, x, y1);
363 outline->create_objects();
364 x += outline->get_w() + 2*margin;
366 add_tool(stroker_title = new BC_Title(x, y, _("Stroker:")));
367 stroker = new TitleStroker(client, this, x, y1);
368 stroker->create_objects();
369 x += stroker->get_w() + margin;
371 y += outline_title->get_h() + margin;
372 add_tool(timecode = new TitleTimecode(client, x1=x, y));
373 x += timecode->get_w() + margin;
374 add_tool(timecode_format = new TitleTimecodeFormat(client, x, y,
375 Units::print_time_format(client->config.timecode_format, string)));
376 timecode_format->create_objects();
377 y += timecode_format->get_h() + margin;
380 add_tool(background = new TitleBackground(client, this, x, y));
381 x += background->get_w() + margin;
382 add_tool(background_path = new TitleBackgroundPath(client, this, x, y));
383 x += background_path->get_w() + margin;
384 add_tool(background_browse = new BrowseButton(
385 client->server->mwindow->theme, this, background_path,
386 x, y, "", _("background media"), _("Select background media path")));
387 x += background_browse->get_w() + 3*margin;
388 add_tool(loop_playback = new TitleLoopPlayback(client, x, y));
389 y += loop_playback->get_h() + 10;
392 add_tool(text_title = new BC_Title(x, y, _("Text:")));
393 x += text_title->get_w() + 20;
394 int wid = BC_Title::calculate_w(this,"0")*10;
395 add_tool(text_chars = new TitleTextChars(x,y,wid));
396 x += text_chars->get_w() + 20;
397 add_tool(text_bfrsz = new TitleTextBfrSz(x,y,wid));
399 y += text_title->get_h() + margin;
401 text = new TitleText(client, this, x, y, get_w()-margin - x, get_h() - y - 10);
402 text->create_objects();
404 add_tool(cur_popup = new TitleCurPopup(client, this));
405 cur_popup->create_objects();
406 add_tool(fonts_popup = new TitleFontsPopup(client, this));
407 color_popup = new TitleColorPopup(client, this);
408 png_popup = new TitlePngPopup(client, this);
414 int TitleWindow::resize_event(int w, int h)
416 client->config.window_w = w;
417 client->config.window_h = h;
419 clear_box(0, 0, w, h);
420 font_title->reposition_window(font_title->get_x(), font_title->get_y());
421 font->reposition_window(font->get_x(), font->get_y());
422 font_tumbler->reposition_window(font_tumbler->get_x(), font_tumbler->get_y());
423 x_title->reposition_window(x_title->get_x(), x_title->get_y());
424 title_x->reposition_window(title_x->get_x(), title_x->get_y());
425 y_title->reposition_window(y_title->get_x(), y_title->get_y());
426 title_y->reposition_window(title_y->get_x(), title_y->get_y());
427 w_title->reposition_window(w_title->get_x(), w_title->get_y());
428 title_w->reposition_window(title_w->get_x(), title_w->get_y());
429 h_title->reposition_window(h_title->get_x(), h_title->get_y());
430 title_h->reposition_window(title_h->get_x(), title_h->get_y());
431 style_title->reposition_window(style_title->get_x(), style_title->get_y());
432 italic->reposition_window(italic->get_x(), italic->get_y());
433 bold->reposition_window(bold->get_x(), bold->get_y());
434 drag->reposition_window(drag->get_x(), drag->get_y());
435 size_title->reposition_window(size_title->get_x(), size_title->get_y());
436 size->reposition_window(size->get_x(), size->get_y());
437 size_tumbler->reposition_window(size_tumbler->get_x(), size_tumbler->get_y());
438 pitch_title->reposition_window(pitch_title->get_x(), pitch_title->get_y());
439 pitch->reposition_window(pitch->get_x(), pitch->get_y());
441 color_button->reposition_window(color_button->get_x(), color_button->get_y());
442 outline_color_button->reposition_window(outline_color_button->get_x(), outline_color_button->get_y());
443 motion_title->reposition_window(motion_title->get_x(), motion_title->get_y());
444 motion->reposition_window(motion->get_x(), motion->get_y());
445 loop->reposition_window(loop->get_x(), loop->get_y());
446 dropshadow_title->reposition_window(dropshadow_title->get_x(), dropshadow_title->get_y());
447 dropshadow->reposition_window(dropshadow->get_x(), dropshadow->get_y());
448 fadein_title->reposition_window(fadein_title->get_x(), fadein_title->get_y());
449 fade_in->reposition_window(fade_in->get_x(), fade_in->get_y());
450 fadeout_title->reposition_window(fadeout_title->get_x(), fadeout_title->get_y());
451 fade_out->reposition_window(fade_out->get_x(), fade_out->get_y());
452 text_title->reposition_window(text_title->get_x(), text_title->get_y());
453 timecode->reposition_window(timecode->get_x(), timecode->get_y());
454 text->reposition_window(text->get_x(), text->get_y(), w - text->get_x() - 10,
455 BC_TextBox::pixels_to_rows(this, MEDIUMFONT, h - text->get_y() - 10));
456 justify_title->reposition_window(justify_title->get_x(), justify_title->get_y());
457 left->reposition_window(left->get_x(), left->get_y());
458 center->reposition_window(center->get_x(), center->get_y());
459 right->reposition_window(right->get_x(), right->get_y());
460 top->reposition_window(top->get_x(), top->get_y());
461 mid->reposition_window(mid->get_x(), mid->get_y());
462 bottom->reposition_window(bottom->get_x(), bottom->get_y());
463 speed_title->reposition_window(speed_title->get_x(), speed_title->get_y());
464 speed->reposition_window(speed->get_x(), speed->get_y());
471 int TitleWindow::grab_event(XEvent *event)
473 switch( event->type ) {
474 case ButtonPress: break;
475 case ButtonRelease: break;
476 case MotionNotify: break;
480 MWindow *mwindow = client->server->mwindow;
481 CWindowGUI *cwindow_gui = mwindow->cwindow->gui;
482 CWindowCanvas *canvas = cwindow_gui->canvas;
483 int cx, cy; cwindow_gui->get_relative_cursor_xy(cx, cy);
484 cx -= mwindow->theme->ccanvas_x;
485 cy -= mwindow->theme->ccanvas_y;
488 if( cx < 0 || cx >= mwindow->theme->ccanvas_w ) return 0;
489 if( cy < 0 || cy >= mwindow->theme->ccanvas_h ) return 0;
492 switch( event->type ) {
494 if( !dragging ) break;
497 if( !dragging ) return 0;
501 if( !dragging ) return 0;
507 float cursor_x = cx, cursor_y = cy;
508 canvas->canvas_to_output(mwindow->edl, 0, cursor_x, cursor_y);
509 int64_t position = client->get_source_position();
510 float projector_x, projector_y, projector_z;
511 Track *track = client->server->plugin->track;
512 int track_w = track->track_w, track_h = track->track_h;
513 track->automation->get_projector(
514 &projector_x, &projector_y, &projector_z,
515 position, PLAY_FORWARD);
516 projector_x += mwindow->edl->session->output_w / 2;
517 projector_y += mwindow->edl->session->output_h / 2;
518 cursor_x = (cursor_x - projector_x) / projector_z + track_w / 2;
519 cursor_y = (cursor_y - projector_y) / projector_z + track_h / 2;
520 int title_x = client->config.title_x, title_y = client->config.title_y;
521 int title_w = client->config.title_w, title_h = client->config.title_h;
522 if( !title_w ) title_w = track_w;
523 if( !title_h ) title_h = track_h;
524 int r = MIN(track_w, track_h)/100 + 2;
525 int x0 = title_x, x1 = title_x+(title_w+1)/2, x2 = title_x+title_w;
526 int y0 = title_y, y1 = title_y+(title_h+1)/2, y2 = title_y+title_h;
527 int drag_dx = 0, drag_dy = 0;
528 if( !dragging ) { // clockwise
529 if( abs(drag_dx = cursor_x-x0) < r && // x0,y0
530 abs(drag_dy = cursor_y-y0) < r ) dragging = 1;
531 else if( abs(drag_dx = cursor_x-x1) < r && // x1,y0
532 abs(drag_dy = cursor_y-y0) < r ) dragging = 2;
533 else if( abs(drag_dx = cursor_x-x2) < r && // x2,y0
534 abs(drag_dy = cursor_y-y0) < r ) dragging = 3;
535 else if( abs(drag_dx = cursor_x-x2) < r && // x2,y1
536 abs(drag_dy = cursor_y-y1) < r ) dragging = 4;
537 else if( abs(drag_dx = cursor_x-x2) < r && // x2,y2
538 abs(drag_dy = cursor_y-y2) < r ) dragging = 5;
539 else if( abs(drag_dx = cursor_x-x1) < r && // x1,y2
540 abs(drag_dy = cursor_y-y2) < r ) dragging = 6;
541 else if( abs(drag_dx = cursor_x-x0) < r && // x0,y2
542 abs(drag_dy = cursor_y-y2) < r ) dragging = 7;
543 else if( abs(drag_dx = cursor_x-x0) < r && // x0,y1
544 abs(drag_dy = cursor_y-y1) < r ) dragging = 8;
545 else if( abs(drag_dx = cursor_x-x1) < r && // x1,y1
546 abs(drag_dy = cursor_y-y1) < r ) dragging = 9;
551 int cur_x = cursor_x - drag_dx, dx = cur_x - x0;
552 int cur_y = cursor_y - drag_dy, dy = cur_y - y0;
553 if( !dx && !dy ) return 1;
554 int cur_w = title_w - dx; if( cur_w < 1 ) cur_w = 1;
555 int cur_h = title_h - dy; if( cur_h < 1 ) cur_h = 1;
556 this->title_x->update((int64_t)(client->config.title_x = cur_x));
557 this->title_y->update((int64_t)(client->config.title_y = cur_y));
558 this->title_w->update((int64_t)(client->config.title_w = cur_w));
559 this->title_h->update((int64_t)(client->config.title_h = cur_h));
562 int cur_y = cursor_y - drag_dy, dy = cur_y - y0;
564 int cur_h = title_h - dy; if( cur_h < 1 ) cur_h = 1;
565 this->title_y->update((int64_t)(client->config.title_y = cur_y));
566 this->title_h->update((int64_t)(client->config.title_h = cur_h));
569 int cur_x = cursor_x - drag_dx, dx = cur_x - x2;
570 int cur_y = cursor_y - drag_dy, dy = cur_y - y0;
571 int cur_w = title_w + dx; if( cur_w < 1 ) cur_w = 1;
572 int cur_h = title_h - dy; if( cur_h < 1 ) cur_h = 1;
573 this->title_w->update((int64_t)(client->config.title_w = cur_w));
574 this->title_y->update((int64_t)(client->config.title_y = cur_y));
575 this->title_h->update((int64_t)(client->config.title_h = cur_h));
578 int cur_x = cursor_x - drag_dx, dx = cur_x - x2;
580 int cur_w = title_w + dx; if( cur_w < 1 ) cur_w = 1;
581 this->title_w->update((int64_t)(client->config.title_w = cur_w));
584 int cur_x = cursor_x - drag_dx, dx = cur_x - x2;
585 int cur_y = cursor_y - drag_dy, dy = cur_y - y2;
586 int cur_w = title_w + dx; if( cur_w < 1 ) cur_w = 1;
587 int cur_h = title_h + dy; if( cur_h < 1 ) cur_h = 1;
588 this->title_w->update((int64_t)(client->config.title_w = cur_w));
589 this->title_h->update((int64_t)(client->config.title_h = cur_h));
592 int cur_y = cursor_y - drag_dy, dy = cur_y - y2;
593 if( client->config.title_h == cur_y ) return 1;
594 int cur_h = title_h + dy; if( cur_h < 1 ) cur_h = 1;
595 this->title_h->update((int64_t)(client->config.title_h = cur_h));
598 int cur_x = cursor_x - drag_dx, dx = cur_x - x0;
599 int cur_y = cursor_y - drag_dy, dy = cur_y - y2;
600 int cur_w = title_w - dx; if( cur_w < 1 ) cur_w = 1;
601 int cur_h = title_h + dy; if( cur_h < 1 ) cur_h = 1;
602 this->title_x->update((int64_t)(client->config.title_x = cur_x));
603 this->title_w->update((int64_t)(client->config.title_w = cur_w));
604 this->title_h->update((int64_t)(client->config.title_h = cur_h));
607 int cur_x = cursor_x - drag_dx, dx = cur_x - x0;
609 int cur_w = title_w - dx; if( cur_w < 1 ) cur_w = 1;
610 this->title_x->update((int64_t)(client->config.title_x = cur_x));
611 this->title_w->update((int64_t)(client->config.title_w = cur_w));
614 int cur_x = cursor_x - drag_dx, dx = cur_x - x1;
615 int cur_y = cursor_y - drag_dy, dy = cur_y - y1;
616 if( title_x == cur_x && title_y == cur_y ) return 1;
617 this->title_x->update((int64_t)(client->config.title_x += dx));
618 this->title_y->update((int64_t)(client->config.title_y += dy));
621 client->send_configure_change();
625 void TitleWindow::previous_font()
627 int current_font = font->get_number();
629 if( current_font < 0 ) current_font = fonts.total - 1;
631 if( current_font < 0 || current_font >= fonts.total ) return;
633 for( int i=0; i<fonts.total; ++i ) {
634 fonts.values[i]->set_selected(i == current_font);
637 font->update(fonts.values[current_font]->get_text());
638 strcpy(client->config.font, fonts.values[current_font]->get_text());
639 check_style(client->config.font,1);
640 client->send_configure_change();
643 void TitleWindow::next_font()
645 int current_font = font->get_number();
647 if( current_font >= fonts.total ) current_font = 0;
649 if( current_font < 0 || current_font >= fonts.total ) return;
651 for( int i=0; i<fonts.total; ++i ) {
652 fonts.values[i]->set_selected(i == current_font);
655 font->update(fonts.values[current_font]->get_text());
656 strcpy(client->config.font, fonts.values[current_font]->get_text());
657 check_style(client->config.font,1);
658 client->send_configure_change();
661 int TitleWindow::insert_ibeam(const char *txt, int ofs)
663 int ibeam = cur_ibeam;
664 int ilen = strlen(txt)+1;
666 int len = BC_Resources::encode(client->config.encoding, BC_Resources::wide_encoding,
667 (char*)txt,ilen, (char *)wtxt,ilen*sizeof(wtxt[0])) / sizeof(wchar_t);
668 client->insert_text(wtxt, ibeam);
669 while( len > 0 && !wtxt[len] ) --len;
670 int adv = len+1 + ofs;
671 if( (ibeam += adv) >= client->config.wlen)
672 ibeam = client->config.wlen;
673 text->wset_selection(-1, -1, ibeam);
674 text->update(client->config.wtext);
675 client->send_configure_change();
679 void TitleWindow::update_color()
681 //printf("TitleWindow::update_color %x\n", client->config.color);
682 set_color(client->config.color);
683 draw_box(color_x, color_y, COLOR_W, COLOR_H);
684 flash(color_x, color_y, COLOR_W, COLOR_H);
685 set_color(client->config.outline_color);
686 draw_box(outline_color_x, outline_color_y, COLOR_W, COLOR_H);
688 draw_rectangle(color_x, color_y, COLOR_W, COLOR_H);
689 draw_rectangle(outline_color_x, outline_color_y, COLOR_W, COLOR_H);
690 flash(outline_color_x, outline_color_y, COLOR_W, COLOR_H);
693 void TitleWindow::update_justification()
695 left->update(client->config.hjustification == JUSTIFY_LEFT);
696 center->update(client->config.hjustification == JUSTIFY_CENTER);
697 right->update(client->config.hjustification == JUSTIFY_RIGHT);
698 top->update(client->config.vjustification == JUSTIFY_TOP);
699 mid->update(client->config.vjustification == JUSTIFY_MID);
700 bottom->update(client->config.vjustification == JUSTIFY_BOTTOM);
703 void TitleWindow::update_stats()
705 text_chars->update(client->config.wlen);
706 int len = MESSAGESIZE - BCTEXTLEN - strlen(text->get_text()) - 1;
707 if( len < 0 ) len = 0;
708 text_bfrsz->update(len);
711 void TitleWindow::update()
713 title_x->update((int64_t)client->config.title_x);
714 title_y->update((int64_t)client->config.title_y);
715 title_w->update((int64_t)client->config.title_w);
716 title_h->update((int64_t)client->config.title_h);
717 italic->update(client->config.style & BC_FONT_ITALIC);
718 bold->update(client->config.style & BC_FONT_BOLD);
719 size->update(client->config.size);
720 motion->update(TitleMain::motion_to_text(client->config.motion_strategy));
721 loop->update(client->config.loop);
722 dropshadow->update((int64_t)client->config.dropshadow);
723 fade_in->update((float)client->config.fade_in);
724 fade_out->update((float)client->config.fade_out);
725 font->update(client->config.font);
726 check_style(client->config.font,0);
727 text->update(&client->config.wtext[0]);
728 speed->update(client->config.pixels_per_second);
729 outline->update((int64_t)client->config.outline_size);
731 stroker->update((int64_t)client->config.stroke_width);
733 timecode->update(client->config.timecode);
734 timecode_format->update(client->config.timecode_format);
735 background->update(client->config.background);
736 background_path->update(client->config.background_path);
737 loop_playback->update((int64_t)client->config.loop_playback);
739 char string[BCTEXTLEN];
740 for( int i=0; i<lengthof(timeunit_formats); ++i ) {
741 if( timeunit_formats[i] == client->config.timecode_format ) {
742 timecode_format->set_text(
743 Units::print_time_format(timeunit_formats[i], string));
747 update_justification();
753 TitleFontTumble::TitleFontTumble(TitleMain *client, TitleWindow *window, int x, int y)
756 this->client = client;
757 this->window = window;
759 int TitleFontTumble::handle_up_event()
761 window->previous_font();
765 int TitleFontTumble::handle_down_event()
773 TitleSizeTumble::TitleSizeTumble(TitleMain *client, TitleWindow *window, int x, int y)
776 this->client = client;
777 this->window = window;
780 int TitleSizeTumble::handle_up_event()
782 int current_index = -1;
783 int current_difference = -1;
784 for( int i=0; i<window->sizes.size(); ++i ) {
785 int size = atoi(window->sizes.get(i)->get_text());
786 if( current_index < 0 ||
787 abs(size - client->config.size) < current_difference ) {
789 current_difference = abs(size - client->config.size);
794 if( current_index >= window->sizes.size() ) current_index = 0;
797 client->config.size = atoi(window->sizes.get(current_index)->get_text());
798 window->size->update(client->config.size);
799 client->send_configure_change();
803 int TitleSizeTumble::handle_down_event()
805 int current_index = -1;
806 int current_difference = -1;
807 for( int i=0; i<window->sizes.size(); ++i ) {
808 int size = atoi(window->sizes.get(i)->get_text());
809 if( current_index < 0 ||
810 abs(size - client->config.size) < current_difference ) {
812 current_difference = abs(size - client->config.size);
817 if( current_index < 0 ) current_index = window->sizes.size() - 1;
820 client->config.size = atoi(window->sizes.get(current_index)->get_text());
821 window->size->update(client->config.size);
822 client->send_configure_change();
826 TitleBold::TitleBold(TitleMain *client, TitleWindow *window, int x, int y)
827 : BC_CheckBox(x, y, client->config.style & BC_FONT_BOLD, _("Bold"))
829 this->client = client;
830 this->window = window;
833 int TitleBold::handle_event()
835 client->config.style =
836 (client->config.style & ~BC_FONT_BOLD) |
837 (get_value() ? BC_FONT_BOLD : 0);
838 client->send_configure_change();
842 TitleItalic::TitleItalic(TitleMain *client, TitleWindow *window, int x, int y)
843 : BC_CheckBox(x, y, client->config.style & BC_FONT_ITALIC, _("Italic"))
845 this->client = client;
846 this->window = window;
848 int TitleItalic::handle_event()
850 client->config.style =
851 (client->config.style & ~BC_FONT_ITALIC) |
852 (get_value() ? BC_FONT_ITALIC : 0);
853 client->send_configure_change();
859 TitleSize::TitleSize(TitleMain *client, TitleWindow *window, int x, int y, char *text)
860 : BC_PopupTextBox(window, &window->sizes, text, x, y, 64, 300)
862 this->client = client;
863 this->window = window;
865 TitleSize::~TitleSize()
868 int TitleSize::handle_event()
870 client->config.size = atol(get_text());
871 //printf("TitleSize::handle_event 1 %s\n", get_text());
872 client->send_configure_change();
875 void TitleSize::update(int size)
877 char string[BCTEXTLEN];
878 sprintf(string, "%d", size);
879 BC_PopupTextBox::update(string);
883 TitlePitch(TitleMain *client, TitleWindow *window, int x, int y, int *value)
884 : BC_TumbleTextBox(window, *value, 0, INT_MAX, x, y, 64)
886 this->client = client;
887 this->window = window;
896 int TitlePitch::handle_event()
898 *value = atol(get_text());
899 client->send_configure_change();
903 TitleColorButton::TitleColorButton(TitleMain *client, TitleWindow *window, int x, int y)
904 : BC_GenericButton(x, y, _("Text Color..."))
906 this->client = client;
907 this->window = window;
909 int TitleColorButton::handle_event()
911 window->color_thread->start_window(client->config.color,
912 client->config.alpha);
915 TitleOutlineColorButton::TitleOutlineColorButton(TitleMain *client, TitleWindow *window, int x, int y)
916 : BC_GenericButton(x, y, _("Outline color..."))
918 this->client = client;
919 this->window = window;
921 int TitleOutlineColorButton::handle_event()
923 window->outline_color_thread->start_window(client->config.outline_color,
924 client->config.outline_alpha);
929 TitleMotion::TitleMotion(TitleMain *client, TitleWindow *window, int x, int y)
930 : BC_PopupTextBox(window, &window->paths,
931 client->motion_to_text(client->config.motion_strategy),
934 this->client = client;
935 this->window = window;
937 int TitleMotion::handle_event()
939 client->config.motion_strategy = client->text_to_motion(get_text());
940 client->send_configure_change();
944 TitleLoop::TitleLoop(TitleMain *client, int x, int y)
945 : BC_CheckBox(x, y, client->config.loop, _("Loop"))
947 this->client = client;
949 int TitleLoop::handle_event()
951 client->config.loop = get_value();
952 client->send_configure_change();
955 TitleTimecode::TitleTimecode(TitleMain *client, int x, int y)
956 : BC_CheckBox(x, y, client->config.timecode, _("Stamp timecode"))
958 this->client = client;
960 int TitleTimecode::handle_event()
962 client->config.timecode = get_value();
963 client->send_configure_change();
967 TitleTimecodeFormat::TitleTimecodeFormat(TitleMain *client, int x, int y, const char *text)
968 : BC_PopupMenu(x, y, 100, text, 1)
970 this->client = client;
973 int TitleTimecodeFormat::handle_event()
975 client->config.timecode_format = Units::text_to_format(get_text());
976 client->send_configure_change();
980 void TitleTimecodeFormat::create_objects()
982 char string[BCTEXTLEN];
983 for( int i=0; i<lengthof(timeunit_formats); ++i ) {
984 add_item(new BC_MenuItem(
985 Units::print_time_format(timeunit_formats[i], string)));
990 int TitleTimecodeFormat::update(int timecode_format)
992 char string[BCTEXTLEN];
993 for( int i=0; i<lengthof(timeunit_formats); ++i ) {
994 if( timeunit_formats[i] == timecode_format ) {
995 set_text(Units::print_time_format(timeunit_formats[i], string));
1002 TitleFade::TitleFade(TitleMain *client, TitleWindow *window,
1003 double *value, int x, int y)
1004 : BC_TextBox(x, y, 80, 1, (float)*value)
1006 this->client = client;
1007 this->window = window;
1008 this->value = value;
1012 int TitleFade::handle_event()
1014 *value = atof(get_text());
1015 client->send_configure_change();
1019 void TitleWindow::check_style(const char *font_name, int update)
1021 BC_FontEntry *font_nrm = TitleMain::get_font(font_name, 0);
1022 BC_FontEntry *font_itl = TitleMain::get_font(font_name, BC_FONT_ITALIC);
1023 BC_FontEntry *font_bld = TitleMain::get_font(font_name, BC_FONT_BOLD);
1024 BC_FontEntry *font_bit = TitleMain::get_font(font_name, BC_FONT_ITALIC | BC_FONT_BOLD);
1025 int has_norm = font_nrm != 0 ? 1 : 0;
1026 int has_ital = font_itl != 0 || font_bit != 0 ? 1 : 0;
1027 int has_bold = font_bld != 0 || font_bit != 0 ? 1 : 0;
1028 if( bold->get_value() ) {
1029 if( !has_bold ) bold->update(0);
1032 if( !has_norm && has_bold ) bold->update(1);
1034 if( italic->get_value() ) {
1035 if( !has_ital ) italic->update(0);
1038 if( !has_norm && has_ital ) italic->update(1);
1040 if( has_norm && has_bold ) bold->enable(); else bold->disable();
1041 if( has_norm && has_ital ) italic->enable(); else italic->disable();
1043 int style = stroker && atof(stroker->get_text()) ? BC_FONT_OUTLINE : 0;
1044 if( bold->get_value() ) style |= BC_FONT_BOLD;
1045 if( italic->get_value() ) style |= BC_FONT_ITALIC;
1046 client->config.style = style;
1050 TitleFont::TitleFont(TitleMain *client, TitleWindow *window, int x, int y)
1051 : BC_PopupTextBox(window, &window->fonts, client->config.font,
1052 x, y, 240, 300, LISTBOX_ICON_LIST)
1054 this->client = client;
1055 this->window = window;
1057 int TitleFont::handle_event()
1059 strcpy(client->config.font, get_text());
1060 window->check_style(client->config.font, 1);
1061 client->send_configure_change();
1065 TitleText::TitleText(TitleMain *client, TitleWindow *window,
1066 int x, int y, int w, int h)
1067 : BC_ScrollTextBox(window, x, y, w,
1068 BC_TextBox::pixels_to_rows(window, MEDIUMFONT, h),
1069 client->config.wtext, 8192)
1071 this->client = client;
1072 this->window = window;
1073 //printf("TitleText::TitleText %s\n", client->config.text);
1076 int TitleText::button_press_event()
1078 if( get_buttonpress() == 3 ) {
1079 window->cur_ibeam = get_ibeam_letter();
1080 window->cur_popup->activate_menu();
1083 return BC_ScrollTextBox::button_press_event();
1086 int TitleText::handle_event()
1088 window->fonts_popup->deactivate();
1089 int text_len = strlen(get_text());
1090 int avail = MESSAGESIZE - BCTEXTLEN;
1091 if( text_len >= avail ) { // back off last utf8 char
1092 char text[2*sizeof(client->config.wtext)];
1093 strcpy(text, get_text());
1095 while( text_len > 0 && (text[text_len-1] & 0xc0) == 0x80 )
1096 text[--text_len] = 0;
1098 text[--text_len] = 0;
1101 int len = sizeof(client->config.wtext) / sizeof(wchar_t);
1102 wcsncpy(client->config.wtext, get_wtext(), len);
1103 client->config.wtext[len-1] = 0;
1104 client->config.wlen = wcslen(client->config.wtext);
1105 window->update_stats();
1106 client->send_configure_change();
1109 TitleTextChars::TitleTextChars(int x, int y, int w)
1110 : BC_Title(x, y, "", MEDIUMFONT, -1, 0, w)
1113 TitleTextChars::~TitleTextChars()
1116 int TitleTextChars::update(int n)
1118 char text[BCSTRLEN];
1119 sprintf(text, _("chars: %d "),n);
1120 return BC_Title::update(text, 0);
1123 TitleTextBfrSz::TitleTextBfrSz(int x, int y, int w)
1124 : BC_Title(x, y, "", MEDIUMFONT, -1, 0, w)
1127 TitleTextBfrSz::~TitleTextBfrSz()
1130 int TitleTextBfrSz::update(int n)
1132 char text[BCSTRLEN];
1133 sprintf(text, _("bfrsz: %d "),n);
1134 return BC_Title::update(text, 0);
1138 TitleDropShadow::TitleDropShadow(TitleMain *client, TitleWindow *window, int x, int y)
1139 : BC_TumbleTextBox(window, (int64_t)client->config.dropshadow,
1140 (int64_t)-1000, (int64_t)1000, x, y, 70)
1142 this->client = client;
1143 this->window = window;
1145 int TitleDropShadow::handle_event()
1147 client->config.dropshadow = atol(get_text());
1148 client->send_configure_change();
1153 TitleOutline::TitleOutline(TitleMain *client, TitleWindow *window, int x, int y)
1154 : BC_TumbleTextBox(window, (int64_t)client->config.outline_size,
1155 (int64_t)0, (int64_t)1000, x, y, 70)
1157 this->client = client;
1158 this->window = window;
1160 int TitleOutline::handle_event()
1162 client->config.outline_size = atol(get_text());
1163 client->send_configure_change();
1168 TitleStroker::TitleStroker(TitleMain *client, TitleWindow *window, int x, int y)
1169 : BC_TumbleTextBox(window, (int64_t)client->config.stroke_width,
1170 (int64_t)0, (int64_t)1000, x, y, 70)
1172 this->client = client;
1173 this->window = window;
1175 int TitleStroker::handle_event()
1177 client->config.stroke_width = atof(get_text());
1178 if( client->config.stroke_width )
1179 client->config.style |= BC_FONT_OUTLINE;
1181 client->config.style &= ~BC_FONT_OUTLINE;
1182 client->send_configure_change();
1187 TitleX::TitleX(TitleMain *client, TitleWindow *window, int x, int y)
1188 : BC_TumbleTextBox(window, (int64_t)client->config.title_x,
1189 (int64_t)-32767, (int64_t)32767, x, y, 50)
1191 this->client = client;
1192 this->window = window;
1194 int TitleX::handle_event()
1196 client->config.title_x = atol(get_text());
1197 client->send_configure_change();
1201 TitleY::TitleY(TitleMain *client, TitleWindow *window, int x, int y)
1202 : BC_TumbleTextBox(window, (int64_t)client->config.title_y,
1203 (int64_t)-32767, (int64_t)32767, x, y, 50)
1205 this->client = client;
1206 this->window = window;
1208 int TitleY::handle_event()
1210 client->config.title_y = atol(get_text());
1211 client->send_configure_change();
1215 TitleW::TitleW(TitleMain *client, TitleWindow *window, int x, int y)
1216 : BC_TumbleTextBox(window, (int64_t)client->config.title_w,
1217 (int64_t)0, (int64_t)32767, x, y, 50)
1219 this->client = client;
1220 this->window = window;
1222 int TitleW::handle_event()
1224 client->config.title_w = atol(get_text());
1225 client->send_configure_change();
1229 TitleH::TitleH(TitleMain *client, TitleWindow *window, int x, int y)
1230 : BC_TumbleTextBox(window, (int64_t)client->config.title_h,
1231 (int64_t)0, (int64_t)32767, x, y, 50)
1233 this->client = client;
1234 this->window = window;
1236 int TitleH::handle_event()
1238 client->config.title_h = atol(get_text());
1239 client->send_configure_change();
1243 TitleSpeed::TitleSpeed(TitleMain *client, TitleWindow *window, int x, int y)
1244 : BC_TumbleTextBox(window, (float)client->config.pixels_per_second,
1245 (float)0, (float)1000, x, y, 100)
1247 this->client = client;
1253 int TitleSpeed::handle_event()
1255 client->config.pixels_per_second = atof(get_text());
1256 client->send_configure_change();
1261 TitleLeft::TitleLeft(TitleMain *client, TitleWindow *window, int x, int y)
1262 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_LEFT, _("Left"))
1264 this->client = client;
1265 this->window = window;
1267 int TitleLeft::handle_event()
1269 client->config.hjustification = JUSTIFY_LEFT;
1270 window->update_justification();
1271 client->send_configure_change();
1275 TitleCenter::TitleCenter(TitleMain *client, TitleWindow *window, int x, int y)
1276 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_CENTER, _("Center"))
1278 this->client = client;
1279 this->window = window;
1281 int TitleCenter::handle_event()
1283 client->config.hjustification = JUSTIFY_CENTER;
1284 window->update_justification();
1285 client->send_configure_change();
1289 TitleRight::TitleRight(TitleMain *client, TitleWindow *window, int x, int y)
1290 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_RIGHT, _("Right"))
1292 this->client = client;
1293 this->window = window;
1295 int TitleRight::handle_event()
1297 client->config.hjustification = JUSTIFY_RIGHT;
1298 window->update_justification();
1299 client->send_configure_change();
1305 TitleTop::TitleTop(TitleMain *client, TitleWindow *window, int x, int y)
1306 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_TOP, _("Top"))
1308 this->client = client;
1309 this->window = window;
1311 int TitleTop::handle_event()
1313 client->config.vjustification = JUSTIFY_TOP;
1314 window->update_justification();
1315 client->send_configure_change();
1319 TitleMid::TitleMid(TitleMain *client, TitleWindow *window, int x, int y)
1320 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_MID, _("Mid"))
1322 this->client = client;
1323 this->window = window;
1325 int TitleMid::handle_event()
1327 client->config.vjustification = JUSTIFY_MID;
1328 window->update_justification();
1329 client->send_configure_change();
1333 TitleBottom::TitleBottom(TitleMain *client, TitleWindow *window, int x, int y)
1334 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_BOTTOM, _("Bottom"))
1336 this->client = client;
1337 this->window = window;
1339 int TitleBottom::handle_event()
1341 client->config.vjustification = JUSTIFY_BOTTOM;
1342 window->update_justification();
1343 client->send_configure_change();
1349 TitleColorThread::TitleColorThread(TitleMain *client, TitleWindow *window, int is_outline)
1350 : ColorPicker(1, is_outline? _("Outline Color") : _("Text Color"))
1352 this->client = client;
1353 this->window = window;
1354 this->is_outline = is_outline;
1357 int TitleColorThread::handle_new_color(int output, int alpha)
1360 client->config.outline_color = output;
1361 client->config.outline_alpha = alpha;
1364 client->config.color = output;
1365 client->config.alpha = alpha;
1368 window->lock_window("TitleColorThread::handle_new_color");
1369 window->update_color();
1371 window->unlock_window();
1373 client->send_configure_change();
1377 TitleDrag::TitleDrag(TitleMain *client, TitleWindow *window, int x, int y)
1378 : BC_CheckBox(x, y, client->config.drag, _("Drag"))
1380 this->client = client;
1381 this->window = window;
1384 int TitleDrag::handle_event()
1386 int value = get_value();
1387 CWindowGUI *cwindow_gui = client->server->mwindow->cwindow->gui;
1389 if( !window->grab(cwindow_gui) ) {
1395 window->ungrab(cwindow_gui);
1396 client->config.drag = value;
1397 client->send_configure_change();
1401 TitleBackground::TitleBackground(TitleMain *client, TitleWindow *window, int x, int y)
1402 : BC_CheckBox(x, y, client->config.background, _("Background:"))
1404 this->client = client;
1405 this->window = window;
1408 int TitleBackground::handle_event()
1410 client->config.background = get_value();
1411 client->send_configure_change();
1415 TitleBackgroundPath::TitleBackgroundPath(TitleMain *client, TitleWindow *window, int x, int y)
1416 : BC_TextBox(x, y, 240, 1, client->config.background_path)
1418 this->client = client;
1419 this->window = window;
1422 int TitleBackgroundPath::handle_event()
1424 strncpy(client->config.background_path, get_text(), sizeof(client->config.background_path));
1425 client->send_configure_change();
1429 TitleLoopPlayback::TitleLoopPlayback(TitleMain *client, int x, int y)
1430 : BC_CheckBox(x, y, client->config.loop_playback, _("Loop playback"))
1432 this->client = client;
1434 int TitleLoopPlayback::handle_event()
1436 client->config.loop_playback = get_value();
1437 client->send_configure_change();
1442 TitleCurPopup::TitleCurPopup(TitleMain *client, TitleWindow *window)
1443 : BC_PopupMenu(0, 0, 0, "", 0)
1445 this->client = client;
1446 this->window = window;
1448 int TitleCurPopup::handle_event()
1453 void TitleCurSubMenu::add_subitemx(int popup_type, va_list ap, const char *fmt)
1455 char item[BCSTRLEN];
1456 vsnprintf(item, sizeof(item)-1, fmt, ap);
1457 item[sizeof(item)-1] = 0;
1458 add_submenuitem(new TitleCurSubMenuItem(this, item, popup_type));
1461 void TitleCurPopup::create_objects()
1463 TitleCurItem *cur_item;
1464 TitleCurSubMenu *sub_menu;
1466 add_item(cur_item = new TitleCurItem(this, item = KW_NUDGE));
1467 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1468 sub_menu->add_subitem("%s dx,dy",item);
1469 sub_menu->add_subitem("/%s",item);
1470 add_item(cur_item = new TitleCurItem(this, item = KW_COLOR));
1471 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1472 sub_menu->add_subitem(POPUP_COLOR,"%s %s",item,_("#"));
1473 sub_menu->add_subitem("%s ",item);
1474 sub_menu->add_subitem("/%s",item);
1475 add_item(cur_item = new TitleCurItem(this, item = KW_ALPHA));
1476 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1477 sub_menu->add_subitem("%s ",item);
1478 sub_menu->add_subitem("%s 0.",item);
1479 sub_menu->add_subitem("%s .5",item);
1480 sub_menu->add_subitem("%s 1.",item);
1481 sub_menu->add_subitem("/%s",item);
1482 add_item(cur_item = new TitleCurItem(this, item = KW_FONT));
1483 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1484 sub_menu->add_subitem(POPUP_FONT,"%s %s",item, _("name"));
1485 sub_menu->add_subitem(POPUP_OFFSET, "%s ",item);
1486 sub_menu->add_subitem("/%s",item);
1487 add_item(cur_item = new TitleCurItem(this, item = KW_SIZE));
1488 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1489 sub_menu->add_subitem("%s +",item);
1490 sub_menu->add_subitem("%s -",item);
1491 sub_menu->add_subitem("%s ",item);
1492 sub_menu->add_subitem("/%s",item);
1493 add_item(cur_item = new TitleCurItem(this, item = KW_BOLD));
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",item);
1498 add_item(cur_item = new TitleCurItem(this, item = KW_ITALIC));
1499 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1500 sub_menu->add_subitem("%s 1",item);
1501 sub_menu->add_subitem("%s 0",item);
1502 sub_menu->add_subitem("/%s",item);
1503 add_item(cur_item = new TitleCurItem(this, item = KW_CAPS));
1504 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1505 sub_menu->add_subitem("%s 1",item);
1506 sub_menu->add_subitem("%s 0",item);
1507 sub_menu->add_subitem("%s -1",item);
1508 sub_menu->add_subitem("/%s",item);
1509 add_item(cur_item = new TitleCurItem(this, item = KW_UL));
1510 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1511 sub_menu->add_subitem("%s 1",item);
1512 sub_menu->add_subitem("%s 0",item);
1513 sub_menu->add_subitem("/%s",item);
1514 add_item(cur_item = new TitleCurItem(this, item = KW_BLINK));
1515 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1516 sub_menu->add_subitem("%s 1",item);
1517 sub_menu->add_subitem("%s -1",item);
1518 sub_menu->add_subitem("%s ",item);
1519 sub_menu->add_subitem("%s 0",item);
1520 sub_menu->add_subitem("/%s",item);
1521 add_item(cur_item = new TitleCurItem(this, item = KW_FIXED));
1522 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1523 sub_menu->add_subitem("%s ",item);
1524 sub_menu->add_subitem("%s 20",item);
1525 sub_menu->add_subitem("%s 10",item);
1526 sub_menu->add_subitem("%s 0",item);
1527 sub_menu->add_subitem("/%s",item);
1528 add_item(cur_item = new TitleCurItem(this, item = KW_SUP));
1529 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1530 sub_menu->add_subitem("%s 1",item);
1531 sub_menu->add_subitem("%s 0",item);
1532 sub_menu->add_subitem("%s -1",item);
1533 sub_menu->add_subitem("/%s",item);
1534 add_item(cur_item = new TitleCurItem(this, item = KW_PNG));
1535 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1536 sub_menu->add_subitem(POPUP_PNG,"%s %s", item, _("file"));
1539 TitleCurItem::TitleCurItem(TitleCurPopup *popup, const char *text)
1542 this->popup = popup;
1544 int TitleCurItem::handle_event()
1549 TitleCurSubMenu::TitleCurSubMenu(TitleCurItem *cur_item)
1551 this->cur_item = cur_item;
1553 TitleCurSubMenu::~TitleCurSubMenu()
1557 TitleCurSubMenuItem::TitleCurSubMenuItem(TitleCurSubMenu *submenu, const char *text, int popup_type)
1560 this->submenu = submenu;
1561 this->popup_type = popup_type;
1563 TitleCurSubMenuItem::~TitleCurSubMenuItem()
1566 int TitleCurSubMenuItem::handle_event()
1568 TitleCurPopup *popup = submenu->cur_item->popup;
1569 TitleWindow *window = popup->window;
1570 const char *item_text = get_text();
1571 int ofs = *item_text == '/' ? 0 : -1;
1572 switch( popup_type ) {
1575 window->get_pop_cursor_xy(px ,py);
1576 window->fonts_popup->activate(px, py, 300,200);
1579 window->color_popup->activate();
1582 window->png_popup->activate();
1589 sprintf(txt, "<%s>", item_text);
1590 return window->insert_ibeam(txt, ofs);
1593 TitleFontsPopup::TitleFontsPopup(TitleMain *client, TitleWindow *window)
1594 : BC_ListBox(-1, -1, 1, 1, LISTBOX_ICON_LIST,
1595 &window->fonts, 0, 0, 1, 0, 1)
1597 this->client = client;
1598 this->window = window;
1602 TitleFontsPopup::~TitleFontsPopup()
1605 int TitleFontsPopup::keypress_event()
1607 switch( get_keypress() ) {
1615 return BC_ListBox::keypress_event();
1618 int TitleFontsPopup::handle_event()
1621 BC_ListBoxItem *item = get_selection(0, 0);
1622 if( !item ) return 1;
1623 const char *item_text = item->get_text();
1624 char txt[BCTEXTLEN]; sprintf(txt, "<%s %s>", KW_FONT, item_text);
1625 return window->insert_ibeam(txt);
1628 TitleColorPopup::TitleColorPopup(TitleMain *client, TitleWindow *window)
1629 : ColorPicker(0, _("Color"))
1631 this->client = client;
1632 this->window = window;
1633 this->color_value = client->config.color;
1635 TitleColorPopup::~TitleColorPopup()
1638 int TitleColorPopup::handle_new_color(int output, int alpha)
1640 color_value = output;
1643 int TitleColorPopup::activate()
1645 start_window(client->config.color, 255, 1);
1648 void TitleColorPopup::handle_done_event(int result)
1650 if( result ) return;
1651 char txt[BCSTRLEN]; sprintf(txt, "<%s #%06x>", KW_COLOR, color_value);
1652 window->insert_ibeam(txt);
1655 TitlePngPopup::TitlePngPopup(TitleMain *client, TitleWindow *window)
1658 this->client = client;
1659 this->window = window;
1662 TitlePngPopup::~TitlePngPopup()
1667 void TitlePngPopup::handle_done_event(int result)
1669 if( result ) return;
1670 BrowseButtonWindow *gui = (BrowseButtonWindow *)get_gui();
1671 const char *path = gui->get_submitted_path();
1672 char txt[BCSTRLEN]; sprintf(txt, "<%s %s>", KW_PNG, path);
1673 window->insert_ibeam(txt);
1676 BC_Window *TitlePngPopup::new_gui()
1678 MWindow *mwindow = client->server->mwindow;
1679 int x, y; mwindow->gui->get_abs_cursor_xy(x, y);
1681 BC_Window *gui = new BrowseButtonWindow(mwindow->theme,
1682 x-25, y-100, window, "", _("Png file"), _("Png path"), 0);
1683 gui->create_objects();
1687 int TitlePngPopup::activate()
1689 BC_DialogThread::start();