X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;ds=sidebyside;f=cinelerra-5.1%2Fcinelerra%2Fassetpopup.C;h=ba828166fa48e285de9f62f922c55a863a94007b;hb=bb755e4be7602e9e2705fdb49a76e49dbb2c5008;hp=244e472fe82f1bcfafb42ec0c64b80bd0dfdc80d;hpb=e41864cf7931bfb86f68c5d35d4578dfe161d386;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/cinelerra/assetpopup.C b/cinelerra-5.1/cinelerra/assetpopup.C index 244e472f..ba828166 100644 --- a/cinelerra-5.1/cinelerra/assetpopup.C +++ b/cinelerra-5.1/cinelerra/assetpopup.C @@ -76,12 +76,16 @@ void AssetPopup::create_objects() BC_SubMenu *submenu; add_item(info = new AssetPopupInfo(mwindow, this)); add_item(format = new AWindowListFormat(mwindow, gui)); - add_item(new AssetPopupSort(mwindow, this)); + add_item(open_edl = new AssetPopupOpenEDL(mwindow, this)); + add_item(close_edl = new AssetPopupCloseEDL(mwindow, gui)); + add_item(to_clip = new AssetPopupToClip(mwindow, this)); + add_item(sort = new AssetPopupSort(mwindow, this)); add_item(index = new AssetPopupBuildIndex(mwindow, this)); add_item(view = new AssetPopupView(mwindow, this)); add_item(view_window = new AssetPopupViewWindow(mwindow, this)); - add_item(mixer = new AssetPopupMixer(mwindow, this)); - add_item(new AssetPopupPaste(mwindow, this)); + add_item(open_mixer = new AssetPopupOpenMixer(mwindow, this)); + add_item(insert_mixer = new AssetPopupInsertMixer(mwindow, this)); + add_item(paste = new AssetPopupPaste(mwindow, this)); add_item(menu_item = new BC_MenuItem(_("Match..."))); menu_item->add_submenu(submenu = new BC_SubMenu()); submenu->add_submenuitem(new AssetMatchSize(mwindow, this)); @@ -142,6 +146,28 @@ int AssetPopup::update() format->update(); int proxy = mwindow->edl->session->awindow_folder == AW_PROXY_FOLDER ? 1 : 0; gui->collect_assets(proxy); + int enable_open = 0; + int assets_total = mwindow->session->drag_assets->size(); + Indexable *idxbl = !assets_total ? 0 : + mwindow->session->drag_assets->get(0); + if( idxbl ) { + if( idxbl->is_asset ) { + Asset *asset = (Asset *)idxbl; + if( asset->format == FILE_REF ) + enable_open = 1; + } + else + enable_open = 1; + } + open_edl->set_enabled(enable_open); + int enable_close = mwindow->stack.size() > 0 ? 1 : 0; + close_edl->set_enabled(enable_close); + int enable_clip = 0; + for( int i=0; !enable_clip && isession->drag_assets->get(i); + if( !idxbl->is_asset ) enable_clip = 1; + } + to_clip->set_enabled(enable_clip); return 0; } @@ -163,10 +189,11 @@ int AssetPopupInfo::handle_event() popup->gui->get_abs_cursor(cur_x, cur_y); int n = mwindow->session->drag_assets->size(); if( n > 0 ) { + int xs30 = xS(30), ys30 = yS(30); 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); + mwindow->session->drag_assets->values[i], cur_x-xs30*i, cur_y-ys30*i); } } else if( mwindow->session->drag_clips->size() ) { @@ -177,6 +204,91 @@ int AssetPopupInfo::handle_event() } +AssetPopupOpenEDL::AssetPopupOpenEDL(MWindow *mwindow, AssetPopup *popup) + : BC_MenuItem(_("Open EDL")) +{ + this->mwindow = mwindow; + this->popup = popup; +} +AssetPopupOpenEDL::~AssetPopupOpenEDL() +{ +} + +int AssetPopupOpenEDL::handle_event() +{ + int assets_total = mwindow->session->drag_assets->size(); + if( !assets_total ) return 1; + popup->unlock_window(); + EDL *edl = 0; + Indexable *idxbl = mwindow->session->drag_assets->get(0); + if( idxbl->is_asset ) { + Asset *asset = (Asset *)idxbl; + if( asset->format == FILE_REF ) { + FileXML xml_file; + const char *filename = asset->path; + if( xml_file.read_from_file(filename, 1) ) { + eprintf(_("Error: unable to open:\n %s"), filename); + return 1; + } + edl = new EDL; + edl->create_objects(); + if( edl->load_xml(&xml_file, LOAD_ALL) ) { + eprintf(_("Error: unable to load:\n %s"), filename); + edl->remove_user(); + return 1; + } + } + } + else { + edl = (EDL *)idxbl; + } + if( edl ) + mwindow->stack_push(edl, idxbl); + else + eprintf(_("media is not EDL:\n%s"), idxbl->path); + popup->lock_window("AssetPopupOpenEDL::handle_event"); + return 1; +} + +AssetPopupCloseEDL::AssetPopupCloseEDL(MWindow *mwindow, AWindowGUI *gui) + : BC_MenuItem(_("Close EDL")) +{ + this->mwindow = mwindow; + this->gui = gui; +} +AssetPopupCloseEDL::~AssetPopupCloseEDL() +{ +} + +int AssetPopupCloseEDL::handle_event() +{ + gui->unlock_window(); + mwindow->gui->lock_window("AssetPopupCloseEDL::handle_event"); + mwindow->stack_pop(); + mwindow->gui->unlock_window(); + gui->lock_window("AssetPopupCloseEDL::handle_event"); + return 1; +} + + +AssetPopupToClip::AssetPopupToClip(MWindow *mwindow, AssetPopup *popup) + : BC_MenuItem(_("EDL to clip")) +{ + this->mwindow = mwindow; + this->popup = popup; +} + +AssetPopupToClip::~AssetPopupToClip() +{ +} + +int AssetPopupToClip::handle_event() +{ + mwindow->media_to_clip(); + return 1; +} + + AssetPopupBuildIndex::AssetPopupBuildIndex(MWindow *mwindow, AssetPopup *popup) : BC_MenuItem(_("Rebuild index")) { @@ -269,25 +381,44 @@ int AssetPopupViewWindow::handle_event() return 1; } -AssetPopupMixer::AssetPopupMixer(MWindow *mwindow, AssetPopup *popup) +AssetPopupOpenMixer::AssetPopupOpenMixer(MWindow *mwindow, AssetPopup *popup) : BC_MenuItem(_("Open Mixers")) { this->mwindow = mwindow; this->popup = popup; } -AssetPopupMixer::~AssetPopupMixer() +AssetPopupOpenMixer::~AssetPopupOpenMixer() { } -int AssetPopupMixer::handle_event() +int AssetPopupOpenMixer::handle_event() { - mwindow->gui->lock_window("AssetPopupMixer::handle_event"); + mwindow->gui->lock_window("AssetPopupOpenMixer::handle_event"); mwindow->create_mixers(); mwindow->gui->unlock_window(); return 1; } +AssetPopupInsertMixer::AssetPopupInsertMixer(MWindow *mwindow, AssetPopup *popup) + : BC_MenuItem(_("Insert Mixers")) +{ + this->mwindow = mwindow; + this->popup = popup; +} + +AssetPopupInsertMixer::~AssetPopupInsertMixer() +{ +} + +int AssetPopupInsertMixer::handle_event() +{ + mwindow->gui->lock_window("AssetPopupInsertMixer::handle_event"); + mwindow->create_mixers(-1); + mwindow->gui->unlock_window(); + return 1; +} + AssetPopupPaste::AssetPopupPaste(MWindow *mwindow, AssetPopup *popup) : BC_MenuItem(_("Paste")) { @@ -359,9 +490,10 @@ AssetPopupProjectRemove::~AssetPopupProjectRemove() int AssetPopupProjectRemove::handle_event() { - mwindow->remove_assets_from_project(1, 1, - mwindow->session->drag_assets, - mwindow->session->drag_clips); + popup->gui->unlock_window(); + mwindow->remove_assets_from_project(1, 1, 1, + mwindow->session->drag_assets, 0); + popup->gui->lock_window("AssetPopupProjectRemove::handle_event"); return 1; } @@ -394,21 +526,20 @@ AssetListMenu::AssetListMenu(MWindow *mwindow, AWindowGUI *gui) AssetListMenu::~AssetListMenu() { - if( !shots_displayed ) { - delete asset_snapshot; - delete asset_grabshot; - } } void AssetListMenu::create_objects() { add_item(load_file = new AssetPopupLoadFile(mwindow, gui)); add_item(format = new AWindowListFormat(mwindow, gui)); + add_item(close_edl = new AssetPopupCloseEDL(mwindow, gui)); add_item(select_used = new AssetSelectUsed(mwindow, gui)); BC_SubMenu *submenu; select_used->add_submenu(submenu = new BC_SubMenu()); + submenu->add_submenuitem(new AssetSelectUsedItem(select_used, _("All"), SELECT_ALL)); submenu->add_submenuitem(new AssetSelectUsedItem(select_used, _("Used"), SELECT_USED)); submenu->add_submenuitem(new AssetSelectUsedItem(select_used, _("Unused"), SELECT_UNUSED)); + submenu->add_submenuitem(new AssetSelectUsedItem(select_used, _("None"), SELECT_NONE)); add_item(new AWindowListSort(mwindow, gui)); add_item(new AssetListCopy(mwindow, gui)); add_item(new AssetListPaste(mwindow, gui)); @@ -426,7 +557,7 @@ void AssetListMenu::create_objects() 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); + update_titles(1); } AssetPopupLoadFile::AssetPopupLoadFile(MWindow *mwindow, AWindowGUI *gui) @@ -449,16 +580,10 @@ int AssetPopupLoadFile::handle_event() void AssetListMenu::update_titles(int shots) { format->update(); - if( shots && !shots_displayed ) { - shots_displayed = 1; - add_item(asset_snapshot); - add_item(asset_grabshot); - } - else if( !shots && shots_displayed ) { - shots_displayed = 0; - remove_item(asset_snapshot); - remove_item(asset_grabshot); - } + int enable_close = mwindow->stack.size() > 0 ? 1 : 0; + close_edl->set_enabled(enable_close); + asset_snapshot->set_enabled(shots); + asset_grabshot->set_enabled(shots); } AssetListCopy::AssetListCopy(MWindow *mwindow, AWindowGUI *gui) @@ -549,11 +674,13 @@ void AssetCopyDialog::handle_close_event(int result) copy_window = 0; } +#define ACW_W xS(500) +#define ACW_H yS(200) AssetCopyWindow::AssetCopyWindow(AssetCopyDialog *copy_dialog) : BC_Window(_(PROGRAM_NAME ": Copy File List"), - copy_dialog->x - 500/2, copy_dialog->y - 200/2, - 500, 200, 500, 200, 1, 0, 1) + copy_dialog->x - ACW_W/2, copy_dialog->y - ACW_H/2, + ACW_W, ACW_H, ACW_W, ACW_H, 1, 0, 1) { this->copy_dialog = copy_dialog; } @@ -566,11 +693,13 @@ void AssetCopyWindow::create_objects() { lock_window("AssetCopyWindow::create_objects"); BC_Title *title; - int x = 10, y = 10, pad = 5; + int xs10 = xS(10); + int ys5 = yS(5), ys10 = yS(10); + int x = xs10, y = ys10; add_subwindow(title = new BC_Title(x, y, _("List of asset paths:"))); - y += title->get_h() + pad; + y += title->get_h() + ys5; int text_w = get_w() - x - 10; - int text_h = get_h() - y - BC_OKButton::calculate_h() - pad; + int text_h = get_h() - y - BC_OKButton::calculate_h() - ys5; int text_rows = BC_TextBox::pixels_to_rows(this, MEDIUMFONT, text_h); char *text = copy_dialog->text; int len = strlen(text) + BCTEXTLEN; @@ -584,9 +713,9 @@ void AssetCopyWindow::create_objects() int AssetCopyWindow::resize_event(int w, int h) { - int fx = file_list->get_x(), fy = file_list->get_y(), pad = 5; - int text_w = w - fx - 10; - int text_h = h - fy - BC_OKButton::calculate_h() - pad; + int fx = file_list->get_x(), fy = file_list->get_y(); + int text_w = w - fx - xS(10); + int text_h = h - fy - BC_OKButton::calculate_h() - yS(5); int text_rows = BC_TextBox::pixels_to_rows(this, MEDIUMFONT, text_h); file_list->reposition_window(fx, fy, text_w, text_rows); return 0; @@ -658,7 +787,8 @@ void AssetPasteDialog::handle_done_event(int result) MWindow *mwindow = paste->mwindow; mwindow->interrupt_indexes(); mwindow->gui->lock_window("AssetPasteDialog::handle_done_event"); - result = mwindow->load_filenames(&path_list, LOADMODE_RESOURCESONLY, 0); + result = mwindow->load_filenames(&path_list, + LOADMODE_RESOURCESONLY, LOADMODE_EDL_CLIP, 0); mwindow->gui->unlock_window(); path_list.remove_all_objects(); mwindow->save_backup(); @@ -677,10 +807,13 @@ void AssetPasteDialog::start(int x, int y) BC_DialogThread::start(); } +#define APW_W xS(500) +#define APW_H yS(200) + AssetPasteWindow::AssetPasteWindow(AssetPasteDialog *paste_dialog) : BC_Window(_(PROGRAM_NAME ": Paste File List"), - paste_dialog->x - 500/2, paste_dialog->y - 200/2, - 500, 200, 500, 200, 1, 0, 1) + paste_dialog->x - APW_W/2, paste_dialog->y - APW_H/2, + APW_W, APW_H, APW_W, APW_H, 1, 0, 1) { this->paste_dialog = paste_dialog; } @@ -693,11 +826,13 @@ void AssetPasteWindow::create_objects() { lock_window("AssetPasteWindow::create_objects()"); BC_Title *title; - int x = 10, y = 10, pad = 5; + int xs10 = xS(10); + int ys5 = yS(5), ys10 = yS(10); + int x = xs10, y = ys10; add_subwindow(title = new BC_Title(x, y, _("Enter list of asset paths:"))); - y += title->get_h() + pad; - int text_w = get_w() - x - 10; - int text_h = get_h() - y - BC_OKButton::calculate_h() - pad; + y += title->get_h() + ys5; + int text_w = get_w() - x - xs10; + int text_h = get_h() - y - BC_OKButton::calculate_h() - ys5; int text_rows = BC_TextBox::pixels_to_rows(this, MEDIUMFONT, text_h); file_list = new BC_ScrollTextBox(this, x, y, text_w, text_rows, (char*)0, 65536); file_list->create_objects(); @@ -709,9 +844,9 @@ void AssetPasteWindow::create_objects() int AssetPasteWindow::resize_event(int w, int h) { - int fx = file_list->get_x(), fy = file_list->get_y(), pad = 5; - int text_w = w - fx - 10; - int text_h = h - fy - BC_OKButton::calculate_h() - pad; + int fx = file_list->get_x(), fy = file_list->get_y(); + int text_w = w - fx - xS(10); + int text_h = h - fy - BC_OKButton::calculate_h() - yS(5); int text_rows = BC_TextBox::pixels_to_rows(this, MEDIUMFONT, text_h); file_list->reposition_window(fx, fy, text_w, text_rows); return 0; @@ -757,12 +892,13 @@ int SnapshotMenuItem::handle_event() if( !edl->have_video() ) return 1; Preferences *preferences = mwindow->preferences; - char filename[BCTEXTLEN]; + char filename[BCTEXTLEN], snapshot_path[BCTEXTLEN]; static const char *exts[] = { "png", "jpg", "tif", "ppm" }; time_t tt; time(&tt); struct tm tm; localtime_r(&tt,&tm); + File::getenv_path(snapshot_path, preferences->snapshot_path); snprintf(filename,sizeof(filename),"%s/%s_%04d%02d%02d-%02d%02d%02d.%s", - preferences->snapshot_path, _("snap"), + 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); @@ -982,12 +1118,13 @@ int GrabshotPopup::grab_event(XEvent *event) MWindow *mwindow = grab_thread->mwindow; Preferences *preferences = mwindow->preferences; - char filename[BCTEXTLEN]; + char filename[BCTEXTLEN], snapshot_path[BCTEXTLEN]; static const char *exts[] = { "png", "jpg", "tif", "ppm" }; time_t tt; time(&tt); struct tm tm; localtime_r(&tt,&tm); + File::getenv_path(snapshot_path, preferences->snapshot_path); snprintf(filename,sizeof(filename),"%s/%s_%04d%02d%02d-%02d%02d%02d.%s", - preferences->snapshot_path, _("grab"), + 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]); char *asset_path = FileSystem::basepath(filename);