[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdenlive] src/effectstack/widgets: Fix random keyframe type when adding composite & transform trans
From:       Jean-Baptiste Mardelle <jb () kdenlive ! org>
Date:       2016-11-20 14:30:09
Message-ID: E1c8T8D-0005hW-7a () code ! kde ! org
[Download RAW message or body]

Git commit 70cf8089e95039ebf31486acad29f0b622e7f1e9 by Jean-Baptiste Mardelle.
Committed on 20/11/2016 at 13:18.
Pushed by mardelle into branch 'master'.

Fix random keyframe type when adding composite & transform transition

M  +15   -12   src/effectstack/widgets/animationwidget.cpp

http://commits.kde.org/kdenlive/70cf8089e95039ebf31486acad29f0b622e7f1e9

diff --git a/src/effectstack/widgets/animationwidget.cpp b/src/effectstack/widgets/animationwidget.cpp
index 254303b..f2eb854 100644
--- a/src/effectstack/widgets/animationwidget.cpp
+++ b/src/effectstack/widgets/animationwidget.cpp
@@ -294,13 +294,15 @@ void AnimationWidget::doAddKeyframe(int pos, QString paramName, bool directUpdat
     pos -= m_offset;
     // Try to get previous key's type
     mlt_keyframe_type type = (mlt_keyframe_type) KdenliveSettings::defaultkeyframeinterp();
-    int previous = m_animController.previous_key(pos);
-    if (m_animController.is_key(previous)) {
-        type =  m_animController.keyframe_type(previous);
-    } else {
-        int next = m_animController.next_key(pos);
-        if (m_animController.is_key(next)) {
-            type =  m_animController.keyframe_type(next);
+    if (m_animController.key_count() > 1) {
+        int previous = m_animController.previous_key(pos);
+        if (m_animController.is_key(previous)) {
+            type =  m_animController.keyframe_type(previous);
+        } else {
+            int next = m_animController.next_key(pos);
+            if (m_animController.is_key(next)) {
+                type =  m_animController.keyframe_type(next);
+            }
         }
     }
 
@@ -437,12 +439,13 @@ void AnimationWidget::rebuildKeyframes()
     QVector <int> types;
     int frame;
     mlt_keyframe_type type;
-    for (int i = 0; i < m_animController.key_count(); i++) {
+    int count = m_animController.key_count();
+    for (int i = 0; i < count; i++) {
         if (!m_animController.key_get(i, frame, type)) {
             frame += m_offset;
             if (frame >= 0) {
 		  keyframes << frame;
-		  types << (int) type;
+		  types << (count > 1 ? (int) type : mlt_keyframe_linear);
 	    }
         }
     }
@@ -466,7 +469,7 @@ void AnimationWidget::updateToolbar()
                 break;
             }
         }
-        m_selectType->setEnabled(true);
+        m_selectType->setEnabled(m_animController.key_count() > 1);
         m_addKeyframe->setActive(true);
         m_addKeyframe->setEnabled(m_animController.key_count() > 1);
         if (m_doubleWidgets.value(m_inTimeline))
@@ -536,7 +539,7 @@ void AnimationWidget::updateSlider(int pos)
                 if (m_active) m_monitor->setEffectKeyframe(true);
                 m_addKeyframe->setActive(true);
                 m_addKeyframe->setEnabled(m_animController.key_count() > 1);
-                m_selectType->setEnabled(true);
+                m_selectType->setEnabled(m_animController.key_count() > 1);
                 m_endAttach->setEnabled(true);
                 m_endAttach->setChecked(m_attachedToEnd > -2 && pos >= m_attachedToEnd);
                 mlt_keyframe_type currentType = m_animController.keyframe_type(pos);
@@ -606,7 +609,7 @@ void AnimationWidget::updateRect(int pos)
         }
         m_addKeyframe->setActive(true);
         m_addKeyframe->setEnabled(m_animController.key_count() > 1);
-        m_selectType->setEnabled(true);
+        m_selectType->setEnabled(m_animController.key_count() > 1);
         m_endAttach->setEnabled(true);
         m_endAttach->setChecked(m_attachedToEnd > -2 && pos >= m_attachedToEnd);
         mlt_keyframe_type currentType = m_animController.keyframe_type(pos);

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic