Commit ee143106 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

When copying effect with keyframes, don't copy keyframes that are past the clip end.

Related to #794
parent 9e11b4d6
Pipeline #206772 passed with stage
in 9 minutes and 8 seconds
......@@ -1324,7 +1324,7 @@ std::shared_ptr<Mlt::Properties> KeyframeModel::getAnimation(std::shared_ptr<Ass
return mlt_prop;
}
const QString KeyframeModel::getAnimationStringWithOffset(std::shared_ptr<AssetParameterModel> model, const QString &animData, int offset)
const QString KeyframeModel::getAnimationStringWithOffset(std::shared_ptr<AssetParameterModel> model, const QString &animData, int offset, int duration)
{
Mlt::Properties mlt_prop;
model->passProperties(mlt_prop);
......@@ -1345,7 +1345,7 @@ const QString KeyframeModel::getAnimationStringWithOffset(std::shared_ptr<AssetP
}
}
}
return qstrdup(anim.serialize_cut());
return qstrdup(anim.serialize_cut(0, duration));
}
QList<GenTime> KeyframeModel::getKeyframePos() const
......
......@@ -160,7 +160,7 @@ public:
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
static QList<QPoint> getRanges(const QString &animData, const std::shared_ptr<AssetParameterModel> &model);
static std::shared_ptr<Mlt::Properties> getAnimation(std::shared_ptr<AssetParameterModel> model, const QString &animData, int duration = 0);
static const QString getAnimationStringWithOffset(std::shared_ptr<AssetParameterModel> model, const QString &animData, int offset);
static const QString getAnimationStringWithOffset(std::shared_ptr<AssetParameterModel> model, const QString &animData, int offset, int duration);
protected:
/** @brief Helper function that generate a lambda to change type / value of given keyframe */
......
......@@ -343,7 +343,11 @@ bool EffectStackModel::fromXml(const QDomElement &effectsXml, Fun &undo, Fun &re
}
if (keyframeParams.contains(pName)) {
// This is a keyframable parameter, fix offset
QString pValue = KeyframeModel::getAnimationStringWithOffset(effect, pnode.text(), currentIn - parentIn);
int currentDuration = pCore->getItemDuration(m_ownerId);
if (currentDuration > 1) {
currentDuration--;
}
QString pValue = KeyframeModel::getAnimationStringWithOffset(effect, pnode.text(), currentIn - parentIn, currentDuration);
parameters.append(QPair<QString, QVariant>(pName, QVariant(pValue)));
} else {
parameters.append(QPair<QString, QVariant>(pName, QVariant(pnode.text())));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment