From: Good Guy Date: Sat, 17 Mar 2018 21:58:58 +0000 (-0600) Subject: fixes for errs in nested edl rework, proxy popup delete X-Git-Url: https://cinelerra-gg.org/git/?a=commitdiff_plain;h=d079f6253a75cc8cfedbab636ad0bc7f5dc9c5f5;p=goodguy%2Fhistory.git fixes for errs in nested edl rework, proxy popup delete --- diff --git a/cinelerra-5.1/cinelerra/clipedls.C b/cinelerra-5.1/cinelerra/clipedls.C index 52dd7678..6f384fe8 100644 --- a/cinelerra-5.1/cinelerra/clipedls.C +++ b/cinelerra-5.1/cinelerra/clipedls.C @@ -35,7 +35,7 @@ void ClipEDLs::remove_clip(EDL *clip) } -EDL* ClipEDLs::get_copy(EDL *src) +EDL* ClipEDLs::get_nested(EDL *src) { if( !src ) return 0; for( int i=0; ilock_window("ClipPopupNest::handle_event 1"); if( mwindow->session->drag_clips->total > 0 ) { EDL *edl = mwindow->edl; + time_t dt; time(&dt); + struct tm dtm; localtime_r(&dt, &dtm); + char path[BCSTRLEN]; + sprintf(path, _("Nested_%02d%02d%02d-%02d%02d%02d"), + dtm.tm_year+1900, dtm.tm_mon+1, dtm.tm_mday, + dtm.tm_hour, dtm.tm_min, dtm.tm_sec); EDL *clip = mwindow->session->drag_clips->values[0]; - EDL *new_clip = new EDL(edl); - new_clip->create_objects(); - new_clip->copy_all(clip); + EDL *nested = edl->new_nested(clip, path); + EDL *new_clip = edl->create_nested_clip(nested); new_clip->awindow_folder = AW_CLIP_FOLDER; + sprintf(new_clip->local_session->clip_icon, + "clip_%02d%02d%02d-%02d%02d%02d.png", + dtm.tm_year+1900, dtm.tm_mon+1, dtm.tm_mday, + dtm.tm_hour, dtm.tm_min, dtm.tm_sec); snprintf(new_clip->local_session->clip_title, sizeof(new_clip->local_session->clip_title), _("Nested: %s"), clip->local_session->clip_title); strcpy(new_clip->local_session->clip_notes, clip->local_session->clip_notes); - time_t dt; time(&dt); - struct tm dtm; localtime_r(&dt, &dtm); - sprintf(new_clip->local_session->clip_icon, - "clip_%02d%02d%02d-%02d%02d%02d.png", - dtm.tm_year+1900, dtm.tm_mon+1, dtm.tm_mday, - dtm.tm_hour, dtm.tm_min, dtm.tm_sec); - char path[BCSTRLEN]; - sprintf(path, _("Nested_%02d%02d%02d-%02d%02d%02d"), - dtm.tm_year+1900, dtm.tm_mon+1, dtm.tm_mday, - dtm.tm_hour, dtm.tm_min, dtm.tm_sec); - EDL *clip_edl = edl->new_nested(new_clip, path); - new_clip->remove_user(); int idx = edl->clips.number_of(clip); if( idx >= 0 ) { - edl->clips[idx] = clip_edl; + edl->clips[idx] = new_clip; clip->remove_user(); } else - edl->clips.append(clip_edl); - mwindow->mainindexes->add_next_asset(0, clip_edl); + edl->clips.append(new_clip); + mwindow->mainindexes->add_next_asset(0, nested); mwindow->mainindexes->start_build(); popup->gui->async_update_assets(); } diff --git a/cinelerra-5.1/cinelerra/edit.C b/cinelerra-5.1/cinelerra/edit.C index ce2612ac..853baf7e 100644 --- a/cinelerra-5.1/cinelerra/edit.C +++ b/cinelerra-5.1/cinelerra/edit.C @@ -241,7 +241,7 @@ int Edit::silence() void Edit::copy_from(Edit *edit) { - this->nested_edl = edl->nested_edls.get_copy(edit->nested_edl); + this->nested_edl = edl->nested_edls.get_nested(edit->nested_edl); this->asset = edl->assets->update(edit->asset); this->startsource = edit->startsource; this->startproject = edit->startproject; diff --git a/cinelerra-5.1/cinelerra/edits.C b/cinelerra-5.1/cinelerra/edits.C index d4886476..a79bb171 100644 --- a/cinelerra-5.1/cinelerra/edits.C +++ b/cinelerra-5.1/cinelerra/edits.C @@ -169,7 +169,7 @@ void Edits::insert_edits(Edits *source_edits, { EDL *dest_nested_edl = 0; if(source_edit->nested_edl) - dest_nested_edl = edl->nested_edls.get_copy(source_edit->nested_edl); + dest_nested_edl = edl->nested_edls.get_nested(source_edit->nested_edl); // Update Assets Asset *dest_asset = 0; diff --git a/cinelerra-5.1/cinelerra/edl.C b/cinelerra-5.1/cinelerra/edl.C index 55b2caf4..1334e5e7 100644 --- a/cinelerra-5.1/cinelerra/edl.C +++ b/cinelerra-5.1/cinelerra/edl.C @@ -597,36 +597,47 @@ int EDL::copy(double start, double end, int all, return 0; } -EDL *EDL::get_nested(EDL *nested_edl, const char *path) +void EDL::copy_indexables(EDL *edl) { - for( int i=0; ipath) ) return dst; + for( Track *track=edl->tracks->first; track; track=track->next ) { + for( Edit *edit=track->edits->first; edit; edit=edit->next ) { + if( edit->asset ) + assets->update(edit->asset); + if( edit->nested_edl ) + nested_edls.get_nested(edit->nested_edl); + } } - return new_nested(nested_edl, path); } -EDL *EDL::new_nested(EDL *nested_edl, const char *path) +EDL *EDL::new_nested(EDL *edl, const char *path) +{ + EDL *nested = new EDL; // no parent for nested edl + nested->create_objects(); + nested->copy_session(edl); + nested->set_path(path); + nested->update_index(edl); + nested->copy_indexables(edl); + nested->tracks->copy_from(edl->tracks); + nested_edls.append(nested); + return nested; +} + +EDL *EDL::create_nested_clip(EDL *nested) { - EDL *new_edl = new EDL; // no parent for nested clip + EDL *new_edl = new EDL(this); // parent for clip edl new_edl->create_objects(); - new_edl->copy_session(this); - new_edl->create_nested(nested_edl, path); + new_edl->create_nested(nested); return new_edl; } -void EDL::create_nested(EDL *nested_edl, const char *path) +void EDL::create_nested(EDL *nested) { - set_path(path); - strcpy(local_session->clip_title, path); -// save a ref to nested edl for garbage delete - EDL *nest = clips.get_copy(nested_edl); // Keep frame rate, sample rate, and output size unchanged. // Nest all video & audio outputs session->video_tracks = 1; - session->audio_tracks = nest->session->audio_channels; + session->audio_tracks = nested->session->audio_channels; create_default_tracks(); - insert_asset(0, nest, 0, 0, 0); + insert_asset(0, nested, 0, 0, 0); } void EDL::retrack() @@ -1048,7 +1059,7 @@ void EDL::insert_asset(Asset *asset, EDL *new_nested_edl = 0; if( asset ) new_asset = assets->update(asset); - if( nested_edl ) new_nested_edl = nested_edls.get_copy(nested_edl); + if( nested_edl ) new_nested_edl = nested_edls.get_nested(nested_edl); // Paste video int vtrack = 0; diff --git a/cinelerra-5.1/cinelerra/edl.h b/cinelerra-5.1/cinelerra/edl.h index 77b7bfd8..04170ad1 100644 --- a/cinelerra-5.1/cinelerra/edl.h +++ b/cinelerra-5.1/cinelerra/edl.h @@ -189,9 +189,10 @@ public: int copy(double start, double end, int all, const char *closer, FileXML *file, const char *output_path, int rewind_it); - EDL *get_nested(EDL *nested_edl, const char *path); - EDL *new_nested(EDL *nested_edl, const char *path); - void create_nested(EDL *nested_edl, const char *path); + void copy_indexables(EDL *edl); + EDL *new_nested(EDL *edl, const char *path); + EDL *create_nested_clip(EDL *nested); + void create_nested(EDL *nested); void paste_silence(double start, double end, int edit_labels /* = 1 */, int edit_plugins, diff --git a/cinelerra-5.1/cinelerra/indexable.C b/cinelerra-5.1/cinelerra/indexable.C index 1fff3eff..3aacee67 100644 --- a/cinelerra-5.1/cinelerra/indexable.C +++ b/cinelerra-5.1/cinelerra/indexable.C @@ -64,7 +64,7 @@ void Indexable::update_index(Indexable *src) if( index_state == src->index_state ) return; if( index_state ) index_state->remove_user(); index_state = src->index_state; - index_state->add_user(); + if( index_state ) index_state->add_user(); } diff --git a/cinelerra-5.1/cinelerra/mwindow.C b/cinelerra-5.1/cinelerra/mwindow.C index a69af4e7..38e37d2f 100644 --- a/cinelerra-5.1/cinelerra/mwindow.C +++ b/cinelerra-5.1/cinelerra/mwindow.C @@ -1961,7 +1961,8 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); nested_edl->create_objects(); nested_edl->load_xml(&xml_file, LOAD_ALL); //printf("MWindow::load_filenames %p %s\n", nested_edl, nested_edl->project_path); - new_edl->create_nested(nested_edl, filenames->get(i)); + new_edl->create_nested(nested_edl); + new_edl->set_path(filenames->get(i)); nested_edl->Garbage::remove_user(); } else { diff --git a/cinelerra-5.1/cinelerra/mwindowedit.C b/cinelerra-5.1/cinelerra/mwindowedit.C index 51f1b421..ca3475ed 100644 --- a/cinelerra-5.1/cinelerra/mwindowedit.C +++ b/cinelerra-5.1/cinelerra/mwindowedit.C @@ -1209,7 +1209,8 @@ if( debug ) printf("MWindow::load_assets %d\n", __LINE__); new_edl->copy_session(edl); if( !indexable->is_asset ) { EDL *nested_edl = (EDL*)indexable; - new_edl->create_nested(nested_edl, indexable->path); + new_edl->create_nested(nested_edl); + new_edl->set_path(indexable->path); } else { Asset *asset = (Asset*)indexable; @@ -1557,7 +1558,7 @@ int MWindow::paste_edls(ArrayList *new_edls, int load_mode, edl->add_clip(new_edl->clips[j]); } for( int j=0; jnested_edls.size(); ++j ) { - edl->nested_edls.get_copy(new_edl->nested_edls[j]); + edl->nested_edls.get_nested(new_edl->nested_edls[j]); } if( new_edl->total_vwindow_edls() ) { diff --git a/cinelerra-5.1/cinelerra/proxypopup.C b/cinelerra-5.1/cinelerra/proxypopup.C index 225b21bd..583f6a57 100644 --- a/cinelerra-5.1/cinelerra/proxypopup.C +++ b/cinelerra-5.1/cinelerra/proxypopup.C @@ -20,6 +20,7 @@ */ #include "assetedit.h" +#include "assetremove.h" #include "proxypopup.h" #include "awindow.h" #include "awindowgui.h" @@ -57,6 +58,8 @@ ProxyPopup::~ProxyPopup() void ProxyPopup::create_objects() { + BC_MenuItem *menu_item; + BC_SubMenu *submenu; add_item(info = new ProxyPopupInfo(mwindow, this)); add_item(format = new AWindowListFormat(mwindow, gui)); add_item(new ProxyPopupSort(mwindow, this)); @@ -64,6 +67,10 @@ void ProxyPopup::create_objects() add_item(view_window = new ProxyPopupViewWindow(mwindow, this)); add_item(new ProxyPopupCopy(mwindow, this)); add_item(new ProxyPopupPaste(mwindow, this)); + add_item(menu_item = new BC_MenuItem(_("Remove..."))); + menu_item->add_submenu(submenu = new BC_SubMenu()); + submenu->add_submenuitem(new ProxyPopupProjectRemove(mwindow, this)); + submenu->add_submenuitem(new ProxyPopupDiskRemove(mwindow, this)); } void ProxyPopup::paste_assets() @@ -245,6 +252,48 @@ int ProxyPopupPaste::handle_event() } +ProxyPopupProjectRemove::ProxyPopupProjectRemove(MWindow *mwindow, ProxyPopup *popup) + : BC_MenuItem(_("Remove from project")) +{ + this->mwindow = mwindow; + this->popup = popup; +} + +ProxyPopupProjectRemove::~ProxyPopupProjectRemove() +{ +} + +int ProxyPopupProjectRemove::handle_event() +{ + popup->gui->collect_assets(); + mwindow->remove_assets_from_project(1, 1, + mwindow->session->drag_assets, + mwindow->session->drag_clips); + return 1; +} + + +ProxyPopupDiskRemove::ProxyPopupDiskRemove(MWindow *mwindow, ProxyPopup *popup) + : BC_MenuItem(_("Remove from disk")) +{ + this->mwindow = mwindow; + this->popup = popup; +} + + +ProxyPopupDiskRemove::~ProxyPopupDiskRemove() +{ +} + +int ProxyPopupDiskRemove::handle_event() +{ + popup->gui->collect_assets(); + mwindow->awindow->asset_remove->start(); + return 1; +} + + + ProxyListMenu::ProxyListMenu(MWindow *mwindow, AWindowGUI *gui) : BC_PopupMenu(0, 0, 0, "", 0) { diff --git a/cinelerra-5.1/cinelerra/proxypopup.h b/cinelerra-5.1/cinelerra/proxypopup.h index 3a079806..5f03a793 100644 --- a/cinelerra-5.1/cinelerra/proxypopup.h +++ b/cinelerra-5.1/cinelerra/proxypopup.h @@ -126,6 +126,30 @@ public: ProxyPopup *popup; }; +class ProxyPopupProjectRemove : public BC_MenuItem +{ +public: + ProxyPopupProjectRemove(MWindow *mwindow, ProxyPopup *popup); + ~ProxyPopupProjectRemove(); + + int handle_event(); + + MWindow *mwindow; + ProxyPopup *popup; +}; + +class ProxyPopupDiskRemove : public BC_MenuItem +{ +public: + ProxyPopupDiskRemove(MWindow *mwindow, ProxyPopup *popup); + ~ProxyPopupDiskRemove(); + + int handle_event(); + + MWindow *mwindow; + ProxyPopup *popup; +}; + class ProxyListMenu : public BC_PopupMenu { public: diff --git a/cinelerra-5.1/cinelerra/proxypopup.inc b/cinelerra-5.1/cinelerra/proxypopup.inc index e0a544ad..10e42257 100644 --- a/cinelerra-5.1/cinelerra/proxypopup.inc +++ b/cinelerra-5.1/cinelerra/proxypopup.inc @@ -28,6 +28,8 @@ class ProxyPopupSort; class ProxyPopupView; class ProxyPopupViewWindow; class ProxyPopupCopy; +class ProxyPopupProjectRemove; +class ProxyPopupDiskRemove; class ProxyListMenu; #endif