]> git.sesse.net Git - kdenlive/blob - src/effectstackedit.cpp
2d93948f44faca9fd7234d0c20e6836166e81404
[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_colorval_ui.h"
23 #include "ui_wipeval_ui.h"
24 #include "complexparameter.h"
25 #include "geometryval.h"
26 #include "positionedit.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
33 #include <KDebug>
34 #include <KLocale>
35
36 #include <QVBoxLayout>
37 #include <QSlider>
38 #include <QLabel>
39 #include <QPushButton>
40 #include <QCheckBox>
41 #include <QScrollArea>
42
43
44 class Boolval: public QWidget, public Ui::Boolval_UI
45 {
46 };
47
48 class Colorval: public QWidget, public Ui::Colorval_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
65 QMap<QString, QImage> EffectStackEdit::iconCache;
66
67 EffectStackEdit::EffectStackEdit(QWidget *parent) :
68         QScrollArea(parent),
69         m_in(0),
70         m_out(0),
71         m_frameSize(QPoint()),
72         m_keyframeEditor(NULL)
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") {
105             Geometryval *geom = ((Geometryval*)m_valueItems[paramName+"geometry"]);
106             geom->setFrameSize(m_frameSize);
107             break;
108         }
109     }
110
111 }
112
113 void EffectStackEdit::updateProjectFormat(MltVideoProfile profile, Timecode t)
114 {
115     m_profile = profile;
116     m_timecode = t;
117 }
118
119 void EffectStackEdit::updateParameter(const QString &name, const QString &value)
120 {
121     m_params.setAttribute(name, value);
122 }
123
124 void EffectStackEdit::transferParamDesc(const QDomElement d, int in, int out)
125 {
126     clearAllItems();
127     if (m_keyframeEditor) delete m_keyframeEditor;
128     m_keyframeEditor = NULL;
129     m_params = d;
130     m_in = in;
131     m_out = out;
132     if (m_params.isNull()) {
133         kDebug() << "// EMPTY EFFECT STACK";
134         return;
135     }
136
137     /*QDomDocument doc;
138     doc.appendChild(doc.importNode(m_params, true));
139     kDebug() << "IMPORTED TRANS: " << doc.toString();*/
140
141     QDomNodeList namenode = m_params.elementsByTagName("parameter");
142     QDomElement e = m_params.toElement();
143     const int minFrame = e.attribute("start").toInt();
144     const int maxFrame = e.attribute("end").toInt();
145
146
147     for (int i = 0; i < namenode.count() ; i++) {
148         QDomElement pa = namenode.item(i).toElement();
149         QDomNode na = pa.firstChildElement("name");
150         QString type = pa.attribute("type");
151         QString paramName = i18n(na.toElement().text().toUtf8().data());
152         QWidget * toFillin = new QWidget(m_baseWidget);
153         QString value = pa.attribute("value").isNull() ?
154                         pa.attribute("default") : pa.attribute("value");
155
156         /** Currently supported parameter types are:
157             * constant (=double): a slider with an integer value (use the "factor" attribute to divide the value so that you can get a double
158             * list: a combobox containing a list of values to choose
159             * bool: a checkbox
160             * complex: designed for keyframe parameters, but old and not finished, do not use
161             * geometry: a rectangle that can be moved & resized, with possible keyframes, used in composite transition
162             * keyframe: a list widget with a list of entries (position and value)
163             * color: a color chooser button
164             * position: a slider representing the position of a frame in the current clip
165             * curve: a single curve representing multiple points
166             * wipe: a widget designed for the wipe transition, allowing to choose a position (left, right, top,...)
167         */
168
169         if (type == "double" || type == "constant") {
170             int min;
171             int max;
172             if (pa.attribute("min").startsWith('%')) {
173                 min = (int) ProfilesDialog::getStringEval(m_profile, pa.attribute("min"));
174             } else min = pa.attribute("min").toInt();
175             if (pa.attribute("max").startsWith('%')) {
176                 max = (int) ProfilesDialog::getStringEval(m_profile, pa.attribute("max"));
177             } else max = pa.attribute("max").toInt();
178             createSliderItem(paramName, (int)(value.toDouble() + 0.5) , min, max, pa.attribute("suffix", QString()));
179             delete toFillin;
180             toFillin = NULL;
181         } else if (type == "list") {
182             Listval *lsval = new Listval;
183             lsval->setupUi(toFillin);
184             QStringList listitems = pa.attribute("paramlist").split(',');
185             QStringList listitemsdisplay = pa.attribute("paramlistdisplay").split(',');
186             if (listitemsdisplay.count() != listitems.count()) listitemsdisplay = listitems;
187             //lsval->list->addItems(listitems);
188             lsval->list->setIconSize(QSize(30, 30));
189             for (int i = 0; i < listitems.count(); i++) {
190                 lsval->list->addItem(listitemsdisplay.at(i), listitems.at(i));
191                 QString entry = listitems.at(i);
192                 if (!entry.isEmpty() && (entry.endsWith(".png") || entry.endsWith(".pgm"))) {
193                     if (!EffectStackEdit::iconCache.contains(entry)) {
194                         QImage pix(entry);
195                         EffectStackEdit::iconCache[entry] = pix.scaled(30, 30);
196                     }
197                     lsval->list->setItemIcon(i, QPixmap::fromImage(iconCache[entry]));
198                 }
199             }
200             if (!value.isEmpty()) lsval->list->setCurrentIndex(listitems.indexOf(value));
201             lsval->title->setTitle(paramName);
202             m_valueItems[paramName] = lsval;
203             connect(lsval->list, SIGNAL(currentIndexChanged(int)) , this, SLOT(collectAllParameters()));
204             m_uiItems.append(lsval);
205         } else if (type == "bool") {
206             Boolval *bval = new Boolval;
207             bval->setupUi(toFillin);
208             bval->checkBox->setCheckState(value == "0" ? Qt::Unchecked : Qt::Checked);
209             bval->checkBox->setText(paramName);
210             m_valueItems[paramName] = bval;
211             connect(bval->checkBox, SIGNAL(stateChanged(int)) , this, SLOT(collectAllParameters()));
212             m_uiItems.append(bval);
213         } else if (type == "complex") {
214             /*QStringList names=nodeAtts.namedItem("name").nodeValue().split(';');
215             QStringList max=nodeAtts.namedItem("max").nodeValue().split(';');
216             QStringList min=nodeAtts.namedItem("min").nodeValue().split(';');
217             QStringList val=value.split(';');
218             kDebug() << "in complex"<<names.size() << " " << max.size() << " " << min.size() << " " << val.size()  ;
219             if ( (names.size() == max.size() ) &&
220                  (names.size()== min.size()) &&
221                  (names.size()== val.size()) )
222             {
223              for (int i=0;i< names.size();i++){
224               createSliderItem(names[i],val[i].toInt(),min[i].toInt(),max[i].toInt());
225              };
226             }*/
227             ComplexParameter *pl = new ComplexParameter;
228             pl->setupParam(d, pa.attribute("name"), 0, 100);
229             m_vbox->addWidget(pl);
230             m_valueItems[paramName+"complex"] = pl;
231             connect(pl, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
232         } else if (type == "geometry") {
233             Geometryval *geo = new Geometryval(m_profile, m_frameSize, m_in);
234             geo->setupParam(pa, minFrame, maxFrame);
235             m_vbox->addWidget(geo);
236             m_valueItems[paramName+"geometry"] = geo;
237             connect(geo, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
238             connect(geo, SIGNAL(seekToPos(int)), this, SLOT(slotSeekToPos(int)));
239         } else if (type == "keyframe" || type == "simplekeyframe") {
240             // keyframe editor widget
241             kDebug() << "min: " << m_in << ", MAX: " << m_out;
242             if (m_keyframeEditor == NULL) {
243                 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());
244                 m_vbox->addWidget(geo);
245                 m_valueItems[paramName+"keyframe"] = geo;
246                 m_keyframeEditor = geo;
247                 connect(geo, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
248                 connect(geo, SIGNAL(seekToPos(int)), this, SLOT(slotSeekToPos(int)));
249             } else {
250                 // we already have a keyframe editor, so just add another column for the new param
251                 m_keyframeEditor->addParameter(pa);
252             }
253         } else if (type == "color") {
254             Colorval *cval = new Colorval;
255             cval->setupUi(toFillin);
256             bool ok;
257             if (value.startsWith('#')) value = value.replace('#', "0x");
258             cval->kcolorbutton->setColor(value.toUInt(&ok, 16));
259             //kDebug() << "color: " << value << ", " << value.toUInt(&ok, 16);
260             cval->label->setText(paramName);
261             m_valueItems[paramName] = cval;
262             connect(cval->kcolorbutton, SIGNAL(clicked()) , this, SLOT(collectAllParameters()));
263             m_uiItems.append(cval);
264         } else if (type == "position") {
265             int pos = value.toInt();
266             if (d.attribute("id") == "fadein" || d.attribute("id") == "fade_from_black") {
267                 pos = pos - m_in;
268             } else if (d.attribute("id") == "fadeout" || d.attribute("id") == "fade_to_black") {
269                 // fadeout position starts from clip end
270                 pos = m_out - (pos - m_in);
271             }
272             PositionEdit *posedit = new PositionEdit(paramName, pos, 1, m_out, m_timecode);
273             m_vbox->addWidget(posedit);
274             m_valueItems[paramName+"position"] = posedit;
275             connect(posedit, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
276         } else if (type == "curve") {
277             KisCurveWidget *curve = new KisCurveWidget(this);
278             curve->setMaxPoints(pa.attribute("max").toInt());
279             QList<QPointF> points;
280             int number = EffectsList::parameter(e, pa.attribute("number")).toInt();
281             QString inName = pa.attribute("inpoints");
282             QString outName = pa.attribute("outpoints");
283             int start = pa.attribute("min").toInt();
284             for (int j = start; j <= number; j++) {
285                 QString in = inName;
286                 in.replace("%i", QString::number(j));
287                 QString out = outName;
288                 out.replace("%i", QString::number(j));
289                 points << QPointF(EffectsList::parameter(e, in).toDouble(), EffectsList::parameter(e, out).toDouble());
290             }
291             if (!points.isEmpty()) curve->setCurve(KisCubicCurve(points));
292             QSpinBox *spinin = new QSpinBox();
293             spinin->setRange(0, 1000);
294             QSpinBox *spinout = new QSpinBox();
295             spinout->setRange(0, 1000);
296             curve->setupInOutControls(spinin, spinout, 0, 1000);
297             m_vbox->addWidget(curve);
298             m_vbox->addWidget(spinin);
299             m_vbox->addWidget(spinout);
300             connect(curve, SIGNAL(modified()), this, SLOT(collectAllParameters()));
301             m_valueItems[paramName] = curve;
302         } else if (type == "wipe") {
303             Wipeval *wpval = new Wipeval;
304             wpval->setupUi(toFillin);
305             wipeInfo w = getWipeInfo(value);
306             switch (w.start) {
307             case UP:
308                 wpval->start_up->setChecked(true);
309                 break;
310             case DOWN:
311                 wpval->start_down->setChecked(true);
312                 break;
313             case RIGHT:
314                 wpval->start_right->setChecked(true);
315                 break;
316             case LEFT:
317                 wpval->start_left->setChecked(true);
318                 break;
319             default:
320                 wpval->start_center->setChecked(true);
321                 break;
322             }
323             switch (w.end) {
324             case UP:
325                 wpval->end_up->setChecked(true);
326                 break;
327             case DOWN:
328                 wpval->end_down->setChecked(true);
329                 break;
330             case RIGHT:
331                 wpval->end_right->setChecked(true);
332                 break;
333             case LEFT:
334                 wpval->end_left->setChecked(true);
335                 break;
336             default:
337                 wpval->end_center->setChecked(true);
338                 break;
339             }
340             wpval->start_transp->setValue(w.startTransparency);
341             wpval->end_transp->setValue(w.endTransparency);
342             m_valueItems[paramName] = wpval;
343             connect(wpval->end_up, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
344             connect(wpval->end_down, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
345             connect(wpval->end_left, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
346             connect(wpval->end_right, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
347             connect(wpval->end_center, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
348             connect(wpval->start_up, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
349             connect(wpval->start_down, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
350             connect(wpval->start_left, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
351             connect(wpval->start_right, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
352             connect(wpval->start_center, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
353             connect(wpval->start_transp, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
354             connect(wpval->end_transp, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
355             //wpval->title->setTitle(na.toElement().text());
356             m_uiItems.append(wpval);
357         } else {
358             delete toFillin;
359             toFillin = NULL;
360         }
361
362         if (toFillin) {
363             m_vbox->addWidget(toFillin);
364         }
365     }
366     m_vbox->addStretch();
367 }
368
369 void EffectStackEdit::slotSeekToPos(int pos)
370 {
371     emit seekTimeline(pos);
372 }
373
374 wipeInfo EffectStackEdit::getWipeInfo(QString value)
375 {
376     wipeInfo info;
377     QString start = value.section(';', 0, 0);
378     QString end = value.section(';', 1, 1).section('=', 1, 1);
379     if (start.startsWith("-100%,0")) info.start = LEFT;
380     else if (start.startsWith("100%,0")) info.start = RIGHT;
381     else if (start.startsWith("0%,100%")) info.start = DOWN;
382     else if (start.startsWith("0%,-100%")) info.start = UP;
383     else info.start = CENTER;
384     if (start.count(':') == 2) info.startTransparency = start.section(':', -1).toInt();
385     else info.startTransparency = 100;
386
387     if (end.startsWith("-100%,0")) info.end = LEFT;
388     else if (end.startsWith("100%,0")) info.end = RIGHT;
389     else if (end.startsWith("0%,100%")) info.end = DOWN;
390     else if (end.startsWith("0%,-100%")) info.end = UP;
391     else info.end = CENTER;
392     if (end.count(':') == 2) info.endTransparency = end.section(':', -1).toInt();
393     else info.endTransparency = 100;
394     return info;
395 }
396
397 QString EffectStackEdit::getWipeString(wipeInfo info)
398 {
399
400     QString start;
401     QString end;
402     switch (info.start) {
403     case LEFT:
404         start = "-100%,0%:100%x100%";
405         break;
406     case RIGHT:
407         start = "100%,0%:100%x100%";
408         break;
409     case DOWN:
410         start = "0%,100%:100%x100%";
411         break;
412     case UP:
413         start = "0%,-100%:100%x100%";
414         break;
415     default:
416         start = "0%,0%:100%x100%";
417         break;
418     }
419     start.append(':' + QString::number(info.startTransparency));
420
421     switch (info.end) {
422     case LEFT:
423         end = "-100%,0%:100%x100%";
424         break;
425     case RIGHT:
426         end = "100%,0%:100%x100%";
427         break;
428     case DOWN:
429         end = "0%,100%:100%x100%";
430         break;
431     case UP:
432         end = "0%,-100%:100%x100%";
433         break;
434     default:
435         end = "0%,0%:100%x100%";
436         break;
437     }
438     end.append(':' + QString::number(info.endTransparency));
439     return QString(start + ";-1=" + end);
440 }
441
442 void EffectStackEdit::collectAllParameters()
443 {
444     if (m_valueItems.isEmpty() || m_params.isNull()) return;
445     const QDomElement oldparam = m_params.cloneNode().toElement();
446     QDomElement newparam = oldparam.cloneNode().toElement();
447     QDomNodeList namenode = newparam.elementsByTagName("parameter");
448
449     for (int i = 0; i < namenode.count() ; i++) {
450         QDomNode pa = namenode.item(i);
451         QDomNode na = pa.firstChildElement("name");
452         QString type = pa.attributes().namedItem("type").nodeValue();
453         QString paramName = i18n(na.toElement().text().toUtf8().data());
454         if (type == "complex") paramName.append("complex");
455         else if (type == "position") paramName.append("position");
456         else if (type == "geometry") paramName.append("geometry");
457         else if (type == "keyframe") paramName.append("keyframe");
458         if (type != "simplekeyframe" && !m_valueItems.contains(paramName)) {
459             kDebug() << "// Param: " << paramName << " NOT FOUND";
460             continue;
461         }
462
463         QString setValue;
464         if (type == "double" || type == "constant") {
465             QSlider* slider = ((Constval*)m_valueItems.value(paramName))->horizontalSlider;
466             setValue = QString::number(slider->value());
467         } else if (type == "list") {
468             KComboBox *box = ((Listval*)m_valueItems.value(paramName))->list;
469             setValue = box->itemData(box->currentIndex()).toString();
470         } else if (type == "bool") {
471             QCheckBox *box = ((Boolval*)m_valueItems.value(paramName))->checkBox;
472             setValue = box->checkState() == Qt::Checked ? "1" : "0" ;
473         } else if (type == "color") {
474             KColorButton *color = ((Colorval*)m_valueItems.value(paramName))->kcolorbutton;
475             setValue = color->color().name();
476         } else if (type == "complex") {
477             ComplexParameter *complex = ((ComplexParameter*)m_valueItems.value(paramName));
478             namenode.item(i) = complex->getParamDesc();
479         } else if (type == "geometry") {
480             Geometryval *geom = ((Geometryval*)m_valueItems.value(paramName));
481             namenode.item(i).toElement().setAttribute("value", geom->getValue());
482         } else if (type == "position") {
483             PositionEdit *pedit = ((PositionEdit*)m_valueItems.value(paramName));
484             int pos = pedit->getPosition();
485             setValue = QString::number(pos);
486             if (newparam.attribute("id") == "fadein" || newparam.attribute("id") == "fade_from_black") {
487                 // Make sure duration is not longer than clip
488                 /*if (pos > m_out) {
489                     pos = m_out;
490                     pedit->setPosition(pos);
491                 }*/
492                 EffectsList::setParameter(newparam, "in", QString::number(m_in));
493                 EffectsList::setParameter(newparam, "out", QString::number(m_in + pos));
494                 setValue.clear();
495             } else if (newparam.attribute("id") == "fadeout" || newparam.attribute("id") == "fade_to_black") {
496                 // Make sure duration is not longer than clip
497                 /*if (pos > m_out) {
498                     pos = m_out;
499                     pedit->setPosition(pos);
500                 }*/
501                 EffectsList::setParameter(newparam, "in", QString::number(m_out + m_in - pos));
502                 EffectsList::setParameter(newparam, "out", QString::number(m_out + m_in));
503                 setValue.clear();
504             }
505         } else if (type == "curve") {
506             KisCurveWidget *curve = ((KisCurveWidget*)m_valueItems.value(paramName));
507             QList<QPointF> points = curve->curve().points();
508             QString number = pa.attributes().namedItem("number").nodeValue();
509             QString inName = pa.attributes().namedItem("inpoints").nodeValue();
510             QString outName = pa.attributes().namedItem("outpoints").nodeValue();
511             int off = pa.attributes().namedItem("min").nodeValue().toInt();
512             int end = pa.attributes().namedItem("max").nodeValue().toInt();
513             EffectsList::setParameter(newparam, number, QString::number(points.count()));
514             for (int j = 0; (j < points.count() && j + off <= end); j++) {
515                 QString in = inName;
516                 in.replace("%i", QString::number(j+off));
517                 QString out = outName;
518                 out.replace("%i", QString::number(j+off));
519                 EffectsList::setParameter(newparam, in, QString::number(points.at(j).x()));
520                 EffectsList::setParameter(newparam, out, QString::number(points.at(j).y()));
521             }
522         } else if (type == "wipe") {
523             Wipeval *wp = (Wipeval*)m_valueItems.value(paramName);
524             wipeInfo info;
525             if (wp->start_left->isChecked()) info.start = LEFT;
526             else if (wp->start_right->isChecked()) info.start = RIGHT;
527             else if (wp->start_up->isChecked()) info.start = UP;
528             else if (wp->start_down->isChecked()) info.start = DOWN;
529             else if (wp->start_center->isChecked()) info.start = CENTER;
530             else info.start = LEFT;
531             info.startTransparency = wp->start_transp->value();
532             if (wp->end_left->isChecked()) info.end = LEFT;
533             else if (wp->end_right->isChecked()) info.end = RIGHT;
534             else if (wp->end_up->isChecked()) info.end = UP;
535             else if (wp->end_down->isChecked()) info.end = DOWN;
536             else if (wp->end_center->isChecked()) info.end = CENTER;
537             else info.end = RIGHT;
538             info.endTransparency = wp->end_transp->value();
539             setValue = getWipeString(info);
540         } else if ((type == "simplekeyframe" || type == "keyframe") && m_keyframeEditor) {
541             QString realName = i18n(na.toElement().text().toUtf8().data());
542             QString val = m_keyframeEditor->getValue(realName);
543             kDebug() << "SET VALUE: " << val;
544             namenode.item(i).toElement().setAttribute("keyframes", val);
545         }
546         if (!setValue.isNull()) {
547             pa.attributes().namedItem("value").setNodeValue(setValue);
548         }
549     }
550     emit parameterChanged(oldparam, newparam);
551 }
552
553 void EffectStackEdit::createSliderItem(const QString& name, int val , int min, int max, const QString suffix)
554 {
555     QWidget* toFillin = new QWidget(m_baseWidget);
556     Constval *ctval = new Constval;
557     ctval->setupUi(toFillin);
558     ctval->horizontalSlider->setMinimum(min);
559     ctval->horizontalSlider->setMaximum(max);
560     if (!suffix.isEmpty()) ctval->spinBox->setSuffix(suffix);
561     ctval->spinBox->setMinimum(min);
562     ctval->spinBox->setMaximum(max);
563     ctval->horizontalSlider->setPageStep((int)(max - min) / 10);
564     ctval->horizontalSlider->setValue(val);
565     ctval->label->setText(name);
566     m_valueItems[name] = ctval;
567     m_uiItems.append(ctval);
568     connect(ctval->horizontalSlider, SIGNAL(valueChanged(int)) , this, SLOT(collectAllParameters()));
569     m_vbox->addWidget(toFillin);
570 }
571
572 void EffectStackEdit::slotSliderMoved(int)
573 {
574     collectAllParameters();
575 }
576
577 void EffectStackEdit::clearAllItems()
578 {
579     blockSignals(true);
580     m_valueItems.clear();
581     m_uiItems.clear();
582     /*while (!m_items.isEmpty()) {
583         QWidget *die = m_items.takeFirst();
584         die->disconnect();
585         delete die;
586     }*/
587     //qDeleteAll(m_uiItems);
588     QLayoutItem *child;
589     while ((child = m_vbox->takeAt(0)) != 0) {
590         QWidget *wid = child->widget();
591         delete child;
592         if (wid) delete wid;
593     }
594     m_keyframeEditor = NULL;
595     blockSignals(false);
596 }