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;
121 void TitleWindow::done_event(int result)
123 ungrab(client->server->mwindow->cwindow->gui);
124 color_thread->close_window();
125 outline_color_thread->close_window();
126 color_popup->close_window();
127 png_popup->close_window();
130 TitleWindow::~TitleWindow()
134 for( int i=0; i<fonts.size(); ++i )
135 delete fonts[i]->get_icon();
137 sizes.remove_all_objects();
138 delete timecode_format;
144 void TitleWindow::create_objects()
147 int margin = client->get_theme()->widget_border;
148 char string[BCTEXTLEN];
152 client->build_previews(this);
154 sizes.append(new BC_ListBoxItem("8"));
155 sizes.append(new BC_ListBoxItem("9"));
156 sizes.append(new BC_ListBoxItem("10"));
157 sizes.append(new BC_ListBoxItem("11"));
158 sizes.append(new BC_ListBoxItem("12"));
159 sizes.append(new BC_ListBoxItem("13"));
160 sizes.append(new BC_ListBoxItem("14"));
161 sizes.append(new BC_ListBoxItem("16"));
162 sizes.append(new BC_ListBoxItem("18"));
163 sizes.append(new BC_ListBoxItem("20"));
164 sizes.append(new BC_ListBoxItem("22"));
165 sizes.append(new BC_ListBoxItem("24"));
166 sizes.append(new BC_ListBoxItem("26"));
167 sizes.append(new BC_ListBoxItem("28"));
168 sizes.append(new BC_ListBoxItem("32"));
169 sizes.append(new BC_ListBoxItem("36"));
170 sizes.append(new BC_ListBoxItem("40"));
171 sizes.append(new BC_ListBoxItem("48"));
172 sizes.append(new BC_ListBoxItem("56"));
173 sizes.append(new BC_ListBoxItem("64"));
174 sizes.append(new BC_ListBoxItem("72"));
175 sizes.append(new BC_ListBoxItem("100"));
176 sizes.append(new BC_ListBoxItem("128"));
177 sizes.append(new BC_ListBoxItem("256"));
178 sizes.append(new BC_ListBoxItem("512"));
179 sizes.append(new BC_ListBoxItem("1024"));
181 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(NO_MOTION)));
182 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(BOTTOM_TO_TOP)));
183 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(TOP_TO_BOTTOM)));
184 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(RIGHT_TO_LEFT)));
185 paths.append(new BC_ListBoxItem(TitleMain::motion_to_text(LEFT_TO_RIGHT)));
189 // Construct font list
190 ArrayList<BC_FontEntry*> *fontlist = get_resources()->fontlist;
192 for( int i=0; i<fontlist->size(); ++i ) {
194 for( int j=0; j<fonts.size(); ++j ) {
195 if( !strcasecmp(fonts.get(j)->get_text(),
196 fontlist->get(i)->displayname) ) {
202 BC_ListBoxItem *item = 0;
204 fonts.append(item = new
205 BC_ListBoxItem(fontlist->get(i)->displayname));
206 if( !strcmp(client->config.font, item->get_text()) )
207 item->set_selected(1);
208 if( fontlist->values[i]->image ) {
209 VFrame *vframe = fontlist->get(i)->image;
210 BC_Pixmap *icon = new BC_Pixmap(this, vframe, PIXMAP_ALPHA);
211 item->set_icon(icon);
212 item->set_icon_vframe(vframe);
221 for( int i=0; i<fonts.size()-1; ++i ) {
222 if( strcmp(fonts.values[i]->get_text(),
223 fonts.values[i + 1]->get_text()) > 0 ) {
224 BC_ListBoxItem *temp = fonts.values[i + 1];
225 fonts.values[i + 1] = fonts.values[i];
226 fonts.values[i] = temp;
232 add_tool(font_title = new BC_Title(x, y, _("Font:")));
233 font = new TitleFont(client, this, x, y + font_title->get_h());
234 font->create_objects();
235 font->set_show_query(1);
237 add_subwindow(font_tumbler = new TitleFontTumble(client, this, x, y+margin));
238 x += font_tumbler->get_w() + margin;
241 add_tool(size_title = new BC_Title(x1, y1+margin, _("Size:")));
242 sprintf(string, "%.2f", client->config.size);
243 x1 += size_title->get_w() + margin;
244 size = new TitleSize(client, this, x1, y1+margin, string);
245 size->create_objects();
246 int x2 = x1 + size->get_w(), y2 = y1 + size->get_h() + margin;
247 add_subwindow(size_tumbler = new TitleSizeTumble(client, this, x2, y1+margin));
249 add_tool(pitch_title = new BC_Title(x-5, y2+margin, _("Pitch:")));
250 pitch = new TitlePitch(client, this, x1, y2+margin, &client->config.line_pitch);
251 pitch->create_objects();
253 int x3 = x2 + size_tumbler->get_w() + 50;
254 int y3 = pitch->get_y() + pitch->get_h();
256 add_tool(style_title = new BC_Title(x=x3, y, _("Style:")));
257 add_tool(italic = new TitleItalic(client, this, x, y + 20));
258 int w1 = italic->get_w();
259 add_tool(bold = new TitleBold(client, this, x, y + 50));
260 if( bold->get_w() > w1 ) w1 = bold->get_w();
262 add_tool(drag = new TitleDrag(client, this, x, y + 80));
263 if( drag->get_w() > w1 ) w1 = drag->get_w();
264 if( client->config.drag ) {
265 if( !grab(client->server->mwindow->cwindow->gui) )
266 eprintf("drag enabled, but compositor already grabbed\n");
270 add_tool(justify_title = new BC_Title(x, y, _("Justify:")));
271 add_tool(left = new TitleLeft(client, this, x, y + 20));
273 add_tool(center = new TitleCenter(client, this, x, y + 50));
274 if( center->get_w() > w1 ) w1 = center->get_w();
275 add_tool(right = new TitleRight(client, this, x, y + 80));
276 if( right->get_w() > w1 ) w1 = right->get_w();
279 add_tool(top = new TitleTop(client, this, x, y + 20));
280 add_tool(mid = new TitleMid(client, this, x, y + 50));
281 add_tool(bottom= new TitleBottom(client, this, x, y + 80));
286 w1 = BC_Title::calculate_w(this, _("X:"));
287 if( (x1 = BC_Title::calculate_w(this, _("Y:"))) > w1 ) w1 = x1;
288 if( (x1 = BC_Title::calculate_w(this, _("W:"))) > w1 ) w1 = x1;
289 if( (x1 = BC_Title::calculate_w(this, _("H:"))) > w1 ) w1 = x1;
290 add_tool(x_title = new BC_Title(x1=x, y, _("X:")));
292 title_x = new TitleX(client, this, x1, y);
293 title_x->create_objects();
294 x1 += title_x->get_w()+margin;
295 add_tool(y_title = new BC_Title(x1, y, _("Y:")));
297 title_y = new TitleY(client, this, x1, y);
298 title_y->create_objects();
299 x1 += title_y->get_w();
300 y1 = y + title_y->get_h();
302 add_tool(w_title = new BC_Title(x1=x, y1, _("W:")));
304 title_w = new TitleW(client, this, x1, y1);
305 title_w->create_objects();
306 x1 += title_w->get_w()+margin;
307 add_tool(h_title = new BC_Title(x1, y1, _("H:")));
309 title_h = new TitleH(client, this, x1, y1);
310 title_h->create_objects();
311 x1 += title_h->get_w();
314 add_tool(motion_title = new BC_Title(x1=x, y, _("Motion:")));
315 x1 += motion_title->get_w()+margin;
316 motion = new TitleMotion(client, this, x1, y);
317 motion->create_objects();
318 add_tool(loop = new TitleLoop(client, this, x, y1));
319 x = margin; y = y1 + loop->get_h()+20;
321 add_tool(dropshadow_title = new BC_Title(x, y, _("Drop shadow:")));
322 w1 = dropshadow_title->get_w();
323 dropshadow = new TitleDropShadow(client, this, x, y + 20);
324 dropshadow->create_objects();
325 if( dropshadow->get_w() > w1 ) w1 = dropshadow->get_w();
328 add_tool(fadein_title = new BC_Title(x, y, _("Fade in (sec):")));
329 w1 = fadein_title->get_w();
330 add_tool(fade_in = new TitleFade(client, this, &client->config.fade_in, x, y + 20));
331 if( fade_in->get_w() > w1 ) w1 = fade_in->get_w();
334 add_tool(fadeout_title = new BC_Title(x, y, _("Fade out (sec):")));
335 w1 = fadeout_title->get_w();
336 add_tool(fade_out = new TitleFade(client, this, &client->config.fade_out, x, y + 20));
337 if( fade_out->get_w() > w1 ) w1 = fade_out->get_w();
340 add_tool(speed_title = new BC_Title(x, y1=y, _("Speed:")));
341 w1 = speed_title->get_w();
342 y += speed_title->get_h() + 5;
343 speed = new TitleSpeed(client, this, x, y);
344 speed->create_objects();
345 if( speed->get_w() > w1 ) w1 = speed->get_w();
347 y2 = y + speed->get_h() + 10;
349 color_x = x3; color_y = y = y1;
350 color_thread = new TitleColorThread(client, this, 0);
351 x1 = color_x + COLOR_W + 2*margin;
353 add_tool(color_button = new TitleColorButton(client, this, x1, y1));
355 outline_color_x = x3; outline_color_y = y;
356 outline_color_thread = new TitleColorThread(client, this, 1);
357 y1 = outline_color_y + 5;
358 add_tool(outline_color_button = new TitleOutlineColorButton(client, this, x1, y1));
361 add_tool(outline_title = new BC_Title(x, y, _("Outline:")));
362 y1 = y + outline_title->get_h() + margin;
363 outline = new TitleOutline(client, this, x, y1);
364 outline->create_objects();
365 x += outline->get_w() + 2*margin;
367 add_tool(stroker_title = new BC_Title(x, y, _("Stroker:")));
368 stroker = new TitleStroker(client, this, x, y1);
369 stroker->create_objects();
370 x += stroker->get_w() + margin;
372 y += outline_title->get_h() + margin;
373 add_tool(timecode = new TitleTimecode(client, this, x1=x, y));
374 x += timecode->get_w() + margin;
375 add_tool(timecode_format = new TitleTimecodeFormat(client, this, x, y,
376 Units::print_time_format(client->config.timecode_format, string)));
377 timecode_format->create_objects();
378 y += timecode_format->get_h() + margin;
381 add_tool(background = new TitleBackground(client, this, x, y));
382 x += background->get_w() + margin;
383 add_tool(background_path = new TitleBackgroundPath(client, this, x, y));
384 x += background_path->get_w() + margin;
385 add_tool(background_browse = new BrowseButton(
386 client->server->mwindow->theme, this, background_path,
387 x, y, "", _("background media"), _("Select background media path")));
388 x += background_browse->get_w() + 3*margin;
389 add_tool(loop_playback = new TitleLoopPlayback(client, this, x, y));
390 y += loop_playback->get_h() + 10;
393 add_tool(text_title = new BC_Title(x, y, _("Text:")));
394 x += text_title->get_w() + 20;
395 int wid = BC_Title::calculate_w(this,"0")*10;
396 add_tool(text_chars = new TitleTextChars(x,y,wid));
397 x += text_chars->get_w() + 20;
398 add_tool(text_bfrsz = new TitleTextBfrSz(x,y,wid));
400 y += text_title->get_h() + margin;
402 text = new TitleText(client, this, x, y, get_w()-margin - x, get_h() - y - 10);
403 text->create_objects();
405 add_tool(cur_popup = new TitleCurPopup(client, this));
406 cur_popup->create_objects();
407 add_tool(fonts_popup = new TitleFontsPopup(client, this));
408 color_popup = new TitleColorPopup(client, this);
409 png_popup = new TitlePngPopup(client, this);
415 int TitleWindow::resize_event(int w, int h)
417 client->config.window_w = w;
418 client->config.window_h = h;
420 clear_box(0, 0, w, h);
421 font_title->reposition_window(font_title->get_x(), font_title->get_y());
422 font->reposition_window(font->get_x(), font->get_y());
423 font_tumbler->reposition_window(font_tumbler->get_x(), font_tumbler->get_y());
424 x_title->reposition_window(x_title->get_x(), x_title->get_y());
425 title_x->reposition_window(title_x->get_x(), title_x->get_y());
426 y_title->reposition_window(y_title->get_x(), y_title->get_y());
427 title_y->reposition_window(title_y->get_x(), title_y->get_y());
428 w_title->reposition_window(w_title->get_x(), w_title->get_y());
429 title_w->reposition_window(title_w->get_x(), title_w->get_y());
430 h_title->reposition_window(h_title->get_x(), h_title->get_y());
431 title_h->reposition_window(title_h->get_x(), title_h->get_y());
432 style_title->reposition_window(style_title->get_x(), style_title->get_y());
433 italic->reposition_window(italic->get_x(), italic->get_y());
434 bold->reposition_window(bold->get_x(), bold->get_y());
435 drag->reposition_window(drag->get_x(), drag->get_y());
436 size_title->reposition_window(size_title->get_x(), size_title->get_y());
437 size->reposition_window(size->get_x(), size->get_y());
438 size_tumbler->reposition_window(size_tumbler->get_x(), size_tumbler->get_y());
439 pitch_title->reposition_window(pitch_title->get_x(), pitch_title->get_y());
440 pitch->reposition_window(pitch->get_x(), pitch->get_y());
442 color_button->reposition_window(color_button->get_x(), color_button->get_y());
443 outline_color_button->reposition_window(outline_color_button->get_x(), outline_color_button->get_y());
444 motion_title->reposition_window(motion_title->get_x(), motion_title->get_y());
445 motion->reposition_window(motion->get_x(), motion->get_y());
446 loop->reposition_window(loop->get_x(), loop->get_y());
447 dropshadow_title->reposition_window(dropshadow_title->get_x(), dropshadow_title->get_y());
448 dropshadow->reposition_window(dropshadow->get_x(), dropshadow->get_y());
449 fadein_title->reposition_window(fadein_title->get_x(), fadein_title->get_y());
450 fade_in->reposition_window(fade_in->get_x(), fade_in->get_y());
451 fadeout_title->reposition_window(fadeout_title->get_x(), fadeout_title->get_y());
452 fade_out->reposition_window(fade_out->get_x(), fade_out->get_y());
453 text_title->reposition_window(text_title->get_x(), text_title->get_y());
454 timecode->reposition_window(timecode->get_x(), timecode->get_y());
455 text->reposition_window(text->get_x(), text->get_y(), w - text->get_x() - 10,
456 BC_TextBox::pixels_to_rows(this, MEDIUMFONT, h - text->get_y() - 10));
457 justify_title->reposition_window(justify_title->get_x(), justify_title->get_y());
458 left->reposition_window(left->get_x(), left->get_y());
459 center->reposition_window(center->get_x(), center->get_y());
460 right->reposition_window(right->get_x(), right->get_y());
461 top->reposition_window(top->get_x(), top->get_y());
462 mid->reposition_window(mid->get_x(), mid->get_y());
463 bottom->reposition_window(bottom->get_x(), bottom->get_y());
464 speed_title->reposition_window(speed_title->get_x(), speed_title->get_y());
465 speed->reposition_window(speed->get_x(), speed->get_y());
472 void TitleWindow::send_configure_change()
475 client->send_configure_change();
477 int TitleWindow::check_configure_change(int ret)
479 if( pending_config && !grab_event_count() )
480 send_configure_change();
484 int TitleWindow::grab_event(XEvent *event)
486 switch( event->type ) {
487 case ButtonPress: break;
488 case ButtonRelease: break;
489 case MotionNotify: break;
491 return check_configure_change(0);
494 MWindow *mwindow = client->server->mwindow;
495 CWindowGUI *cwindow_gui = mwindow->cwindow->gui;
496 CWindowCanvas *canvas = cwindow_gui->canvas;
497 int cx, cy; cwindow_gui->get_relative_cursor(cx, cy);
498 cx -= mwindow->theme->ccanvas_x;
499 cy -= mwindow->theme->ccanvas_y;
502 if( cx < 0 || cx >= mwindow->theme->ccanvas_w ||
503 cy < 0 || cy >= mwindow->theme->ccanvas_h )
504 return check_configure_change(0);
507 switch( event->type ) {
509 if( !dragging ) break;
512 if( !dragging ) return check_configure_change(0);
516 if( !dragging ) return check_configure_change(0);
519 return check_configure_change(0);
522 float cursor_x = cx, cursor_y = cy;
523 canvas->canvas_to_output(mwindow->edl, 0, cursor_x, cursor_y);
524 int64_t position = client->get_source_position();
525 float projector_x, projector_y, projector_z;
526 Track *track = client->server->plugin->track;
527 int track_w = track->track_w, track_h = track->track_h;
528 track->automation->get_projector(
529 &projector_x, &projector_y, &projector_z,
530 position, PLAY_FORWARD);
531 projector_x += mwindow->edl->session->output_w / 2;
532 projector_y += mwindow->edl->session->output_h / 2;
533 cursor_x = (cursor_x - projector_x) / projector_z + track_w / 2;
534 cursor_y = (cursor_y - projector_y) / projector_z + track_h / 2;
535 int title_x = client->config.title_x, title_y = client->config.title_y;
536 int title_w = client->config.title_w, title_h = client->config.title_h;
537 if( !title_w ) title_w = track_w;
538 if( !title_h ) title_h = track_h;
539 int r = MIN(track_w, track_h)/100 + 2;
540 int x0 = title_x, x1 = title_x+(title_w+1)/2, x2 = title_x+title_w;
541 int y0 = title_y, y1 = title_y+(title_h+1)/2, y2 = title_y+title_h;
542 int drag_dx = 0, drag_dy = 0;
543 if( !dragging ) { // clockwise
544 if( abs(drag_dx = cursor_x-x0) < r && // x0,y0
545 abs(drag_dy = cursor_y-y0) < r ) dragging = 1;
546 else if( abs(drag_dx = cursor_x-x1) < r && // x1,y0
547 abs(drag_dy = cursor_y-y0) < r ) dragging = 2;
548 else if( abs(drag_dx = cursor_x-x2) < r && // x2,y0
549 abs(drag_dy = cursor_y-y0) < r ) dragging = 3;
550 else if( abs(drag_dx = cursor_x-x2) < r && // x2,y1
551 abs(drag_dy = cursor_y-y1) < r ) dragging = 4;
552 else if( abs(drag_dx = cursor_x-x2) < r && // x2,y2
553 abs(drag_dy = cursor_y-y2) < r ) dragging = 5;
554 else if( abs(drag_dx = cursor_x-x1) < r && // x1,y2
555 abs(drag_dy = cursor_y-y2) < r ) dragging = 6;
556 else if( abs(drag_dx = cursor_x-x0) < r && // x0,y2
557 abs(drag_dy = cursor_y-y2) < r ) dragging = 7;
558 else if( abs(drag_dx = cursor_x-x0) < r && // x0,y1
559 abs(drag_dy = cursor_y-y1) < r ) dragging = 8;
560 else if( abs(drag_dx = cursor_x-x1) < r && // x1,y1
561 abs(drag_dy = cursor_y-y1) < r ) dragging = 9;
566 int cur_x = cursor_x - drag_dx, dx = cur_x - x0;
567 int cur_y = cursor_y - drag_dy, dy = cur_y - y0;
568 if( !dx && !dy ) return 1;
569 int cur_w = title_w - dx; if( cur_w < 1 ) cur_w = 1;
570 int cur_h = title_h - dy; if( cur_h < 1 ) cur_h = 1;
571 this->title_x->update((int64_t)(client->config.title_x = cur_x));
572 this->title_y->update((int64_t)(client->config.title_y = cur_y));
573 this->title_w->update((int64_t)(client->config.title_w = cur_w));
574 this->title_h->update((int64_t)(client->config.title_h = cur_h));
577 int cur_y = cursor_y - drag_dy, dy = cur_y - y0;
579 int cur_h = title_h - dy; if( cur_h < 1 ) cur_h = 1;
580 this->title_y->update((int64_t)(client->config.title_y = cur_y));
581 this->title_h->update((int64_t)(client->config.title_h = cur_h));
584 int cur_x = cursor_x - drag_dx, dx = cur_x - x2;
585 int cur_y = cursor_y - drag_dy, dy = cur_y - y0;
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_y->update((int64_t)(client->config.title_y = cur_y));
590 this->title_h->update((int64_t)(client->config.title_h = cur_h));
593 int cur_x = cursor_x - drag_dx, dx = cur_x - x2;
595 int cur_w = title_w + dx; if( cur_w < 1 ) cur_w = 1;
596 this->title_w->update((int64_t)(client->config.title_w = cur_w));
599 int cur_x = cursor_x - drag_dx, dx = cur_x - x2;
600 int cur_y = cursor_y - drag_dy, dy = cur_y - y2;
601 int cur_w = title_w + dx; if( cur_w < 1 ) cur_w = 1;
602 int cur_h = title_h + dy; if( cur_h < 1 ) cur_h = 1;
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_y = cursor_y - drag_dy, dy = cur_y - y2;
608 if( client->config.title_h == cur_y ) return 1;
609 int cur_h = title_h + dy; if( cur_h < 1 ) cur_h = 1;
610 this->title_h->update((int64_t)(client->config.title_h = cur_h));
613 int cur_x = cursor_x - drag_dx, dx = cur_x - x0;
614 int cur_y = cursor_y - drag_dy, dy = cur_y - y2;
615 int cur_w = title_w - dx; if( cur_w < 1 ) cur_w = 1;
616 int cur_h = title_h + dy; if( cur_h < 1 ) cur_h = 1;
617 this->title_x->update((int64_t)(client->config.title_x = cur_x));
618 this->title_w->update((int64_t)(client->config.title_w = cur_w));
619 this->title_h->update((int64_t)(client->config.title_h = cur_h));
622 int cur_x = cursor_x - drag_dx, dx = cur_x - x0;
624 int cur_w = title_w - dx; if( cur_w < 1 ) cur_w = 1;
625 this->title_x->update((int64_t)(client->config.title_x = cur_x));
626 this->title_w->update((int64_t)(client->config.title_w = cur_w));
629 int cur_x = cursor_x - drag_dx, dx = cur_x - x1;
630 int cur_y = cursor_y - drag_dy, dy = cur_y - y1;
631 if( title_x == cur_x && title_y == cur_y ) return 1;
632 this->title_x->update((int64_t)(client->config.title_x += dx));
633 this->title_y->update((int64_t)(client->config.title_y += dy));
636 if( !grab_event_count() )
637 send_configure_change();
643 void TitleWindow::previous_font()
645 int current_font = font->get_number();
647 if( current_font < 0 ) current_font = fonts.total - 1;
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 send_configure_change();
661 void TitleWindow::next_font()
663 int current_font = font->get_number();
665 if( current_font >= fonts.total ) current_font = 0;
667 if( current_font < 0 || current_font >= fonts.total ) return;
669 for( int i=0; i<fonts.total; ++i ) {
670 fonts.values[i]->set_selected(i == current_font);
673 font->update(fonts.values[current_font]->get_text());
674 strcpy(client->config.font, fonts.values[current_font]->get_text());
675 check_style(client->config.font,1);
676 send_configure_change();
679 int TitleWindow::insert_ibeam(const char *txt, int ofs)
681 int ibeam = cur_ibeam;
682 int ilen = strlen(txt)+1;
684 int len = BC_Resources::encode(client->config.encoding, BC_Resources::wide_encoding,
685 (char*)txt,ilen, (char *)wtxt,ilen*sizeof(wtxt[0])) / sizeof(wchar_t);
686 client->insert_text(wtxt, ibeam);
687 while( len > 0 && !wtxt[len] ) --len;
688 int adv = len+1 + ofs;
689 if( (ibeam += adv) >= client->config.wlen)
690 ibeam = client->config.wlen;
691 text->wset_selection(-1, -1, ibeam);
692 text->update(client->config.wtext);
693 send_configure_change();
697 void TitleWindow::update_color()
699 //printf("TitleWindow::update_color %x\n", client->config.color);
700 set_color(client->config.color);
701 draw_box(color_x, color_y, COLOR_W, COLOR_H);
702 flash(color_x, color_y, COLOR_W, COLOR_H);
703 set_color(client->config.outline_color);
704 draw_box(outline_color_x, outline_color_y, COLOR_W, COLOR_H);
706 draw_rectangle(color_x, color_y, COLOR_W, COLOR_H);
707 draw_rectangle(outline_color_x, outline_color_y, COLOR_W, COLOR_H);
708 flash(outline_color_x, outline_color_y, COLOR_W, COLOR_H);
711 void TitleWindow::update_justification()
713 left->update(client->config.hjustification == JUSTIFY_LEFT);
714 center->update(client->config.hjustification == JUSTIFY_CENTER);
715 right->update(client->config.hjustification == JUSTIFY_RIGHT);
716 top->update(client->config.vjustification == JUSTIFY_TOP);
717 mid->update(client->config.vjustification == JUSTIFY_MID);
718 bottom->update(client->config.vjustification == JUSTIFY_BOTTOM);
721 void TitleWindow::update_stats()
723 text_chars->update(client->config.wlen);
724 int len = MESSAGESIZE - BCTEXTLEN - strlen(text->get_text()) - 1;
725 if( len < 0 ) len = 0;
726 text_bfrsz->update(len);
729 void TitleWindow::update()
731 title_x->update((int64_t)client->config.title_x);
732 title_y->update((int64_t)client->config.title_y);
733 title_w->update((int64_t)client->config.title_w);
734 title_h->update((int64_t)client->config.title_h);
735 italic->update(client->config.style & BC_FONT_ITALIC);
736 bold->update(client->config.style & BC_FONT_BOLD);
737 size->update(client->config.size);
738 motion->update(TitleMain::motion_to_text(client->config.motion_strategy));
739 loop->update(client->config.loop);
740 dropshadow->update((int64_t)client->config.dropshadow);
741 fade_in->update((float)client->config.fade_in);
742 fade_out->update((float)client->config.fade_out);
743 font->update(client->config.font);
744 check_style(client->config.font,0);
745 text->update(&client->config.wtext[0]);
746 speed->update(client->config.pixels_per_second);
747 outline->update((int64_t)client->config.outline_size);
749 stroker->update((int64_t)client->config.stroke_width);
751 timecode->update(client->config.timecode);
752 timecode_format->update(client->config.timecode_format);
753 background->update(client->config.background);
754 background_path->update(client->config.background_path);
755 loop_playback->update((int64_t)client->config.loop_playback);
757 char string[BCTEXTLEN];
758 for( int i=0; i<lengthof(timeunit_formats); ++i ) {
759 if( timeunit_formats[i] == client->config.timecode_format ) {
760 timecode_format->set_text(
761 Units::print_time_format(timeunit_formats[i], string));
765 update_justification();
771 TitleFontTumble::TitleFontTumble(TitleMain *client, TitleWindow *window, int x, int y)
774 this->client = client;
775 this->window = window;
777 int TitleFontTumble::handle_up_event()
779 window->previous_font();
783 int TitleFontTumble::handle_down_event()
791 TitleSizeTumble::TitleSizeTumble(TitleMain *client, TitleWindow *window, int x, int y)
794 this->client = client;
795 this->window = window;
798 int TitleSizeTumble::handle_up_event()
800 int current_index = -1;
801 int current_difference = -1;
802 for( int i=0; i<window->sizes.size(); ++i ) {
803 int size = atoi(window->sizes.get(i)->get_text());
804 if( current_index < 0 ||
805 abs(size - client->config.size) < current_difference ) {
807 current_difference = abs(size - client->config.size);
812 if( current_index >= window->sizes.size() ) current_index = 0;
815 client->config.size = atoi(window->sizes.get(current_index)->get_text());
816 window->size->update(client->config.size);
817 window->send_configure_change();
821 int TitleSizeTumble::handle_down_event()
823 int current_index = -1;
824 int current_difference = -1;
825 for( int i=0; i<window->sizes.size(); ++i ) {
826 int size = atoi(window->sizes.get(i)->get_text());
827 if( current_index < 0 ||
828 abs(size - client->config.size) < current_difference ) {
830 current_difference = abs(size - client->config.size);
835 if( current_index < 0 ) current_index = window->sizes.size() - 1;
838 client->config.size = atoi(window->sizes.get(current_index)->get_text());
839 window->size->update(client->config.size);
840 window->send_configure_change();
844 TitleBold::TitleBold(TitleMain *client, TitleWindow *window, int x, int y)
845 : BC_CheckBox(x, y, client->config.style & BC_FONT_BOLD, _("Bold"))
847 this->client = client;
848 this->window = window;
851 int TitleBold::handle_event()
853 client->config.style =
854 (client->config.style & ~BC_FONT_BOLD) |
855 (get_value() ? BC_FONT_BOLD : 0);
856 window->send_configure_change();
860 TitleItalic::TitleItalic(TitleMain *client, TitleWindow *window, int x, int y)
861 : BC_CheckBox(x, y, client->config.style & BC_FONT_ITALIC, _("Italic"))
863 this->client = client;
864 this->window = window;
866 int TitleItalic::handle_event()
868 client->config.style =
869 (client->config.style & ~BC_FONT_ITALIC) |
870 (get_value() ? BC_FONT_ITALIC : 0);
871 window->send_configure_change();
877 TitleSize::TitleSize(TitleMain *client, TitleWindow *window, int x, int y, char *text)
878 : BC_PopupTextBox(window, &window->sizes, text, x, y, 64, 300)
880 this->client = client;
881 this->window = window;
883 TitleSize::~TitleSize()
886 int TitleSize::handle_event()
888 client->config.size = atol(get_text());
889 //printf("TitleSize::handle_event 1 %s\n", get_text());
890 window->send_configure_change();
893 void TitleSize::update(int size)
895 char string[BCTEXTLEN];
896 sprintf(string, "%d", size);
897 BC_PopupTextBox::update(string);
901 TitlePitch(TitleMain *client, TitleWindow *window, int x, int y, int *value)
902 : BC_TumbleTextBox(window, *value, 0, INT_MAX, x, y, 64)
904 this->client = client;
905 this->window = window;
914 int TitlePitch::handle_event()
916 *value = atol(get_text());
917 window->send_configure_change();
921 TitleColorButton::TitleColorButton(TitleMain *client, TitleWindow *window, int x, int y)
922 : BC_GenericButton(x, y, _("Text Color..."))
924 this->client = client;
925 this->window = window;
927 int TitleColorButton::handle_event()
929 window->color_thread->start_window(client->config.color,
930 client->config.alpha);
933 TitleOutlineColorButton::TitleOutlineColorButton(TitleMain *client, TitleWindow *window, int x, int y)
934 : BC_GenericButton(x, y, _("Outline color..."))
936 this->client = client;
937 this->window = window;
939 int TitleOutlineColorButton::handle_event()
941 window->outline_color_thread->start_window(client->config.outline_color,
942 client->config.outline_alpha);
947 TitleMotion::TitleMotion(TitleMain *client, TitleWindow *window, int x, int y)
948 : BC_PopupTextBox(window, &window->paths,
949 client->motion_to_text(client->config.motion_strategy),
952 this->client = client;
953 this->window = window;
955 int TitleMotion::handle_event()
957 client->config.motion_strategy = client->text_to_motion(get_text());
958 window->send_configure_change();
962 TitleLoop::TitleLoop(TitleMain *client, TitleWindow *window, int x, int y)
963 : BC_CheckBox(x, y, client->config.loop, _("Loop"))
965 this->client = client;
966 this->window = window;
968 int TitleLoop::handle_event()
970 client->config.loop = get_value();
971 window->send_configure_change();
974 TitleTimecode::TitleTimecode(TitleMain *client, TitleWindow *window, int x, int y)
975 : BC_CheckBox(x, y, client->config.timecode, _("Stamp timecode"))
977 this->client = client;
978 this->window = window;
980 int TitleTimecode::handle_event()
982 client->config.timecode = get_value();
983 client->send_configure_change();
987 TitleTimecodeFormat::TitleTimecodeFormat(TitleMain *client, TitleWindow *window,
988 int x, int y, const char *text)
989 : BC_PopupMenu(x, y, 100, text, 1)
991 this->client = client;
992 this->window = window;
995 int TitleTimecodeFormat::handle_event()
997 client->config.timecode_format = Units::text_to_format(get_text());
998 window->send_configure_change();
1002 void TitleTimecodeFormat::create_objects()
1004 char string[BCTEXTLEN];
1005 for( int i=0; i<lengthof(timeunit_formats); ++i ) {
1006 add_item(new BC_MenuItem(
1007 Units::print_time_format(timeunit_formats[i], string)));
1012 int TitleTimecodeFormat::update(int timecode_format)
1014 char string[BCTEXTLEN];
1015 for( int i=0; i<lengthof(timeunit_formats); ++i ) {
1016 if( timeunit_formats[i] == timecode_format ) {
1017 set_text(Units::print_time_format(timeunit_formats[i], string));
1024 TitleFade::TitleFade(TitleMain *client, TitleWindow *window,
1025 double *value, int x, int y)
1026 : BC_TextBox(x, y, 80, 1, (float)*value)
1028 this->client = client;
1029 this->window = window;
1030 this->value = value;
1034 int TitleFade::handle_event()
1036 *value = atof(get_text());
1037 window->send_configure_change();
1041 void TitleWindow::check_style(const char *font_name, int update)
1043 BC_FontEntry *font_nrm = TitleMain::get_font(font_name, 0);
1044 BC_FontEntry *font_itl = TitleMain::get_font(font_name, BC_FONT_ITALIC);
1045 BC_FontEntry *font_bld = TitleMain::get_font(font_name, BC_FONT_BOLD);
1046 BC_FontEntry *font_bit = TitleMain::get_font(font_name, BC_FONT_ITALIC | BC_FONT_BOLD);
1047 int has_norm = font_nrm != 0 ? 1 : 0;
1048 int has_ital = font_itl != 0 || font_bit != 0 ? 1 : 0;
1049 int has_bold = font_bld != 0 || font_bit != 0 ? 1 : 0;
1050 if( bold->get_value() ) {
1051 if( !has_bold ) bold->update(0);
1054 if( !has_norm && has_bold ) bold->update(1);
1056 if( italic->get_value() ) {
1057 if( !has_ital ) italic->update(0);
1060 if( !has_norm && has_ital ) italic->update(1);
1062 if( has_norm && has_bold ) bold->enable(); else bold->disable();
1063 if( has_norm && has_ital ) italic->enable(); else italic->disable();
1065 int style = stroker && atof(stroker->get_text()) ? BC_FONT_OUTLINE : 0;
1066 if( bold->get_value() ) style |= BC_FONT_BOLD;
1067 if( italic->get_value() ) style |= BC_FONT_ITALIC;
1068 client->config.style = style;
1072 TitleFont::TitleFont(TitleMain *client, TitleWindow *window, int x, int y)
1073 : BC_PopupTextBox(window, &window->fonts, client->config.font,
1074 x, y, 240, 300, LISTBOX_ICON_LIST)
1076 this->client = client;
1077 this->window = window;
1079 int TitleFont::handle_event()
1081 strcpy(client->config.font, get_text());
1082 window->check_style(client->config.font, 1);
1083 window->send_configure_change();
1087 TitleText::TitleText(TitleMain *client, TitleWindow *window,
1088 int x, int y, int w, int h)
1089 : BC_ScrollTextBox(window, x, y, w,
1090 BC_TextBox::pixels_to_rows(window, MEDIUMFONT, h),
1091 client->config.wtext, 8192)
1093 this->client = client;
1094 this->window = window;
1095 //printf("TitleText::TitleText %s\n", client->config.text);
1098 int TitleText::button_press_event()
1100 if( get_buttonpress() == 3 ) {
1101 window->cur_ibeam = get_ibeam_letter();
1102 window->cur_popup->activate_menu();
1105 return BC_ScrollTextBox::button_press_event();
1108 int TitleText::handle_event()
1110 window->fonts_popup->deactivate();
1111 int text_len = strlen(get_text());
1112 int avail = MESSAGESIZE - BCTEXTLEN;
1113 if( text_len >= avail ) { // back off last utf8 char
1114 char text[2*sizeof(client->config.wtext)];
1115 strcpy(text, get_text());
1117 while( text_len > 0 && (text[text_len-1] & 0xc0) == 0x80 )
1118 text[--text_len] = 0;
1120 text[--text_len] = 0;
1123 int len = sizeof(client->config.wtext) / sizeof(wchar_t);
1124 wcsncpy(client->config.wtext, get_wtext(), len);
1125 client->config.wtext[len-1] = 0;
1126 client->config.wlen = wcslen(client->config.wtext);
1127 window->update_stats();
1128 window->send_configure_change();
1131 TitleTextChars::TitleTextChars(int x, int y, int w)
1132 : BC_Title(x, y, "", MEDIUMFONT, -1, 0, w)
1135 TitleTextChars::~TitleTextChars()
1138 int TitleTextChars::update(int n)
1140 char text[BCSTRLEN];
1141 sprintf(text, _("chars: %d "),n);
1142 return BC_Title::update(text, 0);
1145 TitleTextBfrSz::TitleTextBfrSz(int x, int y, int w)
1146 : BC_Title(x, y, "", MEDIUMFONT, -1, 0, w)
1149 TitleTextBfrSz::~TitleTextBfrSz()
1152 int TitleTextBfrSz::update(int n)
1154 char text[BCSTRLEN];
1155 sprintf(text, _("bfrsz: %d "),n);
1156 return BC_Title::update(text, 0);
1160 TitleDropShadow::TitleDropShadow(TitleMain *client, TitleWindow *window, int x, int y)
1161 : BC_TumbleTextBox(window, (int64_t)client->config.dropshadow,
1162 (int64_t)-1000, (int64_t)1000, x, y, 70)
1164 this->client = client;
1165 this->window = window;
1167 int TitleDropShadow::handle_event()
1169 client->config.dropshadow = atol(get_text());
1170 window->send_configure_change();
1175 TitleOutline::TitleOutline(TitleMain *client, TitleWindow *window, int x, int y)
1176 : BC_TumbleTextBox(window, (int64_t)client->config.outline_size,
1177 (int64_t)0, (int64_t)1000, x, y, 70)
1179 this->client = client;
1180 this->window = window;
1182 int TitleOutline::handle_event()
1184 client->config.outline_size = atol(get_text());
1185 window->send_configure_change();
1190 TitleStroker::TitleStroker(TitleMain *client, TitleWindow *window, int x, int y)
1191 : BC_TumbleTextBox(window, (int64_t)client->config.stroke_width,
1192 (int64_t)0, (int64_t)1000, x, y, 70)
1194 this->client = client;
1195 this->window = window;
1197 int TitleStroker::handle_event()
1199 client->config.stroke_width = atof(get_text());
1200 if( client->config.stroke_width )
1201 client->config.style |= BC_FONT_OUTLINE;
1203 client->config.style &= ~BC_FONT_OUTLINE;
1204 window->send_configure_change();
1209 TitleX::TitleX(TitleMain *client, TitleWindow *window, int x, int y)
1210 : BC_TumbleTextBox(window, (int64_t)client->config.title_x,
1211 (int64_t)-32767, (int64_t)32767, x, y, 50)
1213 this->client = client;
1214 this->window = window;
1216 int TitleX::handle_event()
1218 client->config.title_x = atol(get_text());
1219 window->send_configure_change();
1223 TitleY::TitleY(TitleMain *client, TitleWindow *window, int x, int y)
1224 : BC_TumbleTextBox(window, (int64_t)client->config.title_y,
1225 (int64_t)-32767, (int64_t)32767, x, y, 50)
1227 this->client = client;
1228 this->window = window;
1230 int TitleY::handle_event()
1232 client->config.title_y = atol(get_text());
1233 window->send_configure_change();
1237 TitleW::TitleW(TitleMain *client, TitleWindow *window, int x, int y)
1238 : BC_TumbleTextBox(window, (int64_t)client->config.title_w,
1239 (int64_t)0, (int64_t)32767, x, y, 50)
1241 this->client = client;
1242 this->window = window;
1244 int TitleW::handle_event()
1246 client->config.title_w = atol(get_text());
1247 window->send_configure_change();
1251 TitleH::TitleH(TitleMain *client, TitleWindow *window, int x, int y)
1252 : BC_TumbleTextBox(window, (int64_t)client->config.title_h,
1253 (int64_t)0, (int64_t)32767, x, y, 50)
1255 this->client = client;
1256 this->window = window;
1258 int TitleH::handle_event()
1260 client->config.title_h = atol(get_text());
1261 window->send_configure_change();
1265 TitleSpeed::TitleSpeed(TitleMain *client, TitleWindow *window, int x, int y)
1266 : BC_TumbleTextBox(window, (float)client->config.pixels_per_second,
1267 (float)0, (float)1000, x, y, 100)
1269 this->client = client;
1270 this->window = window;
1276 int TitleSpeed::handle_event()
1278 client->config.pixels_per_second = atof(get_text());
1279 window->send_configure_change();
1284 TitleLeft::TitleLeft(TitleMain *client, TitleWindow *window, int x, int y)
1285 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_LEFT, _("Left"))
1287 this->client = client;
1288 this->window = window;
1290 int TitleLeft::handle_event()
1292 client->config.hjustification = JUSTIFY_LEFT;
1293 window->update_justification();
1294 window->send_configure_change();
1298 TitleCenter::TitleCenter(TitleMain *client, TitleWindow *window, int x, int y)
1299 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_CENTER, _("Center"))
1301 this->client = client;
1302 this->window = window;
1304 int TitleCenter::handle_event()
1306 client->config.hjustification = JUSTIFY_CENTER;
1307 window->update_justification();
1308 window->send_configure_change();
1312 TitleRight::TitleRight(TitleMain *client, TitleWindow *window, int x, int y)
1313 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_RIGHT, _("Right"))
1315 this->client = client;
1316 this->window = window;
1318 int TitleRight::handle_event()
1320 client->config.hjustification = JUSTIFY_RIGHT;
1321 window->update_justification();
1322 window->send_configure_change();
1328 TitleTop::TitleTop(TitleMain *client, TitleWindow *window, int x, int y)
1329 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_TOP, _("Top"))
1331 this->client = client;
1332 this->window = window;
1334 int TitleTop::handle_event()
1336 client->config.vjustification = JUSTIFY_TOP;
1337 window->update_justification();
1338 window->send_configure_change();
1342 TitleMid::TitleMid(TitleMain *client, TitleWindow *window, int x, int y)
1343 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_MID, _("Mid"))
1345 this->client = client;
1346 this->window = window;
1348 int TitleMid::handle_event()
1350 client->config.vjustification = JUSTIFY_MID;
1351 window->update_justification();
1352 window->send_configure_change();
1356 TitleBottom::TitleBottom(TitleMain *client, TitleWindow *window, int x, int y)
1357 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_BOTTOM, _("Bottom"))
1359 this->client = client;
1360 this->window = window;
1362 int TitleBottom::handle_event()
1364 client->config.vjustification = JUSTIFY_BOTTOM;
1365 window->update_justification();
1366 window->send_configure_change();
1372 TitleColorThread::TitleColorThread(TitleMain *client, TitleWindow *window, int is_outline)
1373 : ColorPicker(1, is_outline? _("Outline Color") : _("Text Color"))
1375 this->client = client;
1376 this->window = window;
1377 this->is_outline = is_outline;
1380 int TitleColorThread::handle_new_color(int output, int alpha)
1383 client->config.outline_color = output;
1384 client->config.outline_alpha = alpha;
1387 client->config.color = output;
1388 client->config.alpha = alpha;
1391 window->lock_window("TitleColorThread::handle_new_color");
1392 window->update_color();
1394 window->unlock_window();
1396 window->send_configure_change();
1400 TitleDrag::TitleDrag(TitleMain *client, TitleWindow *window, int x, int y)
1401 : BC_CheckBox(x, y, client->config.drag, _("Drag"))
1403 this->client = client;
1404 this->window = window;
1407 int TitleDrag::handle_event()
1409 int value = get_value();
1410 CWindowGUI *cwindow_gui = client->server->mwindow->cwindow->gui;
1412 if( !window->grab(cwindow_gui) ) {
1418 window->ungrab(cwindow_gui);
1419 client->config.drag = value;
1420 window->send_configure_change();
1424 TitleBackground::TitleBackground(TitleMain *client, TitleWindow *window, int x, int y)
1425 : BC_CheckBox(x, y, client->config.background, _("Background:"))
1427 this->client = client;
1428 this->window = window;
1431 int TitleBackground::handle_event()
1433 client->config.background = get_value();
1434 window->send_configure_change();
1438 TitleBackgroundPath::TitleBackgroundPath(TitleMain *client, TitleWindow *window, int x, int y)
1439 : BC_TextBox(x, y, 240, 1, client->config.background_path)
1441 this->client = client;
1442 this->window = window;
1445 int TitleBackgroundPath::handle_event()
1447 strncpy(client->config.background_path, get_text(), sizeof(client->config.background_path));
1448 window->send_configure_change();
1452 TitleLoopPlayback::TitleLoopPlayback(TitleMain *client, TitleWindow *window, int x, int y)
1453 : BC_CheckBox(x, y, client->config.loop_playback, _("Loop playback"))
1455 this->client = client;
1456 this->window = window;
1458 int TitleLoopPlayback::handle_event()
1460 client->config.loop_playback = get_value();
1461 window->send_configure_change();
1466 TitleCurPopup::TitleCurPopup(TitleMain *client, TitleWindow *window)
1467 : BC_PopupMenu(0, 0, 0, "", 0)
1469 this->client = client;
1470 this->window = window;
1472 int TitleCurPopup::handle_event()
1477 void TitleCurSubMenu::add_subitemx(int popup_type, va_list ap, const char *fmt)
1479 char item[BCSTRLEN];
1480 vsnprintf(item, sizeof(item)-1, fmt, ap);
1481 item[sizeof(item)-1] = 0;
1482 add_submenuitem(new TitleCurSubMenuItem(this, item, popup_type));
1485 void TitleCurPopup::create_objects()
1487 TitleCurItem *cur_item;
1488 TitleCurSubMenu *sub_menu;
1490 add_item(cur_item = new TitleCurItem(this, item = KW_NUDGE));
1491 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1492 sub_menu->add_subitem("%s dx,dy",item);
1493 sub_menu->add_subitem("/%s",item);
1494 add_item(cur_item = new TitleCurItem(this, item = KW_COLOR));
1495 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1496 sub_menu->add_subitem(POPUP_COLOR,"%s %s",item,_("#"));
1497 sub_menu->add_subitem("%s ",item);
1498 sub_menu->add_subitem("/%s",item);
1499 add_item(cur_item = new TitleCurItem(this, item = KW_ALPHA));
1500 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1501 sub_menu->add_subitem("%s ",item);
1502 sub_menu->add_subitem("%s 0.",item);
1503 sub_menu->add_subitem("%s .5",item);
1504 sub_menu->add_subitem("%s 1.",item);
1505 sub_menu->add_subitem("/%s",item);
1506 add_item(cur_item = new TitleCurItem(this, item = KW_FONT));
1507 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1508 sub_menu->add_subitem(POPUP_FONT,"%s %s",item, _("name"));
1509 sub_menu->add_subitem(POPUP_OFFSET, "%s ",item);
1510 sub_menu->add_subitem("/%s",item);
1511 add_item(cur_item = new TitleCurItem(this, item = KW_SIZE));
1512 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1513 sub_menu->add_subitem("%s +",item);
1514 sub_menu->add_subitem("%s -",item);
1515 sub_menu->add_subitem("%s ",item);
1516 sub_menu->add_subitem("/%s",item);
1517 add_item(cur_item = new TitleCurItem(this, item = KW_BOLD));
1518 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1519 sub_menu->add_subitem("%s 1",item);
1520 sub_menu->add_subitem("%s 0",item);
1521 sub_menu->add_subitem("/%s",item);
1522 add_item(cur_item = new TitleCurItem(this, item = KW_ITALIC));
1523 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1524 sub_menu->add_subitem("%s 1",item);
1525 sub_menu->add_subitem("%s 0",item);
1526 sub_menu->add_subitem("/%s",item);
1527 add_item(cur_item = new TitleCurItem(this, item = KW_CAPS));
1528 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1529 sub_menu->add_subitem("%s 1",item);
1530 sub_menu->add_subitem("%s 0",item);
1531 sub_menu->add_subitem("%s -1",item);
1532 sub_menu->add_subitem("/%s",item);
1533 add_item(cur_item = new TitleCurItem(this, item = KW_UL));
1534 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1535 sub_menu->add_subitem("%s 1",item);
1536 sub_menu->add_subitem("%s 0",item);
1537 sub_menu->add_subitem("/%s",item);
1538 add_item(cur_item = new TitleCurItem(this, item = KW_BLINK));
1539 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1540 sub_menu->add_subitem("%s 1",item);
1541 sub_menu->add_subitem("%s -1",item);
1542 sub_menu->add_subitem("%s ",item);
1543 sub_menu->add_subitem("%s 0",item);
1544 sub_menu->add_subitem("/%s",item);
1545 add_item(cur_item = new TitleCurItem(this, item = KW_FIXED));
1546 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1547 sub_menu->add_subitem("%s ",item);
1548 sub_menu->add_subitem("%s 20",item);
1549 sub_menu->add_subitem("%s 10",item);
1550 sub_menu->add_subitem("%s 0",item);
1551 sub_menu->add_subitem("/%s",item);
1552 add_item(cur_item = new TitleCurItem(this, item = KW_SUP));
1553 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1554 sub_menu->add_subitem("%s 1",item);
1555 sub_menu->add_subitem("%s 0",item);
1556 sub_menu->add_subitem("%s -1",item);
1557 sub_menu->add_subitem("/%s",item);
1558 add_item(cur_item = new TitleCurItem(this, item = KW_PNG));
1559 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1560 sub_menu->add_subitem(POPUP_PNG,"%s %s", item, _("file"));
1563 TitleCurItem::TitleCurItem(TitleCurPopup *popup, const char *text)
1566 this->popup = popup;
1568 int TitleCurItem::handle_event()
1573 TitleCurSubMenu::TitleCurSubMenu(TitleCurItem *cur_item)
1575 this->cur_item = cur_item;
1577 TitleCurSubMenu::~TitleCurSubMenu()
1581 TitleCurSubMenuItem::TitleCurSubMenuItem(TitleCurSubMenu *submenu, const char *text, int popup_type)
1584 this->submenu = submenu;
1585 this->popup_type = popup_type;
1587 TitleCurSubMenuItem::~TitleCurSubMenuItem()
1590 int TitleCurSubMenuItem::handle_event()
1592 TitleCurPopup *popup = submenu->cur_item->popup;
1593 TitleWindow *window = popup->window;
1594 const char *item_text = get_text();
1595 int ofs = *item_text == '/' ? 0 : -1;
1596 switch( popup_type ) {
1599 window->get_pop_cursor(px ,py);
1600 window->fonts_popup->activate(px, py, 300,200);
1603 window->color_popup->activate();
1606 window->png_popup->activate();
1613 sprintf(txt, "<%s>", item_text);
1614 return window->insert_ibeam(txt, ofs);
1617 TitleFontsPopup::TitleFontsPopup(TitleMain *client, TitleWindow *window)
1618 : BC_ListBox(-1, -1, 1, 1, LISTBOX_ICON_LIST,
1619 &window->fonts, 0, 0, 1, 0, 1)
1621 this->client = client;
1622 this->window = window;
1626 TitleFontsPopup::~TitleFontsPopup()
1629 int TitleFontsPopup::keypress_event()
1631 switch( get_keypress() ) {
1639 return BC_ListBox::keypress_event();
1642 int TitleFontsPopup::handle_event()
1645 BC_ListBoxItem *item = get_selection(0, 0);
1646 if( !item ) return 1;
1647 const char *item_text = item->get_text();
1648 char txt[BCTEXTLEN]; sprintf(txt, "<%s %s>", KW_FONT, item_text);
1649 return window->insert_ibeam(txt);
1652 TitleColorPopup::TitleColorPopup(TitleMain *client, TitleWindow *window)
1653 : ColorPicker(0, _("Color"))
1655 this->client = client;
1656 this->window = window;
1657 this->color_value = client->config.color;
1659 TitleColorPopup::~TitleColorPopup()
1662 int TitleColorPopup::handle_new_color(int output, int alpha)
1664 color_value = output;
1667 int TitleColorPopup::activate()
1669 start_window(client->config.color, 255, 1);
1672 void TitleColorPopup::handle_done_event(int result)
1674 if( result ) return;
1675 char txt[BCSTRLEN]; sprintf(txt, "<%s #%06x>", KW_COLOR, color_value);
1676 window->insert_ibeam(txt);
1679 TitlePngPopup::TitlePngPopup(TitleMain *client, TitleWindow *window)
1682 this->client = client;
1683 this->window = window;
1686 TitlePngPopup::~TitlePngPopup()
1691 void TitlePngPopup::handle_done_event(int result)
1693 if( result ) return;
1694 BrowseButtonWindow *gui = (BrowseButtonWindow *)get_gui();
1695 const char *path = gui->get_submitted_path();
1696 char txt[BCSTRLEN]; sprintf(txt, "<%s %s>", KW_PNG, path);
1697 window->insert_ibeam(txt);
1700 BC_Window *TitlePngPopup::new_gui()
1702 MWindow *mwindow = client->server->mwindow;
1703 int x, y; mwindow->gui->get_abs_cursor(x, y);
1705 BC_Window *gui = new BrowseButtonWindow(mwindow->theme,
1706 x-25, y-100, window, "", _("Png file"), _("Png path"), 0);
1707 gui->create_objects();
1711 int TitlePngPopup::activate()
1713 BC_DialogThread::start();