]> git.sesse.net Git - kdenlive/blobdiff - src/effectstackedit.cpp
Fix monitor scene not showing up when switching between effects in effect stack
[kdenlive] / src / effectstackedit.cpp
index 2c20c8fd4e558388f91913f1bfea92d5823eb97e..621275c837b60fe961b217adf653f6094ae82241 100644 (file)
@@ -16,7 +16,6 @@
  ***************************************************************************/
 
 #include "effectstackedit.h"
-#include "ui_constval_ui.h"
 #include "ui_listval_ui.h"
 #include "ui_boolval_ui.h"
 #include "ui_wipeval_ui.h"
 #include "kis_cubic_curve.h"
 #include "choosecolorwidget.h"
 #include "geometrywidget.h"
+#include "colortools.h"
+#include "doubleparameterwidget.h"
 
 #include <KDebug>
 #include <KLocale>
 #include <KFileDialog>
 
 #include <QVBoxLayout>
-#include <QSlider>
 #include <QLabel>
 #include <QPushButton>
 #include <QCheckBox>
@@ -49,10 +49,6 @@ class Boolval: public QWidget, public Ui::Boolval_UI
 {
 };
 
-class Constval: public QWidget, public Ui::Constval_UI
-{
-};
-
 class Listval: public QWidget, public Ui::Listval_UI
 {
 };
@@ -117,6 +113,7 @@ void EffectStackEdit::updateTimecodeFormat()
 {
     if (m_keyframeEditor)
         m_keyframeEditor->updateTimecodeFormat();
+
     QDomNodeList namenode = m_params.elementsByTagName("parameter");
     for (int i = 0; i < namenode.count() ; i++) {
         QDomNode pa = namenode.item(i);
@@ -142,6 +139,17 @@ void EffectStackEdit::updateTimecodeFormat()
     }
 }
 
+void EffectStackEdit::meetDependency(const QString& name, QString type, QString value)
+{
+    if (type == "curve") {
+        KisCurveWidget *curve = (KisCurveWidget*)m_valueItems[name];
+        if (curve) {
+            int color = value.toInt();
+            curve->setPixmap(QPixmap::fromImage(ColorTools::rgbCurvePlane(curve->size(), (ColorTools::ColorsRGB)color)));
+        }
+    }
+}
+
 void EffectStackEdit::updateProjectFormat(MltVideoProfile profile, Timecode t)
 {
     m_profile = profile;
@@ -166,10 +174,6 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, in
         return;
     }
 
-    /*QDomDocument doc;
-    doc.appendChild(doc.importNode(m_params, true));
-    kDebug() << "IMPORTED TRANS: " << doc.toString();*/
-
     QDomNodeList namenode = m_params.elementsByTagName("parameter");
     QDomElement e = m_params.toElement();
     const int minFrame = e.attribute("start").toInt();
@@ -209,9 +213,12 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, in
                 max = (int) ProfilesDialog::getStringEval(m_profile, pa.attribute("max"));
             else
                 max = pa.attribute("max").toInt();
