From 6b455ec7f0b45327eea2fd0bc8b5dab83821e0bf Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Sun, 8 Apr 2012 02:41:28 +0200 Subject: [PATCH] Add background property to rotate filter so that we can have transparent background or user chosen color --- effects/rotation.xml | 3 +++ effects/rotation_keyframable.xml | 3 +++ src/choosecolorwidget.cpp | 10 ++++---- src/effectstack/collapsibleeffect.cpp | 34 ++++++++++++++------------- src/renderer.cpp | 2 +- 5 files changed, 31 insertions(+), 21 deletions(-) diff --git a/effects/rotation.xml b/effects/rotation.xml index 99e35ed5..0130102b 100644 --- a/effects/rotation.xml +++ b/effects/rotation.xml @@ -36,4 +36,7 @@ Pan and Zoom + + Background Color + diff --git a/effects/rotation_keyframable.xml b/effects/rotation_keyframable.xml index b07d61d1..d78b14f9 100644 --- a/effects/rotation_keyframable.xml +++ b/effects/rotation_keyframable.xml @@ -18,6 +18,9 @@ Offset Y + + Background Color + diff --git a/src/choosecolorwidget.cpp b/src/choosecolorwidget.cpp index 86138195..26c18743 100644 --- a/src/choosecolorwidget.cpp +++ b/src/choosecolorwidget.cpp @@ -33,7 +33,6 @@ static QColor stringToColor(QString strColor) bool ok = false; QColor color("black"); int intval = 0; - if (strColor.startsWith("0x")) { if (strColor.length() == 10) { // 0xRRGGBBAA @@ -55,6 +54,10 @@ static QColor stringToColor(QString strColor) ( intval >> 8 ) & 0xff, // g ( intval ) & 0xff, // b ( intval >> 24 ) & 0xff ); // a + } else if (strColor.length() == 8) { + // 0xRRGGBB + strColor = strColor.replace('#', "0x"); + color.setNamedColor(strColor); } else { // #RRGGBB, #RGB color.setNamedColor(strColor); @@ -68,17 +71,16 @@ static QString colorToString(QColor color, bool alpha) { QString colorStr; QTextStream stream(&colorStr); - stream << "#"; + stream << "0x"; stream.setIntegerBase(16); stream.setFieldWidth(2); stream.setFieldAlignment(QTextStream::AlignRight); stream.setPadChar('0'); + stream << color.red() << color.green() << color.blue(); if(alpha) { stream << color.alpha(); } - stream << color.red() << color.green() << color.blue(); - return colorStr; } diff --git a/src/effectstack/collapsibleeffect.cpp b/src/effectstack/collapsibleeffect.cpp index 523afe10..9f2af1f5 100644 --- a/src/effectstack/collapsibleeffect.cpp +++ b/src/effectstack/collapsibleeffect.cpp @@ -769,9 +769,11 @@ ParameterContainer::ParameterContainer(QDomElement effect, ItemInfo info, Effect m_keyframeEditor->addParameter(pa); } } else if (type == "color") { + if (pa.hasAttribute("paramprefix")) value.remove(0, pa.attribute("paramprefix").size()); if (value.startsWith('#')) value = value.replace('#', "0x"); ChooseColorWidget *choosecolor = new ChooseColorWidget(paramName, value, parent); + choosecolor->setAlphaChannelEnabled(true); m_vbox->addWidget(choosecolor); m_valueItems[paramName] = choosecolor; connect(choosecolor, SIGNAL(displayMessage(const QString&, int)), this, SIGNAL(displayMessage(const QString&, int))); @@ -1086,10 +1088,10 @@ void ParameterContainer::slotCollectAllParameters() QDomNodeList namenode = m_effect.elementsByTagName("parameter"); for (int i = 0; i < namenode.count() ; i++) { - QDomNode pa = namenode.item(i); + QDomElement pa = namenode.item(i).toElement(); QDomElement na = pa.firstChildElement("name"); - QString type = pa.attributes().namedItem("type").nodeValue(); - QString paramName = na.isNull() ? pa.attributes().namedItem("name").nodeValue() : i18n(na.text().toUtf8().data()); + QString type = pa.attribute("type"); + QString paramName = na.isNull() ? pa.attribute("name") : i18n(na.text().toUtf8().data()); if (type == "complex") paramName.append("complex"); else if (type == "position") @@ -1116,6 +1118,7 @@ void ParameterContainer::slotCollectAllParameters() } else if (type == "color") { ChooseColorWidget *choosecolor = ((ChooseColorWidget*)m_valueItems.value(paramName)); setValue = choosecolor->getColor(); + if (pa.hasAttribute("paramprefix")) setValue.prepend(pa.attribute("paramprefix")); } else if (type == "complex") { ComplexParameter *complex = ((ComplexParameter*)m_valueItems.value(paramName)); namenode.item(i) = complex->getParamDesc(); @@ -1154,11 +1157,11 @@ void ParameterContainer::slotCollectAllParameters() } else if (type == "curve") { KisCurveWidget *curve = ((KisCurveWidget*)m_valueItems.value(paramName)); QList points = curve->curve().points(); - QString number = pa.attributes().namedItem("number").nodeValue(); - QString inName = pa.attributes().namedItem("inpoints").nodeValue(); - QString outName = pa.attributes().namedItem("outpoints").nodeValue(); - int off = pa.attributes().namedItem("min").nodeValue().toInt(); - int end = pa.attributes().namedItem("max").nodeValue().toInt(); + QString number = pa.attribute("number"); + QString inName = pa.attribute("inpoints"); + QString outName = pa.attribute("outpoints"); + int off = pa.attribute("min").toInt(); + int end = pa.attribute("max").toInt(); if (oldparam.attribute("version").toDouble() > 0.2) { EffectsList::setParameter(m_effect, number, locale.toString(points.count() / 10.)); } else { @@ -1172,13 +1175,13 @@ void ParameterContainer::slotCollectAllParameters() EffectsList::setParameter(m_effect, in, locale.toString(points.at(j).x())); EffectsList::setParameter(m_effect, out, locale.toString(points.at(j).y())); } - QString depends = pa.attributes().namedItem("depends").nodeValue(); + QString depends = pa.attribute("depends"); if (!depends.isEmpty()) meetDependency(paramName, type, EffectsList::parameter(m_effect, depends)); } else if (type == "bezier_spline") { BezierSplineWidget *widget = (BezierSplineWidget*)m_valueItems.value(paramName); setValue = widget->spline(); - QString depends = pa.attributes().namedItem("depends").nodeValue(); + QString depends = pa.attribute("depends"); if (!depends.isEmpty()) meetDependency(paramName, type, EffectsList::parameter(m_effect, depends)); #ifdef USE_QJSON @@ -1219,16 +1222,15 @@ void ParameterContainer::slotCollectAllParameters() setValue = getWipeString(info); } else if ((type == "simplekeyframe" || type == "keyframe") && m_keyframeEditor) { - QDomElement elem = pa.toElement(); QString realName = i18n(na.toElement().text().toUtf8().data()); QString val = m_keyframeEditor->getValue(realName); - elem.setAttribute("keyframes", val); + pa.setAttribute("keyframes", val); if (m_keyframeEditor->isVisibleParam(realName)) { - elem.setAttribute("intimeline", "1"); + pa.setAttribute("intimeline", "1"); } - else if (elem.hasAttribute("intimeline")) - elem.removeAttribute("intimeline"); + else if (pa.hasAttribute("intimeline")) + pa.removeAttribute("intimeline"); } else if (type == "url") { KUrlRequester *req = ((Urlval*)m_valueItems.value(paramName))->urlwidget; setValue = req->url().path(); @@ -1247,7 +1249,7 @@ void ParameterContainer::slotCollectAllParameters() setValue = fontfamily->currentFont().family(); } if (!setValue.isNull()) - pa.attributes().namedItem("value").setNodeValue(setValue); + pa.setAttribute("value", setValue); } emit parameterChanged(oldparam, m_effect, m_effect.attribute("kdenlive_ix").toInt()); diff --git a/src/renderer.cpp b/src/renderer.cpp index 9f7da6d5..14927a75 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -2755,7 +2755,7 @@ bool Render::mltEditEffect(int track, GenTime position, EffectsParameterList par int index = params.paramValue("kdenlive_ix").toInt(); QString tag = params.paramValue("tag"); - if (!params.paramValue("keyframes").isEmpty() || /*it.key().startsWith("#") || */tag.startsWith("ladspa") || tag == "sox" || tag == "autotrack_rectangle" || params.hasParam("region")) { + if (!params.paramValue("keyframes").isEmpty() || (tag == "affine" && params.hasParam("background")) || tag.startsWith("ladspa") || tag == "sox" || tag == "autotrack_rectangle" || params.hasParam("region")) { // This is a keyframe effect, to edit it, we remove it and re-add it. bool success = mltRemoveEffect(track, position, index, false); // if (!success) kDebug() << "// ERROR Removing effect : " << index; -- 2.39.2