summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Baptiste Mardelle <jb@kdenlive.org>2016-09-28 20:41:23 (GMT)
committerJean-Baptiste Mardelle <jb@kdenlive.org>2016-09-28 20:41:23 (GMT)
commitdcf45a03726a674425f65b98015a4712fa109f9f (patch)
treea0c10e2eba73bb0e03e2c3dd2326a37da54823f7
parent57c33d5cdb176f6c9f91053e825a6944c3864412 (diff)
Ensure we always have a keyframe at the end of a transition when resizing it to avoid artifacts
CCBUG: 369479
-rw-r--r--src/effectstack/widgets/animationwidget.cpp2
-rw-r--r--src/timeline/transition.cpp34
2 files changed, 24 insertions, 12 deletions
diff --git a/src/effectstack/widgets/animationwidget.cpp b/src/effectstack/widgets/animationwidget.cpp
index 02323ae..cc86e26 100644
--- a/src/effectstack/widgets/animationwidget.cpp
+++ b/src/effectstack/widgets/animationwidget.cpp
@@ -488,7 +488,7 @@ void AnimationWidget::slotPositionChanged(int pos, bool seek)
m_timePos->setValue(pos);
m_ruler->setValue(pos);
if (m_spinX) {
- updateRect(pos);
+ updateRect(pos - m_offset);
}
updateSlider(pos - m_offset);
if (seek)
diff --git a/src/timeline/transition.cpp b/src/timeline/transition.cpp
index 2a99e39..9cfc54c 100644
--- a/src/timeline/transition.cpp
+++ b/src/timeline/transition.cpp
@@ -395,7 +395,8 @@ bool Transition::updateKeyframes(ItemInfo oldInfo, ItemInfo newInfo)
QDomNodeList namenode = m_parameters.elementsByTagName(QStringLiteral("parameter"));
for (int i = 0; i < namenode.count() ; ++i) {
pa = namenode.item(i).toElement();
- if (pa.attribute(QStringLiteral("type")) == QLatin1String("geometry")) {
+ QString type = pa.attribute(QStringLiteral("type"));
+ if (type == QLatin1String("geometry") || type == QLatin1String("animated") || type == QLatin1String("animatedrect")) {
keyframes = pa.attribute(QStringLiteral("value"));
break;
}
@@ -408,15 +409,21 @@ bool Transition::updateKeyframes(ItemInfo oldInfo, ItemInfo newInfo)
int i = 0;
if (oldEnd < duration) {
// Transition was expanded, check if we had a keyframe at end position
- foreach(const QString &pos, values) {
- if (!pos.contains('=')) {
+ foreach(QString pos, values) {
+ if (!pos.contains(QLatin1Char('='))) {
++i;
continue;
}
- frame = pos.section('=', 0, 0).toInt();
+ frame = pos.section(QLatin1Char('='), 0, 0).remove(QLatin1Char('~')).remove(QLatin1Char('|')).toInt();
if (frame == oldEnd) {
// Move that keyframe to new end
- values[i] = QString::number(duration) + '=' + pos.section('=', 1);
+ QString separator = QStringLiteral("=");
+ if (pos.contains(QLatin1Char('~'))) {
+ separator.prepend(QStringLiteral("~"));
+ } else if (pos.contains(QLatin1Char('|'))) {
+ separator.prepend(QStringLiteral("|"));
+ }
+ values[i] = QString::number(duration) + separator + pos.section('=', 1);
pa.setAttribute(QStringLiteral("value"), values.join(QStringLiteral(";")));
return true;
}
@@ -427,11 +434,11 @@ bool Transition::updateKeyframes(ItemInfo oldInfo, ItemInfo newInfo)
else if (oldEnd > duration) {
// Transition was shortened, check for out of bounds keyframes
foreach(const QString &pos, values) {
- if (!pos.contains('=')) {
+ if (!pos.contains(QLatin1Char('='))) {
++i;
continue;
}
- frame = pos.section('=', 0, 0).toInt();
+ frame = pos.section(QLatin1Char('='), 0, 0).remove(QLatin1Char('~')).remove(QLatin1Char('|')).toInt();
if (frame > duration) {
modified = true;
break;
@@ -444,8 +451,8 @@ bool Transition::updateKeyframes(ItemInfo oldInfo, ItemInfo newInfo)
// Check if there is a keyframe at transition end
QString prev = values.at(i-1);
bool done = false;
- if (prev.contains('=')) {
- int previousKeyframe = prev.section('=', 0, 0).toInt();
+ if (prev.contains(QLatin1Char('='))) {
+ int previousKeyframe = prev.section(QLatin1Char('='), 0, 0).remove(QLatin1Char('~')).remove(QLatin1Char('|')).toInt();
if (previousKeyframe == duration) {
// Remove the last keyframes
while (values.count() > i) {
@@ -457,7 +464,13 @@ bool Transition::updateKeyframes(ItemInfo oldInfo, ItemInfo newInfo)
if (!done) {
// Add new keyframe at end and remove last keyframes
QString last = values.at(i);
- last = QString::number(duration) + '=' + last.section('=', 1);
+ QString separator = QStringLiteral("=");
+ if (last.contains(QLatin1Char('~'))) {
+ separator.prepend(QStringLiteral("~"));
+ } else if (last.contains(QLatin1Char('|'))) {
+ separator.prepend(QStringLiteral("|"));
+ }
+ last = QString::number(duration) + separator + last.section(QLatin1Char('='), 1);
values[i] = last;
while (values.count() > (i + 1)) {
values.removeLast();
@@ -476,7 +489,6 @@ void Transition::updateKeyframes(QDomElement /*effect*/)
//virtual
void Transition::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
{
- qDebug()<<"* * * ENTER TRANSITION DRAG";
if (isItemLocked()) event->setAccepted(false);
else if (event->mimeData()->hasFormat(QStringLiteral("kdenlive/geometry"))) {
event->acceptProposedAction();