From: Good Guy Date: Fri, 14 Dec 2018 15:43:22 +0000 (-0700) Subject: copy/paste behavior tweaks X-Git-Tag: 2019-08~153 X-Git-Url: https://cinelerra-gg.org/git/?a=commitdiff_plain;h=c6016b2d08ac0fdda37ee6e1f59dadcfd4335388;p=goodguy%2Fcinelerra.git copy/paste behavior tweaks --- diff --git a/cinelerra-5.1/cinelerra/editpopup.C b/cinelerra-5.1/cinelerra/editpopup.C index b12c5d07..c03653b1 100644 --- a/cinelerra-5.1/cinelerra/editpopup.C +++ b/cinelerra-5.1/cinelerra/editpopup.C @@ -89,7 +89,7 @@ int EditPopup::activate_menu(Track *track, Edit *edit, } EditPopupClearSelect::EditPopupClearSelect(MWindow *mwindow, EditPopup *popup) - : BC_MenuItem(_("Clear Select"),_("Ctrl-A"),'A') + : BC_MenuItem(_("Clear Select"),_("Ctrl-Shift-A"),'A') { this->mwindow = mwindow; this->popup = popup; @@ -119,7 +119,7 @@ int EditPopupCopy::handle_event() } EditPopupCopyPack::EditPopupCopyPack(MWindow *mwindow, EditPopup *popup) - : BC_MenuItem(_("Copy pack"),_("Ctrl-C"),'C') + : BC_MenuItem(_("Copy pack"),_("Ctrl-Shift-C"),'C') { this->mwindow = mwindow; this->popup = popup; @@ -176,7 +176,7 @@ int EditPopupMute::handle_event() } EditPopupMutePack::EditPopupMutePack(MWindow *mwindow, EditPopup *popup) - : BC_MenuItem(_("Mute pack"),_("Ctrl-M"),'M') + : BC_MenuItem(_("Mute pack"),_("Ctrl-Shift-M"),'M') { this->mwindow = mwindow; this->popup = popup; @@ -201,6 +201,8 @@ EditPopupPaste::EditPopupPaste(MWindow *mwindow, EditPopup *popup) int EditPopupPaste::handle_event() { mwindow->paste(popup->position, popup->track, 0, 0); + mwindow->edl->tracks->clear_selected_edits(); + popup->gui->draw_overlays(1); if( mwindow->session->current_operation == DROP_TARGETING ) { mwindow->session->current_operation = NO_OPERATION; popup->gui->update_cursor(); @@ -219,6 +221,8 @@ EditPopupOverwrite::EditPopupOverwrite(MWindow *mwindow, EditPopup *popup) int EditPopupOverwrite::handle_event() { mwindow->paste(popup->position, popup->track, 0, -1); + mwindow->edl->tracks->clear_selected_edits(); + popup->gui->draw_overlays(1); if( mwindow->session->current_operation == DROP_TARGETING ) { mwindow->session->current_operation = NO_OPERATION; popup->gui->update_cursor(); diff --git a/cinelerra-5.1/cinelerra/edl.C b/cinelerra-5.1/cinelerra/edl.C index c1c7e325..4cea20f5 100644 --- a/cinelerra-5.1/cinelerra/edl.C +++ b/cinelerra-5.1/cinelerra/edl.C @@ -1631,6 +1631,25 @@ Asset *EDL::get_proxy_asset() tracks->first->edits->first->asset : 0; } +Track *EDL::add_new_track(int data_type) +{ + Track *new_track = 0; + switch( data_type ) { + case TRACK_VIDEO: + ++session->video_tracks; + new_track = tracks->add_video_track(0, 0); + break; + case TRACK_AUDIO: + ++session->audio_tracks; + new_track = tracks->add_audio_track(0, 0); + break; + case TRACK_SUBTITLE: + new_track = tracks->add_subttl_track(0, 0); + break; + } + return new_track; +} + double EDL::get_cursor_position(int cursor_x, int pane_no) { return (double)cursor_x * local_session->zoom_sample / session->sample_rate + diff --git a/cinelerra-5.1/cinelerra/edl.h b/cinelerra-5.1/cinelerra/edl.h index 4befb9ff..5e184d22 100644 --- a/cinelerra-5.1/cinelerra/edl.h +++ b/cinelerra-5.1/cinelerra/edl.h @@ -263,6 +263,7 @@ public: void add_proxy(int use_scaler, ArrayList *orig_assets, ArrayList *proxy_assets); Asset *get_proxy_asset(); + Track *add_new_track(int data_type); // Titles of all subfolders BinFolders folders; diff --git a/cinelerra-5.1/cinelerra/mwindowedit.C b/cinelerra-5.1/cinelerra/mwindowedit.C index a86b031d..efe891df 100644 --- a/cinelerra-5.1/cinelerra/mwindowedit.C +++ b/cinelerra-5.1/cinelerra/mwindowedit.C @@ -905,6 +905,15 @@ void MWindow::match_output_size(Track *track) void MWindow::selected_to_clipboard(int packed) { + int64_t start = INT64_MAX, end = -INT64_MAX, pos = 0; + for( Track *track=edl->tracks->first; track; track=track->next ) { + if( !track->record ) continue; + for( Edit *edit=track->edits->first; edit; edit=edit->next ) { + if( !edit->is_selected || edit->silence() ) continue; + if( start > (pos=edit->startproject) ) start = pos; + if( end < (pos+=edit->length) ) end = pos; + } + } EDL *new_edl = new EDL(); new_edl->create_objects(); new_edl->copy_session(edl); @@ -917,45 +926,20 @@ void MWindow::selected_to_clipboard(int packed) for( Track *track=edl->tracks->first; track; track=track->next ) { if( !track->record ) continue; Track *new_track = 0; - if( !packed ) { - switch( track->data_type ) { - case TRACK_VIDEO: - ++new_edl->session->video_tracks; - new_track = new_edl->tracks->add_video_track(0, 0); - break; - case TRACK_AUDIO: - ++new_edl->session->audio_tracks; - new_track = new_edl->tracks->add_audio_track(0, 0); - break; - case TRACK_SUBTITLE: - new_track = new_edl->tracks->add_subttl_track(0, 0); - break; - } - } - int64_t startproject = 0, last_startproject = 0; + if( !packed ) + new_track = new_edl->add_new_track(track->data_type); + int64_t startproject = 0, last_startproject = start; for( Edit *edit=track->edits->first; edit; edit=edit->next ) { + if( edit->startproject < start ) continue; + if( edit->startproject >= end ) break; if( !edit->is_selected || edit->silence() ) { if( !packed ) startproject += edit->length; continue; } - if( !new_track ) { - switch( track->data_type ) { - case TRACK_VIDEO: - ++new_edl->session->video_tracks; - new_track = new_edl->tracks->add_video_track(0, 0); - break; - case TRACK_AUDIO: - ++new_edl->session->audio_tracks; - new_track = new_edl->tracks->add_audio_track(0, 0); - break; - case TRACK_SUBTITLE: - new_track = new_edl->tracks->add_subttl_track(0, 0); - break; - } - } + if( !new_track ) + new_track = new_edl->add_new_track(track->data_type); if( new_track ) { - if( !packed && last_startproject > 0 && - startproject > last_startproject ) { + if( !packed && startproject > last_startproject ) { Edit *silence = new Edit(new_edl, new_track); silence->startproject = last_startproject; silence->length = startproject - last_startproject; diff --git a/cinelerra-5.1/cinelerra/mwindowgui.C b/cinelerra-5.1/cinelerra/mwindowgui.C index d66cf3b1..71adc847 100644 --- a/cinelerra-5.1/cinelerra/mwindowgui.C +++ b/cinelerra-5.1/cinelerra/mwindowgui.C @@ -1222,6 +1222,8 @@ int MWindowGUI::keypress_event() else position = mwindow->edl->local_session->get_selectionstart(); mwindow->paste(position, first_track, 0, overwrite); + mwindow->edl->tracks->clear_selected_edits(); + draw_overlays(1); result = 1; break; case 'M':