pop tool_gui on open, add camera/projector add_keyfrm/reset, overlay gui pan/mode...
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / titler / titlerwindow.C
index 251389cd3240a5782c8330528a86acb506e6b883..ba93e19980a70c0ca995f9e136e2c644670d62a4 100644 (file)
@@ -367,10 +367,16 @@ void TitleWindow::create_objects()
        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;
@@ -405,7 +411,7 @@ void TitleWindow::create_objects()
        png_popup = new TitlePngPopup(client, this);
 
        show_window(1);
-       update();
+       update_gui();
 }
 
 int TitleWindow::resize_event(int w, int h)
@@ -484,8 +490,9 @@ void TitleWindow::send_configure_change()
 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;
 
@@ -502,8 +509,9 @@ void TitleWindow::previous_font()
 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;
 
@@ -556,7 +564,7 @@ void TitleWindow::update_stats()
        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);
@@ -806,7 +814,9 @@ 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();
        }
 }
 
@@ -852,8 +862,8 @@ int TitleTimecode::handle_event()
 }
 
 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;
@@ -932,6 +942,7 @@ void TitleWindow::check_style(const char *font_name, int update)
                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;
        }
 }
@@ -1224,7 +1235,8 @@ TitleDrag::TitleDrag(TitleMain *client, TitleWindow *window, int x, int 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()
 {