vicon jittering, opengl no draw_refresh if no ovly for last frame
[goodguy/history.git] / cinelerra-5.1 / cinelerra / awindowgui.C
index 9f966f75f6a8116087033dd530b7abd62979aa85..d7f6268b3cbc4a49ba7968c70fc33675dc65d60b 100644 (file)
@@ -173,12 +173,12 @@ int64_t AssetVIcon::set_seq_no(int64_t no)
 int AssetVIcon::get_vx()
 {
        BC_ListBox *lbox = picon->gui->asset_list;
-       return lbox->get_item_x(picon) + ICON_MARGIN;
+       return lbox->get_icon_x(picon);
 }
 int AssetVIcon::get_vy()
 {
        BC_ListBox *lbox = picon->gui->asset_list;
-       return lbox->get_item_y(picon) + ICON_MARGIN;
+       return lbox->get_icon_y(picon);
 }
 
 void AssetVIcon::load_audio()
@@ -371,6 +371,7 @@ AssetPicon::~AssetPicon()
 {
        if( vicon )
                gui->vicon_thread->del_vicon(vicon);
+       delete vicon_frame;
        if( indexable ) indexable->remove_user();
        if( edl ) edl->remove_user();
        if( icon && !gui->protected_pixmap(icon) ) {
@@ -436,6 +437,7 @@ void AssetPicon::reset()
        icon = 0;
        icon_vframe = 0;
        vicon = 0;
+       vicon_frame = 0;
        in_use = 1;
        comments_time = 0;
        id = 0;
@@ -1049,8 +1051,7 @@ void AWindowGUI::create_objects()
        add_subwindow(asset_list = new AWindowAssets(mwindow, this, x1, y1, w1, h1));
 
        vicon_thread = new VIconThread(asset_list);
-       int x0 = 0, y0 = asset_list->get_title_h();
-       vicon_thread->set_drawing_area(x0,y0, get_w(),get_h());
+       asset_list->update_vicon_area();
        vicon_thread->start();
        vicon_audio = new AssetVIconAudio(this);
 
@@ -1136,10 +1137,7 @@ int AWindowGUI::resize_event(int w, int h)
 //     view->reposition_window(x, y);
 
        BC_WindowBase::resize_event(w, h);
-       int x0 = 0, x1 = asset_list->get_w();
-       int y0 = asset_list->get_title_h();
-       int y1 = asset_list->get_h();
-       vicon_thread->set_drawing_area(x0,y0, x1,y1);
+       asset_list->update_vicon_area();
        return 1;
 }
 
@@ -1201,13 +1199,14 @@ int AWindowGUI::close_event()
 
 void AWindowGUI::start_vicon_drawing()
 {
-       if( !vicon_drawing ) return;
+       if( !vicon_drawing || !vicon_thread->interrupted ) return;
        if( mwindow->edl->session->awindow_folder == AW_MEDIA_FOLDER ||
            mwindow->edl->session->awindow_folder >= AWINDOW_USER_FOLDERS ) {
                switch( mwindow->edl->session->assetlist_format ) {
                case ASSETS_ICONS:
                case ASSETS_ICONS_PACKED:
                case ASSETS_ICON_LIST:
+                       asset_list->update_vicon_area();
                        vicon_thread->start_drawing();
                        break;
                default:
@@ -1218,9 +1217,22 @@ void AWindowGUI::start_vicon_drawing()
 
 void AWindowGUI::stop_vicon_drawing()
 {
+       if( vicon_thread->interrupted ) return;
        vicon_thread->stop_drawing();
 }
 
+VFrame *AssetPicon::get_vicon_frame()
+{
+       if( !vicon ) return 0;
+       if( gui->vicon_thread->interrupted ) return 0;
+       VFrame *frame = vicon->frame();
+       if( !frame ) return 0;
+       if( !vicon_frame )
+               vicon_frame = new VFrame(vicon->vw, vicon->vh, frame->get_color_model());
+       vicon_frame->transfer_from(frame);
+       return vicon_frame;
+}
+
 int AWindowGUI::cycle_assetlist_format()
 {
        EDLSession *session = mwindow->edl->session;
@@ -1244,11 +1256,6 @@ int AWindowGUI::cycle_assetlist_format()
        stop_vicon_drawing();
        session->assetlist_format = format;
        asset_list->update_format(session->assetlist_format, 0);
-       int x0 = 0;
-       int x1 = asset_list->get_w();
-       int y0 = asset_list->get_title_h();
-       int y1 = asset_list->get_h();
-       vicon_thread->set_drawing_area(x0,y0, x1,y1);
        async_update_assets();
        start_vicon_drawing();
        return 1;
@@ -1882,11 +1889,6 @@ void AWindowGUI::update_assets()
 
        if( mwindow->edl->session->assetlist_format != asset_list->get_format() ) {
                asset_list->update_format(mwindow->edl->session->assetlist_format, 0);
-               int x0 = 0;
-               int x1 = asset_list->get_w();
-               int y0 = asset_list->get_title_h();
-               int y1 = asset_list->get_h();
-               vicon_thread->set_drawing_area(x0,y0, x1,y1);
        }
        int asset_xposition = asset_list->get_xposition();
        int asset_yposition = asset_list->get_yposition();
@@ -2225,7 +2227,6 @@ int AWindowAssets::selection_changed()
                }
 
                BC_ListBox::deactivate_selection();
-               return 1;
        }
        else if( gui->vicon_drawing &&
                 get_button_down() && get_buttonpress() == 1 &&
@@ -2237,7 +2238,7 @@ int AWindowAssets::selection_changed()
                gui->vicon_thread->set_view_popup(vicon);
 
        }
-       return 0;
+       return 1;
 }
 
 void AWindowAssets::draw_background()
@@ -2412,6 +2413,18 @@ int AWindowAssets::focus_out_event()
        return BC_ListBox::focus_out_event();
 }
 
+void AWindowAssets::update_vicon_area()
+{
+       int x0 = 0, x1 = get_w();
+       int y0 = get_title_h();
+       int y1 = get_h();
+       if( is_highlighted() ) {
+               x0 += LISTBOX_BORDER;  x1 -= LISTBOX_BORDER;
+               y0 += LISTBOX_BORDER;  y1 -= LISTBOX_BORDER;
+       }
+       gui->vicon_thread->set_drawing_area(x0,y0, x1,y1);
+}
+
 AWindowSearchTextBox::AWindowSearchTextBox(AWindowSearchText *search_text, int x, int y, int w)
  : BC_TextBox(x, y, w, 1, "")
 {