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