alt transport keys, snap editing, grab focus, inv hilight clr, subtitle fix
[goodguy/history.git] / cinelerra-5.1 / cinelerra / edl.C
index 5d9ff496238e1f15727fe154c333bf04ae015786..134aa8c9641f0faaa1407cf4e30da16d7c15a1b1 100644 (file)
@@ -1549,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 = INFINITY;
+
+       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;
+}
+