]> git.sesse.net Git - kdenlive/blob - src/effectstackedit.cpp
Use RGB plane as Curve Widget background:
[kdenlive] / src / effectstackedit.cpp
1 /***************************************************************************
2                           effecstackview.cpp  -  description
3                              -------------------
4     begin                : Feb 15 2008
5     copyright            : (C) 2008 by Marco Gittler
6     email                : g.marco@freenet.de
7  ***************************************************************************/
8
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17
18 #include "effectstackedit.h"
19 #include "ui_constval_ui.h"
20 #include "ui_listval_ui.h"
21 #include "ui_boolval_ui.h"
22 #include "ui_wipeval_ui.h"
23 #include "ui_urlval_ui.h"
24 #include "complexparameter.h"
25 #include "geometryval.h"
26 #include "positionedit.h"
27 #include "projectlist.h"
28 #include "effectslist.h"
29 #include "kdenlivesettings.h"
30 #include "profilesdialog.h"
31 #include "kis_curve_widget.h"
32 #include "kis_cubic_curve.h"
33 #include "choosecolorwidget.h"
34 #include "geometrywidget.h"
35 #include "colortools.h"
36
37 #include <KDebug>
38 #include <KLocale>
39 #include <KFileDialog>
40
41 #include <QVBoxLayout>
42 #include <QSlider>
43 #include <QLabel>
44 #include <QPushButton>
45 #include <QCheckBox>
46 #include <QScrollArea>
47
48
49 class Boolval: public QWidget, public Ui::Boolval_UI
50 {
51 };
52
53 class Constval: public QWidget, public Ui::Constval_UI
54 {
55 };
56
57 class Listval: public QWidget, public Ui::Listval_UI
58 {
59 };
60
61 class Wipeval: public QWidget, public Ui::Wipeval_UI
62 {
63 };
64
65 class Urlval: public QWidget, public Ui::Urlval_UI
66 {
67 };
68
69 QMap<QString, QImage> EffectStackEdit::iconCache;
70
71 EffectStackEdit::EffectStackEdit(Monitor *monitor, QWidget *parent) :
72         QScrollArea(parent),
73         m_in(0),
74         m_out(0),
75         m_frameSize(QPoint()),
76         m_keyframeEditor(NULL),
77         m_monitor(monitor)
78 {
79     m_baseWidget = new QWidget(this);
80     setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
81     setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
82     setFrameStyle(QFrame::NoFrame);
83     setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding));
84
85     setWidget(m_baseWidget);
86     setWidgetResizable(true);
87     m_vbox = new QVBoxLayout(m_baseWidget);
88     m_vbox->setContentsMargins(0, 0, 0, 0);
89     m_vbox->setSpacing(0);
90     //wid->show();
91 }
92
93 EffectStackEdit::~EffectStackEdit()
94 {
95     iconCache.clear();
96     delete m_baseWidget;
97 }
98
99 void EffectStackEdit::setFrameSize(QPoint p)
100 {
101     m_frameSize = p;
102     QDomNodeList namenode = m_params.elementsByTagName("parameter");
103     for (int i = 0; i < namenode.count() ; i++) {
104         QDomNode pa = namenode.item(i);
105         QDomNode na = pa.firstChildElement("name");
106         QString type = pa.attributes().namedItem("type").nodeValue();
107         QString paramName = i18n(na.toElement().text().toUtf8().data());
108
109         if (type == "geometry" && !KdenliveSettings::on_monitor_effects()) {
110             Geometryval *geom = ((Geometryval*)m_valueItems[paramName+"geometry"]);
111             geom->setFrameSize(m_frameSize);
112             break;
113         }
114     }
115 }
116
117 void EffectStackEdit::updateTimecodeFormat()
118 {
119     if (m_keyframeEditor)
120         m_keyframeEditor->updateTimecodeFormat();
121     QDomNodeList namenode = m_params.elementsByTagName("parameter");
122     for (int i = 0; i < namenode.count() ; i++) {
123         QDomNode pa = namenode.item(i);
124         QDomNode na = pa.firstChildElement("name");
125         QString type = pa.attributes().namedItem("type").nodeValue();
126         QString paramName = i18n(na.toElement().text().toUtf8().data());
127
128         if (type == "geometry") {
129             if (KdenliveSettings::on_monitor_effects()) {
130                 GeometryWidget *geom = (GeometryWidget*)m_valueItems[paramName+"geometry"];
131                 geom->updateTimecodeFormat();
132             } else {
133                 Geometryval *geom = ((Geometryval*)m_valueItems[paramName+"geometry"]);
134                 geom->updateTimecodeFormat();
135             }
136             break;
137         }
138         if (type == "position") {
139             PositionEdit *posi = ((PositionEdit*)m_valueItems[paramName+"position"]);
140             posi->updateTimecodeFormat();
141             break;
142         }
143     }
144 }
145
146 void EffectStackEdit::meetDependency(const QString& name, QString type, QString value)
147 {
148     if (type == "curve") {
149         KisCurveWidget *curve = (KisCurveWidget*)m_valueItems[name];
150         if (curve) {
151             int color = value.toInt();
152             if (color < 3)
153                 curve->setPixmap(QPixmap::fromImage(ColorTools::rgbCurvePlane(curve->size(), (ColorTools::ColorsRGB)color)));
154             else
155                 curve->setPixmap(QPixmap());
156         }
157     }
158 }
159
160 void EffectStackEdit::updateProjectFormat(MltVideoProfile profile, Timecode t)
161 {
162     m_profile = profile;
163     m_timecode = t;
164 }
165
166 void EffectStackEdit::updateParameter(const QString &name, const QString &value)
167 {
168     m_params.setAttribute(name, value);
169 }
170
171 void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, int out, bool isEffect)
172 {
173     clearAllItems();
174     if (m_keyframeEditor) delete m_keyframeEditor;
175     m_keyframeEditor = NULL;
176     m_params = d;
177     m_in = in;
178     m_out = out;
179     if (m_params.isNull()) {
180         kDebug() << "// EMPTY EFFECT STACK";
181         return;
182     }
183
184     /*QDomDocument doc;
185     doc.appendChild(doc.importNode(m_params, true));
186     kDebug() << "IMPORTED TRANS: " << doc.toString();*/
187
188     QDomNodeList namenode = m_params.elementsByTagName("parameter");
189     QDomElement e = m_params.toElement();
190     const int minFrame = e.attribute("start").toInt();
191     const int maxFrame = e.attribute("end").toInt();
192
193
194     for (int i = 0; i < namenode.count() ; i++) {
195         QDomElement pa = namenode.item(i).toElement();
196         QDomNode na = pa.firstChildElement("name");
197         QString type = pa.attribute("type");
198         QString paramName = i18n(na.toElement().text().toUtf8().data());
199         QWidget * toFillin = new QWidget(m_baseWidget);
200         QString value = pa.attribute("value").isNull() ?
201                         pa.attribute("default") : pa.attribute("value");
202
203         /** Currently supported parameter types are:
204             * constant (=double): a slider with an integer value (use the "factor" attribute to divide the value so that you can get a double
205             * list: a combobox containing a list of values to choose
206             * bool: a checkbox
207             * complex: designed for keyframe parameters, but old and not finished, do not use
208             * geometry: a rectangle that can be moved & resized, with possible keyframes, used in composite transition
209             * keyframe: a list widget with a list of entries (position and value)
210             * color: a color chooser button
211             * position: a slider representing the position of a frame in the current clip
212             * curve: a single curve representing multiple points
213             * wipe: a widget designed for the wipe transition, allowing to choose a position (left, right, top,...)
214         */
215
216         if (type == "double" || type == "constant") {
217             int min;
218             int max;
219             if (pa.attribute("min").startsWith('%'))
220                 min = (int) ProfilesDialog::getStringEval(m_profile, pa.attribute("min"));
221             else
222                 min = pa.attribute("min").toInt();
223             if (pa.attribute("max").startsWith('%'))
224                 max = (int) ProfilesDialog::getStringEval(m_profile, pa.attribute("max"));
225             else
226                 max = pa.attribute("max").toInt();
227             createSliderItem(paramName, (int)(value.toDouble() + 0.5) , min, max, pa.attribute("suffix", QString()));
228             delete toFillin;
229             toFillin = NULL;
230         } else if (type == "list") {
231             Listval *lsval = new Listval;
232             lsval->setupUi(toFillin);
233             QStringList listitems = pa.attribute("paramlist").split(',');
234             QStringList listitemsdisplay = pa.attribute("paramlistdisplay").split(',');
235             if (listitemsdisplay.count() != listitems.count()) listitemsdisplay = listitems;
236             //lsval->list->addItems(listitems);
237             lsval->list->setIconSize(QSize(30, 30));
238             for (int i = 0; i < listitems.count(); i++) {
239                 lsval->list->addItem(listitemsdisplay.at(i), listitems.at(i));
240                 QString entry = listitems.at(i);
241                 if (!entry.isEmpty() && (entry.endsWith(".png") || entry.endsWith(".pgm"))) {
242                     if (!EffectStackEdit::iconCache.contains(entry)) {
243                         QImage pix(entry);
244                         EffectStackEdit::iconCache[entry] = pix.scaled(30, 30);
245                     }
246                     lsval->list->setItemIcon(i, QPixmap::fromImage(iconCache[entry]));
247                 }
248             }
249             if (!value.isEmpty()) lsval->list->setCurrentIndex(listitems.indexOf(value));
250             lsval->title->setTitle(paramName);
251             m_valueItems[paramName] = lsval;
252             connect(lsval->list, SIGNAL(currentIndexChanged(int)) , this, SLOT(collectAllParameters()));
253             m_uiItems.append(lsval);
254         } else if (type == "bool") {
255             Boolval *bval = new Boolval;
256             bval->setupUi(toFillin);
257             bval->checkBox->setCheckState(value == "0" ? Qt::Unchecked : Qt::Checked);
258             bval->checkBox->setText(paramName);
259             m_valueItems[paramName] = bval;
260             connect(bval->checkBox, SIGNAL(stateChanged(int)) , this, SLOT(collectAllParameters()));
261             m_uiItems.append(bval);
262         } else if (type == "complex") {
263             /*QStringList names=nodeAtts.namedItem("name").nodeValue().split(';');
264             QStringList max=nodeAtts.namedItem("max").nodeValue().split(';');
265             QStringList min=nodeAtts.namedItem("min").nodeValue().split(';');
266             QStringList val=value.split(';');
267             kDebug() << "in complex"<<names.size() << " " << max.size() << " " << min.size() << " " << val.size()  ;
268             if ( (names.size() == max.size() ) &&
269                  (names.size()== min.size()) &&
270                  (names.size()== val.size()) )
271             {
272              for (int i=0;i< names.size();i++){
273               createSliderItem(names[i],val[i].toInt(),min[i].toInt(),max[i].toInt());
274              };
275             }*/
276             ComplexParameter *pl = new ComplexParameter;
277             pl->setupParam(d, pa.attribute("name"), 0, 100);
278             m_vbox->addWidget(pl);
279             m_valueItems[paramName+"complex"] = pl;
280             connect(pl, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
281         } else if (type == "geometry") {
282             if (KdenliveSettings::on_monitor_effects()) {
283                 GeometryWidget *geometry = new GeometryWidget(m_monitor, m_timecode, pos, isEffect, this);
284                 if (minFrame == maxFrame)
285                     geometry->setupParam(pa, m_in, m_out);
286                 else
287                     geometry->setupParam(pa, minFrame, maxFrame);
288                 m_vbox->addWidget(geometry);
289                 m_valueItems[paramName+"geometry"] = geometry;
290                 connect(geometry, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
291                 connect(geometry, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
292                 connect(geometry, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
293                 connect(this, SIGNAL(syncEffectsPos(int)), geometry, SLOT(slotSyncPosition(int)));
294             } else {
295                 Geometryval *geo = new Geometryval(m_profile, m_timecode, m_frameSize, pos);
296                 if (minFrame == maxFrame)
297                     geo->setupParam(pa, m_in, m_out);
298                 else
299                     geo->setupParam(pa, minFrame, maxFrame);
300                 m_vbox->addWidget(geo);
301                 m_valueItems[paramName+"geometry"] = geo;
302                 connect(geo, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
303                 connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
304                 connect(this, SIGNAL(syncEffectsPos(int)), geo, SLOT(slotSyncPosition(int)));
305             }
306         } else if (type == "keyframe" || type == "simplekeyframe") {
307             // keyframe editor widget
308             kDebug() << "min: " << m_in << ", MAX: " << m_out;
309             if (m_keyframeEditor == NULL) {
310                 KeyframeEdit *geo = new KeyframeEdit(pa, m_in, m_in + m_out, pa.attribute("min").toInt(), pa.attribute("max").toInt(), m_timecode, e.attribute("active_keyframe", "-1").toInt());
311                 m_vbox->addWidget(geo);
312                 m_valueItems[paramName+"keyframe"] = geo;
313                 m_keyframeEditor = geo;
314                 connect(geo, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
315                 connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
316             } else {
317                 // we already have a keyframe editor, so just add another column for the new param
318                 m_keyframeEditor->addParameter(pa);
319             }
320         } else if (type == "color") {
321             if (value.startsWith('#'))
322                 value = value.replace('#', "0x");
323             bool ok;
324             ChooseColorWidget *choosecolor = new ChooseColorWidget(paramName, QColor(value.toUInt(&ok, 16)), this);
325             m_vbox->addWidget(choosecolor);
326             m_valueItems[paramName] = choosecolor;
327             connect(choosecolor, SIGNAL(displayMessage(const QString&, int)), this, SIGNAL(displayMessage(const QString&, int)));
328             connect(choosecolor, SIGNAL(modified()) , this, SLOT(collectAllParameters()));
329         } else if (type == "position") {
330             int pos = value.toInt();
331             if (d.attribute("id") == "fadein" || d.attribute("id") == "fade_from_black") {
332                 pos = pos - m_in;
333             } else if (d.attribute("id") == "fadeout" || d.attribute("id") == "fade_to_black") {
334                 // fadeout position starts from clip end
335                 pos = m_out - (pos - m_in);
336             }
337             PositionEdit *posedit = new PositionEdit(paramName, pos, 1, m_out, m_timecode);
338             m_vbox->addWidget(posedit);
339             m_valueItems[paramName+"position"] = posedit;
340             connect(posedit, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
341         } else if (type == "curve") {
342             KisCurveWidget *curve = new KisCurveWidget(this);
343             curve->setMaxPoints(pa.attribute("max").toInt());
344             QList<QPointF> points;
345             int number = EffectsList::parameter(e, pa.attribute("number")).toInt();
346             QString inName = pa.attribute("inpoints");
347             QString outName = pa.attribute("outpoints");
348             int start = pa.attribute("min").toInt();
349             for (int j = start; j <= number; j++) {
350                 QString in = inName;
351                 in.replace("%i", QString::number(j));
352                 QString out = outName;
353                 out.replace("%i", QString::number(j));
354                 points << QPointF(EffectsList::parameter(e, in).toDouble(), EffectsList::parameter(e, out).toDouble());
355             }
356             if (!points.isEmpty())
357                 curve->setCurve(KisCubicCurve(points));
358             QSpinBox *spinin = new QSpinBox();
359             spinin->setRange(0, 1000);
360             QSpinBox *spinout = new QSpinBox();
361             spinout->setRange(0, 1000);
362             curve->setupInOutControls(spinin, spinout, 0, 1000);
363             m_vbox->addWidget(curve);
364             m_vbox->addWidget(spinin);
365             m_vbox->addWidget(spinout);
366
367             connect(curve, SIGNAL(modified()), this, SLOT(collectAllParameters()));
368             m_valueItems[paramName] = curve;
369
370             QString depends = pa.attribute("depends");
371             if (!depends.isEmpty())
372                 meetDependency(paramName, type, EffectsList::parameter(e, depends));
373         } else if (type == "wipe") {
374             Wipeval *wpval = new Wipeval;
375             wpval->setupUi(toFillin);
376             wipeInfo w = getWipeInfo(value);
377             switch (w.start) {
378             case UP:
379                 wpval->start_up->setChecked(true);
380                 break;
381             case DOWN:
382                 wpval->start_down->setChecked(true);
383                 break;
384             case RIGHT:
385                 wpval->start_right->setChecked(true);
386                 break;
387             case LEFT:
388                 wpval->start_left->setChecked(true);
389                 break;
390             default:
391                 wpval->start_center->setChecked(true);
392                 break;
393             }
394             switch (w.end) {
395             case UP:
396                 wpval->end_up->setChecked(true);
397                 break;
398             case DOWN:
399                 wpval->end_down->setChecked(true);
400                 break;
401             case RIGHT:
402                 wpval->end_right->setChecked(true);
403                 break;
404             case LEFT:
405                 wpval->end_left->setChecked(true);
406                 break;
407             default:
408                 wpval->end_center->setChecked(true);
409                 break;
410             }
411             wpval->start_transp->setValue(w.startTransparency);
412             wpval->end_transp->setValue(w.endTransparency);
413             m_valueItems[paramName] = wpval;
414             connect(wpval->end_up, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
415             connect(wpval->end_down, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
416             connect(wpval->end_left, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
417             connect(wpval->end_right, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
418             connect(wpval->end_center, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
419             connect(wpval->start_up, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
420             connect(wpval->start_down, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
421             connect(wpval->start_left, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
422             connect(wpval->start_right, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
423             connect(wpval->start_center, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
424             connect(wpval->start_transp, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
425             connect(wpval->end_transp, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
426             //wpval->title->setTitle(na.toElement().text());
427             m_uiItems.append(wpval);
428         } else if (type == "url") {
429             Urlval *cval = new Urlval;
430             cval->setupUi(toFillin);
431             cval->label->setText(paramName);
432             cval->urlwidget->fileDialog()->setFilter(ProjectList::getExtensions());
433             m_valueItems[paramName] = cval;
434             cval->urlwidget->setUrl(KUrl(value));
435             connect(cval->urlwidget, SIGNAL(returnPressed()) , this, SLOT(collectAllParameters()));
436             connect(cval->urlwidget, SIGNAL(urlSelected(const KUrl&)) , this, SLOT(collectAllParameters()));
437             m_uiItems.append(cval);
438         } else {
439             delete toFillin;
440             toFillin = NULL;
441         }
442
443         if (toFillin)
444             m_vbox->addWidget(toFillin);
445     }
446     m_vbox->addStretch();
447 }
448
449 wipeInfo EffectStackEdit::getWipeInfo(QString value)
450 {
451     wipeInfo info;
452     QString start = value.section(';', 0, 0);
453     QString end = value.section(';', 1, 1).section('=', 1, 1);
454
455     if (start.startsWith("-100%,0"))
456         info.start = LEFT;
457     else if (start.startsWith("100%,0"))
458         info.start = RIGHT;
459     else if (start.startsWith("0%,100%"))
460         info.start = DOWN;
461     else if (start.startsWith("0%,-100%"))
462         info.start = UP;
463     else
464         info.start = CENTER;
465
466     if (start.count(':') == 2)
467         info.startTransparency = start.section(':', -1).toInt();
468     else
469         info.startTransparency = 100;
470
471     if (end.startsWith("-100%,0"))
472         info.end = LEFT;
473     else if (end.startsWith("100%,0"))
474         info.end = RIGHT;
475     else if (end.startsWith("0%,100%"))
476         info.end = DOWN;
477     else if (end.startsWith("0%,-100%"))
478         info.end = UP;
479     else
480         info.end = CENTER;
481
482     if (end.count(':') == 2)
483         info.endTransparency = end.section(':', -1).toInt();
484     else
485         info.endTransparency = 100;
486
487     return info;
488 }
489
490 QString EffectStackEdit::getWipeString(wipeInfo info)
491 {
492
493     QString start;
494     QString end;
495     switch (info.start) {
496     case LEFT:
497         start = "-100%,0%:100%x100%";
498         break;
499     case RIGHT:
500         start = "100%,0%:100%x100%";
501         break;
502     case DOWN:
503         start = "0%,100%:100%x100%";
504         break;
505     case UP:
506         start = "0%,-100%:100%x100%";
507         break;
508     default:
509         start = "0%,0%:100%x100%";
510         break;
511     }
512     start.append(':' + QString::number(info.startTransparency));
513
514     switch (info.end) {
515     case LEFT:
516         end = "-100%,0%:100%x100%";
517         break;
518     case RIGHT:
519         end = "100%,0%:100%x100%";
520         break;
521     case DOWN:
522         end = "0%,100%:100%x100%";
523         break;
524     case UP:
525         end = "0%,-100%:100%x100%";
526         break;
527     default:
528         end = "0%,0%:100%x100%";
529         break;
530     }
531     end.append(':' + QString::number(info.endTransparency));
532     return QString(start + ";-1=" + end);
533 }
534
535 void EffectStackEdit::collectAllParameters()
536 {
537     if (m_valueItems.isEmpty() || m_params.isNull()) return;
538     const QDomElement oldparam = m_params.cloneNode().toElement();
539     QDomElement newparam = oldparam.cloneNode().toElement();
540     QDomNodeList namenode = newparam.elementsByTagName("parameter");
541
542     for (int i = 0; i < namenode.count() ; i++) {
543         QDomNode pa = namenode.item(i);
544         QDomNode na = pa.firstChildElement("name");
545         QString type = pa.attributes().namedItem("type").nodeValue();
546         QString paramName = i18n(na.toElement().text().toUtf8().data());
547         if (type == "complex")
548             paramName.append("complex");
549         else if (type == "position")
550             paramName.append("position");
551         else if (type == "geometry")
552             paramName.append("geometry");
553         else if (type == "keyframe")
554             paramName.append("keyframe");
555         if (type != "simplekeyframe" && !m_valueItems.contains(paramName)) {
556             kDebug() << "// Param: " << paramName << " NOT FOUND";
557             continue;
558         }
559
560         QString setValue;
561         if (type == "double" || type == "constant") {
562             QSlider* slider = ((Constval*)m_valueItems.value(paramName))->horizontalSlider;
563             setValue = QString::number(slider->value());
564         } else if (type == "list") {
565             KComboBox *box = ((Listval*)m_valueItems.value(paramName))->list;
566             setValue = box->itemData(box->currentIndex()).toString();
567         } else if (type == "bool") {
568             QCheckBox *box = ((Boolval*)m_valueItems.value(paramName))->checkBox;
569             setValue = box->checkState() == Qt::Checked ? "1" : "0" ;
570         } else if (type == "color") {
571             ChooseColorWidget *choosecolor = ((ChooseColorWidget*)m_valueItems.value(paramName));
572             setValue = choosecolor->getColor().name();
573         } else if (type == "complex") {
574             ComplexParameter *complex = ((ComplexParameter*)m_valueItems.value(paramName));
575             namenode.item(i) = complex->getParamDesc();
576         } else if (type == "geometry") {
577             if (KdenliveSettings::on_monitor_effects()) {
578                 GeometryWidget *geometry = ((GeometryWidget*)m_valueItems.value(paramName));
579                 namenode.item(i).toElement().setAttribute("value", geometry->getValue());
580             } else {
581                 Geometryval *geom = ((Geometryval*)m_valueItems.value(paramName));
582                 namenode.item(i).toElement().setAttribute("value", geom->getValue());
583             }
584         } else if (type == "position") {
585             PositionEdit *pedit = ((PositionEdit*)m_valueItems.value(paramName));
586             int pos = pedit->getPosition();
587             setValue = QString::number(pos);
588             if (newparam.attribute("id") == "fadein" || newparam.attribute("id") == "fade_from_black") {
589                 // Make sure duration is not longer than clip
590                 /*if (pos > m_out) {
591                     pos = m_out;
592                     pedit->setPosition(pos);
593                 }*/
594                 EffectsList::setParameter(newparam, "in", QString::number(m_in));
595                 EffectsList::setParameter(newparam, "out", QString::number(m_in + pos));
596                 setValue.clear();
597             } else if (newparam.attribute("id") == "fadeout" || newparam.attribute("id") == "fade_to_black") {
598                 // Make sure duration is not longer than clip
599                 /*if (pos > m_out) {
600                     pos = m_out;
601                     pedit->setPosition(pos);
602                 }*/
603                 EffectsList::setParameter(newparam, "in", QString::number(m_out + m_in - pos));
604                 EffectsList::setParameter(newparam, "out", QString::number(m_out + m_in));
605                 setValue.clear();
606             }
607         } else if (type == "curve") {
608             KisCurveWidget *curve = ((KisCurveWidget*)m_valueItems.value(paramName));
609             QList<QPointF> points = curve->curve().points();
610             QString number = pa.attributes().namedItem("number").nodeValue();
611             QString inName = pa.attributes().namedItem("inpoints").nodeValue();
612             QString outName = pa.attributes().namedItem("outpoints").nodeValue();
613             int off = pa.attributes().namedItem("min").nodeValue().toInt();
614             int end = pa.attributes().namedItem("max").nodeValue().toInt();
615             EffectsList::setParameter(newparam, number, QString::number(points.count()));
616             for (int j = 0; (j < points.count() && j + off <= end); j++) {
617                 QString in = inName;
618                 in.replace("%i", QString::number(j + off));
619                 QString out = outName;
620                 out.replace("%i", QString::number(j + off));
621                 EffectsList::setParameter(newparam, in, QString::number(points.at(j).x()));
622                 EffectsList::setParameter(newparam, out, QString::number(points.at(j).y()));
623             }
624             QString depends = pa.attributes().namedItem("depends").nodeValue();
625             if (!depends.isEmpty())
626                 meetDependency(paramName, type, EffectsList::parameter(newparam, depends));
627         } else if (type == "wipe") {
628             Wipeval *wp = (Wipeval*)m_valueItems.value(paramName);
629             wipeInfo info;
630             if (wp->start_left->isChecked())
631                 info.start = LEFT;
632             else if (wp->start_right->isChecked())
633                 info.start = RIGHT;
634             else if (wp->start_up->isChecked())
635                 info.start = UP;
636             else if (wp->start_down->isChecked())
637                 info.start = DOWN;
638             else if (wp->start_center->isChecked())
639                 info.start = CENTER;
640             else
641                 info.start = LEFT;
642             info.startTransparency = wp->start_transp->value();
643
644             if (wp->end_left->isChecked())
645                 info.end = LEFT;
646             else if (wp->end_right->isChecked())
647                 info.end = RIGHT;
648             else if (wp->end_up->isChecked())
649                 info.end = UP;
650             else if (wp->end_down->isChecked())
651                 info.end = DOWN;
652             else if (wp->end_center->isChecked())
653                 info.end = CENTER;
654             else
655                 info.end = RIGHT;
656             info.endTransparency = wp->end_transp->value();
657
658             setValue = getWipeString(info);
659         } else if ((type == "simplekeyframe" || type == "keyframe") && m_keyframeEditor) {
660             QString realName = i18n(na.toElement().text().toUtf8().data());
661             QString val = m_keyframeEditor->getValue(realName);
662             kDebug() << "SET VALUE: " << val;
663             namenode.item(i).toElement().setAttribute("keyframes", val);
664         } else if (type == "url") {
665             KUrlRequester *req = ((Urlval*)m_valueItems.value(paramName))->urlwidget;
666             setValue = req->url().path();
667         }
668
669         if (!setValue.isNull())
670             pa.attributes().namedItem("value").setNodeValue(setValue);
671
672     }
673     emit parameterChanged(oldparam, newparam);
674 }
675
676 void EffectStackEdit::createSliderItem(const QString& name, int val , int min, int max, const QString suffix)
677 {
678     QWidget* toFillin = new QWidget(m_baseWidget);
679     Constval *ctval = new Constval;
680     ctval->setupUi(toFillin);
681     ctval->horizontalSlider->setMinimum(min);
682     ctval->horizontalSlider->setMaximum(max);
683     if (!suffix.isEmpty()) ctval->spinBox->setSuffix(suffix);
684     ctval->spinBox->setMinimum(min);
685     ctval->spinBox->setMaximum(max);
686     ctval->horizontalSlider->setPageStep((int)(max - min) / 10);
687     ctval->horizontalSlider->setValue(val);
688     ctval->label->setText(name);
689     m_valueItems[name] = ctval;
690     m_uiItems.append(ctval);
691     connect(ctval->horizontalSlider, SIGNAL(valueChanged(int)) , this, SLOT(collectAllParameters()));
692     m_vbox->addWidget(toFillin);
693 }
694
695 void EffectStackEdit::slotSliderMoved(int)
696 {
697     collectAllParameters();
698 }
699
700 void EffectStackEdit::clearAllItems()
701 {
702     blockSignals(true);
703     m_valueItems.clear();
704     m_uiItems.clear();
705     /*while (!m_items.isEmpty()) {
706         QWidget *die = m_items.takeFirst();
707         die->disconnect();
708         delete die;
709     }*/
710     //qDeleteAll(m_uiItems);
711     QLayoutItem *child;
712     while ((child = m_vbox->takeAt(0)) != 0) {
713         QWidget *wid = child->widget();
714         delete child;
715         if (wid) delete wid;
716     }
717     m_keyframeEditor = NULL;
718     blockSignals(false);
719 }
720
721 void EffectStackEdit::slotSyncEffectsPos(int pos)
722 {
723     emit syncEffectsPos(pos);
724 }