[pitivi] timeline/track.py: implement naive transition detection



commit 83d5395bff802af313f014e486dcd50da63fef17
Author: Brandon Lewis <brandon_lewis alum berkeley edu>
Date:   Thu Mar 4 17:51:54 2010 -0800

    timeline/track.py: implement naive transition detection

 pitivi/timeline/track.py |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/pitivi/timeline/track.py b/pitivi/timeline/track.py
index b0af41d..56573a6 100644
--- a/pitivi/timeline/track.py
+++ b/pitivi/timeline/track.py
@@ -738,6 +738,7 @@ class Track(Signallable, Loggable):
         self.composition.connect('notify::duration', self._compositionDurationChangedCb)
         self.track_objects = []
         self.transitions = {}
+        self._update_transitions = True
         self._max_priority = 0
 
         self.mixer = self._getMixerForStream(stream)
@@ -907,6 +908,8 @@ class Track(Signallable, Loggable):
         self._connectToTrackObject(track_object)
 
         self.emit('track-object-added', track_object)
+        if self._update_transitions:
+            self.updateTransitions()
 
     def removeTrackObject(self, track_object):
         if track_object.track is None:
@@ -923,12 +926,15 @@ class Track(Signallable, Loggable):
 
         self.track_objects.remove(track_object)
         track_object.track = None
+
         self._disconnectTrackObjectSignals(track_object)
 
         self._updateMaxPriority()
         self.updateDefaultSources()
 
         self.emit('track-object-removed', track_object)
+        if self._update_transitions:
+            self.updateTransitions()
 
     def removeAllTrackObjects(self):
         for track_object in list(self.track_objects):
@@ -979,6 +985,7 @@ class Track(Signallable, Loggable):
     def enableUpdates(self):
         self.composition.props.update = True
         self.updateDefaultSources()
+        self.updateTransitions()
 
     def disableUpdates(self):
         self.composition.props.update = False
@@ -1038,3 +1045,18 @@ class Track(Signallable, Loggable):
                 safe = end
         return slots
 
+    def updateTransitions(self):
+        # create all new transitions
+        valid_slots = set()
+        if type(self.stream) is VideoStream:
+            for layer in self.getTrackObjectsGroupedByLayer():
+                pos = 0
+                for slot in self.getValidTransitionSlots(layer):
+                    a, b = slot
+                    valid_slots.add(slot)
+                    if not slot in self.transitions:
+                        tr = Transition(a, b)
+                        self.addTransition(tr)
+        current_slots = set(self.transitions.iterkeys())
+        for slot in current_slots - valid_slots:
+            self.removeTransition(self.transitions[slot])



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