bool ClipItem::checkKeyFrames()
{
bool clipEffectsModified = false;
- for (int ix = 0; ix < m_effectList.count(); ix ++) {
- QString kfr = keyframes(ix);
- if (!kfr.isEmpty()) {
+ // go through all effects this clip has
+ for (int ix = 0; ix < m_effectList.count(); ++ix) {
+ QStringList keyframeParams = keyframes(ix);
+ QStringList newKeyFrameParams;
+ bool effModified = false;
+
+ // go through all params which have keyframes
+ foreach (const QString &kfr, keyframeParams) {
const QStringList keyframes = kfr.split(';', QString::SkipEmptyParts);
QStringList newKeyFrames;
bool cutKeyFrame = false;
double lastValue = -1;
int start = cropStart().frames(m_fps);
int end = (cropStart() + cropDuration()).frames(m_fps);
+
+ // go through all keyframes for one param
foreach(const QString &str, keyframes) {
int pos = str.section(':', 0, 0).toInt();
double val = str.section(':', 1, 1).toDouble();
lastPos = pos;
lastValue = val;
}
- if (modified) {
- // update KeyFrames
- setKeyframes(ix, newKeyFrames.join(";"));
- clipEffectsModified = true;
- }
+
+ newKeyFrameParams.append(newKeyFrames.join(";"));
+ if (modified)
+ effModified = true;
+ }
+
+ if (effModified) {
+ // update KeyFrames
+ setKeyframes(ix, newKeyFrameParams);
+ clipEffectsModified = true;
}
}
return clipEffectsModified;
}
-void ClipItem::setKeyframes(const int ix, const QString keyframes)
+void ClipItem::setKeyframes(const int ix, const QStringList keyframes)
{
QDomElement effect = getEffectAt(ix);
if (effect.attribute("disable") == "1") return;
QDomNodeList params = effect.elementsByTagName("parameter");
+ int keyframeParams = 0;
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")) {
- e.setAttribute("keyframes", keyframes);
- if (ix == m_selectedEffect) {
+ e.setAttribute("keyframes", keyframes.at(keyframeParams));
+ if (ix == m_selectedEffect && keyframeParams == 0) {
m_keyframes.clear();
double max = e.attribute("max").toDouble();
double min = e.attribute("min").toDouble();
if (m_keyframes.find(m_editedKeyframe) == m_keyframes.end()) m_editedKeyframe = -1;
if (m_keyframes.find(m_editedKeyframe) == m_keyframes.end()) m_editedKeyframe = -1;
update();
- return;
}
- break;
+ ++keyframeParams;
}
}
}
}
}
-QString ClipItem::keyframes(const int index)
+QStringList ClipItem::keyframes(const int index)
{
- QString result;
+ QStringList result;
QDomElement effect = effectAt(index);
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")) {
- result = e.attribute("keyframes");
- break;
- }
+ if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe"))
+ result.append(e.attribute("keyframes"));
}
return result;
}
QDomElement selectedEffect();
int selectedEffectIndex() const;
void initEffect(QDomElement effect, int diff = 0);
- QString keyframes(const int index);
- void setKeyframes(const int ix, const QString keyframes);
+
+ /** @brief Gets all keyframes.
+ * @param index Number of the effect
+ * @return a list of strings of keyframes (one string per param) */
+ QStringList keyframes(const int index);
+
+ /** @brief Sets params with keyframes and updates the visible keyframes.
+ * @param ix Number of the effect
+ * @param keyframes a list of strings of keyframes (one string per param), which should be used */
+ void setKeyframes(const int ix, const QStringList keyframes);
void setEffectList(const EffectsList effectList);
void setSpeed(const double speed, int strobe);
double speed() const;
GenTime speedIndependantCropDuration() const;
const ItemInfo speedIndependantInfo() const;
int hasEffect(const QString &tag, const QString &id) const;
+
+ /** @brief Makes sure all keyframes are in the clip's cropped duration.
+ * @return Whether or not changes were made */
bool checkKeyFrames();
QPixmap startThumb() const;
QPixmap endThumb() const;
void CustomTrackView::editKeyFrame(const GenTime pos, const int track, const int index, const QString keyframes)
{
- ClipItem *clip = getClipItemAt((int)pos.frames(m_document->fps()), track);
+ /*ClipItem *clip = getClipItemAt((int)pos.frames(m_document->fps()), track);
if (clip) {
clip->setKeyframes(index, keyframes);
updateEffect(m_document->tracksCount() - clip->track(), clip->startPos(), clip->effectAt(index), index, false);
- } else emit displayMessage(i18n("Cannot find clip with keyframe"), ErrorMessage);
+ } else emit displayMessage(i18n("Cannot find clip with keyframe"), ErrorMessage);*/
}