X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fmwindowedit.C;h=7e6c644548f55b4d741836c455f272f39994df44;hp=2db6fa0bd33e3788d436bd75dd90227fdcb929da;hb=e719f1246ff9bb42b055306396c9160640a88884;hpb=0e16112661802284c0d2c9eb8d1df84141125e91 diff --git a/cinelerra-5.1/cinelerra/mwindowedit.C b/cinelerra-5.1/cinelerra/mwindowedit.C index 2db6fa0b..7e6c6445 100644 --- a/cinelerra-5.1/cinelerra/mwindowedit.C +++ b/cinelerra-5.1/cinelerra/mwindowedit.C @@ -27,6 +27,7 @@ #include "clip.h" #include "clipedit.h" #include "commercials.h" +#include "convert.h" #include "cplayback.h" #include "ctimebar.h" #include "cwindow.h" @@ -1249,10 +1250,16 @@ void MWindow::overwrite(EDL *source, int all) // so we need to clear only when not using both io points // FIXME: need to write simple overwrite_edl to be used for overwrite function if( edl->local_session->get_inpoint() < 0 || - edl->local_session->get_outpoint() < 0 ) - edl->clear(dst_start, dst_start + overwrite_len, 0, 0, 0); + edl->local_session->get_outpoint() < 0 ) + edl->clear(dst_start, dst_start + overwrite_len, + edl->session->labels_follow_edits, + edl->session->plugins_follow_edits, + edl->session->autos_follow_edits); - paste(dst_start, dst_start + overwrite_len, &file, 0, 0, 0, 0, 0); + paste(dst_start, dst_start + overwrite_len, &file, + edl->session->labels_follow_edits, + edl->session->plugins_follow_edits, + edl->session->autos_follow_edits, 0, 0); edl->local_session->set_selectionstart(dst_start + overwrite_len); edl->local_session->set_selectionend(dst_start + overwrite_len); @@ -1370,7 +1377,7 @@ if( debug ) printf("MWindow::load_assets %d\n", __LINE__); for( int i=0; itotal; ++i ) { Indexable *indexable = new_assets->get(i); if( indexable->is_asset ) { - remove_asset_from_caches((Asset*)indexable); + remove_from_caches(indexable); } EDL *new_edl = new EDL; new_edl->create_objects(); @@ -1544,8 +1551,7 @@ int MWindow::paste_edls(ArrayList *new_edls, int load_mode, else // Recycle existing tracks of master EDL if( load_mode == LOADMODE_CONCATENATE || - load_mode == LOADMODE_PASTE || - load_mode == LOADMODE_NESTED ) { + load_mode == LOADMODE_PASTE ) { Track *current = first_track ? first_track : edl->tracks->first; for( ; current; current=NEXT ) { if( current->record ) { @@ -1582,13 +1588,15 @@ int MWindow::paste_edls(ArrayList *new_edls, int load_mode, // Add assets and prepare index files for( Asset *new_asset=new_edl->assets->first; new_asset; new_asset=new_asset->next ) { - mainindexes->add_next_asset(0, new_asset); + mainindexes->add_indexable(new_asset); } // Capture index file status from mainindex test edl->update_assets(new_edl); //PRINT_TRACE // Get starting point of insertion. Need this to paste labels. switch( load_mode ) { + case LOADMODE_NOTHING: + continue; case LOADMODE_REPLACE: current_position = 0; break; @@ -1607,7 +1615,6 @@ int MWindow::paste_edls(ArrayList *new_edls, int load_mode, break; case LOADMODE_PASTE: - case LOADMODE_NESTED: destination_track = 0; if( i == 0 ) { for( int j=0; j *new_edls, int load_mode, load_mode != LOADMODE_ASSETSONLY ) { // Insert labels if( edit_labels ) { - if( load_mode == LOADMODE_PASTE || load_mode == LOADMODE_NESTED ) + if( load_mode == LOADMODE_PASTE ) edl->labels->insert_labels(new_edl->labels, destination_tracks.total ? paste_position[0] : 0.0, edl_length, 1); @@ -1668,7 +1675,6 @@ int MWindow::paste_edls(ArrayList *new_edls, int load_mode, break; case LOADMODE_PASTE: - case LOADMODE_NESTED: current_position = paste_position[destination_track]; paste_position[destination_track] += new_track->get_length(); break; @@ -1695,8 +1701,7 @@ int MWindow::paste_edls(ArrayList *new_edls, int load_mode, } } - if( load_mode == LOADMODE_PASTE || - load_mode == LOADMODE_NESTED ) + if( load_mode == LOADMODE_PASTE ) current_position += edl_length; } @@ -2170,28 +2175,24 @@ void MWindow::save_clip(EDL *new_edl, const char *txt) time_t now; time(&now); struct tm dtm; localtime_r(&now, &dtm); char *cp = new_edl->local_session->clip_notes; - int n, sz = sizeof(new_edl->local_session->clip_notes)-1; - if( txt && *txt ) { - n = snprintf(cp, sz, "%s", txt); - cp += n; sz -= n; - } - n = snprintf(cp, sz, + char *ep = cp + sizeof(new_edl->local_session->clip_notes)-1; + if( txt && *txt ) + cp += snprintf(cp, ep-cp, "%s", txt); + cp += snprintf(cp, ep-cp, "%02d/%02d/%02d %02d:%02d:%02d, +%s\n", dtm.tm_year+1900, dtm.tm_mon+1, dtm.tm_mday, dtm.tm_hour, dtm.tm_min, dtm.tm_sec, duration); - cp += n; sz -= n; if( path && *path ) { FileSystem fs; char title[BCTEXTLEN]; fs.extract_name(title, path); - n = snprintf(cp, sz, "%s", title); - cp += n; sz -= n; + cp += snprintf(cp, ep-cp, "%s", title); } - cp[n] = 0; sprintf(new_edl->local_session->clip_icon, - "clip_%02d%02d%02d-%02d%02d%02d.png", + "clip_%02d%02d%02d-%02d%02d%02d-%d.png", dtm.tm_year+1900, dtm.tm_mon+1, dtm.tm_mday, - dtm.tm_hour, dtm.tm_min, dtm.tm_sec); + dtm.tm_hour, dtm.tm_min, dtm.tm_sec, + new_edl->id); new_edl->folder_no = AW_CLIP_FOLDER; edl->update_assets(new_edl); int cur_x, cur_y; @@ -2443,6 +2444,45 @@ void MWindow::add_proxy(ArrayList *orig_assets, ArrayListadd_proxy(orig_assets, proxy_assets); } +void MWindow::start_convert(Asset *format_asset, const char *suffix, + float beep, int to_proxy, int remove_originals) +{ + if( !convert_render ) + convert_render = new ConvertRender(this); + convert_render->set_format(format_asset, suffix, to_proxy); + int found = convert_render->find_convertable_assets(edl); + if( convert_render->needed_idxbls.size() > 0 ) + convert_render->start_convert(beep, remove_originals); + else if( found > 0 ) + finish_convert(remove_originals); + else if( found < 0 ) + eprintf(_("convert assets format error")); + else + eprintf(_("No convertable assets found")); +} + +void MWindow::finish_convert(int remove_originals) +{ + gui->lock_window("MWindow::finish_convert"); + undo_before(); + edl->replace_assets( + convert_render->orig_idxbls, + convert_render->orig_copies); + if( remove_originals ) { + remove_assets_from_project(0, 0, 0, + &convert_render->orig_idxbls, 0); + } + save_backup(); + undo_after(_("convert"), LOAD_ALL); + + update_plugin_guis(); + gui->update(1, FORCE_REDRAW, 1, 1, 1, 1, 0); + cwindow->update(1, 0, 0, 0, 1); + awindow->gui->async_update_assets(); + cwindow->refresh_frame(CHANGE_EDL); + gui->unlock_window(); +} + void MWindow::cut_commercials() { #ifdef HAVE_COMMERCIAL @@ -2517,3 +2557,89 @@ int MWindow::speed_after(int done) return result; } +void MWindow::collect_effects() +{ + FileXML file; + const char *file_string = ""; + EDL *group = 0; + int ret = edl->collect_effects(group); + switch( ret ) { + case COLLECT_EFFECTS_RECORD: + eprintf(_("Selected edit track not armed.")); + break; + case COLLECT_EFFECTS_MULTIPLE: + eprintf(_("More than one edit selected on a track.")); + break; + case COLLECT_EFFECTS_MISSING: + eprintf(_("No effects under selected edit.")); + break; + case COLLECT_EFFECTS_EMPTY: + eprintf(_("No edits selected.")); + break; + case COLLECT_EFFECTS_MASTER: + eprintf(_("Shared effect added without master.")); + break; + case 0: + group->save_xml(&file, ""); + file_string = file.string(); + group->remove_user(); + } + long file_length = strlen(file_string); + gui->to_clipboard(file_string, file_length, BC_PRIMARY_SELECTION); + gui->to_clipboard(file_string, file_length, SECONDARY_SELECTION); +} + +void MWindow::paste_effects() +{ + char *string = 0; + int64_t len = gui->clipboard_len(BC_PRIMARY_SELECTION); + if( len ) { + string = new char[len]; + gui->from_clipboard(string, len, BC_PRIMARY_SELECTION); + } + if( !string || !string[0] ) { + eprintf(_("Error clipboard buffer empty.")); + return; + } + FileXML file; + file.read_from_string(string); + EDL *group = new EDL(); + group->create_objects(); + if( !group->load_xml(&file, LOAD_ALL) ) { + undo_before(); + int ret = edl->insert_effects(group); + switch( ret ) { + case INSERT_EFFECTS_RECORD: + eprintf(_("Selected edit track not armed.")); + break; + case INSERT_EFFECTS_TYPE: + eprintf(_("Track type mismatched.")); + break; + case INSERT_EFFECTS_MULTIPLE: + eprintf(_("More than one edit selected on a track.")); + break; + case INSERT_EFFECTS_MISSING: + eprintf(_("Too few target edits to add group effects.")); + break; + case INSERT_EFFECTS_EXTRA: + eprintf(_("Too many target edits to add group effects.")); + break; + case INSERT_EFFECTS_MASTER: + eprintf(_("Shared effect added without master.")); + break; + case 0: + break; + } + save_backup(); + undo_after(_("paste effects"), LOAD_ALL); + restart_brender(); + cwindow->refresh_frame(CHANGE_EDL); + update_plugin_guis(); + gui->update(1, NORMAL_DRAW, 1, 0, 0, 0, 0); + } + else + eprintf(_("Error loading clip from clipboard buffer.")); + delete [] string; + group->remove_user(); +} +