copy/paste behavior tweaks
authorGood Guy <good1.2guy@gmail.com>
Fri, 14 Dec 2018 15:43:22 +0000 (08:43 -0700)
committerGood Guy <good1.2guy@gmail.com>
Fri, 14 Dec 2018 15:43:22 +0000 (08:43 -0700)
cinelerra-5.1/cinelerra/editpopup.C
cinelerra-5.1/cinelerra/edl.C
cinelerra-5.1/cinelerra/edl.h
cinelerra-5.1/cinelerra/mwindowedit.C
cinelerra-5.1/cinelerra/mwindowgui.C

index b12c5d07f6bf6e753177bb78070a1fd9d2bec451..c03653b1ddf76399f3097a3c3df446c4e87aaf96 100644 (file)
@@ -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();
index c1c7e3258854cf0a8444b913dcdf8d678fe06e86..4cea20f53576bc1415164d4d586a381d9053773b 100644 (file)
@@ -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 +
index 4befb9ffbb3100a0f6e7f430ee4b759df05f7408..5e184d22965f18bdd76545a315a5c4806971f8e0 100644 (file)
@@ -263,6 +263,7 @@ public:
        void add_proxy(int use_scaler,
                ArrayList<Indexable*> *orig_assets, ArrayList<Indexable*> *proxy_assets);
        Asset *get_proxy_asset();
+       Track *add_new_track(int data_type);
 
 // Titles of all subfolders
        BinFolders folders;
index a86b031d4095f0ad7c1bbc2f5f5c4da8766d8254..efe891df50e5044a37bc399beefab5f4312c1a9e 100644 (file)
@@ -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;
index d66cf3b1caea8f102852a884596a901d8b76c187..71adc84715ba2c83fb34234d08327678e65030d1 100644 (file)
@@ -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':