From 48c430b1bd59ffbef9ca7ce3a3e8576d8b904072 Mon Sep 17 00:00:00 2001 From: Till Theato Date: Sat, 30 Oct 2010 22:35:15 +0000 Subject: [PATCH] Fix keyframes not editable in timeline if first parameter is not keyframable svn path=/trunk/kdenlive/; revision=5064 --- src/abstractclipitem.h | 2 + src/clipitem.cpp | 110 +++++++++++++++++++++-------------------- src/keyframeedit.h | 2 +- 3 files changed, 60 insertions(+), 54 deletions(-) diff --git a/src/abstractclipitem.h b/src/abstractclipitem.h index c47ec951..f24e0ab2 100644 --- a/src/abstractclipitem.h +++ b/src/abstractclipitem.h @@ -103,6 +103,8 @@ protected: QMap m_keyframes; double m_keyframeFactor; double m_keyframeDefault; + /** The (keyframe) parameter that is visible and editable in timeline (on the clip) */ + int m_visibleParam; double m_fps; //QRect visibleRect(); void drawKeyFrames(QPainter *painter, QRectF exposedRect); diff --git a/src/clipitem.cpp b/src/clipitem.cpp index 3631256a..41dea033 100644 --- a/src/clipitem.cpp +++ b/src/clipitem.cpp @@ -393,6 +393,7 @@ void ClipItem::setKeyframes(const int ix, const QStringList keyframes) e.setAttribute("keyframes", keyframes.at(keyframeParams)); if (ix == m_selectedEffect && keyframeParams == 0) { m_keyframes.clear(); + m_visibleParam = i; double max = e.attribute("max").toDouble(); double min = e.attribute("min").toDouble(); m_keyframeFactor = 100.0 / (max - min); @@ -426,6 +427,7 @@ void ClipItem::setSelectedEffect(const int ix) QDomElement e = params.item(i).toElement(); if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) { m_keyframes.clear(); + m_visibleParam = i; double max = e.attribute("max").toDouble(); double min = e.attribute("min").toDouble(); m_keyframeFactor = 100.0 / (max - min); @@ -471,23 +473,19 @@ void ClipItem::updateKeyframeEffect() QDomElement effect = getEffectAt(m_selectedEffect); if (effect.attribute("disable") == "1") return; QDomNodeList params = effect.elementsByTagName("parameter"); - - for (int i = 0; i < params.count(); i++) { - QDomElement e = params.item(i).toElement(); - if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) { - QString keyframes; - if (m_keyframes.count() > 0) { - QMap::const_iterator i = m_keyframes.constBegin(); - while (i != m_keyframes.constEnd()) { - keyframes.append(QString::number(i.key()) + ':' + QString::number(i.value()) + ';'); - ++i; - } + QDomElement e = params.item(m_visibleParam).toElement(); + + if (!e.isNull()) { + QString keyframes; + if (m_keyframes.count() > 0) { + QMap::const_iterator i = m_keyframes.constBegin(); + while (i != m_keyframes.constEnd()) { + keyframes.append(QString::number(i.key()) + ':' + QString::number(i.value()) + ';'); + ++i; } - // Effect has a keyframe type parameter, we need to set the values - //kDebug() << "::::::::::::::: SETTING EFFECT KEYFRAMES: " << keyframes; - e.setAttribute("keyframes", keyframes); - break; } + // Effect has a keyframe type parameter, we need to set the values + e.setAttribute("keyframes", keyframes); } } @@ -1221,9 +1219,7 @@ bool ClipItem::checkEffectsKeyframesPos(const int previous, const int current, b for (int j = 0; j < params.count(); j++) { bool modified = false; QDomElement e = params.item(j).toElement(); - if (e.isNull()) - continue; - if (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe") { + if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) { // parse keyframes and adjust values const QStringList keyframes = e.attribute("keyframes").split(';', QString::SkipEmptyParts); QMap kfr; @@ -1683,29 +1679,33 @@ void ClipItem::insertKeyframe(QDomElement effect, int pos, int val) QDomNodeList params = effect.elementsByTagName("parameter"); for (int i = 0; i < params.count(); i++) { QDomElement e = params.item(i).toElement(); - QString kfr = e.attribute("keyframes"); - const QStringList keyframes = kfr.split(';', QString::SkipEmptyParts); - QStringList newkfr; - bool added = false; - foreach(const QString &str, keyframes) { - int kpos = str.section(':', 0, 0).toInt(); - double newval = str.section(':', 1, 1).toDouble(); - if (kpos < pos) { - newkfr.append(str); - } else if (!added) { - if (i == 0) newkfr.append(QString::number(pos) + ":" + QString::number(val)); - else newkfr.append(QString::number(pos) + ":" + QString::number(newval)); - if (kpos > pos) newkfr.append(str); - added = true; - } else newkfr.append(str); - } - if (!added) { - if (i == 0) - newkfr.append(QString::number(pos) + ":" + QString::number(val)); - else - newkfr.append(QString::number(pos) + ":" + e.attribute("default")); + if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) { + QString kfr = e.attribute("keyframes"); + const QStringList keyframes = kfr.split(';', QString::SkipEmptyParts); + QStringList newkfr; + bool added = false; + foreach(const QString &str, keyframes) { + int kpos = str.section(':', 0, 0).toInt(); + double newval = str.section(':', 1, 1).toDouble(); + if (kpos < pos) { + newkfr.append(str); + } else if (!added) { + if (i == m_visibleParam) + newkfr.append(QString::number(pos) + ":" + QString::number(val)); + else + newkfr.append(QString::number(pos) + ":" + QString::number(newval)); + if (kpos > pos) newkfr.append(str); + added = true; + } else newkfr.append(str); + } + if (!added) { + if (i == m_visibleParam) + newkfr.append(QString::number(pos) + ":" + QString::number(val)); + else + newkfr.append(QString::number(pos) + ":" + e.attribute("default")); + } + e.setAttribute("keyframes", newkfr.join(";")); } - e.setAttribute("keyframes", newkfr.join(";")); } } @@ -1718,20 +1718,24 @@ void ClipItem::movedKeyframe(QDomElement effect, int oldpos, int newpos, double int end = (cropStart() + cropDuration()).frames(m_fps) - 1; for (int i = 0; i < params.count(); i++) { QDomElement e = params.item(i).toElement(); - QString kfr = e.attribute("keyframes"); - const QStringList keyframes = kfr.split(';', QString::SkipEmptyParts); - QStringList newkfr; - foreach(const QString &str, keyframes) { - if (str.section(':', 0, 0).toInt() != oldpos) { - newkfr.append(str); - } else if (newpos != -1) { - newpos = qMax(newpos, start); - newpos = qMin(newpos, end); - if (i == 0) newkfr.append(QString::number(newpos) + ":" + QString::number(value)); - else newkfr.append(QString::number(newpos) + ":" + str.section(':', 1, 1)); + if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) { + QString kfr = e.attribute("keyframes"); + const QStringList keyframes = kfr.split(';', QString::SkipEmptyParts); + QStringList newkfr; + foreach(const QString &str, keyframes) { + if (str.section(':', 0, 0).toInt() != oldpos) { + newkfr.append(str); + } else if (newpos != -1) { + newpos = qMax(newpos, start); + newpos = qMin(newpos, end); + if (i == m_visibleParam) + newkfr.append(QString::number(newpos) + ":" + QString::number(value)); + else + newkfr.append(QString::number(newpos) + ":" + str.section(':', 1, 1)); + } } + e.setAttribute("keyframes", newkfr.join(";")); } - e.setAttribute("keyframes", newkfr.join(";")); } updateKeyframes(effect); @@ -1743,7 +1747,7 @@ void ClipItem::updateKeyframes(QDomElement effect) m_keyframes.clear(); // parse keyframes QDomNodeList params = effect.elementsByTagName("parameter"); - QDomElement e = params.item(0).toElement(); + QDomElement e = params.item(m_visibleParam).toElement(); const QStringList keyframes = e.attribute("keyframes").split(';', QString::SkipEmptyParts); foreach(const QString &str, keyframes) { int pos = str.section(':', 0, 0).toInt(); diff --git a/src/keyframeedit.h b/src/keyframeedit.h index 3069dd99..a2fcd1c2 100644 --- a/src/keyframeedit.h +++ b/src/keyframeedit.h @@ -115,7 +115,7 @@ private slots: void slotAdjustKeyframePos(int value); void slotAdjustKeyframeValue(int value); /** @brief Turns the seek to keyframe position setting on/off. - * @param state State of the associated checkbox */ + * @param seek true = seeking on */ void slotSetSeeking(bool seek); /** @brief Shows the keyframe table and adds a second keyframe. */ -- 2.39.2