drag = 0;
cur_popup = 0;
fonts_popup = 0;
+ png_popup = 0;
- color_x = color_y = 0;
- outline_color_x = outline_color_y = 0;
drag_dx = drag_dy = dragging = 0;
cur_ibeam = -1;
encoding_title = 0;
encoding = 0;
color_button = 0;
- color_thread = 0;
- outline_color_button = 0;
- outline_color_thread = 0;
+ outline_button = 0;
+ color_popup = 0;
motion_title = 0;
motion = 0;
line_pitch = 0;
void TitleWindow::done_event(int result)
{
+ color_button->close_picker();
+ outline_button->close_picker();
drag->drag_deactivate();
- color_thread->close_window();
- outline_color_thread->close_window();
- color_popup->close_window();
- png_popup->close_window();
+ delete color_popup; color_popup = 0;
+ delete png_popup; png_popup = 0;
+
}
TitleWindow::~TitleWindow()
sizes.remove_all_objects();
delete timecode_format;
- delete color_thread;
delete title_x;
delete title_y;
}
x += w1 + margin;
y2 = y + speed->get_h() + 10;
- color_x = x3; color_y = y = y1;
- color_thread = new TitleColorThread(client, this, 0);
- x1 = color_x + COLOR_W + 2*margin;
- y1 = color_y + 5;
+ add_tool(color_button_title = new BC_Title(x3, y1+10, _("Color:")));
+ x1 = x3 + color_button_title->get_w() + 30;
add_tool(color_button = new TitleColorButton(client, this, x1, y1));
- y += COLOR_H + 5;
- outline_color_x = x3; outline_color_y = y;
- outline_color_thread = new TitleColorThread(client, this, 1);
- y1 = outline_color_y + 5;
- add_tool(outline_color_button = new TitleOutlineColorButton(client, this, x1, y1));
+ y1 += color_button->get_h() + 10;
+ add_tool(outline_button_title = new BC_Title(x3, y1+10, _("Outline:")));
+ add_tool(outline_button = new TitleOutlineColorButton(client, this, x1, y1));
x = 10; y = y2;
add_tool(outline_title = new BC_Title(x, y, _("Outline:")));
stroker->create_objects();
x += stroker->get_w() + margin;
#endif
- y += outline_title->get_h() + margin;
- add_tool(timecode = new TitleTimecode(client, this, x1=x, y));
- x += timecode->get_w() + margin;
- add_tool(timecode_format = new TitleTimecodeFormat(client, this, x, y,
+ add_tool(timecode = new TitleTimecode(client, this, x, y));
+ y += timecode->get_h() + margin;
+ int tw = 0;
+ for( int i=0; i<lengthof(timeunit_formats); ++i ) {
+ char text[BCSTRLEN];
+ Units::print_time_format(timeunit_formats[i], text);
+ int w = get_text_width(MEDIUMFONT, text);
+ if( tw < w ) tw = w;
+ }
+ add_tool(timecode_format = new TitleTimecodeFormat(client, this, x, y, tw,
Units::print_time_format(client->config.timecode_format, string)));
timecode_format->create_objects();
y += timecode_format->get_h() + margin;
png_popup = new TitlePngPopup(client, this);
show_window(1);
- update();
+ update_gui();
}
int TitleWindow::resize_event(int w, int h)
pitch_title->reposition_window(pitch_title->get_x(), pitch_title->get_y());
pitch->reposition_window(pitch->get_x(), pitch->get_y());
+ color_button_title->reposition_window(color_button_title->get_x(), color_button_title->get_y());
color_button->reposition_window(color_button->get_x(), color_button->get_y());
- outline_color_button->reposition_window(outline_color_button->get_x(), outline_color_button->get_y());
+ outline_button_title->reposition_window(outline_button_title->get_x(), outline_button_title->get_y());
+ outline_button->reposition_window(outline_button->get_x(), outline_button->get_y());
motion_title->reposition_window(motion_title->get_x(), motion_title->get_y());
motion->reposition_window(motion->get_x(), motion->get_y());
loop->reposition_window(loop->get_x(), loop->get_y());
void TitleWindow::previous_font()
{
int current_font = font->get_number();
- current_font--;
- if( current_font < 0 ) current_font = fonts.total - 1;
+ if( !fonts.total ) current_font = -1;
+ else if( --current_font < 0 ) current_font = fonts.total - 1;
+ font->set_number(current_font);
if( current_font < 0 || current_font >= fonts.total ) return;
void TitleWindow::next_font()
{
int current_font = font->get_number();
- current_font++;
- if( current_font >= fonts.total ) current_font = 0;
+ if( !fonts.total ) current_font = -1;
+ else if( ++current_font >= fonts.total ) current_font = 0;
+ font->set_number(current_font);
if( current_font < 0 || current_font >= fonts.total ) return;
void TitleWindow::update_color()
{
-//printf("TitleWindow::update_color %x\n", client->config.color);
- set_color(client->config.color);
- draw_box(color_x, color_y, COLOR_W, COLOR_H);
- flash(color_x, color_y, COLOR_W, COLOR_H);
- set_color(client->config.outline_color);
- draw_box(outline_color_x, outline_color_y, COLOR_W, COLOR_H);
- set_color(BLACK);
- draw_rectangle(color_x, color_y, COLOR_W, COLOR_H);
- draw_rectangle(outline_color_x, outline_color_y, COLOR_W, COLOR_H);
- flash(outline_color_x, outline_color_y, COLOR_W, COLOR_H);
+ color_button->update_gui(client->config.color);
+ outline_button->update_gui(client->config.outline_color);
}
void TitleWindow::update_justification()
text_chars->update(client->config.wlen);
}
-void TitleWindow::update()
+void TitleWindow::update_gui()
{
title_x->update((int64_t)client->config.title_x);
title_y->update((int64_t)client->config.title_y);
}
TitleColorButton::TitleColorButton(TitleMain *client, TitleWindow *window, int x, int y)
- : BC_GenericButton(x, y, _("Text Color..."))
+ : ColorCircleButton(_("Text Color"), x, y, COLOR_W, COLOR_H,
+ client->config.color, client->config.alpha, 1)
{
this->client = client;
this->window = window;
}
-int TitleColorButton::handle_event()
+int TitleColorButton::handle_new_color(int output, int alpha)
{
- window->color_thread->start_window(client->config.color,
- client->config.alpha);
+ client->config.color = output;
+ client->config.alpha = alpha;
+ window->send_configure_change();
return 1;
}
+void TitleColorButton::handle_done_event(int result)
+{
+ if( result ) {
+ handle_new_color(orig_color, orig_alpha);
+ window->lock_window("TitleColorButton::handle_done_event");
+ update_gui(orig_color);
+ window->unlock_window();
+ }
+}
+
TitleOutlineColorButton::TitleOutlineColorButton(TitleMain *client, TitleWindow *window, int x, int y)
- : BC_GenericButton(x, y, _("Outline color..."))
+ : ColorCircleButton(_("Outline Color"), x, y, COLOR_W, COLOR_H,
+ client->config.outline_color, client->config.outline_alpha, 1)
{
this->client = client;
this->window = window;
}
-int TitleOutlineColorButton::handle_event()
+int TitleOutlineColorButton::handle_new_color(int output, int alpha)
{
- window->outline_color_thread->start_window(client->config.outline_color,
- client->config.outline_alpha);
+ client->config.outline_color = output;
+ client->config.outline_alpha = alpha;
+ window->send_configure_change();
return 1;
}
+void TitleOutlineColorButton::handle_done_event(int result)
+{
+ if( result ) {
+ handle_new_color(orig_color, orig_alpha);
+ window->lock_window("TitleColorButton::handle_done_event");
+ update_gui(orig_color);
+ window->unlock_window();
+ }
+}
TitleMotion::TitleMotion(TitleMain *client, TitleWindow *window, int x, int y)
}
TitleTimecodeFormat::TitleTimecodeFormat(TitleMain *client, TitleWindow *window,
- int x, int y, const char *text)
- : BC_PopupMenu(x, y, 100, text, 1)
+ int x, int y, int tw, const char *text)
+ : BC_PopupMenu(x, y, BC_PopupMenu::calculate_w(tw)+10, text, 1)
{
this->client = client;
this->window = window;
int style = stroker && atof(stroker->get_text()) ? BC_FONT_OUTLINE : 0;
if( bold->get_value() ) style |= BC_FONT_BOLD;
if( italic->get_value() ) style |= BC_FONT_ITALIC;
+ if( alias->get_value() ) style |= FONT_ALIAS;
client->config.style = style;
}
}
TitleFont::TitleFont(TitleMain *client, TitleWindow *window, int x, int y)
: BC_PopupTextBox(window, &window->fonts, client->config.font,
- x, y, 240, 300, LISTBOX_ICON_LIST)
+ x, y, 340, 300, LISTBOX_ICON_LIST)
{
this->client = client;
this->window = window;
return 1;
}
-
-
-TitleColorThread::TitleColorThread(TitleMain *client, TitleWindow *window, int is_outline)
- : ColorPicker(1, is_outline? _("Outline Color") : _("Text Color"))
-{
- this->client = client;
- this->window = window;
- this->is_outline = is_outline;
-}
-
-int TitleColorThread::handle_new_color(int output, int alpha)
-{
- if( is_outline ) {
- client->config.outline_color = output;
- client->config.outline_alpha = alpha;
- }
- else {
- client->config.color = output;
- client->config.alpha = alpha;
- }
-
- window->lock_window("TitleColorThread::handle_new_color");
- window->update_color();
- window->flush();
- window->unlock_window();
-
- window->send_configure_change();
- return 1;
-}
-
TitleDrag::TitleDrag(TitleMain *client, TitleWindow *window, int x, int y)
: DragCheckBox(client->server->mwindow, x, y, _("Drag"), &client->config.drag,
client->config.title_x, client->config.title_y,
Track *TitleDrag::get_drag_track()
{
- return client->server->plugin->track;
+ return !client->server->plugin ? 0 :
+ client->server->plugin->track;
}
int64_t TitleDrag::get_drag_position()
{
}
void TitleColorPopup::handle_done_event(int result)
{
- if( result ) return;
- char txt[BCSTRLEN]; sprintf(txt, "<%s #%06x>", _(KW_COLOR), color_value);
- window->insert_ibeam(txt);
+ if( !result ) {
+ char txt[BCSTRLEN]; sprintf(txt, "<%s #%06x>", _(KW_COLOR), color_value);
+ window->lock_window("TitleColorPopup::handle_done_event");
+ window->insert_ibeam(txt);
+ window->unlock_window();
+ }
}
TitlePngPopup::TitlePngPopup(TitleMain *client, TitleWindow *window)
BrowseButtonWindow *gui = (BrowseButtonWindow *)get_gui();
const char *path = gui->get_submitted_path();
char txt[BCSTRLEN]; sprintf(txt, "<%s %s>", _(KW_PNG), path);
+ window->lock_window("TitlePngPopup::handle_done_event");
window->insert_ibeam(txt);
+ window->unlock_window();
}
BC_Window *TitlePngPopup::new_gui()