-            createSliderItem(paramName, (int)(value.toDouble() + 0.5) , min, max, pa.attribute("suffix", QString()));
-            delete toFillin;
-            toFillin = NULL;
+
+            DoubleParameterWidget *doubleparam = new DoubleParameterWidget(paramName, (int)(value.toDouble() + 0.5), min, max,
+                                                                           pa.attribute("default").toInt(), pa.attribute("suffix"), this);
+            m_vbox->addWidget(doubleparam);
+            m_valueItems[paramName] = doubleparam;
+            connect(doubleparam, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
         } else if (type == "list") {
             Listval *lsval = new Listval;
             lsval->setupUi(toFillin);
@@ -245,19 +252,6 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, in
             connect(bval->checkBox, SIGNAL(stateChanged(int)) , this, SLOT(collectAllParameters()));
             m_uiItems.append(bval);
         } else if (type == "complex") {
-            /*QStringList names=nodeAtts.namedItem("name").nodeValue().split(';');
-            QStringList max=nodeAtts.namedItem("max").nodeValue().split(';');
-            QStringList min=nodeAtts.namedItem("min").nodeValue().split(';');
-            QStringList val=value.split(';');
-            kDebug() << "in complex"<<names.size() << " " << max.size() << " " << min.size() << " " << val.size()  ;
-            if ( (names.size() == max.size() ) &&
-                 (names.size()== min.size()) &&
-                 (names.size()== val.size()) )
-            {
-             for (int i=0;i< names.size();i++){
-              createSliderItem(names[i],val[i].toInt(),min[i].toInt(),max[i].toInt());
-             };
-            }*/
             ComplexParameter *pl = new ComplexParameter;
             pl->setupParam(d, pa.attribute("name"), 0, 100);
             m_vbox->addWidget(pl);
@@ -266,6 +260,8 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, in
         } else if (type == "geometry") {
             if (KdenliveSettings::on_monitor_effects()) {
                 GeometryWidget *geometry = new GeometryWidget(m_monitor, m_timecode, pos, isEffect, this);
+                // connect this before setupParam to make sure the monitor scene shows up at startup
+                connect(geometry, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
                 if (minFrame == maxFrame)
                     geometry->setupParam(pa, m_in, m_out);
                 else
@@ -273,7 +269,6 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, in
                 m_vbox->addWidget(geometry);
                 m_valueItems[paramName+"geometry"] = geometry;
                 connect(geometry, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
-                connect(geometry, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
                 connect(geometry, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
                 connect(this, SIGNAL(syncEffectsPos(int)), geometry, SLOT(slotSyncPosition(int)));
             } else {
@@ -348,8 +343,13 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, in
             m_vbox->addWidget(curve);
             m_vbox->addWidget(spinin);
             m_vbox->addWidget(spinout);
+
             connect(curve, SIGNAL(modified()), this, SLOT(collectAllParameters()));
             m_valueItems[paramName] = curve;
+
+            QString depends = pa.attribute("depends");
+            if (!depends.isEmpty())
+                meetDependency(paramName, type, EffectsList::parameter(e, depends));
         } else if (type == "wipe") {
             Wipeval *wpval = new Wipeval;
             wpval->setupUi(toFillin);
@@ -539,8 +539,8 @@ void EffectStackEdit::collectAllParameters()
 
         QString setValue;
         if (type == "double" || type == "constant") {
-            QSlider* slider = ((Constval*)m_valueItems.value(paramName))->horizontalSlider;
-            setValue = QString::number(slider->value());
+            DoubleParameterWidget *doubleparam = (DoubleParameterWidget*)m_valueItems.value(paramName);
+            setValue = QString::number(doubleparam->getValue());
         } else if (type == "list") {
             KComboBox *box = ((Listval*)m_valueItems.value(paramName))->list;
             setValue = box->itemData(box->currentIndex()).toString();
@@ -601,6 +601,9 @@ void EffectStackEdit::collectAllParameters()
                 EffectsList::setParameter(newparam, in, QString::number(points.at(j).x()));
                 EffectsList::setParameter(newparam, out, QString::number(points.at(j).y()));
             }
+            QString depends = pa.attributes().namedItem("depends").nodeValue();
+            if (!depends.isEmpty())
+                meetDependency(paramName, type, EffectsList::parameter(newparam, depends));
         } else if (type == "wipe") {
             Wipeval *wp = (Wipeval*)m_valueItems.value(paramName);
             wipeInfo info;
@@ -650,30 +653,6 @@ void EffectStackEdit::collectAllParameters()
     emit parameterChanged(oldparam, newparam);
 }
 
-void EffectStackEdit::createSliderItem(const QString& name, int val , int min, int max, const QString suffix)
-{
-    QWidget* toFillin = new QWidget(m_baseWidget);
-    Constval *ctval = new Constval;
-    ctval->setupUi(toFillin);
-    ctval->horizontalSlider->setMinimum(min);
-    ctval->horizontalSlider->setMaximum(max);
-    if (!suffix.isEmpty()) ctval->spinBox->setSuffix(suffix);
-    ctval->spinBox->setMinimum(min);
-    ctval->spinBox->setMaximum(max);
-    ctval->horizontalSlider->setPageStep((int)(max - min) / 10);
-    ctval->horizontalSlider->setValue(val);
-    ctval->label->setText(name);
-    m_valueItems[name] = ctval;
-    m_uiItems.append(ctval);
-    connect(ctval->horizontalSlider, SIGNAL(valueChanged(int)) , this, SLOT(collectAllParameters()));
-    m_vbox->addWidget(toFillin);
-}
-
-void EffectStackEdit::slotSliderMoved(int)
-{
-    collectAllParameters();
-}
-
 void EffectStackEdit::clearAllItems()
 {
     blockSignals(true);