]> git.sesse.net Git - kdenlive/blobdiff - src/effectstack/parametercontainer.cpp
Improve update of effect stack when resizing clip, start implementing merge of analys...
[kdenlive] / src / effectstack / parametercontainer.cpp
index 0fd2da73b03125dcf948d5f96cdb0e36050886e2..97b2fcf71fb0eb64621edb9d827e56696a9f711b 100644 (file)
@@ -43,6 +43,7 @@
 #include "projectlist.h"
 #include "mainwindow.h"
 #include "parametercontainer.h"
+#include "../customtrackview.h"
 
 #include <KUrlRequester>
 #include <KFileDialog>
@@ -163,7 +164,7 @@ ParameterContainer::ParameterContainer(QDomElement effect, ItemInfo info, Effect
             QStringList listitems = pa.attribute("paramlist").split(';');
             if (listitems.count() == 1) {
                 // probably custom effect created before change to ';' as separator
-                listitems = pa.attribute("paramlist").split(",");
+                listitems = pa.attribute("paramlist").split(',');
             }
             QDomElement list = pa.firstChildElement("paramlistdisplay");
             QStringList listitemsdisplay;
@@ -219,18 +220,23 @@ ParameterContainer::ParameterContainer(QDomElement effect, ItemInfo info, Effect
                 m_geometryWidget = new GeometryWidget(m_metaInfo->monitor, m_metaInfo->timecode, 0, true, effect.hasAttribute("showrotation"), parent);
                 m_geometryWidget->setFrameSize(m_metaInfo->frameSize);
                 connect(m_geometryWidget, SIGNAL(parameterChanged()), this, SLOT(slotCollectAllParameters()));
-                if (minFrame == maxFrame)
+                if (minFrame == maxFrame) {
                     m_geometryWidget->setupParam(pa, m_in, m_out);
+                   connect(this, SIGNAL(updateRange(int,int)), m_geometryWidget, SLOT(slotUpdateRange(int,int)));
+               }
                 else
                     m_geometryWidget->setupParam(pa, minFrame, maxFrame);
                 m_vbox->addWidget(m_geometryWidget);
                 m_valueItems[paramName+"geometry"] = m_geometryWidget;
                 connect(m_geometryWidget, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
+               connect(m_geometryWidget, SIGNAL(importClipKeyframes()), this, SIGNAL(importClipKeyframes()));
                 connect(this, SIGNAL(syncEffectsPos(int)), m_geometryWidget, SLOT(slotSyncPosition(int)));
             } else {
                 Geometryval *geo = new Geometryval(m_metaInfo->profile, m_metaInfo->timecode, m_metaInfo->frameSize, 0);
-                if (minFrame == maxFrame)
+                if (minFrame == maxFrame) {
                     geo->setupParam(pa, m_in, m_out);
+                   connect(this, SIGNAL(updateRange(int,int)), geo, SLOT(slotUpdateRange(int,int)));
+               }
                 else
                     geo->setupParam(pa, minFrame, maxFrame);
                 m_vbox->addWidget(geo);
@@ -249,11 +255,13 @@ ParameterContainer::ParameterContainer(QDomElement effect, ItemInfo info, Effect
                 if (pa.attribute("widget") == "corners") {
                     // we want a corners-keyframe-widget
                     CornersWidget *corners = new CornersWidget(m_metaInfo->monitor, pa, m_in, m_out, m_metaInfo->timecode, e.attribute("active_keyframe", "-1").toInt(), parent);
+                   connect(this, SIGNAL(updateRange(int,int)), corners, SLOT(slotUpdateRange(int,int)));
                    m_needsMonitorEffectScene = true;
                     connect(this, SIGNAL(syncEffectsPos(int)), corners, SLOT(slotSyncPosition(int)));
                     geo = static_cast<KeyframeEdit *>(corners);
                 } else {
                     geo = new KeyframeEdit(pa, m_in, m_out, m_metaInfo->timecode, e.attribute("active_keyframe", "-1").toInt());
+                   connect(this, SIGNAL(updateRange(int,int)), geo, SLOT(slotUpdateRange(int,int)));
                 }
                 m_vbox->addWidget(geo);
                 m_valueItems[paramName+"keyframe"] = geo;
@@ -269,12 +277,12 @@ ParameterContainer::ParameterContainer(QDomElement effect, ItemInfo info, Effect
            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);
+            ChooseColorWidget *choosecolor = new ChooseColorWidget(paramName, value, pa.hasAttribute("alpha"), parent);
             m_vbox->addWidget(choosecolor);
             m_valueItems[paramName] = choosecolor;
             connect(choosecolor, SIGNAL(displayMessage(const QString&, int)), this, SIGNAL(displayMessage(const QString&, int)));
             connect(choosecolor, SIGNAL(modified()) , this, SLOT(slotCollectAllParameters()));
+           connect(choosecolor, SIGNAL(disableCurrentFilter(bool)) , this, SIGNAL(disableCurrentFilter(bool)));
         } else if (type == "position") {
             int pos = value.toInt();
             if (effect.attribute("id") == "fadein" || effect.attribute("id") == "fade_from_black") {
@@ -284,6 +292,7 @@ ParameterContainer::ParameterContainer(QDomElement effect, ItemInfo info, Effect
                 pos = m_out - pos;
             }
             PositionEdit *posedit = new PositionEdit(paramName, pos, 0, m_out - m_in, m_metaInfo->timecode);
+           connect(this, SIGNAL(updateRange(int,int)), posedit, SLOT(setRange(int,int)));
             m_vbox->addWidget(posedit);
             m_valueItems[paramName+"position"] = posedit;
             connect(posedit, SIGNAL(parameterChanged()), this, SLOT(slotCollectAllParameters()));
@@ -807,8 +816,31 @@ void ParameterContainer::slotStartFilterJobAction()
         QDomElement pa = namenode.item(i).toElement();
         QString type = pa.attribute("type");
         if (type == "filterjob") {
-            emit startFilterJob(pa.attribute("filtertag"), pa.attribute("filterparams"), pa.attribute("finalfilter"), pa.attribute("consumer"), pa.attribute("consumerparams"), pa.attribute("wantedproperties"));
-            kDebug()<<" - - -PROPS:\n"<<pa.attribute("filtertag")<<"-"<< pa.attribute("filterparams")<<"-"<< pa.attribute("consumer")<<"-"<< pa.attribute("consumerparams")<<"-"<< pa.attribute("wantedproperties");
+           kDebug()<<"// FILTER POSE: "<<m_geometryWidget->currentPosition();
+           QString filterparams = pa.attribute("filterparams");
+           if (filterparams.contains("%position")) {
+               if (m_geometryWidget) filterparams.replace("%position", QString::number(m_geometryWidget->currentPosition()));
+           }
+           if (filterparams.contains("%params")) {
+               // Replace with current geometry
+               EffectsParameterList parameters;
+               QDomNodeList params = m_effect.elementsByTagName("parameter");
+               CustomTrackView::adjustEffectParameters(parameters, params, m_metaInfo->profile);
+               QString paramData;
+               for (int j = 0; j < parameters.count(); j++)
+                   paramData.append(parameters.at(j).name()+"="+parameters.at(j).value()+" ");
+               filterparams.replace("%params", paramData);
+           }
+           QMap <QString, QString> extraParams;
+           QDomNodeList jobparams = pa.elementsByTagName("jobparam");
+           for (int j = 0; j < jobparams.count(); j++) {
+                QDomElement e = jobparams.item(j).toElement();
+               extraParams.insert(e.attribute("name"), e.text().toUtf8());
+           }
+           kDebug()<<"+++++++++++++++++   CLIP IN: "<<m_in;
+           extraParams.insert("offset", QString::number(m_in));
+            emit startFilterJob(pa.attribute("filtertag"), filterparams, pa.attribute("consumer"), pa.attribute("consumerparams"), extraParams);
+            kDebug()<<" - - -PROPS:\n"<<pa.attribute("filtertag")<<"-"<< filterparams<<"-"<< pa.attribute("consumer")<<"-"<< pa.attribute("consumerparams")<<"-"<< pa.attribute("extraparams");
             break;
         }
     }
@@ -834,3 +866,22 @@ bool ParameterContainer::needsMonitorEffectScene() const
 {
     return m_needsMonitorEffectScene;
 }
+
+void ParameterContainer::setKeyframes(const QString &data, int maximum)
+{
+    if (!m_geometryWidget) {
+       kDebug()<<" / / NO GEOMETRY WIDGET FOUND FOR IMPORTING DATA";
+       return;
+    }
+    m_geometryWidget->importKeyframes(data, maximum);
+    
+}
+
+void ParameterContainer::setRange(int inPoint, int outPoint)
+{
+    m_in = inPoint;
+    m_out = outPoint;
+    emit updateRange(m_in, m_out);
+}
+
+