Second set of 50 GPL attribution for CV-Contributors added
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / pluginset.C
index 86bb4b6687290e24f3904ec637b021481f466cfc..833ab47364430555f99fd8134c5616ecdba0f69b 100644 (file)
@@ -2,6 +2,7 @@
 /*
  * CINELERRA
  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
+ * Copyright (C) 2003-2016 Cinelerra CV contributors
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -160,11 +161,24 @@ Edit* PluginSet::insert_edit_after(Edit *previous_edit)
 
 KeyFrame *PluginSet::nearest_keyframe(int64_t pos, int dir)
 {
+       if( first && pos < first->startproject )
+               pos = first->startproject;
+       else if( last && pos > last->startproject+last->length )
+               pos = last->startproject+last->length;
+       KeyFrame *keyframe = 0;
        Plugin *plugin = (Plugin*)editof(pos, dir, 0);
-       if( !plugin ) return 0;
-       KeyFrame *keyframe = (KeyFrame *)(dir == PLAY_FORWARD ?
-               plugin->keyframes->nearest_after(pos) :
-               plugin->keyframes->nearest_before(pos));
+       if( dir == PLAY_FORWARD ) {
+               for( ; !keyframe && plugin; plugin=(Plugin*)plugin->next ) {
+                       if( plugin->plugin_type == PLUGIN_NONE ) continue;
+                       keyframe = (KeyFrame *)plugin->keyframes->nearest_after(pos);
+               }
+       }
+       else {
+               for( ; !keyframe && plugin; plugin=(Plugin*)plugin->previous ) {
+                       if( plugin->plugin_type == PLUGIN_NONE ) continue;
+                       keyframe = (KeyFrame *)plugin->keyframes->nearest_before(pos);
+               }
+       }
        return keyframe;
 }