version update, rpm spec libva/vdpau fix, colorpicker tweaks, revert opencv v4->v3
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / titler / titlerwindow.C
index c34e29038840f23773e554c3456c43d3279e64e7..251389cd3240a5782c8330528a86acb506e6b883 100644 (file)
@@ -77,9 +77,8 @@ TitleWindow::TitleWindow(TitleMain *client)
        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;
 
@@ -91,9 +90,8 @@ TitleWindow::TitleWindow(TitleMain *client)
        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;
@@ -120,11 +118,12 @@ TitleWindow::TitleWindow(TitleMain *client)
 
 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()
@@ -136,7 +135,6 @@ TitleWindow::~TitleWindow()
 
        sizes.remove_all_objects();
        delete timecode_format;
-       delete color_thread;
        delete title_x;
        delete title_y;
 }
@@ -350,16 +348,12 @@ void TitleWindow::create_objects()
        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:")));
@@ -442,8 +436,10 @@ 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());
@@ -541,16 +537,8 @@ int TitleWindow::insert_ibeam(const char *txt, int ofs)
 
 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()
@@ -777,29 +765,50 @@ int TitlePitch::handle_event()
 }
 
 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, 1);
+       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, 1);
+       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);
+               update_gui(orig_color);
+       }
+}
 
 
 TitleMotion::TitleMotion(TitleMain *client, TitleWindow *window, int x, int y)
@@ -929,7 +938,7 @@ void TitleWindow::check_style(const char *font_name, int update)
 
 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;
@@ -1204,47 +1213,6 @@ int TitleBottom::handle_event()
        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;
-}
-
-void TitleColorThread::handle_done_event(int result)
-{
-       if( result ) {
-               client->config.color = orig_color;
-               client->config.alpha = orig_alpha;
-               handle_new_color(orig_color, orig_alpha);
-               window->update_color();
-               window->send_configure_change();
-       }
-}
-
 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,
@@ -1541,7 +1509,9 @@ void TitleColorPopup::handle_done_event(int result)
 {
        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();
        }
 }
 
@@ -1563,7 +1533,9 @@ void TitlePngPopup::handle_done_event(int result)
        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()