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"
38 #include "beziercurve/cubicbezierspline.h"
42 #include <KFileDialog>
44 #include <QVBoxLayout>
46 #include <QPushButton>
48 #include <QScrollArea>
51 class Boolval: public QWidget, public Ui::Boolval_UI
55 class Listval: public QWidget, public Ui::Listval_UI
59 class Wipeval: public QWidget, public Ui::Wipeval_UI
63 class Urlval: public QWidget, public Ui::Urlval_UI
67 QMap<QString, QImage> EffectStackEdit::iconCache;
69 EffectStackEdit::EffectStackEdit(Monitor *monitor, QWidget *parent) :
73 m_frameSize(QPoint()),
74 m_keyframeEditor(NULL),
77 m_baseWidget = new QWidget(this);
78 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
79 setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
80 setFrameStyle(QFrame::NoFrame);
81 setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding));
83 setWidget(m_baseWidget);
84 setWidgetResizable(true);
85 m_vbox = new QVBoxLayout(m_baseWidget);
86 m_vbox->setContentsMargins(0, 0, 0, 0);
87 m_vbox->setSpacing(0);
91 EffectStackEdit::~EffectStackEdit()
97 void EffectStackEdit::setFrameSize(QPoint p)
100 QDomNodeList namenode = m_params.elementsByTagName("parameter");
101 for (int i = 0; i < namenode.count() ; i++) {
102 QDomNode pa = namenode.item(i);
103 QDomNode na = pa.firstChildElement("name");
104 QString type = pa.attributes().namedItem("type").nodeValue();
105 QString paramName = i18n(na.toElement().text().toUtf8().data());
107 if (type == "geometry" && !KdenliveSettings::on_monitor_effects()) {
108 Geometryval *geom = ((Geometryval*)m_valueItems[paramName+"geometry"]);
109 geom->setFrameSize(m_frameSize);
115 void EffectStackEdit::updateTimecodeFormat()
117 if (m_keyframeEditor)
118 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());
127 if (type == "geometry") {
128 if (KdenliveSettings::on_monitor_effects()) {
129 GeometryWidget *geom = (GeometryWidget*)m_valueItems[paramName+"geometry"];
130 geom->updateTimecodeFormat();
132 Geometryval *geom = ((Geometryval*)m_valueItems[paramName+"geometry"]);
133 geom->updateTimecodeFormat();
137 if (type == "position") {
138 PositionEdit *posi = ((PositionEdit*)m_valueItems[paramName+"position"]);
139 posi->updateTimecodeFormat();
145 void EffectStackEdit::meetDependency(const QString& name, QString type, QString value)
147 if (type == "curve") {
148 KisCurveWidget *curve = (KisCurveWidget*)m_valueItems[name];
150 int color = value.toInt();
151 curve->setPixmap(QPixmap::fromImage(ColorTools::rgbCurvePlane(curve->size(), (ColorTools::ColorsRGB)color, 0.8)));
156 void EffectStackEdit::updateProjectFormat(MltVideoProfile profile, Timecode t)
162 void EffectStackEdit::updateParameter(const QString &name, const QString &value)
164 m_params.setAttribute(name, value);
166 if (name == "disable") {
167 // if effect is disabled, disable parameters widget
168 setEnabled(value.toInt() == 0 || !KdenliveSettings::disable_effect_parameters());
169 if (KdenliveSettings::on_monitor_effects()) {
170 // effect disabled, hide monitor scene if any
171 QDomNodeList namenode = m_params.elementsByTagName("parameter");
172 for (int i = 0; i < namenode.count() ; i++) {
173 QDomNode pa = namenode.item(i);
174 QDomNode na = pa.firstChildElement("name");
175 QString type = pa.attributes().namedItem("type").nodeValue();
176 if (type == "geometry") {
177 QString paramName = i18n(na.toElement().text().toUtf8().data());
178 paramName.append("geometry");
179 GeometryWidget *geometry = ((GeometryWidget*)m_valueItems.value(paramName));
180 geometry->slotShowScene(value.toInt() == 0 || !KdenliveSettings::disable_effect_parameters());
187 void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, int out, bool isEffect)
190 if (m_keyframeEditor) delete m_keyframeEditor;
191 m_keyframeEditor = NULL;
195 if (m_params.isNull()) {
196 kDebug() << "// EMPTY EFFECT STACK";
200 QDomNodeList namenode = m_params.elementsByTagName("parameter");
201 QDomElement e = m_params.toElement();
202 const int minFrame = e.attribute("start").toInt();
203 const int maxFrame = e.attribute("end").toInt();
205 bool disable = d.attribute("disable") == "1" && KdenliveSettings::disable_effect_parameters();
206 setEnabled(!disable);
209 for (int i = 0; i < namenode.count() ; i++) {
210 QDomElement pa = namenode.item(i).toElement();
211 QDomElement na = pa.firstChildElement("name");
212 QDomElement commentElem = pa.firstChildElement("comment");
213 QString type = pa.attribute("type");
214 QString paramName = i18n(na.text().toUtf8().data());
216 if (!commentElem.isNull())
217 comment = i18n(commentElem.text().toUtf8().data());
218 QWidget * toFillin = new QWidget(m_baseWidget);
219 QString value = pa.attribute("value").isNull() ?
220 pa.attribute("default") : pa.attribute("value");
222 /** Currently supported parameter types are:
223 * constant (=double): a slider with an integer value (use the "factor" attribute to divide the value so that you can get a double
224 * list: a combobox containing a list of values to choose
226 * complex: designed for keyframe parameters, but old and not finished, do not use
227 * geometry: a rectangle that can be moved & resized, with possible keyframes, used in composite transition
228 * keyframe: a list widget with a list of entries (position and value)
229 * color: a color chooser button
230 * position: a slider representing the position of a frame in the current clip
231 * curve: a single curve representing multiple points
232 * wipe: a widget designed for the wipe transition, allowing to choose a position (left, right, top,...)
235 if (type == "double" || type == "constant") {
238 if (pa.attribute("min").startsWith('%'))
239 min = (int) ProfilesDialog::getStringEval(m_profile, pa.attribute("min"));
241 min = pa.attribute("min").toInt();
242 if (pa.attribute("max").startsWith('%'))
243 max = (int) ProfilesDialog::getStringEval(m_profile, pa.attribute("max"));
245 max = pa.attribute("max").toInt();
247 DoubleParameterWidget *doubleparam = new DoubleParameterWidget(paramName, (int)(value.toDouble() + 0.5), min, max,
248 pa.attribute("default").toInt(), comment, pa.attribute("suffix"), this);
249 m_vbox->addWidget(doubleparam);
250 m_valueItems[paramName] = doubleparam;
251 connect(doubleparam, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
252 connect(this, SIGNAL(showComments()), doubleparam, SLOT(slotShowComment()));
253 } else if (type == "list") {
254 Listval *lsval = new Listval;
255 lsval->setupUi(toFillin);
256 QStringList listitems = pa.attribute("paramlist").split(',');
257 QStringList listitemsdisplay = pa.attribute("paramlistdisplay").split(',');
258 if (listitemsdisplay.count() != listitems.count())
259 listitemsdisplay = listitems;
260 lsval->list->setIconSize(QSize(30, 30));
261 for (int i = 0; i < listitems.count(); i++) {
262 lsval->list->addItem(listitemsdisplay.at(i), listitems.at(i));
263 QString entry = listitems.at(i);
264 if (!entry.isEmpty() && (entry.endsWith(".png") || entry.endsWith(".pgm"))) {
265 if (!EffectStackEdit::iconCache.contains(entry)) {
267 EffectStackEdit::iconCache[entry] = pix.scaled(30, 30);
269 lsval->list->setItemIcon(i, QPixmap::fromImage(iconCache[entry]));
272 if (!value.isEmpty()) lsval->list->setCurrentIndex(listitems.indexOf(value));
273 lsval->name->setText(paramName);
274 m_valueItems[paramName] = lsval;
275 connect(lsval->list, SIGNAL(currentIndexChanged(int)) , this, SLOT(collectAllParameters()));
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 m_valueItems[paramName] = bval;
283 connect(bval->checkBox, SIGNAL(stateChanged(int)) , this, SLOT(collectAllParameters()));
284 m_uiItems.append(bval);
285 } else if (type == "complex") {
286 ComplexParameter *pl = new ComplexParameter;
287 pl->setupParam(d, pa.attribute("name"), 0, 100);
288 m_vbox->addWidget(pl);
289 m_valueItems[paramName+"complex"] = pl;
290 connect(pl, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
291 } else if (type == "geometry") {
292 if (KdenliveSettings::on_monitor_effects()) {
293 GeometryWidget *geometry = new GeometryWidget(m_monitor, m_timecode, pos, isEffect, disable, this);
294 // connect this before setupParam to make sure the monitor scene shows up at startup
295 connect(geometry, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
296 connect(geometry, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
297 if (minFrame == maxFrame)
298 geometry->setupParam(pa, m_in, m_out);
300 geometry->setupParam(pa, minFrame, maxFrame);
301 m_vbox->addWidget(geometry);
302 m_valueItems[paramName+"geometry"] = geometry;
303 connect(geometry, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
304 connect(this, SIGNAL(syncEffectsPos(int)), geometry, SLOT(slotSyncPosition(int)));
306 Geometryval *geo = new Geometryval(m_profile, m_timecode, m_frameSize, pos);
307 if (minFrame == maxFrame)
308 geo->setupParam(pa, m_in, m_out);
310 geo->setupParam(pa, minFrame, maxFrame);
311 m_vbox->addWidget(geo);
312 m_valueItems[paramName+"geometry"] = geo;
313 connect(geo, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
314 connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
315 connect(this, SIGNAL(syncEffectsPos(int)), geo, SLOT(slotSyncPosition(int)));
317 } else if (type == "keyframe" || type == "simplekeyframe") {
318 // keyframe editor widget
319 if (m_keyframeEditor == NULL) {
320 KeyframeEdit *geo = new KeyframeEdit(pa, m_in, m_in + m_out, m_timecode, e.attribute("active_keyframe", "-1").toInt());
321 m_vbox->addWidget(geo);
322 m_valueItems[paramName+"keyframe"] = geo;
323 m_keyframeEditor = geo;
324 connect(geo, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
325 connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
326 connect(this, SIGNAL(showComments()), geo, SIGNAL(showComments()));
328 // we already have a keyframe editor, so just add another column for the new param
329 m_keyframeEditor->addParameter(pa);
331 } else if (type == "color") {
332 if (value.startsWith('#'))
333 value = value.replace('#', "0x");
335 ChooseColorWidget *choosecolor = new ChooseColorWidget(paramName, QColor(value.toUInt(&ok, 16)), this);
336 m_vbox->addWidget(choosecolor);
337 m_valueItems[paramName] = choosecolor;
338 connect(choosecolor, SIGNAL(displayMessage(const QString&, int)), this, SIGNAL(displayMessage(const QString&, int)));
339 connect(choosecolor, SIGNAL(modified()) , this, SLOT(collectAllParameters()));
340 } else if (type == "position") {
341 int pos = value.toInt();
342 if (d.attribute("id") == "fadein" || d.attribute("id") == "fade_from_black") {
344 } else if (d.attribute("id") == "fadeout" || d.attribute("id") == "fade_to_black") {
345 // fadeout position starts from clip end
348 PositionEdit *posedit = new PositionEdit(paramName, pos, 0, m_out - m_in, m_timecode);
349 m_vbox->addWidget(posedit);
350 m_valueItems[paramName+"position"] = posedit;
351 connect(posedit, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
352 } else if (type == "curve") {
353 KisCurveWidget *curve = new KisCurveWidget(this);
354 curve->setMaxPoints(pa.attribute("max").toInt());
355 QList<QPointF> points;
356 int number = EffectsList::parameter(e, pa.attribute("number")).toInt();
357 QString inName = pa.attribute("inpoints");
358 QString outName = pa.attribute("outpoints");
359 int start = pa.attribute("min").toInt();
360 for (int j = start; j <= number; j++) {
362 in.replace("%i", QString::number(j));
363 QString out = outName;
364 out.replace("%i", QString::number(j));
365 points << QPointF(EffectsList::parameter(e, in).toDouble(), EffectsList::parameter(e, out).toDouble());
367 if (!points.isEmpty())
368 curve->setCurve(KisCubicCurve(points));
369 QSpinBox *spinin = new QSpinBox();
370 spinin->setRange(0, 1000);
371 QSpinBox *spinout = new QSpinBox();
372 spinout->setRange(0, 1000);
373 curve->setupInOutControls(spinin, spinout, 0, 1000);
374 m_vbox->addWidget(curve);
375 m_vbox->addWidget(spinin);
376 m_vbox->addWidget(spinout);
378 connect(curve, SIGNAL(modified()), this, SLOT(collectAllParameters()));
379 m_valueItems[paramName] = curve;
381 QString depends = pa.attribute("depends");
382 if (!depends.isEmpty())
383 meetDependency(paramName, type, EffectsList::parameter(e, depends));
384 } else if (type == "bezier_spline") {
385 BezierSplineWidget *widget = new BezierSplineWidget(this);
386 CubicBezierSpline spline;
387 spline.fromString(value);
388 widget->setSpline(spline);
389 m_vbox->addWidget(widget);
390 m_valueItems[paramName] = widget;
391 connect(widget, SIGNAL(modified()), this, SLOT(collectAllParameters()));
392 } else if (type == "corners") {
393 CornersWidget *corners = new CornersWidget(m_monitor, pos, isEffect, pa.attribute("factor").toInt(), this);
394 connect(corners, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
395 if (minFrame == maxFrame)
396 corners->setRange(m_in, m_out);
398 corners->setRange(minFrame, maxFrame);
400 QString xName = pa.attribute("xpoints");
401 QString yName = pa.attribute("ypoints");
404 for (int j = 1; j <= 4; ++j) {
405 x = EffectsList::parameter(e, QString(xName).replace("%i", QString::number(j))).toInt();
406 y = EffectsList::parameter(e, QString(yName).replace("%i", QString::number(j))).toInt();
407 points << QPoint(x, y);
409 corners->setValue(points);
411 m_vbox->addWidget(corners);
412 connect(corners, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
413 m_valueItems[paramName] = corners;
414 } else if (type == "wipe") {
415 Wipeval *wpval = new Wipeval;
416 wpval->setupUi(toFillin);
417 wipeInfo w = getWipeInfo(value);
420 wpval->start_up->setChecked(true);
423 wpval->start_down->setChecked(true);
426 wpval->start_right->setChecked(true);
429 wpval->start_left->setChecked(true);
432 wpval->start_center->setChecked(true);
437 wpval->end_up->setChecked(true);
440 wpval->end_down->setChecked(true);
443 wpval->end_right->setChecked(true);
446 wpval->end_left->setChecked(true);
449 wpval->end_center->setChecked(true);
452 wpval->start_transp->setValue(w.startTransparency);
453 wpval->end_transp->setValue(w.endTransparency);
454 m_valueItems[paramName] = wpval;
455 connect(wpval->end_up, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
456 connect(wpval->end_down, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
457 connect(wpval->end_left, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
458 connect(wpval->end_right, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
459 connect(wpval->end_center, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
460 connect(wpval->start_up, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
461 connect(wpval->start_down, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
462 connect(wpval->start_left, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
463 connect(wpval->start_right, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
464 connect(wpval->start_center, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
465 connect(wpval->start_transp, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
466 connect(wpval->end_transp, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
467 //wpval->title->setTitle(na.toElement().text());
468 m_uiItems.append(wpval);
469 } else if (type == "url") {
470 Urlval *cval = new Urlval;
471 cval->setupUi(toFillin);
472 cval->label->setText(paramName);
473 cval->urlwidget->fileDialog()->setFilter(ProjectList::getExtensions());
474 m_valueItems[paramName] = cval;
475 cval->urlwidget->setUrl(KUrl(value));
476 connect(cval->urlwidget, SIGNAL(returnPressed()) , this, SLOT(collectAllParameters()));
477 connect(cval->urlwidget, SIGNAL(urlSelected(const KUrl&)) , this, SLOT(collectAllParameters()));
478 m_uiItems.append(cval);
485 m_vbox->addWidget(toFillin);
487 m_vbox->addStretch();
489 if (m_keyframeEditor)
490 m_keyframeEditor->checkVisibleParam();
493 wipeInfo EffectStackEdit::getWipeInfo(QString value)
496 QString start = value.section(';', 0, 0);
497 QString end = value.section(';', 1, 1).section('=', 1, 1);
499 if (start.startsWith("-100%,0"))
501 else if (start.startsWith("100%,0"))
503 else if (start.startsWith("0%,100%"))
505 else if (start.startsWith("0%,-100%"))
510 if (start.count(':') == 2)
511 info.startTransparency = start.section(':', -1).toInt();
513 info.startTransparency = 100;
515 if (end.startsWith("-100%,0"))
517 else if (end.startsWith("100%,0"))
519 else if (end.startsWith("0%,100%"))
521 else if (end.startsWith("0%,-100%"))
526 if (end.count(':') == 2)
527 info.endTransparency = end.section(':', -1).toInt();
529 info.endTransparency = 100;
534 QString EffectStackEdit::getWipeString(wipeInfo info)
539 switch (info.start) {
541 start = "-100%,0%:100%x100%";
544 start = "100%,0%:100%x100%";
547 start = "0%,100%:100%x100%";
550 start = "0%,-100%:100%x100%";
553 start = "0%,0%:100%x100%";
556 start.append(':' + QString::number(info.startTransparency));
560 end = "-100%,0%:100%x100%";
563 end = "100%,0%:100%x100%";
566 end = "0%,100%:100%x100%";
569 end = "0%,-100%:100%x100%";
572 end = "0%,0%:100%x100%";
575 end.append(':' + QString::number(info.endTransparency));
576 return QString(start + ";-1=" + end);
579 void EffectStackEdit::collectAllParameters()
581 if (m_valueItems.isEmpty() || m_params.isNull()) return;
582 const QDomElement oldparam = m_params.cloneNode().toElement();
583 QDomElement newparam = oldparam.cloneNode().toElement();
584 QDomNodeList namenode = newparam.elementsByTagName("parameter");
586 for (int i = 0; i < namenode.count() ; i++) {
587 QDomNode pa = namenode.item(i);
588 QDomNode na = pa.firstChildElement("name");
589 QString type = pa.attributes().namedItem("type").nodeValue();
590 QString paramName = i18n(na.toElement().text().toUtf8().data());
591 if (type == "complex")
592 paramName.append("complex");
593 else if (type == "position")
594 paramName.append("position");
595 else if (type == "geometry")
596 paramName.append("geometry");
597 else if (type == "keyframe")
598 paramName.append("keyframe");
599 if (type != "simplekeyframe" && !m_valueItems.contains(paramName)) {
600 kDebug() << "// Param: " << paramName << " NOT FOUND";
605 if (type == "double" || type == "constant") {
606 DoubleParameterWidget *doubleparam = (DoubleParameterWidget*)m_valueItems.value(paramName);
607 setValue = QString::number(doubleparam->getValue());
608 } else if (type == "list") {
609 KComboBox *box = ((Listval*)m_valueItems.value(paramName))->list;
610 setValue = box->itemData(box->currentIndex()).toString();
611 } else if (type == "bool") {
612 QCheckBox *box = ((Boolval*)m_valueItems.value(paramName))->checkBox;
613 setValue = box->checkState() == Qt::Checked ? "1" : "0" ;
614 } else if (type == "color") {
615 ChooseColorWidget *choosecolor = ((ChooseColorWidget*)m_valueItems.value(paramName));
616 setValue = choosecolor->getColor().name();
617 } else if (type == "complex") {
618 ComplexParameter *complex = ((ComplexParameter*)m_valueItems.value(paramName));
619 namenode.item(i) = complex->getParamDesc();
620 } else if (type == "geometry") {
621 if (KdenliveSettings::on_monitor_effects()) {
622 GeometryWidget *geometry = ((GeometryWidget*)m_valueItems.value(paramName));
623 namenode.item(i).toElement().setAttribute("value", geometry->getValue());
625 Geometryval *geom = ((Geometryval*)m_valueItems.value(paramName));
626 namenode.item(i).toElement().setAttribute("value", geom->getValue());
628 } else if (type == "position") {
629 PositionEdit *pedit = ((PositionEdit*)m_valueItems.value(paramName));
630 int pos = pedit->getPosition();
631 setValue = QString::number(pos);
632 if (newparam.attribute("id") == "fadein" || newparam.attribute("id") == "fade_from_black") {
633 // Make sure duration is not longer than clip
636 pedit->setPosition(pos);
638 EffectsList::setParameter(newparam, "in", QString::number(m_in));
639 EffectsList::setParameter(newparam, "out", QString::number(m_in + pos));
641 } else if (newparam.attribute("id") == "fadeout" || newparam.attribute("id") == "fade_to_black") {
642 // Make sure duration is not longer than clip
645 pedit->setPosition(pos);
647 EffectsList::setParameter(newparam, "in", QString::number(m_out - pos));
648 EffectsList::setParameter(newparam, "out", QString::number(m_out));
651 } else if (type == "curve") {
652 KisCurveWidget *curve = ((KisCurveWidget*)m_valueItems.value(paramName));
653 QList<QPointF> points = curve->curve().points();
654 QString number = pa.attributes().namedItem("number").nodeValue();
655 QString inName = pa.attributes().namedItem("inpoints").nodeValue();
656 QString outName = pa.attributes().namedItem("outpoints").nodeValue();
657 int off = pa.attributes().namedItem("min").nodeValue().toInt();
658 int end = pa.attributes().namedItem("max").nodeValue().toInt();
659 EffectsList::setParameter(newparam, number, QString::number(points.count()));
660 for (int j = 0; (j < points.count() && j + off <= end); j++) {
662 in.replace("%i", QString::number(j + off));
663 QString out = outName;
664 out.replace("%i", QString::number(j + off));
665 EffectsList::setParameter(newparam, in, QString::number(points.at(j).x()));
666 EffectsList::setParameter(newparam, out, QString::number(points.at(j).y()));
668 QString depends = pa.attributes().namedItem("depends").nodeValue();
669 if (!depends.isEmpty())
670 meetDependency(paramName, type, EffectsList::parameter(newparam, depends));
671 } else if (type == "bezier_spline") {
672 BezierSplineWidget *widget = (BezierSplineWidget*)m_valueItems.value(paramName);
673 setValue = widget->spline().toString();
674 } else if (type == "corners") {
675 CornersWidget *corners = ((CornersWidget*)m_valueItems.value(paramName));
676 QString xName = pa.attributes().namedItem("xpoints").nodeValue();
677 QString yName = pa.attributes().namedItem("ypoints").nodeValue();
678 QPolygon points = corners->getValue();
680 for (int j = 1; j <= 4; ++j) {
681 p = points.at(j - 1);
682 EffectsList::setParameter(newparam, QString(xName).replace("%i", QString::number(j)), QString::number(p.x()));
683 EffectsList::setParameter(newparam, QString(yName).replace("%i", QString::number(j)), QString::number(p.y()));
685 } else if (type == "wipe") {
686 Wipeval *wp = (Wipeval*)m_valueItems.value(paramName);
688 if (wp->start_left->isChecked())
690 else if (wp->start_right->isChecked())
692 else if (wp->start_up->isChecked())
694 else if (wp->start_down->isChecked())
696 else if (wp->start_center->isChecked())
700 info.startTransparency = wp->start_transp->value();
702 if (wp->end_left->isChecked())
704 else if (wp->end_right->isChecked())
706 else if (wp->end_up->isChecked())
708 else if (wp->end_down->isChecked())
710 else if (wp->end_center->isChecked())
714 info.endTransparency = wp->end_transp->value();
716 setValue = getWipeString(info);
717 } else if ((type == "simplekeyframe" || type == "keyframe") && m_keyframeEditor) {
718 QDomElement elem = pa.toElement();
719 QString realName = i18n(na.toElement().text().toUtf8().data());
720 QString val = m_keyframeEditor->getValue(realName);
721 elem.setAttribute("keyframes", val);
723 if (m_keyframeEditor->isVisibleParam(realName))
724 elem.setAttribute("intimeline", "1");
725 else if (elem.hasAttribute("intimeline"))
726 elem.removeAttribute("intimeline");
727 } else if (type == "url") {
728 KUrlRequester *req = ((Urlval*)m_valueItems.value(paramName))->urlwidget;
729 setValue = req->url().path();
732 if (!setValue.isNull())
733 pa.attributes().namedItem("value").setNodeValue(setValue);
736 emit parameterChanged(oldparam, newparam);
739 void EffectStackEdit::clearAllItems()
742 m_valueItems.clear();
744 /*while (!m_items.isEmpty()) {
745 QWidget *die = m_items.takeFirst();
749 //qDeleteAll(m_uiItems);
751 while ((child = m_vbox->takeAt(0)) != 0) {
752 QWidget *wid = child->widget();
756 m_keyframeEditor = NULL;
760 void EffectStackEdit::slotSyncEffectsPos(int pos)
762 emit syncEffectsPos(pos);