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);
211 for (int i = 0; i < namenode.count() ; i++) {
212 QDomElement pa = namenode.item(i).toElement();
213 QDomElement na = pa.firstChildElement("name");
214 QDomElement commentElem = pa.firstChildElement("comment");
215 QString type = pa.attribute("type");
216 QString paramName = i18n(na.text().toUtf8().data());
218 if (!commentElem.isNull())
219 comment = i18n(commentElem.text().toUtf8().data());
220 QWidget * toFillin = new QWidget(m_baseWidget);
221 QString value = pa.attribute("value").isNull() ?
222 pa.attribute("default") : pa.attribute("value");
224 /** Currently supported parameter types are:
225 * constant (=double): a slider with an integer value (use the "factor" attribute to divide the value so that you can get a double
226 * list: a combobox containing a list of values to choose
228 * complex: designed for keyframe parameters, but old and not finished, do not use
229 * geometry: a rectangle that can be moved & resized, with possible keyframes, used in composite transition
230 * keyframe: a list widget with a list of entries (position and value)
231 * color: a color chooser button
232 * position: a slider representing the position of a frame in the current clip
233 * curve: a single curve representing multiple points
234 * wipe: a widget designed for the wipe transition, allowing to choose a position (left, right, top,...)
237 if (type == "double" || type == "constant") {
240 if (pa.attribute("min").startsWith('%'))
241 min = (int) ProfilesDialog::getStringEval(m_profile, pa.attribute("min"));
243 min = pa.attribute("min").toInt();
244 if (pa.attribute("max").startsWith('%'))
245 max = (int) ProfilesDialog::getStringEval(m_profile, pa.attribute("max"));
247 max = pa.attribute("max").toInt();
249 DoubleParameterWidget *doubleparam = new DoubleParameterWidget(paramName, (int)(value.toDouble() + 0.5), min, max,
250 pa.attribute("default").toInt(), comment, pa.attribute("suffix"), this);
251 m_vbox->addWidget(doubleparam);
252 m_valueItems[paramName] = doubleparam;
253 connect(doubleparam, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
254 connect(this, SIGNAL(showComments()), doubleparam, SLOT(slotShowComment()));
255 } else if (type == "list") {
256 Listval *lsval = new Listval;
257 lsval->setupUi(toFillin);
258 QStringList listitems = pa.attribute("paramlist").split(',');
259 QStringList listitemsdisplay = pa.attribute("paramlistdisplay").split(',');
260 if (listitemsdisplay.count() != listitems.count())
261 listitemsdisplay = listitems;
262 lsval->list->setIconSize(QSize(30, 30));
263 for (int i = 0; i < listitems.count(); i++) {
264 lsval->list->addItem(listitemsdisplay.at(i), listitems.at(i));
265 QString entry = listitems.at(i);
266 if (!entry.isEmpty() && (entry.endsWith(".png") || entry.endsWith(".pgm"))) {
267 if (!EffectStackEdit::iconCache.contains(entry)) {
269 EffectStackEdit::iconCache[entry] = pix.scaled(30, 30);
271 lsval->list->setItemIcon(i, QPixmap::fromImage(iconCache[entry]));
274 if (!value.isEmpty()) lsval->list->setCurrentIndex(listitems.indexOf(value));
275 lsval->name->setText(paramName);
276 m_valueItems[paramName] = lsval;
277 connect(lsval->list, SIGNAL(currentIndexChanged(int)) , this, SLOT(collectAllParameters()));
278 m_uiItems.append(lsval);
279 } else if (type == "bool") {
280 Boolval *bval = new Boolval;
281 bval->setupUi(toFillin);
282 bval->checkBox->setCheckState(value == "0" ? Qt::Unchecked : Qt::Checked);
283 bval->name->setText(paramName);
284 m_valueItems[paramName] = bval;
285 connect(bval->checkBox, SIGNAL(stateChanged(int)) , this, SLOT(collectAllParameters()));
286 m_uiItems.append(bval);
287 } else if (type == "complex") {
288 ComplexParameter *pl = new ComplexParameter;
289 pl->setupParam(d, pa.attribute("name"), 0, 100);
290 m_vbox->addWidget(pl);
291 m_valueItems[paramName+"complex"] = pl;
292 connect(pl, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
293 } else if (type == "geometry") {
294 if (KdenliveSettings::on_monitor_effects()) {
295 GeometryWidget *geometry = new GeometryWidget(m_monitor, m_timecode, pos, isEffect, disable, this);
296 // connect this before setupParam to make sure the monitor scene shows up at startup
297 connect(geometry, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
298 connect(geometry, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
299 if (minFrame == maxFrame)
300 geometry->setupParam(pa, m_in, m_out);
302 geometry->setupParam(pa, minFrame, maxFrame);
303 m_vbox->addWidget(geometry);
304 m_valueItems[paramName+"geometry"] = geometry;
305 connect(geometry, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
306 connect(this, SIGNAL(syncEffectsPos(int)), geometry, SLOT(slotSyncPosition(int)));
308 Geometryval *geo = new Geometryval(m_profile, m_timecode, m_frameSize, pos);
309 if (minFrame == maxFrame)
310 geo->setupParam(pa, m_in, m_out);
312 geo->setupParam(pa, minFrame, maxFrame);
313 m_vbox->addWidget(geo);
314 m_valueItems[paramName+"geometry"] = geo;
315 connect(geo, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
316 connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
317 connect(this, SIGNAL(syncEffectsPos(int)), geo, SLOT(slotSyncPosition(int)));
319 } else if (type == "keyframe" || type == "simplekeyframe") {
320 // keyframe editor widget
321 if (m_keyframeEditor == NULL) {
322 KeyframeEdit *geo = new KeyframeEdit(pa, m_in, m_in + m_out, m_timecode, e.attribute("active_keyframe", "-1").toInt());
323 m_vbox->addWidget(geo);
324 m_valueItems[paramName+"keyframe"] = geo;
325 m_keyframeEditor = geo;
326 connect(geo, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
327 connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
328 connect(this, SIGNAL(showComments()), geo, SIGNAL(showComments()));
330 // we already have a keyframe editor, so just add another column for the new param
331 m_keyframeEditor->addParameter(pa);
333 } else if (type == "color") {
334 if (value.startsWith('#'))
335 value = value.replace('#', "0x");
337 ChooseColorWidget *choosecolor = new ChooseColorWidget(paramName, QColor(value.toUInt(&ok, 16)), this);
338 m_vbox->addWidget(choosecolor);
339 m_valueItems[paramName] = choosecolor;
340 connect(choosecolor, SIGNAL(displayMessage(const QString&, int)), this, SIGNAL(displayMessage(const QString&, int)));
341 connect(choosecolor, SIGNAL(modified()) , this, SLOT(collectAllParameters()));
342 } else if (type == "position") {
343 int pos = value.toInt();
344 if (d.attribute("id") == "fadein" || d.attribute("id") == "fade_from_black") {
346 } else if (d.attribute("id") == "fadeout" || d.attribute("id") == "fade_to_black") {
347 // fadeout position starts from clip end
350 PositionEdit *posedit = new PositionEdit(paramName, pos, 0, m_out - m_in, m_timecode);
351 m_vbox->addWidget(posedit);
352 m_valueItems[paramName+"position"] = posedit;
353 connect(posedit, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
354 } else if (type == "curve") {
355 KisCurveWidget *curve = new KisCurveWidget(this);
356 curve->setMaxPoints(pa.attribute("max").toInt());
357 QList<QPointF> points;
358 int number = EffectsList::parameter(e, pa.attribute("number")).toInt();
359 QString inName = pa.attribute("inpoints");
360 QString outName = pa.attribute("outpoints");
361 int start = pa.attribute("min").toInt();
362 for (int j = start; j <= number; j++) {
364 in.replace("%i", QString::number(j));
365 QString out = outName;
366 out.replace("%i", QString::number(j));
367 points << QPointF(EffectsList::parameter(e, in).toDouble(), EffectsList::parameter(e, out).toDouble());
369 if (!points.isEmpty())
370 curve->setCurve(KisCubicCurve(points));
371 QSpinBox *spinin = new QSpinBox();
372 spinin->setRange(0, 1000);
373 QSpinBox *spinout = new QSpinBox();
374 spinout->setRange(0, 1000);
375 curve->setupInOutControls(spinin, spinout, 0, 1000);
376 m_vbox->addWidget(curve);
377 m_vbox->addWidget(spinin);
378 m_vbox->addWidget(spinout);
380 connect(curve, SIGNAL(modified()), this, SLOT(collectAllParameters()));
381 m_valueItems[paramName] = curve;
383 QString depends = pa.attribute("depends");
384 if (!depends.isEmpty())
385 meetDependency(paramName, type, EffectsList::parameter(e, depends));
386 } else if (type == "bezier_spline") {
387 BezierSplineWidget *widget = new BezierSplineWidget(this);
388 CubicBezierSpline spline;
389 spline.fromString(value);
390 widget->setSpline(spline);
392 m_vbox->addWidget(widget);
393 m_valueItems[paramName] = widget;
394 connect(widget, SIGNAL(modified()), this, SLOT(collectAllParameters()));
395 } else if (type == "corners") {
396 CornersWidget *corners = new CornersWidget(m_monitor, pos, isEffect, pa.attribute("factor").toInt(), this);
397 connect(corners, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
398 if (minFrame == maxFrame)
399 corners->setRange(m_in, m_out);
401 corners->setRange(minFrame, maxFrame);
403 QString xName = pa.attribute("xpoints");
404 QString yName = pa.attribute("ypoints");
407 for (int j = 1; j <= 4; ++j) {
408 x = EffectsList::parameter(e, QString(xName).replace("%i", QString::number(j))).toInt();
409 y = EffectsList::parameter(e, QString(yName).replace("%i", QString::number(j))).toInt();
410 points << QPoint(x, y);
412 corners->setValue(points);
414 m_vbox->addWidget(corners);
415 connect(corners, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
416 m_valueItems[paramName] = corners;
417 } else if (type == "wipe") {
418 Wipeval *wpval = new Wipeval;
419 wpval->setupUi(toFillin);
420 wipeInfo w = getWipeInfo(value);
423 wpval->start_up->setChecked(true);
426 wpval->start_down->setChecked(true);
429 wpval->start_right->setChecked(true);
432 wpval->start_left->setChecked(true);
435 wpval->start_center->setChecked(true);
440 wpval->end_up->setChecked(true);
443 wpval->end_down->setChecked(true);
446 wpval->end_right->setChecked(true);
449 wpval->end_left->setChecked(true);
452 wpval->end_center->setChecked(true);
455 wpval->start_transp->setValue(w.startTransparency);
456 wpval->end_transp->setValue(w.endTransparency);
457 m_valueItems[paramName] = wpval;
458 connect(wpval->end_up, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
459 connect(wpval->end_down, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
460 connect(wpval->end_left, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
461 connect(wpval->end_right, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
462 connect(wpval->end_center, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
463 connect(wpval->start_up, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
464 connect(wpval->start_down, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
465 connect(wpval->start_left, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
466 connect(wpval->start_right, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
467 connect(wpval->start_center, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
468 connect(wpval->start_transp, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
469 connect(wpval->end_transp, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
470 //wpval->title->setTitle(na.toElement().text());
471 m_uiItems.append(wpval);
472 } else if (type == "url") {
473 Urlval *cval = new Urlval;
474 cval->setupUi(toFillin);
475 cval->label->setText(paramName);
476 cval->urlwidget->fileDialog()->setFilter(ProjectList::getExtensions());
477 m_valueItems[paramName] = cval;
478 cval->urlwidget->setUrl(KUrl(value));
479 connect(cval->urlwidget, SIGNAL(returnPressed()) , this, SLOT(collectAllParameters()));
480 connect(cval->urlwidget, SIGNAL(urlSelected(const KUrl&)) , this, SLOT(collectAllParameters()));
481 m_uiItems.append(cval);
488 m_vbox->addWidget(toFillin);
492 m_vbox->addStretch();
494 if (m_keyframeEditor)
495 m_keyframeEditor->checkVisibleParam();
498 wipeInfo EffectStackEdit::getWipeInfo(QString value)
501 QString start = value.section(';', 0, 0);
502 QString end = value.section(';', 1, 1).section('=', 1, 1);
504 if (start.startsWith("-100%,0"))
506 else if (start.startsWith("100%,0"))
508 else if (start.startsWith("0%,100%"))
510 else if (start.startsWith("0%,-100%"))
515 if (start.count(':') == 2)
516 info.startTransparency = start.section(':', -1).toInt();
518 info.startTransparency = 100;
520 if (end.startsWith("-100%,0"))
522 else if (end.startsWith("100%,0"))
524 else if (end.startsWith("0%,100%"))
526 else if (end.startsWith("0%,-100%"))
531 if (end.count(':') == 2)
532 info.endTransparency = end.section(':', -1).toInt();
534 info.endTransparency = 100;
539 QString EffectStackEdit::getWipeString(wipeInfo info)
544 switch (info.start) {
546 start = "-100%,0%:100%x100%";
549 start = "100%,0%:100%x100%";
552 start = "0%,100%:100%x100%";
555 start = "0%,-100%:100%x100%";
558 start = "0%,0%:100%x100%";
561 start.append(':' + QString::number(info.startTransparency));
565 end = "-100%,0%:100%x100%";
568 end = "100%,0%:100%x100%";
571 end = "0%,100%:100%x100%";
574 end = "0%,-100%:100%x100%";
577 end = "0%,0%:100%x100%";
580 end.append(':' + QString::number(info.endTransparency));
581 return QString(start + ";-1=" + end);
584 void EffectStackEdit::collectAllParameters()
586 if (m_valueItems.isEmpty() || m_params.isNull()) return;
587 const QDomElement oldparam = m_params.cloneNode().toElement();
588 QDomElement newparam = oldparam.cloneNode().toElement();
589 QDomNodeList namenode = newparam.elementsByTagName("parameter");
591 for (int i = 0; i < namenode.count() ; i++) {
592 QDomNode pa = namenode.item(i);
593 QDomNode na = pa.firstChildElement("name");
594 QString type = pa.attributes().namedItem("type").nodeValue();
595 QString paramName = i18n(na.toElement().text().toUtf8().data());
596 if (type == "complex")
597 paramName.append("complex");
598 else if (type == "position")
599 paramName.append("position");
600 else if (type == "geometry")
601 paramName.append("geometry");
602 else if (type == "keyframe")
603 paramName.append("keyframe");
604 if (type != "simplekeyframe" && !m_valueItems.contains(paramName)) {
605 kDebug() << "// Param: " << paramName << " NOT FOUND";
610 if (type == "double" || type == "constant") {
611 DoubleParameterWidget *doubleparam = (DoubleParameterWidget*)m_valueItems.value(paramName);
612 setValue = QString::number(doubleparam->getValue());
613 } else if (type == "list") {
614 KComboBox *box = ((Listval*)m_valueItems.value(paramName))->list;
615 setValue = box->itemData(box->currentIndex()).toString();
616 } else if (type == "bool") {
617 QCheckBox *box = ((Boolval*)m_valueItems.value(paramName))->checkBox;
618 setValue = box->checkState() == Qt::Checked ? "1" : "0" ;
619 } else if (type == "color") {
620 ChooseColorWidget *choosecolor = ((ChooseColorWidget*)m_valueItems.value(paramName));
621 setValue = choosecolor->getColor().name();
622 } else if (type == "complex") {
623 ComplexParameter *complex = ((ComplexParameter*)m_valueItems.value(paramName));
624 namenode.item(i) = complex->getParamDesc();
625 } else if (type == "geometry") {
626 if (KdenliveSettings::on_monitor_effects()) {
627 GeometryWidget *geometry = ((GeometryWidget*)m_valueItems.value(paramName));
628 namenode.item(i).toElement().setAttribute("value", geometry->getValue());
630 Geometryval *geom = ((Geometryval*)m_valueItems.value(paramName));
631 namenode.item(i).toElement().setAttribute("value", geom->getValue());
633 } else if (type == "position") {
634 PositionEdit *pedit = ((PositionEdit*)m_valueItems.value(paramName));
635 int pos = pedit->getPosition();
636 setValue = QString::number(pos);
637 if (newparam.attribute("id") == "fadein" || newparam.attribute("id") == "fade_from_black") {
638 // Make sure duration is not longer than clip
641 pedit->setPosition(pos);
643 EffectsList::setParameter(newparam, "in", QString::number(m_in));
644 EffectsList::setParameter(newparam, "out", QString::number(m_in + pos));
646 } else if (newparam.attribute("id") == "fadeout" || newparam.attribute("id") == "fade_to_black") {
647 // Make sure duration is not longer than clip
650 pedit->setPosition(pos);
652 EffectsList::setParameter(newparam, "in", QString::number(m_out - pos));
653 EffectsList::setParameter(newparam, "out", QString::number(m_out));
656 } else if (type == "curve") {
657 KisCurveWidget *curve = ((KisCurveWidget*)m_valueItems.value(paramName));
658 QList<QPointF> points = curve->curve().points();
659 QString number = pa.attributes().namedItem("number").nodeValue();
660 QString inName = pa.attributes().namedItem("inpoints").nodeValue();
661 QString outName = pa.attributes().namedItem("outpoints").nodeValue();
662 int off = pa.attributes().namedItem("min").nodeValue().toInt();
663 int end = pa.attributes().namedItem("max").nodeValue().toInt();
664 EffectsList::setParameter(newparam, number, QString::number(points.count()));
665 for (int j = 0; (j < points.count() && j + off <= end); j++) {
667 in.replace("%i", QString::number(j + off));
668 QString out = outName;
669 out.replace("%i", QString::number(j + off));
670 EffectsList::setParameter(newparam, in, QString::number(points.at(j).x()));
671 EffectsList::setParameter(newparam, out, QString::number(points.at(j).y()));
673 QString depends = pa.attributes().namedItem("depends").nodeValue();
674 if (!depends.isEmpty())
675 meetDependency(paramName, type, EffectsList::parameter(newparam, depends));
676 } else if (type == "bezier_spline") {
677 BezierSplineWidget *widget = (BezierSplineWidget*)m_valueItems.value(paramName);
678 setValue = widget->spline().toString();
679 } else if (type == "corners") {
680 CornersWidget *corners = ((CornersWidget*)m_valueItems.value(paramName));
681 QString xName = pa.attributes().namedItem("xpoints").nodeValue();
682 QString yName = pa.attributes().namedItem("ypoints").nodeValue();
683 QPolygon points = corners->getValue();
685 for (int j = 1; j <= 4; ++j) {
686 p = points.at(j - 1);
687 EffectsList::setParameter(newparam, QString(xName).replace("%i", QString::number(j)), QString::number(p.x()));
688 EffectsList::setParameter(newparam, QString(yName).replace("%i", QString::number(j)), QString::number(p.y()));
690 } else if (type == "wipe") {
691 Wipeval *wp = (Wipeval*)m_valueItems.value(paramName);
693 if (wp->start_left->isChecked())
695 else if (wp->start_right->isChecked())
697 else if (wp->start_up->isChecked())
699 else if (wp->start_down->isChecked())
701 else if (wp->start_center->isChecked())
705 info.startTransparency = wp->start_transp->value();
707 if (wp->end_left->isChecked())
709 else if (wp->end_right->isChecked())
711 else if (wp->end_up->isChecked())
713 else if (wp->end_down->isChecked())
715 else if (wp->end_center->isChecked())
719 info.endTransparency = wp->end_transp->value();
721 setValue = getWipeString(info);
722 } else if ((type == "simplekeyframe" || type == "keyframe") && m_keyframeEditor) {
723 QDomElement elem = pa.toElement();
724 QString realName = i18n(na.toElement().text().toUtf8().data());
725 QString val = m_keyframeEditor->getValue(realName);
726 elem.setAttribute("keyframes", val);
728 if (m_keyframeEditor->isVisibleParam(realName))
729 elem.setAttribute("intimeline", "1");
730 else if (elem.hasAttribute("intimeline"))
731 elem.removeAttribute("intimeline");
732 } else if (type == "url") {
733 KUrlRequester *req = ((Urlval*)m_valueItems.value(paramName))->urlwidget;
734 setValue = req->url().path();
737 if (!setValue.isNull())
738 pa.attributes().namedItem("value").setNodeValue(setValue);
741 emit parameterChanged(oldparam, newparam);
744 void EffectStackEdit::clearAllItems()
747 m_valueItems.clear();
749 /*while (!m_items.isEmpty()) {
750 QWidget *die = m_items.takeFirst();
754 //qDeleteAll(m_uiItems);
756 while ((child = m_vbox->takeAt(0)) != 0) {
757 QWidget *wid = child->widget();
761 m_keyframeEditor = NULL;
765 void EffectStackEdit::slotSyncEffectsPos(int pos)
767 emit syncEffectsPos(pos);