X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fmwindowedit.C;h=a149b27557fcdfe755678808719e33d5e6cfe1fc;hb=6338f0b010dfd93ae6a823970d853cfdd5279500;hp=7710d4ada162471c62cb6c0d81b1fae6fd5156ed;hpb=d26ed189093987978190ee07f485a4840746c13c;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/cinelerra/mwindowedit.C b/cinelerra-5.1/cinelerra/mwindowedit.C index 7710d4ad..a149b275 100644 --- a/cinelerra-5.1/cinelerra/mwindowedit.C +++ b/cinelerra-5.1/cinelerra/mwindowedit.C @@ -301,7 +301,7 @@ void MWindow::asset_to_rate() void MWindow::clear_entry() { undo->update_undo_before(); - clear(1); + clear(1, 1); edl->optimize(); save_backup(); @@ -315,7 +315,7 @@ void MWindow::clear_entry() send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1); } -void MWindow::clear(int clear_handle) +void MWindow::clear(int clear_handle, int deglitch) { double start = edl->local_session->get_selectionstart(); double end = edl->local_session->get_selectionend(); @@ -326,6 +326,12 @@ void MWindow::clear(int clear_handle) edl->session->plugins_follow_edits, edl->session->autos_follow_edits); } + +// always needed by paste operations + if(deglitch) + { + edl->deglitch(start); + } } void MWindow::set_automation_mode(int mode) @@ -512,22 +518,29 @@ void MWindow::crop_video() void MWindow::cut() { - undo->update_undo_before(); - double start = edl->local_session->get_selectionstart(); double end = edl->local_session->get_selectionend(); + cut(start, end); +} +void MWindow::cut(double start, double end, double new_position) +{ + undo->update_undo_before(); copy(start, end); edl->clear(start, end, edl->session->labels_follow_edits, edl->session->plugins_follow_edits, edl->session->autos_follow_edits); + edl->deglitch(start); edl->optimize(); save_backup(); undo->update_undo_after(_("cut"), LOAD_EDITS | LOAD_TIMEBAR); - + if( new_position >= 0 ) { + edl->local_session->set_selectionstart(new_position); + edl->local_session->set_selectionend(new_position); + } restart_brender(); update_plugin_guis(); gui->update(1, 2, 1, 1, 1, 1, 0); @@ -536,6 +549,42 @@ void MWindow::cut() send_command(CURRENT_FRAME, CHANGE_EDL, edl, 1); } +void MWindow::snap_left_edit() +{ + double start_pos = edl->local_session->get_selectionstart(1); + double position = edl->prev_edit(start_pos); + if( position < start_pos ) + cut(position, start_pos, position); +} + +void MWindow::snap_right_edit() +{ + double end_pos = edl->local_session->get_selectionend(1); + double position = edl->next_edit(end_pos); + if( end_pos < position ) + cut(end_pos, position, end_pos); +} + +void MWindow::snap_left_label() +{ + double start_pos = edl->local_session->get_selectionstart(1); + Label *left_label = edl->labels->prev_label(start_pos); + if( !left_label ) return; + double position = left_label->position; + if( position < start_pos ) + cut(position, start_pos, position); +} + +void MWindow::snap_right_label() +{ + double end_pos = edl->local_session->get_selectionend(1); + Label *right_label = edl->labels->next_label(end_pos); + if( !right_label ) return; + double position = right_label->position; + if( end_pos < position ) + cut(end_pos, position, end_pos); +} + int MWindow::cut_automation() { undo->update_undo_before(); @@ -820,15 +869,20 @@ void MWindow::finish_modify_handles() if( (session->drag_handle == 1 && edit_mode != MOVE_NO_EDITS) || (session->drag_handle == 0 && edit_mode == MOVE_ONE_EDIT) ) { +//printf("MWindow::finish_modify_handles %d\n", __LINE__); edl->local_session->set_selectionstart(session->drag_position); edl->local_session->set_selectionend(session->drag_position); + edl->deglitch(session->drag_position); } else if( edit_mode != MOVE_NO_EDITS ) { +//printf("MWindow::finish_modify_handles %d\n", __LINE__); edl->local_session->set_selectionstart(session->drag_start); edl->local_session->set_selectionend(session->drag_start); + edl->deglitch(session->drag_start); } +// clamp the selection to 0 if( edl->local_session->get_selectionstart(1) < 0 ) { edl->local_session->set_selectionstart(0); edl->local_session->set_selectionend(0); @@ -1005,6 +1059,10 @@ void MWindow::mute_selection() edl->paste_silence(start, end, 0, edl->session->plugins_follow_edits, edl->session->autos_follow_edits); + edl->deglitch(start); + edl->deglitch(end); + + save_backup(); undo->update_undo_after(_("mute"), LOAD_EDITS); @@ -1066,7 +1124,7 @@ int MWindow::paste(double start, int edit_plugins, int edit_autos) { - clear(0); + clear(0, 1); // Want to insert with assets shared with the master EDL. insert(start, file, @@ -1089,7 +1147,7 @@ void MWindow::paste() gui->from_clipboard(string, len, BC_PRIMARY_SELECTION); FileXML file; file.read_from_string(string); - clear(0); + clear(0, 1); insert(start, &file, edl->session->labels_follow_edits, @@ -1567,6 +1625,8 @@ void MWindow::paste_silence() edl->session->labels_follow_edits, edl->session->plugins_follow_edits, edl->session->autos_follow_edits); + edl->deglitch(start); + edl->deglitch(end); edl->optimize(); save_backup(); undo->update_undo_after(_("silence"), LOAD_EDITS | LOAD_TIMEBAR); @@ -2014,7 +2074,7 @@ void MWindow::save_clip(EDL *new_edl, const char *txt) edl->update_assets(new_edl); int cur_x, cur_y; - gui->get_abs_cursor_xy(cur_x, cur_y, 0); + gui->get_abs_cursor(cur_x, cur_y, 0); gui->unlock_window(); awindow->clip_edit->create_clip(new_edl, cur_x, cur_y); @@ -2103,6 +2163,10 @@ void MWindow::trim_selection() edl->session->labels_follow_edits, edl->session->plugins_follow_edits, edl->session->autos_follow_edits); + edl->deglitch(0); + edl->deglitch(edl->local_session->get_selectionend() - + edl->local_session->get_selectionstart()); + save_backup(); undo->update_undo_after(_("trim selection"), LOAD_EDITS | LOAD_TIMEBAR); @@ -2274,6 +2338,100 @@ void MWindow::remap_audio(int pattern) } } +void MWindow::set_proxy(int use_scaler, int new_scale, int auto_scale, + ArrayList *orig_assets, + ArrayList *proxy_assets) +{ + int orig_use_scaler = edl->session->proxy_use_scaler; + int orig_scale = edl->session->proxy_scale; +// rescale to full size asset in read_frame + edl->session->proxy_use_scaler = use_scaler; + edl->session->proxy_scale = new_scale; + edl->session->proxy_auto_scale = auto_scale; + + if( use_scaler ) { + for( int i=0; isize(); ++i ) { + Asset *proxy_asset = (Asset *)proxy_assets->get(i); + proxy_asset->width = orig_assets->get(i)->get_w(); + proxy_asset->height = orig_assets->get(i)->get_h(); + } + new_scale = 1; + } + + if( !orig_use_scaler && new_scale != orig_scale ) { +// project size + float orig_w = (float)edl->session->output_w * orig_scale; + float orig_h = (float)edl->session->output_h * orig_scale; + edl->session->output_w = Units::round(orig_w / new_scale); + edl->session->output_h = Units::round(orig_h / new_scale); + +// track sizes + for( Track *track=edl->tracks->first; track; track=track->next ) { + if( track->data_type != TRACK_VIDEO ) continue; + orig_w = (float)track->track_w * orig_scale; + orig_h = (float)track->track_h * orig_scale; + track->track_w = Units::round(orig_w / new_scale); + track->track_h = Units::round(orig_h / new_scale); + ((MaskAutos*)track->automation->autos[AUTOMATION_MASK])-> + set_proxy(orig_scale, new_scale); + ((FloatAutos*)track->automation->autos[AUTOMATION_CAMERA_X])-> + set_proxy(orig_scale, new_scale); + ((FloatAutos*)track->automation->autos[AUTOMATION_CAMERA_Y])-> + set_proxy(orig_scale, new_scale); + ((FloatAutos*)track->automation->autos[AUTOMATION_PROJECTOR_X])-> + set_proxy(orig_scale, new_scale); + ((FloatAutos*)track->automation->autos[AUTOMATION_PROJECTOR_Y])-> + set_proxy(orig_scale, new_scale); + } + } + +// change original assets to proxy assets + int awindow_folder = use_scaler || new_scale != 1 ? AW_PROXY_FOLDER : AW_MEDIA_FOLDER; + for( int i=0,n=proxy_assets->size(); iassets->update((Asset *)proxy_assets->get(i)); + proxy_asset->awindow_folder = awindow_folder; +// replace track contents + for( Track *track = edl->tracks->first; track; track = track->next ) { + if( track->data_type != TRACK_VIDEO ) continue; + for( Edit *edit = track->edits->first; edit; edit = edit->next ) { + if( !edit->asset ) continue; + if( !strcmp(edit->asset->path, orig_assets->get(i)->path) ) { + edit->asset = proxy_asset; + } + } + } + } +} + +void MWindow::add_proxy(int use_scaler, + ArrayList *orig_assets, + ArrayList *proxy_assets) +{ + if( use_scaler ) { + for( int i=0,n=proxy_assets->size(); iget(i); + proxy_asset->width = orig_assets->get(i)->get_w(); + proxy_asset->height = orig_assets->get(i)->get_h(); + } + } + +// change original assets to proxy assets + for( int i=0,n=proxy_assets->size(); iassets->update((Asset *)proxy_assets->get(i)); + proxy_asset->awindow_folder = AW_PROXY_FOLDER; +// replace track contents + for( Track *track = edl->tracks->first; track; track = track->next ) { + if( track->data_type != TRACK_VIDEO ) continue; + for( Edit *edit = track->edits->first; edit; edit = edit->next ) { + if( !edit->asset ) continue; + if( !strcmp(edit->asset->path, orig_assets->get(i)->path) ) { + edit->asset = proxy_asset; + } + } + } + } +} + void MWindow::cut_commercials() { undo->update_undo_before();