From kde-commits Wed Dec 07 22:48:02 2016 From: Jean-Baptiste Mardelle Date: Wed, 07 Dec 2016 22:48:02 +0000 To: kde-commits Subject: [kdenlive/Applications/16.12] /: * Fix crash on resize clip after removing keyframe effect Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=148115089305563 Git commit 406b7674ae24a0a2cba1e2aff6feeebaaa04d6c8 by Jean-Baptiste Mardel= le. Committed on 07/12/2016 at 22:47. Pushed by mardelle into branch 'Applications/16.12'. * Fix crash on resize clip after removing keyframe effect * Do not display Transform rotation keyframes in timeline * Fix Keyframes for animated rect (transform) not correctly displayed * Fix Geometry keyframes (Position and Zoom) M +1 -1 data/effects/qtblend.xml M +2 -2 src/effectstack/widgets/animationwidget.cpp M +2 -1 src/mltcontroller/effectscontroller.cpp M +1 -1 src/timeline/abstractclipitem.cpp M +38 -17 src/timeline/keyframeview.cpp M +1 -0 src/timeline/keyframeview.h https://commits.kde.org/kdenlive/406b7674ae24a0a2cba1e2aff6feeebaaa04d6c8 diff --git a/data/effects/qtblend.xml b/data/effects/qtblend.xml index 4cf2e733c..829ecb239 100644 --- a/data/effects/qtblend.xml +++ b/data/effects/qtblend.xml @@ -6,7 +6,7 @@ Rectangle - + Rotation diff --git a/src/effectstack/widgets/animationwidget.cpp b/src/effectstack/= widgets/animationwidget.cpp index 9f52e0d5e..f290c6561 100644 --- a/src/effectstack/widgets/animationwidget.cpp +++ b/src/effectstack/widgets/animationwidget.cpp @@ -717,7 +717,7 @@ void AnimationWidget::buildSliderWidget(const QString &= paramTag, const QDomEleme doubleparam->factor =3D factor; connect(doubleparam, SIGNAL(valueChanged(double)), this, SLOT(slotAdju= stKeyframeValue(double))); layout()->addWidget(doubleparam); - if (!e.hasAttribute(QStringLiteral("intimeline")) || e.attribute(QStri= ngLiteral("intimeline")) =3D=3D QLatin1String("1")) { + if ((!e.hasAttribute(QStringLiteral("intimeline")) || e.attribute(QStr= ingLiteral("intimeline")) =3D=3D QLatin1String("1")) && !e.hasAttribute(QSt= ringLiteral("notintimeline"))) { doubleparam->setInTimelineProperty(true); doubleparam->setChecked(true); m_inTimeline =3D paramTag; @@ -888,7 +888,7 @@ void AnimationWidget::slotAdjustRectKeyframeValue() { m_animController =3D m_animProperties.get_animation(m_rectParameter.to= Utf8().constData()); m_inTimeline =3D m_rectParameter; - int pos =3D m_ruler->position(); + int pos =3D m_ruler->position() - m_offset; mlt_rect rect; rect.x =3D m_spinX->value(); rect.y =3D m_spinY->value(); diff --git a/src/mltcontroller/effectscontroller.cpp b/src/mltcontroller/ef= fectscontroller.cpp index 2cdb61037..a63366e77 100644 --- a/src/mltcontroller/effectscontroller.cpp +++ b/src/mltcontroller/effectscontroller.cpp @@ -273,7 +273,8 @@ void EffectsController::initEffect(ItemInfo info, Profi= leInfo pInfo, EffectsList bool hasValue =3D e.hasAttribute(QStringLiteral("value")); // Check if this effect has a variable parameter, init effects def= ault value if ((type =3D=3D QLatin1String("animatedrect") || type =3D=3D QLat= in1String("geometry")) && !hasValue) { - QString kfr =3D AnimationWidget::getDefaultKeyframes(info.crop= Start.frames(fps), e.attribute(QStringLiteral("default")), type =3D=3D QLat= in1String("geometry")); + int pos =3D type =3D=3D QLatin1String("geometry") ? 0 : info.c= ropStart.frames(fps); + QString kfr =3D AnimationWidget::getDefaultKeyframes(pos, e.at= tribute(QStringLiteral("default")), type =3D=3D QLatin1String("geometry")); if (kfr.contains("%")) { kfr =3D EffectsController::getStringRectEval(pInfo, kfr); } diff --git a/src/timeline/abstractclipitem.cpp b/src/timeline/abstractclipi= tem.cpp index 963ed125e..7d51cd5fa 100644 --- a/src/timeline/abstractclipitem.cpp +++ b/src/timeline/abstractclipitem.cpp @@ -481,7 +481,7 @@ void AbstractClipItem::movedKeyframe(QDomElement effect= , int newpos, int oldpos, QDomElement e =3D params.item(i).toElement(); if (e.isNull()) continue; QString paramName =3D e.attribute(QStringLiteral("name")); - if (e.attribute(QStringLiteral("type")) =3D=3D QLatin1String("anim= ated")) { + if (e.attribute(QStringLiteral("type")).startsWith(QLatin1String("= animated"))) { if (m_keyframeView.activeParam(paramName)) { // inserting a keyframe touches all animated params for (int j =3D 0; j < params.count(); ++j) { diff --git a/src/timeline/keyframeview.cpp b/src/timeline/keyframeview.cpp index 30586c7d9..84777d428 100644 --- a/src/timeline/keyframeview.cpp +++ b/src/timeline/keyframeview.cpp @@ -74,7 +74,7 @@ QPointF KeyframeView::keyframePoint(QRectF br, int frame,= double value, double f = void KeyframeView::drawKeyFrames(QRectF br, int length, bool active, QPain= ter *painter, const QTransform &transformation) { - if (duration =3D=3D 0 || m_keyframeType =3D=3D NoKeyframe || !m_keyAni= m.is_valid() || m_keyAnim.key_count() < 1) + if (duration =3D=3D 0 || m_inTimeline.isEmpty() || m_keyframeType =3D= =3D NoKeyframe || !m_keyAnim.is_valid() || m_keyAnim.key_count() < 1) return; duration =3D length; //m_keyAnim.set_length(length); @@ -133,6 +133,8 @@ void KeyframeView::drawKeyFrames(QRectF br, int length,= bool active, QPainter *p // Make sure edited param is painted last paramNames.append(m_inTimeline); foreach (const QString ¶mName, paramNames) { + if (m_notInTimeline.contains(paramName)) + continue; ParameterInfo info =3D m_paramInfos.value(paramName); if (info.max =3D=3D info.min) { // this is probably an animated rect @@ -547,7 +549,13 @@ void KeyframeView::updateKeyFramePos(QRectF br, int fr= ame, const double y) int newpos =3D qBound(prev, frame - m_offset, next); double newval =3D keyframeUnmap(br, y); mlt_keyframe_type type =3D m_keyAnim.keyframe_type(activeKeyframe); - m_keyProperties.anim_set(m_inTimeline.toUtf8().constData(), newval, ne= wpos, duration - m_offset, type); + if (m_keyframeType =3D=3D GeometryKeyframe) { + // Animated rect + mlt_rect rect =3D m_keyProperties.anim_get_rect(m_inTimeline.toUtf= 8().constData(), activeKeyframe - m_offset, duration - m_offset); + m_keyProperties.anim_set(m_inTimeline.toUtf8().constData(), rect, = newpos, duration - m_offset, type); + } else { + m_keyProperties.anim_set(m_inTimeline.toUtf8().constData(), newval= , newpos, duration - m_offset, type); + } if (activeKeyframe !=3D newpos) { m_keyAnim.remove(activeKeyframe); // Move keyframe in other geometries @@ -838,6 +846,7 @@ bool KeyframeView::loadKeyframes(const QLocale locale, = QDomElement effect, int c m_keyframeType =3D NoKeyframe; duration =3D length; m_inTimeline.clear(); + m_notInTimeline.clear(); // reset existing properties int max =3D m_keyProperties.count(); for (int i =3D max -1; i >=3D 0; i--) { @@ -847,15 +856,16 @@ bool KeyframeView::loadKeyframes(const QLocale locale= , QDomElement effect, int c m_useOffset =3D effect.attribute(QStringLiteral("kdenlive:sync_in_out"= )) !=3D QLatin1String("1"); m_offset =3D effect.attribute(QStringLiteral("in")).toInt() - cropStar= t; QDomNodeList params =3D effect.elementsByTagName(QStringLiteral("param= eter")); + QStringList keyframeTypes; + keyframeTypes << QStringLiteral("keyframe") << QStringLiteral("simplek= eyframe") << QStringLiteral("geometry") << QStringLiteral("animatedrect") <= < QStringLiteral("animated"); for (int i =3D 0; i < params.count(); ++i) { QDomElement e =3D params.item(i).toElement(); - if (e.isNull()) continue; + if (e.isNull()) { + continue; + } QString type =3D e.attribute(QStringLiteral("type")); - if (type =3D=3D QLatin1String("keyframe")) m_keyframeType =3D Norm= alKeyframe; - else if (type =3D=3D QLatin1String("simplekeyframe")) m_keyframeTy= pe =3D SimpleKeyframe; - else if (type =3D=3D QLatin1String("geometry") || type =3D=3D QLat= in1String("animatedrect")) m_keyframeType =3D GeometryKeyframe; - else if (type =3D=3D QLatin1String("animated")) m_keyframeType =3D= AnimatedKeyframe; - else continue; + if (!keyframeTypes.contains(type)) + continue; QString paramName =3D e.attribute(QStringLiteral("name")); ParameterInfo info; info.factor =3D locale.toDouble(e.attribute(QStringLiteral("factor= "))); @@ -866,14 +876,23 @@ bool KeyframeView::loadKeyframes(const QLocale locale= , QDomElement effect, int c info.factor =3D 1; } m_paramInfos.insert(paramName, info); - if (!e.hasAttribute(QStringLiteral("intimeline")) || e.attribute(Q= StringLiteral("intimeline")) =3D=3D QLatin1String("1")) { - // Active parameter - m_keyframeMin =3D info.min; - m_keyframeMax =3D info.max; - m_keyframeDefault =3D locale.toDouble(info.defaultValue); - m_keyframeFactor =3D info.factor; - attachToEnd =3D checkNegatives(e.attribute("value").toUtf8().c= onstData(), duration - m_offset); - m_inTimeline =3D paramName; + if (e.hasAttribute(QStringLiteral("notintimeline"))) { + // This param should not be drawn in timeline + m_notInTimeline << paramName; + } else { + if (type =3D=3D QLatin1String("keyframe")) m_keyframeType =3D = NormalKeyframe; + else if (type =3D=3D QLatin1String("simplekeyframe")) m_keyfra= meType =3D SimpleKeyframe; + else if (type =3D=3D QLatin1String("geometry") || type =3D=3D = QLatin1String("animatedrect")) m_keyframeType =3D GeometryKeyframe; + else if (type =3D=3D QLatin1String("animated")) m_keyframeType= =3D AnimatedKeyframe; + if (!e.hasAttribute(QStringLiteral("intimeline")) || e.attribu= te(QStringLiteral("intimeline")) =3D=3D QLatin1String("1")) { + // Active parameter + m_keyframeMin =3D info.min; + m_keyframeMax =3D info.max; + m_keyframeDefault =3D locale.toDouble(info.defaultValue); + m_keyframeFactor =3D info.factor; + attachToEnd =3D checkNegatives(e.attribute("value").toUtf8= ().constData(), duration - m_offset); + m_inTimeline =3D paramName; + } } // parse keyframes QString value =3D e.attribute(QStringLiteral("value")); @@ -904,7 +923,7 @@ bool KeyframeView::loadKeyframes(const QLocale locale, = QDomElement effect, int c = void KeyframeView::setOffset(int frames) { - if (!m_keyAnim.is_valid()) + if (duration =3D=3D 0 || !m_keyAnim.is_valid()) return; if (m_keyAnim.is_key(-m_offset)) { mlt_keyframe_type type =3D m_keyAnim.keyframe_type(-m_offset); @@ -955,6 +974,8 @@ void KeyframeView::reset() duration =3D 0; attachToEnd =3D -2; activeKeyframe =3D -1; + m_inTimeline.clear(); + m_notInTimeline.clear(); int max =3D m_keyProperties.count(); for (int i =3D max -1; i >=3D 0; i--) { m_keyProperties.set(m_keyProperties.get_name(i), (char*) NULL); diff --git a/src/timeline/keyframeview.h b/src/timeline/keyframeview.h index 342b50f06..34b4e7212 100644 --- a/src/timeline/keyframeview.h +++ b/src/timeline/keyframeview.h @@ -120,6 +120,7 @@ private: int m_handleSize; bool m_useOffset; int m_offset; + QStringList m_notInTimeline; double keyframeUnmap(QRectF br, double y); double keyframeMap(QRectF br, double value); QPointF keyframeMap(QRectF br, int frame, double value);