add audio to proxy, and minor bug fixes
[goodguy/history.git] / cinelerra-5.1 / cinelerra / assetpopup.C
index d39aaa13e5c96be7ce326c0119bb8c2c1a402bb8..15620af7a34c35f0f5d4950a445fe0dc5fbec782 100644 (file)
@@ -100,10 +100,11 @@ void AssetPopup::paste_assets()
        mwindow->gui->lock_window("AssetPopup::paste_assets");
        mwindow->cwindow->gui->lock_window("AssetPopup::paste_assets");
 
-       gui->collect_assets();
+       int proxy = mwindow->edl->session->awindow_folder == AW_PROXY_FOLDER ? 1 : 0;
+       gui->collect_assets(proxy);
        mwindow->paste_assets(mwindow->edl->local_session->get_selectionstart(1),
-               mwindow->edl->tracks->first,
-               0);   // do not overwrite
+               mwindow->edl->tracks->first, 0);   // do not overwrite
+       mwindow->session->clear_drag_proxy();
 
        gui->unlock_window();
        mwindow->gui->unlock_window();
@@ -140,7 +141,8 @@ void AssetPopup::match_all()
 int AssetPopup::update()
 {
        format->update();
-       gui->collect_assets();
+       int proxy = mwindow->edl->session->awindow_folder == AW_PROXY_FOLDER ? 1 : 0;
+       gui->collect_assets(proxy);
        return 0;
 }
 
@@ -160,10 +162,13 @@ int AssetPopupInfo::handle_event()
 {
        int cur_x, cur_y;
        popup->gui->get_abs_cursor(cur_x, cur_y);
-       if( mwindow->session->drag_assets->size() ) {
-               AssetEdit *asset_edit = mwindow->awindow->get_asset_editor();
-               asset_edit->edit_asset(
-                       mwindow->session->drag_assets->values[0], cur_x, cur_y);
+       int n = mwindow->session->drag_assets->size();
+       if( n > 0 ) {
+               for( int i=0; i<n; ++i ) {
+                       AssetEdit *asset_edit = mwindow->awindow->get_asset_editor();
+                       asset_edit->edit_asset(
+                               mwindow->session->drag_assets->values[i], cur_x-30*i, cur_y-30*i);
+               }
        }
        else if( mwindow->session->drag_clips->size() ) {
                popup->gui->awindow->clip_edit->edit_clip(
@@ -241,7 +246,6 @@ AssetPopupView::~AssetPopupView()
 int AssetPopupView::handle_event()
 {
        VWindow *vwindow = mwindow->get_viewer(1, DEFAULT_VWINDOW);
-       vwindow->gui->lock_window("AssetPopupView::handle_event");
 
        if( mwindow->session->drag_assets->total )
                vwindow->change_source(
@@ -251,7 +255,6 @@ int AssetPopupView::handle_event()
                vwindow->change_source(
                        mwindow->session->drag_clips->values[0]);
 
-       vwindow->gui->unlock_window();
        return 1;
 }
 
@@ -269,21 +272,18 @@ AssetPopupViewWindow::~AssetPopupViewWindow()
 
 int AssetPopupViewWindow::handle_event()
 {
-// Find window with nothing
-       VWindow *vwindow = mwindow->get_viewer(1);
-
-// TODO: create new vwindow or change current vwindow
-       vwindow->gui->lock_window("AssetPopupView::handle_event");
-
-       if( mwindow->session->drag_assets->total )
-               vwindow->change_source(
-                       mwindow->session->drag_assets->values[0]);
-       else
-       if( mwindow->session->drag_clips->total )
-               vwindow->change_source(
-                       mwindow->session->drag_clips->values[0]);
-
-       vwindow->gui->unlock_window();
+       for( int i=0; i<mwindow->session->drag_assets->size(); ++i ) {
+               VWindow *vwindow = mwindow->get_viewer(1);
+               vwindow->gui->lock_window("AssetPopupView::handle_event 1");
+               vwindow->change_source(mwindow->session->drag_assets->get(i));
+               vwindow->gui->unlock_window();
+       }
+       for( int i=0; i<mwindow->session->drag_clips->size(); ++i ) {
+               VWindow *vwindow = mwindow->get_viewer(1);
+               vwindow->gui->lock_window("AssetPopupView::handle_event 2");
+               vwindow->change_source(mwindow->session->drag_clips->get(i));
+               vwindow->gui->unlock_window();
+       }
        return 1;
 }
 
@@ -809,7 +809,8 @@ int SnapshotMenuItem::handle_event()
 
                double position = edl->local_session->get_selectionstart(1);
                int64_t source_position = (int64_t)(position * edl->get_frame_rate());
-               ret = render_engine.vrender->process_buffer(frame, source_position, 0);
+               ret = !render_engine.vrender ? 1 :
+                       render_engine.vrender->process_buffer(frame, source_position, 0);
                if( !ret )
                        ret = file.write_video_buffer(1);
                file.close_file();
@@ -965,6 +966,7 @@ int GrabshotPopup::grab_event(XEvent *event)
        int cw = lx1-lx0, ch = ly1-ly0;
        hide_window();
        sync_display();
+       grab_thread->done = 1;
 
        MWindow *mwindow = grab_thread->mwindow;
        Preferences *preferences = mwindow->preferences;
@@ -996,12 +998,15 @@ int GrabshotPopup::grab_event(XEvent *event)
                asset->format = FILE_PPM;
                break;
        }
+
 // no odd dimensions
        int rw = get_root_w(0), rh = get_root_h(0);
        if( cx < 0 ) { cw += cx;  cx = 0; }
        if( cy < 0 ) { ch += cy;  cy = 0; }
        if( cx+cw > rw ) cw = rw-cx;
        if( cy+ch > rh ) ch = rh-cy;
+       if( !cw || !ch ) return 1;
+
        VFrame vframe(cw,ch, BC_RGB888);
        if( cx+cw < rw ) ++cw;
        if( cy+ch < rh ) ++ch;
@@ -1040,7 +1045,6 @@ int GrabshotPopup::grab_event(XEvent *event)
                asset->remove_user();
        }
 
-       grab_thread->done = 1;
        return 1;
 }