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