1 /***************************************************************************
2 effecstackedit.cpp - description
5 copyright : (C) 2008 by Marco Gittler
6 email : g.marco@freenet.de
7 ***************************************************************************/
9 /***************************************************************************
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. *
16 ***************************************************************************/
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 #include "cornerswidget.h"
37 #include "beziercurve/beziersplinewidget.h"
41 #include <KFileDialog>
43 #include <QVBoxLayout>
45 #include <QPushButton>
47 #include <QScrollArea>
50 class Boolval: public QWidget, public Ui::Boolval_UI
54 class Listval: public QWidget, public Ui::Listval_UI
58 class Wipeval: public QWidget, public Ui::Wipeval_UI
62 class Urlval: public QWidget, public Ui::Urlval_UI
66 QMap<QString, QImage> EffectStackEdit::iconCache;
68 EffectStackEdit::EffectStackEdit(Monitor *monitor, QWidget *parent) :
72 m_frameSize(QPoint()),
73 m_keyframeEditor(NULL),
76 m_baseWidget = new QWidget(this);
77 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
78 setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
79 setFrameStyle(QFrame::NoFrame);
80 setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding));
82 setWidget(m_baseWidget);
83 setWidgetResizable(true);
84 m_vbox = new QVBoxLayout(m_baseWidget);
85 m_vbox->setContentsMargins(0, 0, 0, 0);
86 m_vbox->setSpacing(0);
90 EffectStackEdit::~EffectStackEdit()
96 void EffectStackEdit::setFrameSize(QPoint p)
99 QDomNodeList namenode = m_params.elementsByTagName("parameter");
100 for (int i = 0; i < namenode.count() ; i++) {
101 QDomNode pa = namenode.item(i);
102 QDomNode na = pa.firstChildElement("name");
103 QString type = pa.attributes().namedItem("type").nodeValue();
104 QString paramName = i18n(na.toElement().text().toUtf8().data());
106 if (type == "geometry" && !KdenliveSettings::on_monitor_effects()) {
107 Geometryval *geom = ((Geometryval*)m_valueItems[paramName+"geometry"]);
108 geom->setFrameSize(m_frameSize);
114 void EffectStackEdit::updateTimecodeFormat()
116 if (m_keyframeEditor)
117 m_keyframeEditor->updateTimecodeFormat();
119 QDomNodeList namenode = m_params.elementsByTagName("parameter");
120 for (int i = 0; i < namenode.count() ; i++) {
121 QDomNode pa = namenode.item(i);
122 QDomNode na = pa.firstChildElement("name");
123 QString type = pa.attributes().namedItem("type").nodeValue();
124 QString paramName = i18n(na.toElement().text().toUtf8().data());
126 if (type == "geometry") {
127 if (KdenliveSettings::on_monitor_effects()) {
128 GeometryWidget *geom = (GeometryWidget*)m_valueItems[paramName+"geometry"];
129 geom->updateTimecodeFormat();
131 Geometryval *geom = ((Geometryval*)m_valueItems[paramName+"geometry"]);
132 geom->updateTimecodeFormat();
136 if (type == "position") {
137 PositionEdit *posi = ((PositionEdit*)m_valueItems[paramName+"position"]);
138 posi->updateTimecodeFormat();
144 void EffectStackEdit::meetDependency(const QString& name, QString type, QString value)
146 if (type == "curve") {
147 KisCurveWidget *curve = (KisCurveWidget*)m_valueItems[name];
149 int color = value.toInt();
150 curve->setPixmap(QPixmap::fromImage(ColorTools::rgbCurvePlane(curve->size(), (ColorTools::ColorsRGB)(color == 3 ? 4 : color), 0.8)));
152 } else if (type == "bezier_spline") {
153 BezierSplineWidget *widget = (BezierSplineWidget*)m_valueItems[name];
155 widget->setMode((BezierSplineWidget::CurveModes)((int)(value.toDouble() * 10)));
160 void EffectStackEdit::updateProjectFormat(MltVideoProfile profile, Timecode t)
166 void EffectStackEdit::updateParameter(const QString &name, const QString &value)
168 m_params.setAttribute(name, value);
170 if (name == "disable") {
171 // if effect is disabled, disable parameters widget
172 bool enabled = value.toInt() == 0 || !KdenliveSettings::disable_effect_parameters();
174 emit effectStateChanged(enabled);
178 void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, int out, bool isEffect)
181 if (m_keyframeEditor) delete m_keyframeEditor;
182 m_keyframeEditor = NULL;
186 if (m_params.isNull()) {
187 kDebug() << "// EMPTY EFFECT STACK";
191 QDomNodeList namenode = m_params.elementsByTagName("parameter");
192 QDomElement e = m_params.toElement();
193 const int minFrame = e.attribute("start").toInt();
194 const int maxFrame = e.attribute("end").toInt();
196 bool disable = d.attribute("disable") == "1" && KdenliveSettings::disable_effect_parameters();
197 setEnabled(!disable);
202 for (int i = 0; i < namenode.count() ; i++) {
203 QDomElement pa = namenode.item(i).toElement();
204 QDomElement na = pa.firstChildElement("name");
205 QDomElement commentElem = pa.firstChildElement("comment");
206 QString type = pa.attribute("type");
207 QString paramName = i18n(na.text().toUtf8().data());
209 if (!commentElem.isNull())
210 comment = i18n(commentElem.text().toUtf8().data());
211 QWidget * toFillin = new QWidget(m_baseWidget);
212 QString value = pa.attribute("value").isNull() ?
213 pa.attribute("default") : pa.attribute("value");
215 /** Currently supported parameter types are:
216 * constant (=double): a slider with an integer value (use the "factor" attribute to divide the value so that you can get a double
217 * list: a combobox containing a list of values to choose
219 * complex: designed for keyframe parameters, but old and not finished, do not use
220 * geometry: a rectangle that can be moved & resized, with possible keyframes, used in composite transition
221 * keyframe: a list widget with a list of entries (position and value)
222 * color: a color chooser button
223 * position: a slider representing the position of a frame in the current clip
224 * curve: a single curve representing multiple points
225 * wipe: a widget designed for the wipe transition, allowing to choose a position (left, right, top,...)
228 if (type == "double" || type == "constant") {
231 if (pa.attribute("min").startsWith('%'))
232 min = (int) ProfilesDialog::getStringEval(m_profile, pa.attribute("min"));
234 min = pa.attribute("min").toInt();
235 if (pa.attribute("max").startsWith('%'))
236 max = (int) ProfilesDialog::getStringEval(m_profile, pa.attribute("max"));
238 max = pa.attribute("max").toInt();
240 DoubleParameterWidget *doubleparam = new DoubleParameterWidget(paramName, (int)(value.toDouble() + 0.5), min, max,
241 pa.attribute("default").toInt(), comment, pa.attribute("suffix"), this);
242 m_vbox->addWidget(doubleparam);
243 m_valueItems[paramName] = doubleparam;
244 connect(doubleparam, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
245 connect(this, SIGNAL(showComments(bool)), doubleparam, SLOT(slotShowComment(bool)));
246 } else if (type == "list") {
247 Listval *lsval = new Listval;
248 lsval->setupUi(toFillin);
249 QStringList listitems = pa.attribute("paramlist").split(',');
250 QDomElement list = pa.firstChildElement("paramlistdisplay");
251 QStringList listitemsdisplay;
252 if (!list.isNull()) listitemsdisplay = i18n(list.text().toUtf8().data()).split(',');
253 else listitemsdisplay = i18n(pa.attribute("paramlistdisplay").toUtf8().data()).split(',');
254 if (listitemsdisplay.count() != listitems.count())
255 listitemsdisplay = listitems;
256 lsval->list->setIconSize(QSize(30, 30));
257 for (int i = 0; i < listitems.count(); i++) {
258 lsval->list->addItem(listitemsdisplay.at(i), listitems.at(i));
259 QString entry = listitems.at(i);
260 if (!entry.isEmpty() && (entry.endsWith(".png") || entry.endsWith(".pgm"))) {
261 if (!EffectStackEdit::iconCache.contains(entry)) {
263 EffectStackEdit::iconCache[entry] = pix.scaled(30, 30);
265 lsval->list->setItemIcon(i, QPixmap::fromImage(iconCache[entry]));
268 if (!value.isEmpty()) lsval->list->setCurrentIndex(listitems.indexOf(value));
269 lsval->name->setText(paramName);
270 lsval->labelComment->setText(comment);
271 lsval->widgetComment->setHidden(true);
272 m_valueItems[paramName] = lsval;
273 connect(lsval->list, SIGNAL(currentIndexChanged(int)) , this, SLOT(collectAllParameters()));
274 if (!comment.isEmpty())
275 connect(this, SIGNAL(showComments(bool)), lsval->widgetComment, SLOT(setVisible(bool)));
276 m_uiItems.append(lsval);
277 } else if (type == "bool") {
278 Boolval *bval = new Boolval;
279 bval->setupUi(toFillin);
280 bval->checkBox->setCheckState(value == "0" ? Qt::Unchecked : Qt::Checked);
281 bval->name->setText(paramName);
282 bval->labelComment->setText(comment);
283 bval->widgetComment->setHidden(true);
284 m_valueItems[paramName] = bval;
285 connect(bval->checkBox, SIGNAL(stateChanged(int)) , this, SLOT(collectAllParameters()));
286 if (!comment.isEmpty())
287 connect(this, SIGNAL(showComments(bool)), bval->widgetComment, SLOT(setVisible(bool)));
288 m_uiItems.append(bval);
289 } else if (type == "complex") {
290 ComplexParameter *pl = new ComplexParameter;
291 pl->setupParam(d, pa.attribute("name"), 0, 100);
292 m_vbox->addWidget(pl);
293 m_valueItems[paramName+"complex"] = pl;
294 connect(pl, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
295 } else if (type == "geometry") {
296 if (KdenliveSettings::on_monitor_effects()) {
297 GeometryWidget *geometry = new GeometryWidget(m_monitor, m_timecode, pos, isEffect, this);
298 geometry->slotShowScene(!disable);
299 // connect this before setupParam to make sure the monitor scene shows up at startup
300 connect(geometry, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
301 connect(geometry, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
302 if (minFrame == maxFrame)
303 geometry->setupParam(pa, m_in, m_out);
305 geometry->setupParam(pa, minFrame, maxFrame);
306 m_vbox->addWidget(geometry);
307 m_valueItems[paramName+"geometry"] = geometry;
308 connect(geometry, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
309 connect(this, SIGNAL(syncEffectsPos(int)), geometry, SLOT(slotSyncPosition(int)));
310 connect(this, SIGNAL(effectStateChanged(bool)), geometry, SLOT(slotShowScene(bool)));
312 Geometryval *geo = new Geometryval(m_profile, m_timecode, m_frameSize, pos);
313 if (minFrame == maxFrame)
314 geo->setupParam(pa, m_in, m_out);
316 geo->setupParam(pa, minFrame, maxFrame);
317 m_vbox->addWidget(geo);
318 m_valueItems[paramName+"geometry"] = geo;
319 connect(geo, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
320 connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
321 connect(this, SIGNAL(syncEffectsPos(int)), geo, SLOT(slotSyncPosition(int)));
323 } else if (type == "keyframe" || type == "simplekeyframe") {
324 // keyframe editor widget
325 if (m_keyframeEditor == NULL) {
327 if (pa.attribute("widget") == "corners") {
328 // we want a corners-keyframe-widget
329 CornersWidget *corners = new CornersWidget(m_monitor, pa, m_in, m_in + m_out, m_timecode, e.attribute("active_keyframe", "-1").toInt(), this);
330 corners->slotShowScene(!disable);
331 connect(corners, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
332 connect(this, SIGNAL(effectStateChanged(bool)), corners, SLOT(slotShowScene(bool)));
333 connect(this, SIGNAL(syncEffectsPos(int)), corners, SLOT(slotSyncPosition(int)));
334 geo = static_cast<KeyframeEdit *>(corners);
336 geo = new KeyframeEdit(pa, m_in, m_in + m_out, m_timecode, e.attribute("active_keyframe", "-1").toInt());
338 m_vbox->addWidget(geo);
339 m_valueItems[paramName+"keyframe"] = geo;
340 m_keyframeEditor = geo;
341 connect(geo, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
342 connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
343 connect(this, SIGNAL(showComments(bool)), geo, SIGNAL(showComments(bool)));
345 // we already have a keyframe editor, so just add another column for the new param
346 m_keyframeEditor->addParameter(pa);
348 } else if (type == "color") {
349 if (value.startsWith('#'))
350 value = value.replace('#', "0x");
352 ChooseColorWidget *choosecolor = new ChooseColorWidget(paramName, QColor(value.toUInt(&ok, 16)), this);
353 m_vbox->addWidget(choosecolor);
354 m_valueItems[paramName] = choosecolor;
355 connect(choosecolor, SIGNAL(displayMessage(const QString&, int)), this, SIGNAL(displayMessage(const QString&, int)));
356 connect(choosecolor, SIGNAL(modified()) , this, SLOT(collectAllParameters()));
357 } else if (type == "position") {
358 int pos = value.toInt();
359 if (d.attribute("id") == "fadein" || d.attribute("id") == "fade_from_black") {
361 } else if (d.attribute("id") == "fadeout" || d.attribute("id") == "fade_to_black") {
362 // fadeout position starts from clip end
365 PositionEdit *posedit = new PositionEdit(paramName, pos, 0, m_out - m_in, m_timecode);
366 m_vbox->addWidget(posedit);
367 m_valueItems[paramName+"position"] = posedit;
368 connect(posedit, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
369 } else if (type == "curve") {
370 KisCurveWidget *curve = new KisCurveWidget(this);
371 curve->setMaxPoints(pa.attribute("max").toInt());
372 QList<QPointF> points;
373 int number = EffectsList::parameter(e, pa.attribute("number")).toInt();
374 QString inName = pa.attribute("inpoints");
375 QString outName = pa.attribute("outpoints");
376 int start = pa.attribute("min").toInt();
377 for (int j = start; j <= number; j++) {
379 in.replace("%i", QString::number(j));
380 QString out = outName;
381 out.replace("%i", QString::number(j));
382 points << QPointF(EffectsList::parameter(e, in).toDouble(), EffectsList::parameter(e, out).toDouble());
384 if (!points.isEmpty())
385 curve->setCurve(KisCubicCurve(points));
386 QSpinBox *spinin = new QSpinBox();
387 spinin->setRange(0, 1000);
388 QSpinBox *spinout = new QSpinBox();
389 spinout->setRange(0, 1000);
390 curve->setupInOutControls(spinin, spinout, 0, 1000);
391 m_vbox->addWidget(curve);
392 m_vbox->addWidget(spinin);
393 m_vbox->addWidget(spinout);
395 connect(curve, SIGNAL(modified()), this, SLOT(collectAllParameters()));
396 m_valueItems[paramName] = curve;
398 QString depends = pa.attribute("depends");
399 if (!depends.isEmpty())
400 meetDependency(paramName, type, EffectsList::parameter(e, depends));
401 } else if (type == "bezier_spline") {
402 BezierSplineWidget *widget = new BezierSplineWidget(value, this);
404 m_vbox->addWidget(widget);
405 m_valueItems[paramName] = widget;
406 connect(widget, SIGNAL(modified()), this, SLOT(collectAllParameters()));
407 QString depends = pa.attribute("depends");
408 if (!depends.isEmpty())
409 meetDependency(paramName, type, EffectsList::parameter(e, depends));
410 } else if (type == "wipe") {
411 Wipeval *wpval = new Wipeval;
412 wpval->setupUi(toFillin);
413 wipeInfo w = getWipeInfo(value);
416 wpval->start_up->setChecked(true);
419 wpval->start_down->setChecked(true);
422 wpval->start_right->setChecked(true);
425 wpval->start_left->setChecked(true);
428 wpval->start_center->setChecked(true);
433 wpval->end_up->setChecked(true);
436 wpval->end_down->setChecked(true);
439 wpval->end_right->setChecked(true);
442 wpval->end_left->setChecked(true);
445 wpval->end_center->setChecked(true);
448 wpval->start_transp->setValue(w.startTransparency);
449 wpval->end_transp->setValue(w.endTransparency);
450 m_valueItems[paramName] = wpval;
451 connect(wpval->end_up, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
452 connect(wpval->end_down, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
453 connect(wpval->end_left, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
454 connect(wpval->end_right, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
455 connect(wpval->end_center, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
456 connect(wpval->start_up, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
457 connect(wpval->start_down, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
458 connect(wpval->start_left, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
459 connect(wpval->start_right, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
460 connect(wpval->start_center, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
461 connect(wpval->start_transp, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
462 connect(wpval->end_transp, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
463 //wpval->title->setTitle(na.toElement().text());
464 m_uiItems.append(wpval);
465 } else if (type == "url") {
466 Urlval *cval = new Urlval;
467 cval->setupUi(toFillin);
468 cval->label->setText(paramName);
469 cval->urlwidget->fileDialog()->setFilter(ProjectList::getExtensions());
470 m_valueItems[paramName] = cval;
471 cval->urlwidget->setUrl(KUrl(value));
472 connect(cval->urlwidget, SIGNAL(returnPressed()) , this, SLOT(collectAllParameters()));
473 connect(cval->urlwidget, SIGNAL(urlSelected(const KUrl&)) , this, SLOT(collectAllParameters()));
474 m_uiItems.append(cval);
481 m_vbox->addWidget(toFillin);
485 m_vbox->addStretch();
487 if (m_keyframeEditor)
488 m_keyframeEditor->checkVisibleParam();
491 wipeInfo EffectStackEdit::getWipeInfo(QString value)
494 QString start = value.section(';', 0, 0);
495 QString end = value.section(';', 1, 1).section('=', 1, 1);
497 if (start.startsWith("-100%,0"))
499 else if (start.startsWith("100%,0"))
501 else if (start.startsWith("0%,100%"))
503 else if (start.startsWith("0%,-100%"))
508 if (start.count(':') == 2)
509 info.startTransparency = start.section(':', -1).toInt();
511 info.startTransparency = 100;
513 if (end.startsWith("-100%,0"))
515 else if (end.startsWith("100%,0"))
517 else if (end.startsWith("0%,100%"))
519 else if (end.startsWith("0%,-100%"))
524 if (end.count(':') == 2)
525 info.endTransparency = end.section(':', -1).toInt();
527 info.endTransparency = 100;
532 QString EffectStackEdit::getWipeString(wipeInfo info)
537 switch (info.start) {
539 start = "-100%,0%:100%x100%";
542 start = "100%,0%:100%x100%";
545 start = "0%,100%:100%x100%";
548 start = "0%,-100%:100%x100%";
551 start = "0%,0%:100%x100%";
554 start.append(':' + QString::number(info.startTransparency));
558 end = "-100%,0%:100%x100%";
561 end = "100%,0%:100%x100%";
564 end = "0%,100%:100%x100%";
567 end = "0%,-100%:100%x100%";
570 end = "0%,0%:100%x100%";
573 end.append(':' + QString::number(info.endTransparency));
574 return QString(start + ";-1=" + end);
577 void EffectStackEdit::collectAllParameters()
579 if (m_valueItems.isEmpty() || m_params.isNull()) return;
580 const QDomElement oldparam = m_params.cloneNode().toElement();
581 QDomElement newparam = oldparam.cloneNode().toElement();
582 QDomNodeList namenode = newparam.elementsByTagName("parameter");
584 for (int i = 0; i < namenode.count() ; i++) {
585 QDomNode pa = namenode.item(i);
586 QDomNode na = pa.firstChildElement("name");
587 QString type = pa.attributes().namedItem("type").nodeValue();
588 QString paramName = i18n(na.toElement().text().toUtf8().data());
589 if (type == "complex")
590 paramName.append("complex");
591 else if (type == "position")
592 paramName.append("position");
593 else if (type == "geometry")
594 paramName.append("geometry");
595 else if (type == "keyframe")
596 paramName.append("keyframe");
597 if (type != "simplekeyframe" && !m_valueItems.contains(paramName)) {
598 kDebug() << "// Param: " << paramName << " NOT FOUND";
603 if (type == "double" || type == "constant") {
604 DoubleParameterWidget *doubleparam = (DoubleParameterWidget*)m_valueItems.value(paramName);
605 setValue = QString::number(doubleparam->getValue());
606 } else if (type == "list") {
607 KComboBox *box = ((Listval*)m_valueItems.value(paramName))->list;
608 setValue = box->itemData(box->currentIndex()).toString();
609 } else if (type == "bool") {
610 QCheckBox *box = ((Boolval*)m_valueItems.value(paramName))->checkBox;
611 setValue = box->checkState() == Qt::Checked ? "1" : "0" ;
612 } else if (type == "color") {
613 ChooseColorWidget *choosecolor = ((ChooseColorWidget*)m_valueItems.value(paramName));
614 setValue = choosecolor->getColor().name();
615 } else if (type == "complex") {
616 ComplexParameter *complex = ((ComplexParameter*)m_valueItems.value(paramName));
617 namenode.item(i) = complex->getParamDesc();
618 } else if (type == "geometry") {
619 if (KdenliveSettings::on_monitor_effects()) {
620 GeometryWidget *geometry = ((GeometryWidget*)m_valueItems.value(paramName));
621 namenode.item(i).toElement().setAttribute("value", geometry->getValue());
623 Geometryval *geom = ((Geometryval*)m_valueItems.value(paramName));
624 namenode.item(i).toElement().setAttribute("value", geom->getValue());
626 } else if (type == "position") {
627 PositionEdit *pedit = ((PositionEdit*)m_valueItems.value(paramName));
628 int pos = pedit->getPosition();
629 setValue = QString::number(pos);
630 if (newparam.attribute("id") == "fadein" || newparam.attribute("id") == "fade_from_black") {
631 // Make sure duration is not longer than clip
634 pedit->setPosition(pos);
636 EffectsList::setParameter(newparam, "in", QString::number(m_in));
637 EffectsList::setParameter(newparam, "out", QString::number(m_in + pos));
639 } else if (newparam.attribute("id") == "fadeout" || newparam.attribute("id") == "fade_to_black") {
640 // Make sure duration is not longer than clip
643 pedit->setPosition(pos);
645 EffectsList::setParameter(newparam, "in", QString::number(m_out - pos));
646 EffectsList::setParameter(newparam, "out", QString::number(m_out));
649 } else if (type == "curve") {
650 KisCurveWidget *curve = ((KisCurveWidget*)m_valueItems.value(paramName));
651 QList<QPointF> points = curve->curve().points();
652 QString number = pa.attributes().namedItem("number").nodeValue();
653 QString inName = pa.attributes().namedItem("inpoints").nodeValue();
654 QString outName = pa.attributes().namedItem("outpoints").nodeValue();
655 int off = pa.attributes().namedItem("min").nodeValue().toInt();
656 int end = pa.attributes().namedItem("max").nodeValue().toInt();
657 EffectsList::setParameter(newparam, number, QString::number(points.count()));
658 for (int j = 0; (j < points.count() && j + off <= end); j++) {
660 in.replace("%i", QString::number(j + off));
661 QString out = outName;
662 out.replace("%i", QString::number(j + off));
663 EffectsList::setParameter(newparam, in, QString::number(points.at(j).x()));
664 EffectsList::setParameter(newparam, out, QString::number(points.at(j).y()));
666 QString depends = pa.attributes().namedItem("depends").nodeValue();
667 if (!depends.isEmpty())
668 meetDependency(paramName, type, EffectsList::parameter(newparam, depends));
669 } else if (type == "bezier_spline") {
670 BezierSplineWidget *widget = (BezierSplineWidget*)m_valueItems.value(paramName);
671 setValue = widget->spline();
672 QString depends = pa.attributes().namedItem("depends").nodeValue();
673 if (!depends.isEmpty())
674 meetDependency(paramName, type, EffectsList::parameter(newparam, depends));
675 } else if (type == "wipe") {
676 Wipeval *wp = (Wipeval*)m_valueItems.value(paramName);
678 if (wp->start_left->isChecked())
680 else if (wp->start_right->isChecked())
682 else if (wp->start_up->isChecked())
684 else if (wp->start_down->isChecked())
686 else if (wp->start_center->isChecked())
690 info.startTransparency = wp->start_transp->value();
692 if (wp->end_left->isChecked())
694 else if (wp->end_right->isChecked())
696 else if (wp->end_up->isChecked())
698 else if (wp->end_down->isChecked())
700 else if (wp->end_center->isChecked())
704 info.endTransparency = wp->end_transp->value();
706 setValue = getWipeString(info);
707 } else if ((type == "simplekeyframe" || type == "keyframe") && m_keyframeEditor) {
708 QDomElement elem = pa.toElement();
709 QString realName = i18n(na.toElement().text().toUtf8().data());
710 QString val = m_keyframeEditor->getValue(realName);
711 elem.setAttribute("keyframes", val);
713 if (m_keyframeEditor->isVisibleParam(realName))
714 elem.setAttribute("intimeline", "1");
715 else if (elem.hasAttribute("intimeline"))
716 elem.removeAttribute("intimeline");
717 } else if (type == "url") {
718 KUrlRequester *req = ((Urlval*)m_valueItems.value(paramName))->urlwidget;
719 setValue = req->url().path();
722 if (!setValue.isNull())
723 pa.attributes().namedItem("value").setNodeValue(setValue);
726 emit parameterChanged(oldparam, newparam);
729 void EffectStackEdit::clearAllItems()
732 m_valueItems.clear();
734 /*while (!m_items.isEmpty()) {
735 QWidget *die = m_items.takeFirst();
739 //qDeleteAll(m_uiItems);
741 while ((child = m_vbox->takeAt(0)) != 0) {
742 QWidget *wid = child->widget();
746 m_keyframeEditor = NULL;
750 void EffectStackEdit::slotSyncEffectsPos(int pos)
752 emit syncEffectsPos(pos);