]> git.sesse.net Git - kdenlive/commitdiff
Add background property to rotate filter so that
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 8 Apr 2012 00:41:28 +0000 (02:41 +0200)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 8 Apr 2012 00:41:28 +0000 (02:41 +0200)
we can have transparent background or user chosen color

effects/rotation.xml
effects/rotation_keyframable.xml
src/choosecolorwidget.cpp
src/effectstack/collapsibleeffect.cpp
src/renderer.cpp

index 99e35ed5be1f31de2d33ea19d2f69ebf034352db..0130102b6665ae23c53d6d5f0e166c83415c642f 100644 (file)
@@ -36,4 +36,7 @@
        <parameter type="geometry" name="transition.geometry" default="0%,0%:100%x100%" fixed="1" opacity="false">
                <name>Pan and Zoom</name>
        </parameter>
+       <parameter type="color" name="background" default="colour:0x00000000" paramprefix="colour:">
+               <name>Background Color</name>
+       </parameter>
 </effect>
index b07d61d15e4190bd8f296a935c3c29d75c0b23ec..d78b14f9f45ffd23d81ee06785b15a98273e02ed 100644 (file)
@@ -18,6 +18,9 @@
         <parameter type="simplekeyframe" name="transition.oy" max="32000" min="-32000" default="0">
                 <name>Offset Y</name>
         </parameter>
+       <parameter type="color" name="background" default="colour:0x00000000" paramprefix="colour:">
+               <name>Background Color</name>
+       </parameter>
         <parameter type="fixed" name="transition.keyed" max="1" min="1" default="1" />
        <parameter type="fixed" name="transition.always_active" max="1" min="1" default="1" />
 </effect>
index 86138195450f47ea95432f8e63519780e71dd82e..26c18743e649ab9455c58669647ca5da7a496738 100644 (file)
@@ -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;
 }
 
index 523afe10010b2646b03f7fcb91c8533d53426750..9f2af1f582e54db74ca74846cd2d5ec3f599d552 100644 (file)
@@ -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<QPointF> 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());
index 9f7da6d539105fdc963db274f691c05103944fba..14927a75045a807cd64cefc97748a809aae9087e 100644 (file)
@@ -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;