[pitivi] timeline/elements: Add support for alpha and volume curves.



commit 736909e1ac34e868962505a2b4f21615b491de04
Author: Mathieu Duponchelle <mathieu duponchelle epitech eu>
Date:   Mon Jul 8 02:36:50 2013 +0200

    timeline/elements: Add support for alpha and volume curves.
    
    That was kind of the purpose after all .

 pitivi/timeline/elements.py |   28 ++++++++++++++++++++++++++--
 pitivi/utils/widgets.py     |    2 +-
 2 files changed, 27 insertions(+), 3 deletions(-)
---
diff --git a/pitivi/timeline/elements.py b/pitivi/timeline/elements.py
index 624bd04..cb42793 100644
--- a/pitivi/timeline/elements.py
+++ b/pitivi/timeline/elements.py
@@ -365,6 +365,9 @@ class TimelineElement(Clutter.Actor, Zoomable):
         self.update(True)
         self.set_reactive(True)
 
+        self.isSelected = False
+        self._createMixingKeyframes()
+
         self._connectToEvents()
 
     # Public API
@@ -417,7 +420,7 @@ class TimelineElement(Clutter.Actor, Zoomable):
         self.keyframes = sorted(self.keyframes, key=lambda keyframe: keyframe.value.timestamp)
         self.updateKeyframes()
 
-    def showKeyframes(self, element, propname):
+    def showKeyframes(self, element, propname, isDefault=False):
         binding = element.get_control_binding(propname.name)
         if not binding:
             source = GstController.InterpolationControlSource()
@@ -432,6 +435,10 @@ class TimelineElement(Clutter.Actor, Zoomable):
         self.keyframedElement = element
         self.source = self.binding.props.control_source
 
+        if isDefault:
+            self.default_prop = propname
+            self.default_element = element
+
         if len(self.source.get_all()) < 2:
             self.source.unset_all()
             val = float(propname.default_value) / (propname.maximum - propname.minimum)
@@ -446,6 +453,9 @@ class TimelineElement(Clutter.Actor, Zoomable):
 
         self.keyframes = []
 
+        if self.isSelected:
+            self.showKeyframes(self.default_element, self.default_prop)
+
         self.drawLines()
 
     def setKeyframePosition(self, keyframe, value):
@@ -508,6 +518,18 @@ class TimelineElement(Clutter.Actor, Zoomable):
             brother.isDragged = dragged
         self.isDragged = dragged
 
+    def _createMixingKeyframes(self):
+        if self.bElement.get_track_type() == GES.TrackType.VIDEO:
+            propname = "alpha"
+        else:
+            propname = "volume"
+
+        for spec in self.bElement.list_children_properties():
+            if spec.name == propname:
+                self.showKeyframes(self.bElement, spec, isDefault=True)
+
+        self.hideKeyframes()
+
     def _setKeyframePosition(self, keyframe, value):
         x = self.nsToPixel(value.timestamp) - KEYFRAME_SIZE / 2
         y = EXPANDED_SIZE - (value.value * EXPANDED_SIZE)
@@ -597,7 +619,8 @@ class TimelineElement(Clutter.Actor, Zoomable):
 
     def zoomChanged(self):
         self.update(True)
-        self.updateKeyframes()
+        if self.isSelected:
+            self.updateKeyframes()
 
     # Callbacks
 
@@ -648,6 +671,7 @@ class TimelineElement(Clutter.Actor, Zoomable):
         self.updateKeyframes()
 
     def _selectedChangedCb(self, selected, isSelected):
+        self.isSelected = isSelected
         if not isSelected:
             self.hideKeyframes()
         elif self.keyframedElement:
diff --git a/pitivi/utils/widgets.py b/pitivi/utils/widgets.py
index 88ae5fd..556b88d 100644
--- a/pitivi/utils/widgets.py
+++ b/pitivi/utils/widgets.py
@@ -1007,7 +1007,7 @@ class GstElementSettingsWidget(Gtk.VBox, Loggable):
                 track_element.ui_element.showKeyframes(effect, prop)
                 binding = self.element.get_control_binding(prop.name)
                 self.bindings[widget] = binding
-            elif hasattr(track_element, "ui_element"):
+            elif hasattr(track_element, "ui_element") and track_type == track_element.get_track_type():
                 track_element.ui_element.hideKeyframes()
 
     def _defaultBtnClickedCb(self, button, widget):


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