[pitivi] timeline/elements: Edge keyframes can't have their timestamps changed.



commit eab5f7b8f1b48a2ba8fd56769fc90d0aecad77f1
Author: Mathieu Duponchelle <mathieu duponchelle epitech eu>
Date:   Tue Jun 25 14:53:33 2013 +0200

    timeline/elements: Edge keyframes can't have their timestamps changed.

 pitivi/timeline/elements.py |   23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)
---
diff --git a/pitivi/timeline/elements.py b/pitivi/timeline/elements.py
index 66dd83f..35b1c57 100644
--- a/pitivi/timeline/elements.py
+++ b/pitivi/timeline/elements.py
@@ -457,8 +457,13 @@ class TimelineElement(Clutter.Actor, Zoomable):
 
         self.keyframes = []
 
-        for value in values:
-            self._createKeyframe(value)
+        l = len(values)
+
+        for i, value in enumerate(values):
+            has_changable_time = True
+            if i == 0 or i == l - 1:
+                has_changable_time = False
+            self._createKeyframe(value, has_changable_time)
             lastPoint = value
 
         self.drawLines()
@@ -482,8 +487,8 @@ class TimelineElement(Clutter.Actor, Zoomable):
         keyframe.set_z_position(2)
         keyframe.set_position(x, y)
 
-    def _createKeyframe(self, value):
-        keyframe = Keyframe(self, value)
+    def _createKeyframe(self, value, has_changable_time):
+        keyframe = Keyframe(self, value, has_changable_time)
 
         self.add_child(keyframe)
         self.keyframes.append(keyframe)
@@ -659,7 +664,10 @@ class Line(Clutter.Actor):
 
 
 class Keyframe(Clutter.Actor):
-    def __init__(self, timelineElement, value):
+    """
+    If has_changable_time is False, it means this is an edge keyframe.
+    """
+    def __init__(self, timelineElement, value, has_changable_time):
         Clutter.Actor.__init__(self)
 
         self.value = value
@@ -671,6 +679,8 @@ class Keyframe(Clutter.Actor):
         self.dragAction = Clutter.DragAction()
         self.add_action(self.dragAction)
 
+        self.has_changable_time = has_changable_time
+
         self.dragAction.connect("drag-begin", self._dragBeginCb)
         self.dragAction.connect("drag-end", self._dragEndCb)
         self.dragAction.connect("drag-progress", self._dragProgressCb)
@@ -715,6 +725,9 @@ class Keyframe(Clutter.Actor):
         if newValue < 0.0 or newValue > 1.0:
             return False
 
+        if not self.has_changable_time:
+            newTs = self.lastTs
+
         self.timelineElement.source.unset(self.lastTs)
         if (self.timelineElement.source.set(newTs, newValue)):
             self.value = Gst.TimedValue()


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