fast drag/drop rework, modify labels in mwin->cwin locks, mods to cut/paste, marks...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / edl.C
index 102c975bc3139520e45b884fa69c864bafe4482f..d033b8d5377c00401f16be10989748eb12494041 100644 (file)
@@ -795,20 +795,22 @@ int EDL::clear(double start, double end,
        return 0;
 }
 
-class Zone { public: Track *track; int64_t start, end; };
+static int dead_edit_cmp(Edit**ap, Edit**bp)
+{
+       Edit *a = *ap, *b = *bp;
+       if( a->track != b->track ) return 0;
+       return a->startproject > b->startproject ? -1 : 1;
+}
 
 void EDL::delete_edits(ArrayList<Edit*> *edits, int collapse)
 {
-       if( session->labels_follow_edits )
-               delete_edit_labels(edits, collapse);
-       ArrayList<Zone> zones;
+       edits->sort(dead_edit_cmp);
        for( int i=0; i<edits->size(); ++i ) {
                Edit *edit = edits->get(i);
                Track *track = edit->track;
                int64_t start = edit->startproject;
-               int64_t end = start + edit->length;
-               Zone &zone = zones.append();
-               zone.track = track;  zone.start = start;  zone.end = end;
+               int64_t length = edit->length;
+               int64_t end = start + length;
                if( session->autos_follow_edits ) {
                        track->automation->clear(start, end, 0, collapse);
                }
@@ -817,21 +819,18 @@ void EDL::delete_edits(ArrayList<Edit*> *edits, int collapse)
                                PluginSet *plugin_set = track->plugin_set[k];
                                plugin_set->clear(start, end, 1);
                                if( !collapse )
-                                       plugin_set->paste_silence(start, end);
+                                       plugin_set->paste_silence(start, end, 1);
+                               plugin_set->optimize();
                        }
                }
-               track->optimize();
-       }
-       for( int i=0; i<zones.size(); ++i ) {
-               Zone &zone = zones[i];
-               Track *track = zone.track;
-               int64_t start = zone.start, end = zone.end;
-               track->edits->clear(start, end);
-               if( !collapse )
-                       track->edits->paste_silence(start, end);
-               track->optimize();
+               Edit *dead_edit = edit;
+               if( collapse ) {
+                       while( (edit=edit->next) )
+                               edit->startproject -= length;
+               }
+               delete dead_edit;
+               track->edits->optimize();
        }
-       optimize();
 }
 
 class Range {
@@ -911,58 +910,33 @@ void EDL::move_edit_labels(ArrayList<Edit*> *edits, double dist)
 }
 
 
-void EDL::modify_edithandles(double oldposition,
-       double newposition,
-       int currentend,
-       int handle_mode,
-       int edit_labels,
-       int edit_plugins,
-       int edit_autos)
+void EDL::modify_edithandles(double oldposition, double newposition,
+       int currentend, int handle_mode, int edit_labels,
+       int edit_plugins, int edit_autos, int group_id)
 {
-       tracks->modify_edithandles(oldposition,
-               newposition,
-               currentend,
-               handle_mode,
-               edit_labels,
-               edit_plugins,
-               edit_autos);
-       labels->modify_handles(oldposition,
-               newposition,
-               currentend,
-               handle_mode,
-               edit_labels);
-}
-
-void EDL::modify_pluginhandles(double oldposition,
-       double newposition,
-       int currentend,
-       int handle_mode,
-       int edit_labels,
-       int edit_autos,
-       Edits *trim_edits)
-{
-       tracks->modify_pluginhandles(oldposition,
-               newposition,
-               currentend,
-               handle_mode,
-               edit_labels,
-               edit_autos,
-               trim_edits);
+       tracks->modify_edithandles(oldposition, newposition,
+               currentend, handle_mode, edit_labels,
+               edit_plugins, edit_autos, group_id);
+       labels->modify_handles(oldposition, newposition,
+               currentend, handle_mode, edit_labels);
+}
+
+void EDL::modify_pluginhandles(double oldposition, double newposition,
+       int currentend, int handle_mode, int edit_labels,
+       int edit_autos, Edits *trim_edits)
+{
+       tracks->modify_pluginhandles(oldposition, newposition,
+               currentend, handle_mode, edit_labels,
+               edit_autos, trim_edits);
        optimize();
 }
 
-void EDL::paste_silence(double start,
-       double end,
-       int edit_labels,
-       int edit_plugins,
-       int edit_autos)
+void EDL::paste_silence(double start, double end,
+       int edit_labels, int edit_plugins, int edit_autos)
 {
        if( edit_labels )
                labels->paste_silence(start, end);
-       tracks->paste_silence(start,
-               end,
-               edit_plugins,
-               edit_autos);
+       tracks->paste_silence(start, end, edit_plugins, edit_autos);
 }