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");
269 add_tool(alias = new TitleAlias(client, this, x, y+110));
270 if( alias->get_w() > w1 ) w1 = drag->get_w();
273 add_tool(justify_title = new BC_Title(x+50, y, _("Justify:")));
274 add_tool(left = new TitleLeft(client, this, x, y + 20));
276 add_tool(center = new TitleCenter(client, this, x, y + 50));
277 if( center->get_w() > w1 ) w1 = center->get_w();
278 add_tool(right = new TitleRight(client, this, x, y + 80));
279 if( right->get_w() > w1 ) w1 = right->get_w();
282 add_tool(top = new TitleTop(client, this, x, y + 20));
283 add_tool(mid = new TitleMid(client, this, x, y + 50));
284 add_tool(bottom= new TitleBottom(client, this, x, y + 80));
289 w1 = BC_Title::calculate_w(this, _("X:"));
290 if( (x1 = BC_Title::calculate_w(this, _("Y:"))) > w1 ) w1 = x1;
291 if( (x1 = BC_Title::calculate_w(this, _("W:"))) > w1 ) w1 = x1;
292 if( (x1 = BC_Title::calculate_w(this, _("H:"))) > w1 ) w1 = x1;
293 add_tool(x_title = new BC_Title(x1=x, y, _("X:")));
295 title_x = new TitleX(client, this, x1, y);
296 title_x->create_objects();
297 x1 += title_x->get_w()+margin;
298 add_tool(y_title = new BC_Title(x1, y, _("Y:")));
300 title_y = new TitleY(client, this, x1, y);
301 title_y->create_objects();
302 x1 += title_y->get_w();
303 y1 = y + title_y->get_h();
305 add_tool(w_title = new BC_Title(x1=x, y1, _("W:")));
307 title_w = new TitleW(client, this, x1, y1);
308 title_w->create_objects();
309 x1 += title_w->get_w()+margin;
310 add_tool(h_title = new BC_Title(x1, y1, _("H:")));
312 title_h = new TitleH(client, this, x1, y1);
313 title_h->create_objects();
314 x1 += title_h->get_w();
317 add_tool(motion_title = new BC_Title(x1=x, y, _("Motion:")));
318 x1 += motion_title->get_w()+margin;
319 motion = new TitleMotion(client, this, x1, y);
320 motion->create_objects();
321 add_tool(loop = new TitleLoop(client, this, x, y1));
322 x = margin; y = y1 + loop->get_h()+20;
324 add_tool(dropshadow_title = new BC_Title(x, y, _("Drop shadow:")));
325 w1 = dropshadow_title->get_w();
326 dropshadow = new TitleDropShadow(client, this, x, y + 20);
327 dropshadow->create_objects();
328 if( dropshadow->get_w() > w1 ) w1 = dropshadow->get_w();
331 add_tool(fadein_title = new BC_Title(x, y, _("Fade in (sec):")));
332 w1 = fadein_title->get_w();
333 add_tool(fade_in = new TitleFade(client, this, &client->config.fade_in, x, y + 20));
334 if( fade_in->get_w() > w1 ) w1 = fade_in->get_w();
337 add_tool(fadeout_title = new BC_Title(x, y, _("Fade out (sec):")));
338 w1 = fadeout_title->get_w();
339 add_tool(fade_out = new TitleFade(client, this, &client->config.fade_out, x, y + 20));
340 if( fade_out->get_w() > w1 ) w1 = fade_out->get_w();
343 add_tool(speed_title = new BC_Title(x, y, _("Speed:")));
344 w1 = speed_title->get_w();
345 y += speed_title->get_h() + 5; y1 = y;
346 speed = new TitleSpeed(client, this, x, y);
347 speed->create_objects();
348 if( speed->get_w() > w1 ) w1 = speed->get_w();
350 y2 = y + speed->get_h() + 10;
352 color_x = x3; color_y = y = y1;
353 color_thread = new TitleColorThread(client, this, 0);
354 x1 = color_x + COLOR_W + 2*margin;
356 add_tool(color_button = new TitleColorButton(client, this, x1, y1));
358 outline_color_x = x3; outline_color_y = y;
359 outline_color_thread = new TitleColorThread(client, this, 1);
360 y1 = outline_color_y + 5;
361 add_tool(outline_color_button = new TitleOutlineColorButton(client, this, x1, y1));
364 add_tool(outline_title = new BC_Title(x, y, _("Outline:")));
365 y1 = y + outline_title->get_h() + margin;
366 outline = new TitleOutline(client, this, x, y1);
367 outline->create_objects();
368 x += outline->get_w() + 2*margin;
370 add_tool(stroker_title = new BC_Title(x, y, _("Stroker:")));
371 stroker = new TitleStroker(client, this, x, y1);
372 stroker->create_objects();
373 x += stroker->get_w() + margin;
375 y += outline_title->get_h() + margin;
376 add_tool(timecode = new TitleTimecode(client, this, x1=x, y));
377 x += timecode->get_w() + margin;
378 add_tool(timecode_format = new TitleTimecodeFormat(client, this, x, y,
379 Units::print_time_format(client->config.timecode_format, string)));
380 timecode_format->create_objects();
381 y += timecode_format->get_h() + margin;
384 add_tool(background = new TitleBackground(client, this, x, y));
385 x += background->get_w() + margin;
386 add_tool(background_path = new TitleBackgroundPath(client, this, x, y));
387 x += background_path->get_w() + margin;
388 add_tool(background_browse = new BrowseButton(
389 client->server->mwindow->theme, this, background_path,
390 x, y, "", _("background media"), _("Select background media path")));
391 x += background_browse->get_w() + 3*margin;
392 add_tool(loop_playback = new TitleLoopPlayback(client, this, x, y));
393 y += loop_playback->get_h() + 10;
396 add_tool(text_title = new BC_Title(x, y, _("Text:")));
397 x += text_title->get_w() + 20;
398 int wid = BC_Title::calculate_w(this,"0")*10;
399 add_tool(text_chars = new TitleTextChars(x,y,wid));
400 x += text_chars->get_w() + 20;
401 add_tool(text_bfrsz = new TitleTextBfrSz(x,y,wid));
403 y += text_title->get_h() + margin;
405 text = new TitleText(client, this, x, y, get_w()-margin - x, get_h() - y - 10);
406 text->create_objects();
408 add_tool(cur_popup = new TitleCurPopup(client, this));
409 cur_popup->create_objects();
410 add_tool(fonts_popup = new TitleFontsPopup(client, this));
411 color_popup = new TitleColorPopup(client, this);
412 png_popup = new TitlePngPopup(client, this);
418 int TitleWindow::resize_event(int w, int h)
420 client->config.window_w = w;
421 client->config.window_h = h;
423 clear_box(0, 0, w, h);
424 font_title->reposition_window(font_title->get_x(), font_title->get_y());
425 font->reposition_window(font->get_x(), font->get_y());
426 font_tumbler->reposition_window(font_tumbler->get_x(), font_tumbler->get_y());
427 x_title->reposition_window(x_title->get_x(), x_title->get_y());
428 title_x->reposition_window(title_x->get_x(), title_x->get_y());
429 y_title->reposition_window(y_title->get_x(), y_title->get_y());
430 title_y->reposition_window(title_y->get_x(), title_y->get_y());
431 w_title->reposition_window(w_title->get_x(), w_title->get_y());
432 title_w->reposition_window(title_w->get_x(), title_w->get_y());
433 h_title->reposition_window(h_title->get_x(), h_title->get_y());
434 title_h->reposition_window(title_h->get_x(), title_h->get_y());
435 style_title->reposition_window(style_title->get_x(), style_title->get_y());
436 italic->reposition_window(italic->get_x(), italic->get_y());
437 bold->reposition_window(bold->get_x(), bold->get_y());
438 drag->reposition_window(drag->get_x(), drag->get_y());
439 alias->reposition_window(alias->get_x(), alias->get_y());
440 size_title->reposition_window(size_title->get_x(), size_title->get_y());
441 size->reposition_window(size->get_x(), size->get_y());
442 size_tumbler->reposition_window(size_tumbler->get_x(), size_tumbler->get_y());
443 pitch_title->reposition_window(pitch_title->get_x(), pitch_title->get_y());
444 pitch->reposition_window(pitch->get_x(), pitch->get_y());
446 color_button->reposition_window(color_button->get_x(), color_button->get_y());
447 outline_color_button->reposition_window(outline_color_button->get_x(), outline_color_button->get_y());
448 motion_title->reposition_window(motion_title->get_x(), motion_title->get_y());
449 motion->reposition_window(motion->get_x(), motion->get_y());
450 loop->reposition_window(loop->get_x(), loop->get_y());
451 dropshadow_title->reposition_window(dropshadow_title->get_x(), dropshadow_title->get_y());
452 dropshadow->reposition_window(dropshadow->get_x(), dropshadow->get_y());
453 fadein_title->reposition_window(fadein_title->get_x(), fadein_title->get_y());
454 fade_in->reposition_window(fade_in->get_x(), fade_in->get_y());
455 fadeout_title->reposition_window(fadeout_title->get_x(), fadeout_title->get_y());
456 fade_out->reposition_window(fade_out->get_x(), fade_out->get_y());
457 text_title->reposition_window(text_title->get_x(), text_title->get_y());
458 timecode->reposition_window(timecode->get_x(), timecode->get_y());
459 text->reposition_window(text->get_x(), text->get_y(), w - text->get_x() - 10,
460 BC_TextBox::pixels_to_rows(this, MEDIUMFONT, h - text->get_y() - 10));
461 justify_title->reposition_window(justify_title->get_x(), justify_title->get_y());
462 left->reposition_window(left->get_x(), left->get_y());
463 center->reposition_window(center->get_x(), center->get_y());
464 right->reposition_window(right->get_x(), right->get_y());
465 top->reposition_window(top->get_x(), top->get_y());
466 mid->reposition_window(mid->get_x(), mid->get_y());
467 bottom->reposition_window(bottom->get_x(), bottom->get_y());
468 speed_title->reposition_window(speed_title->get_x(), speed_title->get_y());
469 speed->reposition_window(speed->get_x(), speed->get_y());
476 void TitleWindow::send_configure_change()
479 client->send_configure_change();
481 int TitleWindow::check_configure_change(int ret)
483 if( pending_config && !grab_event_count() )
484 send_configure_change();
488 int TitleWindow::grab_event(XEvent *event)
490 switch( event->type ) {
491 case ButtonPress: break;
492 case ButtonRelease: break;
493 case MotionNotify: break;
495 return check_configure_change(0);
498 MWindow *mwindow = client->server->mwindow;
499 CWindowGUI *cwindow_gui = mwindow->cwindow->gui;
500 CWindowCanvas *canvas = cwindow_gui->canvas;
501 int cx, cy; cwindow_gui->get_relative_cursor(cx, cy);
502 cx -= mwindow->theme->ccanvas_x;
503 cy -= mwindow->theme->ccanvas_y;
506 if( cx < 0 || cx >= mwindow->theme->ccanvas_w ||
507 cy < 0 || cy >= mwindow->theme->ccanvas_h )
508 return check_configure_change(0);
511 switch( event->type ) {
513 if( !dragging ) break;
516 if( !dragging ) return check_configure_change(0);
520 if( !dragging ) return check_configure_change(0);
523 return check_configure_change(0);
526 float cursor_x = cx, cursor_y = cy;
527 canvas->canvas_to_output(mwindow->edl, 0, cursor_x, cursor_y);
528 int64_t position = client->get_source_position();
529 float projector_x, projector_y, projector_z;
530 Track *track = client->server->plugin->track;
531 int track_w = track->track_w, track_h = track->track_h;
532 track->automation->get_projector(
533 &projector_x, &projector_y, &projector_z,
534 position, PLAY_FORWARD);
535 projector_x += mwindow->edl->session->output_w / 2;
536 projector_y += mwindow->edl->session->output_h / 2;
537 cursor_x = (cursor_x - projector_x) / projector_z + track_w / 2;
538 cursor_y = (cursor_y - projector_y) / projector_z + track_h / 2;
539 int title_x = client->config.title_x, title_y = client->config.title_y;
540 int title_w = client->config.title_w, title_h = client->config.title_h;
541 if( !title_w ) title_w = track_w;
542 if( !title_h ) title_h = track_h;
543 int r = MIN(track_w, track_h)/100 + 2;
544 int x0 = title_x, x1 = title_x+(title_w+1)/2, x2 = title_x+title_w;
545 int y0 = title_y, y1 = title_y+(title_h+1)/2, y2 = title_y+title_h;
546 int drag_dx = 0, drag_dy = 0;
547 if( !dragging ) { // clockwise
548 if( abs(drag_dx = cursor_x-x0) < r && // x0,y0
549 abs(drag_dy = cursor_y-y0) < r ) dragging = 1;
550 else if( abs(drag_dx = cursor_x-x1) < r && // x1,y0
551 abs(drag_dy = cursor_y-y0) < r ) dragging = 2;
552 else if( abs(drag_dx = cursor_x-x2) < r && // x2,y0
553 abs(drag_dy = cursor_y-y0) < r ) dragging = 3;
554 else if( abs(drag_dx = cursor_x-x2) < r && // x2,y1
555 abs(drag_dy = cursor_y-y1) < r ) dragging = 4;
556 else if( abs(drag_dx = cursor_x-x2) < r && // x2,y2
557 abs(drag_dy = cursor_y-y2) < r ) dragging = 5;
558 else if( abs(drag_dx = cursor_x-x1) < r && // x1,y2
559 abs(drag_dy = cursor_y-y2) < r ) dragging = 6;
560 else if( abs(drag_dx = cursor_x-x0) < r && // x0,y2
561 abs(drag_dy = cursor_y-y2) < r ) dragging = 7;
562 else if( abs(drag_dx = cursor_x-x0) < r && // x0,y1
563 abs(drag_dy = cursor_y-y1) < r ) dragging = 8;
564 else if( abs(drag_dx = cursor_x-x1) < r && // x1,y1
565 abs(drag_dy = cursor_y-y1) < r ) dragging = 9;
570 int cur_x = cursor_x - drag_dx, dx = cur_x - x0;
571 int cur_y = cursor_y - drag_dy, dy = cur_y - y0;
572 if( !dx && !dy ) return 1;
573 int cur_w = title_w - dx; if( cur_w < 1 ) cur_w = 1;
574 int cur_h = title_h - dy; if( cur_h < 1 ) cur_h = 1;
575 this->title_x->update((int64_t)(client->config.title_x = cur_x));
576 this->title_y->update((int64_t)(client->config.title_y = cur_y));
577 this->title_w->update((int64_t)(client->config.title_w = cur_w));
578 this->title_h->update((int64_t)(client->config.title_h = cur_h));
581 int cur_y = cursor_y - drag_dy, dy = cur_y - y0;
583 int cur_h = title_h - dy; if( cur_h < 1 ) cur_h = 1;
584 this->title_y->update((int64_t)(client->config.title_y = cur_y));
585 this->title_h->update((int64_t)(client->config.title_h = cur_h));
588 int cur_x = cursor_x - drag_dx, dx = cur_x - x2;
589 int cur_y = cursor_y - drag_dy, dy = cur_y - y0;
590 int cur_w = title_w + dx; if( cur_w < 1 ) cur_w = 1;
591 int cur_h = title_h - dy; if( cur_h < 1 ) cur_h = 1;
592 this->title_w->update((int64_t)(client->config.title_w = cur_w));
593 this->title_y->update((int64_t)(client->config.title_y = cur_y));
594 this->title_h->update((int64_t)(client->config.title_h = cur_h));
597 int cur_x = cursor_x - drag_dx, dx = cur_x - x2;
599 int cur_w = title_w + dx; if( cur_w < 1 ) cur_w = 1;
600 this->title_w->update((int64_t)(client->config.title_w = cur_w));
603 int cur_x = cursor_x - drag_dx, dx = cur_x - x2;
604 int cur_y = cursor_y - drag_dy, dy = cur_y - y2;
605 int cur_w = title_w + dx; if( cur_w < 1 ) cur_w = 1;
606 int cur_h = title_h + dy; if( cur_h < 1 ) cur_h = 1;
607 this->title_w->update((int64_t)(client->config.title_w = cur_w));
608 this->title_h->update((int64_t)(client->config.title_h = cur_h));
611 int cur_y = cursor_y - drag_dy, dy = cur_y - y2;
612 if( client->config.title_h == cur_y ) return 1;
613 int cur_h = title_h + dy; if( cur_h < 1 ) cur_h = 1;
614 this->title_h->update((int64_t)(client->config.title_h = cur_h));
617 int cur_x = cursor_x - drag_dx, dx = cur_x - x0;
618 int cur_y = cursor_y - drag_dy, dy = cur_y - y2;
619 int cur_w = title_w - dx; if( cur_w < 1 ) cur_w = 1;
620 int cur_h = title_h + dy; if( cur_h < 1 ) cur_h = 1;
621 this->title_x->update((int64_t)(client->config.title_x = cur_x));
622 this->title_w->update((int64_t)(client->config.title_w = cur_w));
623 this->title_h->update((int64_t)(client->config.title_h = cur_h));
626 int cur_x = cursor_x - drag_dx, dx = cur_x - x0;
628 int cur_w = title_w - dx; if( cur_w < 1 ) cur_w = 1;
629 this->title_x->update((int64_t)(client->config.title_x = cur_x));
630 this->title_w->update((int64_t)(client->config.title_w = cur_w));
633 int cur_x = cursor_x - drag_dx, dx = cur_x - x1;
634 int cur_y = cursor_y - drag_dy, dy = cur_y - y1;
635 if( title_x == cur_x && title_y == cur_y ) return 1;
636 this->title_x->update((int64_t)(client->config.title_x += dx));
637 this->title_y->update((int64_t)(client->config.title_y += dy));
640 if( !grab_event_count() )
641 send_configure_change();
647 void TitleWindow::previous_font()
649 int current_font = font->get_number();
651 if( current_font < 0 ) current_font = fonts.total - 1;
653 if( current_font < 0 || current_font >= fonts.total ) return;
655 for( int i=0; i<fonts.total; ++i ) {
656 fonts.values[i]->set_selected(i == current_font);
659 font->update(fonts.values[current_font]->get_text());
660 strcpy(client->config.font, fonts.values[current_font]->get_text());
661 check_style(client->config.font,1);
662 send_configure_change();
665 void TitleWindow::next_font()
667 int current_font = font->get_number();
669 if( current_font >= fonts.total ) current_font = 0;
671 if( current_font < 0 || current_font >= fonts.total ) return;
673 for( int i=0; i<fonts.total; ++i ) {
674 fonts.values[i]->set_selected(i == current_font);
677 font->update(fonts.values[current_font]->get_text());
678 strcpy(client->config.font, fonts.values[current_font]->get_text());
679 check_style(client->config.font,1);
680 send_configure_change();
683 int TitleWindow::insert_ibeam(const char *txt, int ofs)
685 int ibeam = cur_ibeam;
686 int ilen = strlen(txt)+1;
688 int len = BC_Resources::encode(client->config.encoding, BC_Resources::wide_encoding,
689 (char*)txt,ilen, (char *)wtxt,ilen*sizeof(wtxt[0])) / sizeof(wchar_t);
690 client->insert_text(wtxt, ibeam);
691 while( len > 0 && !wtxt[len] ) --len;
692 int adv = len+1 + ofs;
693 if( (ibeam += adv) >= client->config.wlen)
694 ibeam = client->config.wlen;
695 text->wset_selection(-1, -1, ibeam);
696 text->update(client->config.wtext);
697 send_configure_change();
701 void TitleWindow::update_color()
703 //printf("TitleWindow::update_color %x\n", client->config.color);
704 set_color(client->config.color);
705 draw_box(color_x, color_y, COLOR_W, COLOR_H);
706 flash(color_x, color_y, COLOR_W, COLOR_H);
707 set_color(client->config.outline_color);
708 draw_box(outline_color_x, outline_color_y, COLOR_W, COLOR_H);
710 draw_rectangle(color_x, color_y, COLOR_W, COLOR_H);
711 draw_rectangle(outline_color_x, outline_color_y, COLOR_W, COLOR_H);
712 flash(outline_color_x, outline_color_y, COLOR_W, COLOR_H);
715 void TitleWindow::update_justification()
717 left->update(client->config.hjustification == JUSTIFY_LEFT);
718 center->update(client->config.hjustification == JUSTIFY_CENTER);
719 right->update(client->config.hjustification == JUSTIFY_RIGHT);
720 top->update(client->config.vjustification == JUSTIFY_TOP);
721 mid->update(client->config.vjustification == JUSTIFY_MID);
722 bottom->update(client->config.vjustification == JUSTIFY_BOTTOM);
725 void TitleWindow::update_stats()
727 text_chars->update(client->config.wlen);
728 int len = MESSAGESIZE - BCTEXTLEN - strlen(text->get_text()) - 1;
729 if( len < 0 ) len = 0;
730 text_bfrsz->update(len);
733 void TitleWindow::update()
735 title_x->update((int64_t)client->config.title_x);
736 title_y->update((int64_t)client->config.title_y);
737 title_w->update((int64_t)client->config.title_w);
738 title_h->update((int64_t)client->config.title_h);
739 italic->update(client->config.style & BC_FONT_ITALIC);
740 bold->update(client->config.style & BC_FONT_BOLD);
741 alias->update(client->config.style & FONT_ALIAS);
742 size->update(client->config.size);
743 motion->update(TitleMain::motion_to_text(client->config.motion_strategy));
744 loop->update(client->config.loop);
745 dropshadow->update((int64_t)client->config.dropshadow);
746 fade_in->update((float)client->config.fade_in);
747 fade_out->update((float)client->config.fade_out);
748 font->update(client->config.font);
749 check_style(client->config.font,0);
750 text->update(&client->config.wtext[0]);
751 speed->update(client->config.pixels_per_second);
752 outline->update((int64_t)client->config.outline_size);
754 stroker->update((int64_t)client->config.stroke_width);
756 timecode->update(client->config.timecode);
757 timecode_format->update(client->config.timecode_format);
758 background->update(client->config.background);
759 background_path->update(client->config.background_path);
760 loop_playback->update((int64_t)client->config.loop_playback);
762 char string[BCTEXTLEN];
763 for( int i=0; i<lengthof(timeunit_formats); ++i ) {
764 if( timeunit_formats[i] == client->config.timecode_format ) {
765 timecode_format->set_text(
766 Units::print_time_format(timeunit_formats[i], string));
770 update_justification();
776 TitleFontTumble::TitleFontTumble(TitleMain *client, TitleWindow *window, int x, int y)
779 this->client = client;
780 this->window = window;
782 int TitleFontTumble::handle_up_event()
784 window->previous_font();
788 int TitleFontTumble::handle_down_event()
796 TitleSizeTumble::TitleSizeTumble(TitleMain *client, TitleWindow *window, int x, int y)
799 this->client = client;
800 this->window = window;
803 int TitleSizeTumble::handle_up_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 >= window->sizes.size() ) current_index = 0;
820 client->config.size = atoi(window->sizes.get(current_index)->get_text());
821 window->size->update(client->config.size);
822 window->send_configure_change();
826 int TitleSizeTumble::handle_down_event()
828 int current_index = -1;
829 int current_difference = -1;
830 for( int i=0; i<window->sizes.size(); ++i ) {
831 int size = atoi(window->sizes.get(i)->get_text());
832 if( current_index < 0 ||
833 abs(size - client->config.size) < current_difference ) {
835 current_difference = abs(size - client->config.size);
840 if( current_index < 0 ) current_index = window->sizes.size() - 1;
843 client->config.size = atoi(window->sizes.get(current_index)->get_text());
844 window->size->update(client->config.size);
845 window->send_configure_change();
849 TitleAlias::TitleAlias(TitleMain *client, TitleWindow *window, int x, int y)
850 : BC_CheckBox(x, y, client->config.style & FONT_ALIAS, _("Smooth"))
852 this->client = client;
853 this->window = window;
856 int TitleAlias::handle_event()
858 client->config.style =
859 (client->config.style & ~FONT_ALIAS) |
860 (get_value() ? FONT_ALIAS : 0);
861 window->send_configure_change();
865 TitleBold::TitleBold(TitleMain *client, TitleWindow *window, int x, int y)
866 : BC_CheckBox(x, y, client->config.style & BC_FONT_BOLD, _("Bold"))
868 this->client = client;
869 this->window = window;
872 int TitleBold::handle_event()
874 client->config.style =
875 (client->config.style & ~BC_FONT_BOLD) |
876 (get_value() ? BC_FONT_BOLD : 0);
877 window->send_configure_change();
881 TitleItalic::TitleItalic(TitleMain *client, TitleWindow *window, int x, int y)
882 : BC_CheckBox(x, y, client->config.style & BC_FONT_ITALIC, _("Italic"))
884 this->client = client;
885 this->window = window;
887 int TitleItalic::handle_event()
889 client->config.style =
890 (client->config.style & ~BC_FONT_ITALIC) |
891 (get_value() ? BC_FONT_ITALIC : 0);
892 window->send_configure_change();
898 TitleSize::TitleSize(TitleMain *client, TitleWindow *window, int x, int y, char *text)
899 : BC_PopupTextBox(window, &window->sizes, text, x, y, 64, 300)
901 this->client = client;
902 this->window = window;
904 TitleSize::~TitleSize()
907 int TitleSize::handle_event()
909 client->config.size = atol(get_text());
910 //printf("TitleSize::handle_event 1 %s\n", get_text());
911 window->send_configure_change();
914 void TitleSize::update(int size)
916 char string[BCTEXTLEN];
917 sprintf(string, "%d", size);
918 BC_PopupTextBox::update(string);
922 TitlePitch(TitleMain *client, TitleWindow *window, int x, int y, int *value)
923 : BC_TumbleTextBox(window, *value, 0, INT_MAX, x, y, 64)
925 this->client = client;
926 this->window = window;
935 int TitlePitch::handle_event()
937 *value = atol(get_text());
938 window->send_configure_change();
942 TitleColorButton::TitleColorButton(TitleMain *client, TitleWindow *window, int x, int y)
943 : BC_GenericButton(x, y, _("Text Color..."))
945 this->client = client;
946 this->window = window;
948 int TitleColorButton::handle_event()
950 window->color_thread->start_window(client->config.color,
951 client->config.alpha);
954 TitleOutlineColorButton::TitleOutlineColorButton(TitleMain *client, TitleWindow *window, int x, int y)
955 : BC_GenericButton(x, y, _("Outline color..."))
957 this->client = client;
958 this->window = window;
960 int TitleOutlineColorButton::handle_event()
962 window->outline_color_thread->start_window(client->config.outline_color,
963 client->config.outline_alpha);
968 TitleMotion::TitleMotion(TitleMain *client, TitleWindow *window, int x, int y)
969 : BC_PopupTextBox(window, &window->paths,
970 client->motion_to_text(client->config.motion_strategy),
973 this->client = client;
974 this->window = window;
976 int TitleMotion::handle_event()
978 client->config.motion_strategy = client->text_to_motion(get_text());
979 window->send_configure_change();
983 TitleLoop::TitleLoop(TitleMain *client, TitleWindow *window, int x, int y)
984 : BC_CheckBox(x, y, client->config.loop, _("Loop"))
986 this->client = client;
987 this->window = window;
989 int TitleLoop::handle_event()
991 client->config.loop = get_value();
992 window->send_configure_change();
995 TitleTimecode::TitleTimecode(TitleMain *client, TitleWindow *window, int x, int y)
996 : BC_CheckBox(x, y, client->config.timecode, _("Stamp timecode"))
998 this->client = client;
999 this->window = window;
1001 int TitleTimecode::handle_event()
1003 client->config.timecode = get_value();
1004 client->send_configure_change();
1008 TitleTimecodeFormat::TitleTimecodeFormat(TitleMain *client, TitleWindow *window,
1009 int x, int y, const char *text)
1010 : BC_PopupMenu(x, y, 100, text, 1)
1012 this->client = client;
1013 this->window = window;
1016 int TitleTimecodeFormat::handle_event()
1018 client->config.timecode_format = Units::text_to_format(get_text());
1019 window->send_configure_change();
1023 void TitleTimecodeFormat::create_objects()
1025 char string[BCTEXTLEN];
1026 for( int i=0; i<lengthof(timeunit_formats); ++i ) {
1027 add_item(new BC_MenuItem(
1028 Units::print_time_format(timeunit_formats[i], string)));
1033 int TitleTimecodeFormat::update(int timecode_format)
1035 char string[BCTEXTLEN];
1036 for( int i=0; i<lengthof(timeunit_formats); ++i ) {
1037 if( timeunit_formats[i] == timecode_format ) {
1038 set_text(Units::print_time_format(timeunit_formats[i], string));
1045 TitleFade::TitleFade(TitleMain *client, TitleWindow *window,
1046 double *value, int x, int y)
1047 : BC_TextBox(x, y, 80, 1, (float)*value)
1049 this->client = client;
1050 this->window = window;
1051 this->value = value;
1055 int TitleFade::handle_event()
1057 *value = atof(get_text());
1058 window->send_configure_change();
1062 void TitleWindow::check_style(const char *font_name, int update)
1064 BC_FontEntry *font_nrm = TitleMain::get_font(font_name, 0);
1065 BC_FontEntry *font_itl = TitleMain::get_font(font_name, BC_FONT_ITALIC);
1066 BC_FontEntry *font_bld = TitleMain::get_font(font_name, BC_FONT_BOLD);
1067 BC_FontEntry *font_bit = TitleMain::get_font(font_name, BC_FONT_ITALIC | BC_FONT_BOLD);
1068 int has_norm = font_nrm != 0 ? 1 : 0;
1069 int has_ital = font_itl != 0 || font_bit != 0 ? 1 : 0;
1070 int has_bold = font_bld != 0 || font_bit != 0 ? 1 : 0;
1071 if( bold->get_value() ) {
1072 if( !has_bold ) bold->update(0);
1075 if( !has_norm && has_bold ) bold->update(1);
1077 if( italic->get_value() ) {
1078 if( !has_ital ) italic->update(0);
1081 if( !has_norm && has_ital ) italic->update(1);
1083 if( has_norm && has_bold ) bold->enable(); else bold->disable();
1084 if( has_norm && has_ital ) italic->enable(); else italic->disable();
1086 int style = stroker && atof(stroker->get_text()) ? BC_FONT_OUTLINE : 0;
1087 if( bold->get_value() ) style |= BC_FONT_BOLD;
1088 if( italic->get_value() ) style |= BC_FONT_ITALIC;
1089 client->config.style = style;
1093 TitleFont::TitleFont(TitleMain *client, TitleWindow *window, int x, int y)
1094 : BC_PopupTextBox(window, &window->fonts, client->config.font,
1095 x, y, 240, 300, LISTBOX_ICON_LIST)
1097 this->client = client;
1098 this->window = window;
1100 int TitleFont::handle_event()
1102 strcpy(client->config.font, get_text());
1103 window->check_style(client->config.font, 1);
1104 window->send_configure_change();
1108 TitleText::TitleText(TitleMain *client, TitleWindow *window,
1109 int x, int y, int w, int h)
1110 : BC_ScrollTextBox(window, x, y, w,
1111 BC_TextBox::pixels_to_rows(window, MEDIUMFONT, h),
1112 client->config.wtext, 8192)
1114 this->client = client;
1115 this->window = window;
1116 //printf("TitleText::TitleText %s\n", client->config.text);
1119 int TitleText::button_press_event()
1121 if( get_buttonpress() == 3 ) {
1122 window->cur_ibeam = get_ibeam_letter();
1123 window->cur_popup->activate_menu();
1126 return BC_ScrollTextBox::button_press_event();
1129 int TitleText::handle_event()
1131 window->fonts_popup->deactivate();
1132 int text_len = strlen(get_text());
1133 int avail = MESSAGESIZE - BCTEXTLEN;
1134 if( text_len >= avail ) { // back off last utf8 char
1135 char text[2*sizeof(client->config.wtext)];
1136 strcpy(text, get_text());
1138 while( text_len > 0 && (text[text_len-1] & 0xc0) == 0x80 )
1139 text[--text_len] = 0;
1141 text[--text_len] = 0;
1144 int len = sizeof(client->config.wtext) / sizeof(wchar_t);
1145 wcsncpy(client->config.wtext, get_wtext(), len);
1146 client->config.wtext[len-1] = 0;
1147 client->config.wlen = wcslen(client->config.wtext);
1148 window->update_stats();
1149 window->send_configure_change();
1152 TitleTextChars::TitleTextChars(int x, int y, int w)
1153 : BC_Title(x, y, "", MEDIUMFONT, -1, 0, w)
1156 TitleTextChars::~TitleTextChars()
1159 int TitleTextChars::update(int n)
1161 char text[BCSTRLEN];
1162 sprintf(text, _("chars: %d "),n);
1163 return BC_Title::update(text, 0);
1166 TitleTextBfrSz::TitleTextBfrSz(int x, int y, int w)
1167 : BC_Title(x, y, "", MEDIUMFONT, -1, 0, w)
1170 TitleTextBfrSz::~TitleTextBfrSz()
1173 int TitleTextBfrSz::update(int n)
1175 char text[BCSTRLEN];
1176 sprintf(text, _("bfrsz: %d "),n);
1177 return BC_Title::update(text, 0);
1181 TitleDropShadow::TitleDropShadow(TitleMain *client, TitleWindow *window, int x, int y)
1182 : BC_TumbleTextBox(window, client->config.dropshadow,
1183 -1000, 1000, x, y, 70)
1185 this->client = client;
1186 this->window = window;
1188 int TitleDropShadow::handle_event()
1190 client->config.dropshadow = atol(get_text());
1191 window->send_configure_change();
1196 TitleOutline::TitleOutline(TitleMain *client, TitleWindow *window, int x, int y)
1197 : BC_TumbleTextBox(window, client->config.outline_size,
1198 0.f, 1000.f, x, y, 70)
1200 this->client = client;
1201 this->window = window;
1204 int TitleOutline::handle_event()
1206 client->config.outline_size = atof(get_text());
1207 window->send_configure_change();
1212 TitleStroker::TitleStroker(TitleMain *client, TitleWindow *window, int x, int y)
1213 : BC_TumbleTextBox(window, client->config.stroke_width,
1214 0.f, 1000.f, x, y, 70)
1216 this->client = client;
1217 this->window = window;
1220 int TitleStroker::handle_event()
1222 client->config.stroke_width = atof(get_text());
1223 if( client->config.stroke_width )
1224 client->config.style |= BC_FONT_OUTLINE;
1226 client->config.style &= ~BC_FONT_OUTLINE;
1227 window->send_configure_change();
1232 TitleX::TitleX(TitleMain *client, TitleWindow *window, int x, int y)
1233 : BC_TumbleTextBox(window, client->config.title_x,
1234 -32767.f, 32767.f, x, y, 50)
1236 this->client = client;
1237 this->window = window;
1240 int TitleX::handle_event()
1242 client->config.title_x = atof(get_text());
1243 window->send_configure_change();
1247 TitleY::TitleY(TitleMain *client, TitleWindow *window, int x, int y)
1248 : BC_TumbleTextBox(window, client->config.title_y,
1249 -32767.f, 32767.f, x, y, 50)
1251 this->client = client;
1252 this->window = window;
1255 int TitleY::handle_event()
1257 client->config.title_y = atof(get_text());
1258 window->send_configure_change();
1262 TitleW::TitleW(TitleMain *client, TitleWindow *window, int x, int y)
1263 : BC_TumbleTextBox(window, client->config.title_w,
1266 this->client = client;
1267 this->window = window;
1269 int TitleW::handle_event()
1271 client->config.title_w = atol(get_text());
1272 window->send_configure_change();
1276 TitleH::TitleH(TitleMain *client, TitleWindow *window, int x, int y)
1277 : BC_TumbleTextBox(window, client->config.title_h,
1280 this->client = client;
1281 this->window = window;
1283 int TitleH::handle_event()
1285 client->config.title_h = atol(get_text());
1286 window->send_configure_change();
1290 TitleSpeed::TitleSpeed(TitleMain *client, TitleWindow *window, int x, int y)
1291 : BC_TumbleTextBox(window, client->config.pixels_per_second,
1292 0.f, 1000.f, x, y, 100)
1294 this->client = client;
1295 this->window = window;
1301 int TitleSpeed::handle_event()
1303 client->config.pixels_per_second = atof(get_text());
1304 window->send_configure_change();
1309 TitleLeft::TitleLeft(TitleMain *client, TitleWindow *window, int x, int y)
1310 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_LEFT, _("Left"))
1312 this->client = client;
1313 this->window = window;
1315 int TitleLeft::handle_event()
1317 client->config.hjustification = JUSTIFY_LEFT;
1318 window->update_justification();
1319 window->send_configure_change();
1323 TitleCenter::TitleCenter(TitleMain *client, TitleWindow *window, int x, int y)
1324 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_CENTER, _("Center"))
1326 this->client = client;
1327 this->window = window;
1329 int TitleCenter::handle_event()
1331 client->config.hjustification = JUSTIFY_CENTER;
1332 window->update_justification();
1333 window->send_configure_change();
1337 TitleRight::TitleRight(TitleMain *client, TitleWindow *window, int x, int y)
1338 : BC_Radial(x, y, client->config.hjustification == JUSTIFY_RIGHT, _("Right"))
1340 this->client = client;
1341 this->window = window;
1343 int TitleRight::handle_event()
1345 client->config.hjustification = JUSTIFY_RIGHT;
1346 window->update_justification();
1347 window->send_configure_change();
1353 TitleTop::TitleTop(TitleMain *client, TitleWindow *window, int x, int y)
1354 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_TOP, _("Top"))
1356 this->client = client;
1357 this->window = window;
1359 int TitleTop::handle_event()
1361 client->config.vjustification = JUSTIFY_TOP;
1362 window->update_justification();
1363 window->send_configure_change();
1367 TitleMid::TitleMid(TitleMain *client, TitleWindow *window, int x, int y)
1368 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_MID, _("Mid"))
1370 this->client = client;
1371 this->window = window;
1373 int TitleMid::handle_event()
1375 client->config.vjustification = JUSTIFY_MID;
1376 window->update_justification();
1377 window->send_configure_change();
1381 TitleBottom::TitleBottom(TitleMain *client, TitleWindow *window, int x, int y)
1382 : BC_Radial(x, y, client->config.vjustification == JUSTIFY_BOTTOM, _("Bottom"))
1384 this->client = client;
1385 this->window = window;
1387 int TitleBottom::handle_event()
1389 client->config.vjustification = JUSTIFY_BOTTOM;
1390 window->update_justification();
1391 window->send_configure_change();
1397 TitleColorThread::TitleColorThread(TitleMain *client, TitleWindow *window, int is_outline)
1398 : ColorPicker(1, is_outline? _("Outline Color") : _("Text Color"))
1400 this->client = client;
1401 this->window = window;
1402 this->is_outline = is_outline;
1405 int TitleColorThread::handle_new_color(int output, int alpha)
1408 client->config.outline_color = output;
1409 client->config.outline_alpha = alpha;
1412 client->config.color = output;
1413 client->config.alpha = alpha;
1416 window->lock_window("TitleColorThread::handle_new_color");
1417 window->update_color();
1419 window->unlock_window();
1421 window->send_configure_change();
1425 TitleDrag::TitleDrag(TitleMain *client, TitleWindow *window, int x, int y)
1426 : BC_CheckBox(x, y, client->config.drag, _("Drag"))
1428 this->client = client;
1429 this->window = window;
1432 int TitleDrag::handle_event()
1434 int value = get_value();
1435 CWindowGUI *cwindow_gui = client->server->mwindow->cwindow->gui;
1437 if( !window->grab(cwindow_gui) ) {
1443 window->ungrab(cwindow_gui);
1444 client->config.drag = value;
1445 window->send_configure_change();
1449 TitleBackground::TitleBackground(TitleMain *client, TitleWindow *window, int x, int y)
1450 : BC_CheckBox(x, y, client->config.background, _("Background:"))
1452 this->client = client;
1453 this->window = window;
1456 int TitleBackground::handle_event()
1458 client->config.background = get_value();
1459 window->send_configure_change();
1463 TitleBackgroundPath::TitleBackgroundPath(TitleMain *client, TitleWindow *window, int x, int y)
1464 : BC_TextBox(x, y, 240, 1, client->config.background_path)
1466 this->client = client;
1467 this->window = window;
1470 int TitleBackgroundPath::handle_event()
1472 strncpy(client->config.background_path, get_text(), sizeof(client->config.background_path));
1473 window->send_configure_change();
1477 TitleLoopPlayback::TitleLoopPlayback(TitleMain *client, TitleWindow *window, int x, int y)
1478 : BC_CheckBox(x, y, client->config.loop_playback, _("Loop playback"))
1480 this->client = client;
1481 this->window = window;
1483 int TitleLoopPlayback::handle_event()
1485 client->config.loop_playback = get_value();
1486 window->send_configure_change();
1491 TitleCurPopup::TitleCurPopup(TitleMain *client, TitleWindow *window)
1492 : BC_PopupMenu(0, 0, 0, "", 0)
1494 this->client = client;
1495 this->window = window;
1497 int TitleCurPopup::handle_event()
1502 void TitleCurSubMenu::add_subitemx(int popup_type, va_list ap, const char *fmt)
1504 char item[BCSTRLEN];
1505 vsnprintf(item, sizeof(item)-1, fmt, ap);
1506 item[sizeof(item)-1] = 0;
1507 add_submenuitem(new TitleCurSubMenuItem(this, item, popup_type));
1510 void TitleCurPopup::create_objects()
1512 TitleCurItem *cur_item;
1513 TitleCurSubMenu *sub_menu;
1515 add_item(cur_item = new TitleCurItem(this, item = KW_NUDGE));
1516 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1517 sub_menu->add_subitem("%s dx,dy",item);
1518 sub_menu->add_subitem("/%s",item);
1519 add_item(cur_item = new TitleCurItem(this, item = KW_COLOR));
1520 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1521 sub_menu->add_subitem(POPUP_COLOR,"%s %s",item,_("#"));
1522 sub_menu->add_subitem("%s ",item);
1523 sub_menu->add_subitem("/%s",item);
1524 add_item(cur_item = new TitleCurItem(this, item = KW_ALPHA));
1525 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1526 sub_menu->add_subitem("%s ",item);
1527 sub_menu->add_subitem("%s 0.",item);
1528 sub_menu->add_subitem("%s .5",item);
1529 sub_menu->add_subitem("%s 1.",item);
1530 sub_menu->add_subitem("/%s",item);
1531 add_item(cur_item = new TitleCurItem(this, item = KW_FONT));
1532 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1533 sub_menu->add_subitem(POPUP_FONT,"%s %s",item, _("name"));
1534 sub_menu->add_subitem(POPUP_OFFSET, "%s ",item);
1535 sub_menu->add_subitem("/%s",item);
1536 add_item(cur_item = new TitleCurItem(this, item = KW_SIZE));
1537 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1538 sub_menu->add_subitem("%s +",item);
1539 sub_menu->add_subitem("%s -",item);
1540 sub_menu->add_subitem("%s ",item);
1541 sub_menu->add_subitem("/%s",item);
1542 add_item(cur_item = new TitleCurItem(this, item = KW_BOLD));
1543 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1544 sub_menu->add_subitem("%s 1",item);
1545 sub_menu->add_subitem("%s 0",item);
1546 sub_menu->add_subitem("/%s",item);
1547 add_item(cur_item = new TitleCurItem(this, item = KW_ITALIC));
1548 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1549 sub_menu->add_subitem("%s 1",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_CAPS));
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_UL));
1559 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1560 sub_menu->add_subitem("%s 1",item);
1561 sub_menu->add_subitem("%s 0",item);
1562 sub_menu->add_subitem("/%s",item);
1563 add_item(cur_item = new TitleCurItem(this, item = KW_BLINK));
1564 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1565 sub_menu->add_subitem("%s 1",item);
1566 sub_menu->add_subitem("%s -1",item);
1567 sub_menu->add_subitem("%s ",item);
1568 sub_menu->add_subitem("%s 0",item);
1569 sub_menu->add_subitem("/%s",item);
1570 add_item(cur_item = new TitleCurItem(this, item = KW_FIXED));
1571 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1572 sub_menu->add_subitem("%s ",item);
1573 sub_menu->add_subitem("%s 20",item);
1574 sub_menu->add_subitem("%s 10",item);
1575 sub_menu->add_subitem("%s 0",item);
1576 sub_menu->add_subitem("/%s",item);
1577 add_item(cur_item = new TitleCurItem(this, item = KW_ALIAS));
1578 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1579 sub_menu->add_subitem("%s 1",item);
1580 sub_menu->add_subitem("%s 0",item);
1581 sub_menu->add_subitem("/%s",item);
1582 add_item(cur_item = new TitleCurItem(this, item = KW_SUP));
1583 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1584 sub_menu->add_subitem("%s 1",item);
1585 sub_menu->add_subitem("%s 0",item);
1586 sub_menu->add_subitem("%s -1",item);
1587 sub_menu->add_subitem("/%s",item);
1588 add_item(cur_item = new TitleCurItem(this, item = KW_PNG));
1589 cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
1590 sub_menu->add_subitem(POPUP_PNG,"%s %s", item, _("file"));
1593 TitleCurItem::TitleCurItem(TitleCurPopup *popup, const char *text)
1596 this->popup = popup;
1598 int TitleCurItem::handle_event()
1603 TitleCurSubMenu::TitleCurSubMenu(TitleCurItem *cur_item)
1605 this->cur_item = cur_item;
1607 TitleCurSubMenu::~TitleCurSubMenu()
1611 TitleCurSubMenuItem::TitleCurSubMenuItem(TitleCurSubMenu *submenu, const char *text, int popup_type)
1614 this->submenu = submenu;
1615 this->popup_type = popup_type;
1617 TitleCurSubMenuItem::~TitleCurSubMenuItem()
1620 int TitleCurSubMenuItem::handle_event()
1622 TitleCurPopup *popup = submenu->cur_item->popup;
1623 TitleWindow *window = popup->window;
1624 const char *item_text = get_text();
1625 int ofs = *item_text == '/' ? 0 : -1;
1626 switch( popup_type ) {
1629 window->get_pop_cursor(px ,py);
1630 window->fonts_popup->activate(px, py, 300,200);
1633 window->color_popup->activate();
1636 window->png_popup->activate();
1643 sprintf(txt, "<%s>", item_text);
1644 return window->insert_ibeam(txt, ofs);
1647 TitleFontsPopup::TitleFontsPopup(TitleMain *client, TitleWindow *window)
1648 : BC_ListBox(-1, -1, 1, 1, LISTBOX_ICON_LIST,
1649 &window->fonts, 0, 0, 1, 0, 1)
1651 this->client = client;
1652 this->window = window;
1656 TitleFontsPopup::~TitleFontsPopup()
1659 int TitleFontsPopup::keypress_event()
1661 switch( get_keypress() ) {
1669 return BC_ListBox::keypress_event();
1672 int TitleFontsPopup::handle_event()
1675 BC_ListBoxItem *item = get_selection(0, 0);
1676 if( !item ) return 1;
1677 const char *item_text = item->get_text();
1678 char txt[BCTEXTLEN]; sprintf(txt, "<%s %s>", KW_FONT, item_text);
1679 return window->insert_ibeam(txt);
1682 TitleColorPopup::TitleColorPopup(TitleMain *client, TitleWindow *window)
1683 : ColorPicker(0, _("Color"))
1685 this->client = client;
1686 this->window = window;
1687 this->color_value = client->config.color;
1689 TitleColorPopup::~TitleColorPopup()
1692 int TitleColorPopup::handle_new_color(int output, int alpha)
1694 color_value = output;
1697 int TitleColorPopup::activate()
1699 start_window(client->config.color, 255, 1);
1702 void TitleColorPopup::handle_done_event(int result)
1704 if( result ) return;
1705 char txt[BCSTRLEN]; sprintf(txt, "<%s #%06x>", KW_COLOR, color_value);
1706 window->insert_ibeam(txt);
1709 TitlePngPopup::TitlePngPopup(TitleMain *client, TitleWindow *window)
1712 this->client = client;
1713 this->window = window;
1716 TitlePngPopup::~TitlePngPopup()
1721 void TitlePngPopup::handle_done_event(int result)
1723 if( result ) return;
1724 BrowseButtonWindow *gui = (BrowseButtonWindow *)get_gui();
1725 const char *path = gui->get_submitted_path();
1726 char txt[BCSTRLEN]; sprintf(txt, "<%s %s>", KW_PNG, path);
1727 window->insert_ibeam(txt);
1730 BC_Window *TitlePngPopup::new_gui()
1732 MWindow *mwindow = client->server->mwindow;
1733 int x, y; mwindow->gui->get_abs_cursor(x, y);
1735 BC_Window *gui = new BrowseButtonWindow(mwindow->theme,
1736 x-25, y-100, window, "", _("Png file"), _("Png path"), 0);
1737 gui->create_objects();
1741 int TitlePngPopup::activate()
1743 BC_DialogThread::start();