sams folder icons, snap drag, sort folders, in/out ptr bug, interp bg fix, filebox...
[goodguy/history.git] / cinelerra-5.1 / cinelerra / edl.C
index 3dc2153e7c7d09cb6d83c5bec671842e0f7ed058..d6810aa763b05bd779b34a4a3c441c648aa381bf 100644 (file)
@@ -609,14 +609,9 @@ int EDL::copy(double start,
 
 // Media
 // Don't replicate all assets for every clip.
-// The assets for the clips are probably in the mane EDL.
-               if(!is_clip)
-                       copy_assets(start,
-                               end,
-                               file,
-                               all,
-                               output_path);
-
+// The assets for the clips are probably in the main EDL.
+               if( !is_clip )
+                       copy_assets(start, end, file, all, output_path);
 // Clips
 // Don't want this if using clipboard
                if(all)
@@ -649,10 +644,9 @@ int EDL::copy(double start,
 //printf("EDL::copy 2\n");
 
 // terminate file
-       if(is_clip)
+       if( is_clip )
                file->tag.set_title("/CLIP_EDL");
-       else
-       if(is_vwindow)
+       else if( is_vwindow )
                file->tag.set_title("/VWINDOW_EDL");
        else
                file->tag.set_title("/EDL");
@@ -1555,3 +1549,51 @@ void EDL::append_vwindow_edl(EDL *edl, int increase_counter)
 }
 
 
+double EDL::next_edit(double position)
+{
+       Units::fix_double(&position);
+       double new_position = tracks->total_length();
+
+       double max_rate = get_frame_rate();
+       int sample_rate = get_sample_rate();
+       if( sample_rate > max_rate ) max_rate = sample_rate;
+       double min_movement = max_rate > 0 ? 1. / max_rate : 1e-6;
+
+// Test for edit handles after position
+       for( Track *track=tracks->first; track; track=track->next ) {
+               if( !track->record ) continue;
+               for( Edit *edit=track->edits->first; edit; edit=edit->next ) {
+                       double edit_end = track->from_units(edit->startproject + edit->length);
+                       Units::fix_double(&edit_end);
+                       if( fabs(edit_end-position) < min_movement ) continue;
+                       if( edit_end > position && edit_end < new_position )
+                               new_position = edit_end;
+               }
+       }
+       return new_position;
+}
+
+double EDL::prev_edit(double position)
+{
+       Units::fix_double(&position);
+       double new_position = -1;
+
+       double max_rate = get_frame_rate();
+       int sample_rate = get_sample_rate();
+       if( sample_rate > max_rate ) max_rate = sample_rate;
+       double min_movement = max_rate > 0 ? 1. / max_rate : 1e-6;
+
+// Test for edit handles before cursor position
+       for( Track *track=tracks->first; track; track=track->next ) {
+               if( !track->record ) continue;
+               for( Edit *edit=track->edits->first; edit; edit=edit->next ) {
+                       double edit_end = track->from_units(edit->startproject);
+                       Units::fix_double(&edit_end);
+                       if( fabs(edit_end-position) < min_movement ) continue;
+                       if( edit_end < position && edit_end > new_position )
+                               new_position = edit_end;
+               }
+       }
+       return new_position;
+}
+