X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fassetpopup.C;h=059e5850d86de696bbe8462c77bb503c41c7e1fd;hb=eecf057a9d6b8c8cffc7d0001bff89bc9cac7b05;hp=bb0e2a339317d3c5d5c197672b50816e45316191;hpb=be678a5c5c4ec7dd15b9f49e4f476375f98649e0;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/cinelerra/assetpopup.C b/cinelerra-5.1/cinelerra/assetpopup.C index bb0e2a33..059e5850 100644 --- a/cinelerra-5.1/cinelerra/assetpopup.C +++ b/cinelerra-5.1/cinelerra/assetpopup.C @@ -37,11 +37,14 @@ #include "edl.h" #include "edlsession.h" #include "file.h" +#include "filesystem.h" #include "filexml.h" #include "language.h" +#include "loadfile.h" #include "localsession.h" #include "mainerror.h" #include "mainindexes.h" +#include "mainmenu.h" #include "mainsession.h" #include "mwindow.h" #include "mwindowgui.h" @@ -100,10 +103,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 +144,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 +165,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; iawindow->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 +249,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 +258,6 @@ int AssetPopupView::handle_event() vwindow->change_source( mwindow->session->drag_clips->values[0]); - vwindow->gui->unlock_window(); return 1; } @@ -269,21 +275,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; isession->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; isession->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; } @@ -300,39 +303,9 @@ AssetPopupMixer::~AssetPopupMixer() int AssetPopupMixer::handle_event() { - ArrayListnew_mixers; - - mwindow->select_zwindow(0); - for( int i=0; isession->drag_assets->total; ++i ) { - Indexable *indexable = mwindow->session->drag_assets->values[i]; - ArrayList new_assets; - new_assets.append(indexable); - Track *track = mwindow->edl->tracks->last; - mwindow->load_assets(&new_assets, -1, LOADMODE_NEW_TRACKS, 0, 0, 0, 0, 0, 0); - track = !track ? mwindow->edl->tracks->first : track->next; - Mixer *mixer = 0; - ZWindow *zwindow = mwindow->get_mixer(mixer); - while( track ) { - track->play = track->record = 0; - if( track->data_type == TRACK_VIDEO ) { - sprintf(track->title, _("Mixer %d"), zwindow->idx); - } - mixer->mixer_ids.append(track->get_mixer_id()); - track = track->next; - } - char *path = indexable->path; - char *tp = strrchr(path, '/'); - if( !tp ) tp = path; else ++tp; - zwindow->set_title(tp); - new_mixers.append(zwindow); - } - - mwindow->tile_mixers(); - for( int i=0; istart(); - - mwindow->refresh_mixers(); - mwindow->resync_guis(); + mwindow->gui->lock_window("AssetPopupMixer::handle_event"); + mwindow->create_mixers(); + mwindow->gui->unlock_window(); return 1; } @@ -450,6 +423,7 @@ AssetListMenu::~AssetListMenu() void AssetListMenu::create_objects() { + add_item(load_file = new AssetPopupLoadFile(mwindow, gui)); add_item(format = new AWindowListFormat(mwindow, gui)); add_item(new AWindowListSort(mwindow, gui)); add_item(new AssetListCopy(mwindow, gui)); @@ -460,15 +434,34 @@ void AssetListMenu::create_objects() snapshot_submenu->add_submenuitem(new SnapshotMenuItem(snapshot_submenu, _("png"), SNAPSHOT_PNG)); snapshot_submenu->add_submenuitem(new SnapshotMenuItem(snapshot_submenu, _("jpeg"), SNAPSHOT_JPEG)); snapshot_submenu->add_submenuitem(new SnapshotMenuItem(snapshot_submenu, _("tiff"), SNAPSHOT_TIFF)); + snapshot_submenu->add_submenuitem(new SnapshotMenuItem(snapshot_submenu, _("ppm"), SNAPSHOT_PPM)); GrabshotSubMenu *grabshot_submenu; add_item(asset_grabshot = new AssetGrabshot(mwindow, this)); asset_grabshot->add_submenu(grabshot_submenu = new GrabshotSubMenu(asset_grabshot)); grabshot_submenu->add_submenuitem(new GrabshotMenuItem(grabshot_submenu, _("png"), GRABSHOT_PNG)); grabshot_submenu->add_submenuitem(new GrabshotMenuItem(grabshot_submenu, _("jpeg"), GRABSHOT_JPEG)); grabshot_submenu->add_submenuitem(new GrabshotMenuItem(grabshot_submenu, _("tiff"), GRABSHOT_TIFF)); + grabshot_submenu->add_submenuitem(new GrabshotMenuItem(grabshot_submenu, _("ppm"), GRABSHOT_PPM)); update_titles(shots_displayed = 1); } +AssetPopupLoadFile::AssetPopupLoadFile(MWindow *mwindow, AWindowGUI *gui) + : BC_MenuItem(_("Load files..."), "o", 'o') +{ + this->mwindow = mwindow; + this->gui = gui; +} + +AssetPopupLoadFile::~AssetPopupLoadFile() +{ +} + +int AssetPopupLoadFile::handle_event() +{ + mwindow->gui->mainmenu->load_file->thread->start(); + return 1; +} + void AssetListMenu::update_titles(int shots) { format->update(); @@ -777,17 +770,20 @@ int SnapshotMenuItem::handle_event() Preferences *preferences = mwindow->preferences; char filename[BCTEXTLEN]; - static const char *exts[] = { "png", "jpg", "tif" }; + static const char *exts[] = { "png", "jpg", "tif", "ppm" }; time_t tt; time(&tt); struct tm tm; localtime_r(&tt,&tm); snprintf(filename,sizeof(filename),"%s/%s_%04d%02d%02d-%02d%02d%02d.%s", preferences->snapshot_path, _("snap"), 1900+tm.tm_year,1+tm.tm_mon,tm.tm_mday, tm.tm_hour,tm.tm_min,tm.tm_sec, exts[mode]); + char *asset_path = FileSystem::basepath(filename); + Asset *asset = new Asset(asset_path); + delete [] asset_path; + int fw = edl->get_w(), fh = edl->get_h(); int fcolor_model = edl->session->color_model; - Asset *asset = new Asset(filename); switch( mode ) { case SNAPSHOT_PNG: asset->format = FILE_PNG; @@ -802,6 +798,9 @@ int SnapshotMenuItem::handle_event() asset->tiff_cmodel = 0; asset->tiff_compression = 0; break; + case SNAPSHOT_PPM: + asset->format = FILE_PPM; + break; } asset->width = fw; asset->height = fh; @@ -834,7 +833,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(); @@ -990,40 +990,48 @@ 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; char filename[BCTEXTLEN]; - static const char *exts[] = { "png", "jpg", "tif" }; + static const char *exts[] = { "png", "jpg", "tif", "ppm" }; time_t tt; time(&tt); struct tm tm; localtime_r(&tt,&tm); snprintf(filename,sizeof(filename),"%s/%s_%04d%02d%02d-%02d%02d%02d.%s", preferences->snapshot_path, _("grab"), 1900+tm.tm_year,1+tm.tm_mon,tm.tm_mday, tm.tm_hour,tm.tm_min,tm.tm_sec, exts[mode]); - - Asset *asset = new Asset(filename); + char *asset_path = FileSystem::basepath(filename); + Asset *asset = new Asset(asset_path); + delete [] asset_path; switch( mode ) { - case SNAPSHOT_PNG: + case GRABSHOT_PNG: asset->format = FILE_PNG; asset->png_use_alpha = 1; break; - case SNAPSHOT_JPEG: + case GRABSHOT_JPEG: asset->format = FILE_JPEG; asset->jpeg_quality = 90; break; - case SNAPSHOT_TIFF: + case GRABSHOT_TIFF: asset->format = FILE_TIFF; asset->tiff_cmodel = 0; asset->tiff_compression = 0; break; + case GRABSHOT_PPM: + 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; @@ -1062,7 +1070,6 @@ int GrabshotPopup::grab_event(XEvent *event) asset->remove_user(); } - grab_thread->done = 1; return 1; }