// Effect has a keyframe type parameter, we need to set the values
if (e.attribute("keyframes").isEmpty()) {
e.setAttribute("keyframes", QString::number(cropStart().frames(m_fps)) + ':' + def + ';' + QString::number((cropStart() + cropDuration()).frames(m_fps) - 1) + ':' + def);
- //kDebug() << "///// EFFECT KEYFRAMES INITED: " << e.attribute("keyframes");
+ kDebug() << "///// EFFECT KEYFRAMES INITED: " << e.attribute("keyframes");
//break;
}
}
void ClipItem::setKeyframes(const int ix, const QString keyframes)
{
QDomElement effect = getEffectAt(ix);
- if (effect.attribute("disabled") == "1") return;
+ 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();
m_keyframeFactor = 100.0 / (max - min);
m_keyframeDefault = e.attribute("default").toDouble();
m_selectedKeyframe = 0;
- m_editedKeyframe = -1;
// parse keyframes
const QStringList keyframes = e.attribute("keyframes").split(';', QString::SkipEmptyParts);
foreach(const QString &str, keyframes) {
double val = str.section(':', 1, 1).toDouble();
m_keyframes[pos] = val;
}
+ 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;
}
QDomElement effect = effectAt(m_selectedEffect);
if (effect.isNull() == false) {
QDomNodeList params = effect.elementsByTagName("parameter");
- if (effect.attribute("disabled") != "1")
+ if (effect.attribute("disable") != "1")
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")) {
m_keyframeFactor = 100.0 / (max - min);
m_keyframeDefault = e.attribute("default").toDouble();
m_selectedKeyframe = 0;
- m_editedKeyframe = -1;
+
// parse keyframes
const QStringList keyframes = e.attribute("keyframes").split(';', QString::SkipEmptyParts);
foreach(const QString &str, keyframes) {
double val = str.section(':', 1, 1).toDouble();
m_keyframes[pos] = val;
}
+ if (m_keyframes.find(m_editedKeyframe) == m_keyframes.end()) m_editedKeyframe = -1;
update();
return;
}
{
// regenerate xml parameter from the clip keyframes
QDomElement effect = getEffectAt(m_selectedEffect);
- if (effect.attribute("disabled") == "1") return;
+ if (effect.attribute("disable") == "1") return;
QDomNodeList params = effect.elementsByTagName("parameter");
for (int i = 0; i < params.count(); i++) {
if (KdenliveSettings::videothumbnails() && !isAudioOnly()) {
QPen pen = painter->pen();
pen.setColor(QColor(255, 255, 255, 150));
- const QRectF source(0.0, 0.0, (double) m_startPix.width(), (double) m_startPix.height());
painter->setPen(pen);
if ((m_clipType == IMAGE || m_clipType == TEXT) && !m_startPix.isNull()) {
const QPointF top = mapped.topRight() - QPointF(m_startPix.width() - 1, 0);
} else mappedRect = mapped;
double scale = painter->matrix().m11();
- int channels = baseClip()->getProperty("channels").toInt();
+ int channels = 0;
+ if (isEnabled() && m_clip) channels = m_clip->getProperty("channels").toInt();
if (scale != m_framePixelWidth)
m_audioThumbCachePic.clear();
double cropLeft = m_info.cropStart.frames(m_fps);
const double scale = projectScene()->scale().x();
double maximumOffset = 6 / scale;
if (isSelected() || (parentItem() && parentItem()->isSelected())) {
- m_editedKeyframe = mouseOverKeyFrames(pos, maximumOffset);
- if (m_editedKeyframe != -1) return KEYFRAME;
+ int kf = mouseOverKeyFrames(pos, maximumOffset);
+ if (kf != -1) {
+ m_editedKeyframe = kf;
+ return KEYFRAME;
+ }
}
QRectF rect = sceneBoundingRect();
int addtransitionOffset = 10;
parameters.addParam("tag", effect.attribute("tag"));
parameters.addParam("kdenlive_ix", effect.attribute("kdenlive_ix"));
if (effect.hasAttribute("src")) parameters.addParam("src", effect.attribute("src"));
- if (effect.hasAttribute("disabled")) parameters.addParam("disabled", effect.attribute("disabled"));
+ if (effect.hasAttribute("disable")) parameters.addParam("disable", effect.attribute("disable"));
QString effectId = effect.attribute("id");
parameters.addParam("kdenlive_ix", effect.attribute("kdenlive_ix"));
parameters.addParam("id", effect.attribute("id"));
if (effect.hasAttribute("src")) parameters.addParam("src", effect.attribute("src"));
- if (effect.hasAttribute("disabled")) parameters.addParam("disabled", effect.attribute("disabled"));
+ if (effect.hasAttribute("disable")) parameters.addParam("disable", effect.attribute("disable"));
QDomNodeList params = effect.elementsByTagName("parameter");
for (int i = 0; i < params.count(); i++) {
return m_videoOnly;
}
+void ClipItem::insertKeyframe(QDomElement effect, int pos, int val)
+{
+ if (effect.attribute("disable") == "1") return;
+ effect.setAttribute("active_keyframe", pos);
+ m_editedKeyframe = pos;
+ 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) newkfr.append(QString::number(pos) + ":" + QString::number(val));
+ e.setAttribute("keyframes", newkfr.join(";"));
+ }
+}
+void ClipItem::movedKeyframe(QDomElement effect, int oldpos, int newpos, double value)
+{
+ if (effect.attribute("disable") == "1") return;
+ effect.setAttribute("active_keyframe", newpos);
+ QDomNodeList params = effect.elementsByTagName("parameter");
+ int start = cropStart().frames(m_fps);
+ 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));
+ }
+ }
+ e.setAttribute("keyframes", newkfr.join(";"));
+ }
+
+ updateKeyframes(effect);
+ update();
+}
+
+void ClipItem::updateKeyframes(QDomElement effect)
+{
+ m_keyframes.clear();
+ // parse keyframes
+ QDomNodeList params = effect.elementsByTagName("parameter");
+ QDomElement e = params.item(0).toElement();
+ const QStringList keyframes = e.attribute("keyframes").split(';', QString::SkipEmptyParts);
+ foreach(const QString &str, keyframes) {
+ int pos = str.section(':', 0, 0).toInt();
+ double val = str.section(':', 1, 1).toDouble();
+ m_keyframes[pos] = val;
+ }
+ if (!m_keyframes.contains(m_selectedKeyframe)) m_selectedKeyframe = -1;
+}
#include "clipitem.moc"