[pitivi] timeline/track.py: implement getValidTransitionSlots



commit f8e080e37ee100bdcb5c4228dbb2c15bcf5188cc
Author: Brandon Lewis <brandon_lewis alum berkeley edu>
Date:   Thu Mar 4 17:47:05 2010 -0800

    timeline/track.py: implement getValidTransitionSlots

 pitivi/timeline/track.py |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/pitivi/timeline/track.py b/pitivi/timeline/track.py
index cf3658b..b0af41d 100644
--- a/pitivi/timeline/track.py
+++ b/pitivi/timeline/track.py
@@ -1007,3 +1007,34 @@ class Track(Signallable, Loggable):
             layers[int(track_object.priority)].append(track_object)
         return layers
 
+    def getValidTransitionSlots(self, objs):
+        prev = None
+        safe = 0
+        duration = 0
+        slots = []
+        def pop():
+            if len(slots):
+                slots.pop(-1)
+        for obj in objs:
+            end = obj.start + obj.duration
+            if obj.start >= duration:
+                safe = obj.start
+                duration = end
+                prev = obj
+            elif end >= duration and obj.start >= safe:
+                slots.append((prev, obj))
+                safe = duration
+                duration = end
+                prev = obj
+            elif end >= duration and obj.start < safe:
+                pop()
+                safe = duration
+                duration = end
+                prev = obj
+            elif end < duration and obj.start >= safe:
+                safe = end
+            elif end < duration and obj.start < safe:
+                pop()
+                safe = end
+        return slots
+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]