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 "rotoscoping/rotowidget.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 == 3 ? 4 : color), 0.8)));
153 } else if (type == "bezier_spline") {
154 BezierSplineWidget *widget = (BezierSplineWidget*)m_valueItems[name];
156 widget->setMode((BezierSplineWidget::CurveModes)((int)(value.toDouble() * 10)));
161 void EffectStackEdit::updateProjectFormat(MltVideoProfile profile, Timecode t)
167 void EffectStackEdit::updateParameter(const QString &name, const QString &value)
169 m_params.setAttribute(name, value);
171 if (name == "disable") {
172 // if effect is disabled, disable parameters widget
173 bool enabled = value.toInt() == 0 || !KdenliveSettings::disable_effect_parameters();
175 emit effectStateChanged(enabled);
179 void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, int out, bool isEffect)
182 if (m_keyframeEditor) delete m_keyframeEditor;
183 m_keyframeEditor = NULL;
187 if (m_params.isNull()) {
188 kDebug() << "// EMPTY EFFECT STACK";
192 QDomNodeList namenode = m_params.elementsByTagName("parameter");
193 QDomElement e = m_params.toElement();
194 const int minFrame = e.attribute("start").toInt();
195 const int maxFrame = e.attribute("end").toInt();
197 bool disable = d.attribute("disable") == "1" && KdenliveSettings::disable_effect_parameters();
198 setEnabled(!disable);
203 for (int i = 0; i < namenode.count() ; i++) {
204 QDomElement pa = namenode.item(i).toElement();
205 QDomElement na = pa.firstChildElement("name");
206 QDomElement commentElem = pa.firstChildElement("comment");
207 QString type = pa.attribute("type");
208 QString paramName = i18n(na.text().toUtf8().data());
210 if (!commentElem.isNull())
211 comment = i18n(commentElem.text().toUtf8().data());
212 QWidget * toFillin = new QWidget(m_baseWidget);
213 QString value = pa.attribute("value").isNull() ?
214 pa.attribute("default") : pa.attribute("value");
216 /** Currently supported parameter types are:
217 * constant (=double): a slider with an integer value (use the "factor" attribute to divide the value so that you can get a double
218 * list: a combobox containing a list of values to choose
220 * complex: designed for keyframe parameters, but old and not finished, do not use
221 * geometry: a rectangle that can be moved & resized, with possible keyframes, used in composite transition
222 * keyframe: a list widget with a list of entries (position and value)
223 * color: a color chooser button
224 * position: a slider representing the position of a frame in the current clip
225 * curve: a single curve representing multiple points
226 * wipe: a widget designed for the wipe transition, allowing to choose a position (left, right, top,...)
229 if (type == "double" || type == "constant") {
232 if (pa.attribute("min").startsWith('%'))
233 min = (int) ProfilesDialog::getStringEval(m_profile, pa.attribute("min"));
235 min = pa.attribute("min").toInt();
236 if (pa.attribute("max").startsWith('%'))
237 max = (int) ProfilesDialog::getStringEval(m_profile, pa.attribute("max"));
239 max = pa.attribute("max").toInt();
241 DoubleParameterWidget *doubleparam = new DoubleParameterWidget(paramName, (int)(value.toDouble() + 0.5), min, max,
242 pa.attribute("default").toInt(), comment, pa.attribute("suffix"), this);
243 m_vbox->addWidget(doubleparam);
244 m_valueItems[paramName] = doubleparam;
245 connect(doubleparam, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
246 connect(this, SIGNAL(showComments(bool)), doubleparam, SLOT(slotShowComment(bool)));
247 } else if (type == "list") {
248 Listval *lsval = new Listval;
249 lsval->setupUi(toFillin);
250 QStringList listitems = pa.attribute("paramlist").split(',');
251 QDomElement list = pa.firstChildElement("paramlistdisplay");
252 QStringList listitemsdisplay;
253 if (!list.isNull()) listitemsdisplay = i18n(list.text().toUtf8().data()).split(',');
254 else listitemsdisplay = i18n(pa.attribute("paramlistdisplay").toUtf8().data()).split(',');
255 if (listitemsdisplay.count() != listitems.count())
256 listitemsdisplay = listitems;
257 lsval->list->setIconSize(QSize(30, 30));
258 for (int i = 0; i < listitems.count(); i++) {
259 lsval->list->addItem(listitemsdisplay.at(i), listitems.at(i));
260 QString entry = listitems.at(i);
261 if (!entry.isEmpty() && (entry.endsWith(".png") || entry.endsWith(".pgm"))) {
262 if (!EffectStackEdit::iconCache.contains(entry)) {
264 EffectStackEdit::iconCache[entry] = pix.scaled(30, 30);
266 lsval->list->setItemIcon(i, QPixmap::fromImage(iconCache[entry]));
269 if (!value.isEmpty()) lsval->list->setCurrentIndex(listitems.indexOf(value));
270 lsval->name->setText(paramName);
271 lsval->labelComment->setText(comment);
272 lsval->widgetComment->setHidden(true);
273 m_valueItems[paramName] = lsval;
274 connect(lsval->list, SIGNAL(currentIndexChanged(int)) , this, SLOT(collectAllParameters()));
275 if (!comment.isEmpty())
276 connect(this, SIGNAL(showComments(bool)), lsval->widgetComment, SLOT(setVisible(bool)));
277 m_uiItems.append(lsval);
278 } else if (type == "bool") {
279 Boolval *bval = new Boolval;
280 bval->setupUi(toFillin);
281 bval->checkBox->setCheckState(value == "0" ? Qt::Unchecked : Qt::Checked);
282 bval->name->setText(paramName);
283 bval->labelComment->setText(comment);
284 bval->widgetComment->setHidden(true);
285 m_valueItems[paramName] = bval;
286 connect(bval->checkBox, SIGNAL(stateChanged(int)) , this, SLOT(collectAllParameters()));
287 if (!comment.isEmpty())
288 connect(this, SIGNAL(showComments(bool)), bval->widgetComment, SLOT(setVisible(bool)));
289 m_uiItems.append(bval);
290 } else if (type == "complex") {
291 ComplexParameter *pl = new ComplexParameter;
292 pl->setupParam(d, pa.attribute("name"), 0, 100);
293 m_vbox->addWidget(pl);
294 m_valueItems[paramName+"complex"] = pl;
295 connect(pl, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
296 } else if (type == "geometry") {
297 if (KdenliveSettings::on_monitor_effects()) {
298 GeometryWidget *geometry = new GeometryWidget(m_monitor, m_timecode, pos, isEffect, this);
299 geometry->slotShowScene(!disable);
300 // connect this before setupParam to make sure the monitor scene shows up at startup
301 connect(geometry, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
302 connect(geometry, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
303 if (minFrame == maxFrame)
304 geometry->setupParam(pa, m_in, m_out);
306 geometry->setupParam(pa, minFrame, maxFrame);
307 m_vbox->addWidget(geometry);
308 m_valueItems[paramName+"geometry"] = geometry;
309 connect(geometry, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
310 connect(this, SIGNAL(syncEffectsPos(int)), geometry, SLOT(slotSyncPosition(int)));
311 connect(this, SIGNAL(effectStateChanged(bool)), geometry, SLOT(slotShowScene(bool)));
313 Geometryval *geo = new Geometryval(m_profile, m_timecode, m_frameSize, pos);
314 if (minFrame == maxFrame)
315 geo->setupParam(pa, m_in, m_out);
317 geo->setupParam(pa, minFrame, maxFrame);
318 m_vbox->addWidget(geo);
319 m_valueItems[paramName+"geometry"] = geo;
320 connect(geo, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
321 connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
322 connect(this, SIGNAL(syncEffectsPos(int)), geo, SLOT(slotSyncPosition(int)));
324 } else if (type == "keyframe" || type == "simplekeyframe") {
325 // keyframe editor widget
326 if (m_keyframeEditor == NULL) {
328 if (pa.attribute("widget") == "corners") {
329 // we want a corners-keyframe-widget
330 CornersWidget *corners = new CornersWidget(m_monitor, pa, m_in, m_in + m_out, m_timecode, e.attribute("active_keyframe", "-1").toInt(), this);
331 corners->slotShowScene(!disable);
332 connect(corners, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
333 connect(this, SIGNAL(effectStateChanged(bool)), corners, SLOT(slotShowScene(bool)));
334 connect(this, SIGNAL(syncEffectsPos(int)), corners, SLOT(slotSyncPosition(int)));
335 geo = static_cast<KeyframeEdit *>(corners);
337 geo = new KeyframeEdit(pa, m_in, m_in + m_out, m_timecode, e.attribute("active_keyframe", "-1").toInt());
339 m_vbox->addWidget(geo);
340 m_valueItems[paramName+"keyframe"] = geo;
341 m_keyframeEditor = geo;
342 connect(geo, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
343 connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
344 connect(this, SIGNAL(showComments(bool)), geo, SIGNAL(showComments(bool)));
346 // we already have a keyframe editor, so just add another column for the new param
347 m_keyframeEditor->addParameter(pa);
349 } else if (type == "color") {
350 if (value.startsWith('#'))
351 value = value.replace('#', "0x");
353 ChooseColorWidget *choosecolor = new ChooseColorWidget(paramName, QColor(value.toUInt(&ok, 16)), this);
354 m_vbox->addWidget(choosecolor);
355 m_valueItems[paramName] = choosecolor;
356 connect(choosecolor, SIGNAL(displayMessage(const QString&, int)), this, SIGNAL(displayMessage(const QString&, int)));
357 connect(choosecolor, SIGNAL(modified()) , this, SLOT(collectAllParameters()));
358 } else if (type == "position") {
359 int pos = value.toInt();
360 if (d.attribute("id") == "fadein" || d.attribute("id") == "fade_from_black") {
362 } else if (d.attribute("id") == "fadeout" || d.attribute("id") == "fade_to_black") {
363 // fadeout position starts from clip end
366 PositionEdit *posedit = new PositionEdit(paramName, pos, 0, m_out - m_in, m_timecode);
367 m_vbox->addWidget(posedit);
368 m_valueItems[paramName+"position"] = posedit;
369 connect(posedit, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
370 } else if (type == "curve") {
371 KisCurveWidget *curve = new KisCurveWidget(this);
372 curve->setMaxPoints(pa.attribute("max").toInt());
373 QList<QPointF> points;
374 int number = EffectsList::parameter(e, pa.attribute("number")).toInt();
375 QString inName = pa.attribute("inpoints");
376 QString outName = pa.attribute("outpoints");
377 int start = pa.attribute("min").toInt();
378 for (int j = start; j <= number; j++) {
380 in.replace("%i", QString::number(j));
381 QString out = outName;
382 out.replace("%i", QString::number(j));
383 points << QPointF(EffectsList::parameter(e, in).toDouble(), EffectsList::parameter(e, out).toDouble());
385 if (!points.isEmpty())
386 curve->setCurve(KisCubicCurve(points));
387 QSpinBox *spinin = new QSpinBox();
388 spinin->setRange(0, 1000);
389 QSpinBox *spinout = new QSpinBox();
390 spinout->setRange(0, 1000);
391 curve->setupInOutControls(spinin, spinout, 0, 1000);
392 m_vbox->addWidget(curve);
393 m_vbox->addWidget(spinin);
394 m_vbox->addWidget(spinout);
396 connect(curve, SIGNAL(modified()), this, SLOT(collectAllParameters()));
397 m_valueItems[paramName] = curve;
399 QString depends = pa.attribute("depends");
400 if (!depends.isEmpty())
401 meetDependency(paramName, type, EffectsList::parameter(e, depends));
402 } else if (type == "bezier_spline") {
403 BezierSplineWidget *widget = new BezierSplineWidget(value, this);
405 m_vbox->addWidget(widget);
406 m_valueItems[paramName] = widget;
407 connect(widget, SIGNAL(modified()), this, SLOT(collectAllParameters()));
408 QString depends = pa.attribute("depends");
409 if (!depends.isEmpty())
410 meetDependency(paramName, type, EffectsList::parameter(e, depends));
411 } else if (type == "roto-spline") {
412 RotoWidget *roto = new RotoWidget(value, m_monitor, m_in, m_out, this);
413 roto->slotShowScene(!disable);
414 connect(roto, SIGNAL(valueChanged()), this, SLOT(collectAllParameters()));
415 connect(roto, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
416 connect(this, SIGNAL(syncEffectsPos(int)), roto, SLOT(slotSyncPosition(int)));
417 connect(this, SIGNAL(effectStateChanged(bool)), roto, SLOT(slotShowScene(bool)));
418 m_vbox->addWidget(roto);
419 m_valueItems[paramName] = roto;
420 } else if (type == "wipe") {
421 Wipeval *wpval = new Wipeval;
422 wpval->setupUi(toFillin);
423 wipeInfo w = getWipeInfo(value);
426 wpval->start_up->setChecked(true);
429 wpval->start_down->setChecked(true);
432 wpval->start_right->setChecked(true);
435 wpval->start_left->setChecked(true);
438 wpval->start_center->setChecked(true);
443 wpval->end_up->setChecked(true);
446 wpval->end_down->setChecked(true);
449 wpval->end_right->setChecked(true);
452 wpval->end_left->setChecked(true);
455 wpval->end_center->setChecked(true);
458 wpval->start_transp->setValue(w.startTransparency);
459 wpval->end_transp->setValue(w.endTransparency);
460 m_valueItems[paramName] = wpval;
461 connect(wpval->end_up, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
462 connect(wpval->end_down, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
463 connect(wpval->end_left, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
464 connect(wpval->end_right, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
465 connect(wpval->end_center, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
466 connect(wpval->start_up, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
467 connect(wpval->start_down, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
468 connect(wpval->start_left, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
469 connect(wpval->start_right, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
470 connect(wpval->start_center, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
471 connect(wpval->start_transp, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
472 connect(wpval->end_transp, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
473 //wpval->title->setTitle(na.toElement().text());
474 m_uiItems.append(wpval);
475 } else if (type == "url") {
476 Urlval *cval = new Urlval;
477 cval->setupUi(toFillin);
478 cval->label->setText(paramName);
479 cval->urlwidget->fileDialog()->setFilter(ProjectList::getExtensions());
480 m_valueItems[paramName] = cval;
481 cval->urlwidget->setUrl(KUrl(value));
482 connect(cval->urlwidget, SIGNAL(returnPressed()) , this, SLOT(collectAllParameters()));
483 connect(cval->urlwidget, SIGNAL(urlSelected(const KUrl&)) , this, SLOT(collectAllParameters()));
484 m_uiItems.append(cval);
491 m_vbox->addWidget(toFillin);
495 m_vbox->addStretch();
497 if (m_keyframeEditor)
498 m_keyframeEditor->checkVisibleParam();
501 wipeInfo EffectStackEdit::getWipeInfo(QString value)
504 QString start = value.section(';', 0, 0);
505 QString end = value.section(';', 1, 1).section('=', 1, 1);
507 if (start.startsWith("-100%,0"))
509 else if (start.startsWith("100%,0"))
511 else if (start.startsWith("0%,100%"))
513 else if (start.startsWith("0%,-100%"))
518 if (start.count(':') == 2)
519 info.startTransparency = start.section(':', -1).toInt();
521 info.startTransparency = 100;
523 if (end.startsWith("-100%,0"))
525 else if (end.startsWith("100%,0"))
527 else if (end.startsWith("0%,100%"))
529 else if (end.startsWith("0%,-100%"))
534 if (end.count(':') == 2)
535 info.endTransparency = end.section(':', -1).toInt();
537 info.endTransparency = 100;
542 QString EffectStackEdit::getWipeString(wipeInfo info)
547 switch (info.start) {
549 start = "-100%,0%:100%x100%";
552 start = "100%,0%:100%x100%";
555 start = "0%,100%:100%x100%";
558 start = "0%,-100%:100%x100%";
561 start = "0%,0%:100%x100%";
564 start.append(':' + QString::number(info.startTransparency));
568 end = "-100%,0%:100%x100%";
571 end = "100%,0%:100%x100%";
574 end = "0%,100%:100%x100%";
577 end = "0%,-100%:100%x100%";
580 end = "0%,0%:100%x100%";
583 end.append(':' + QString::number(info.endTransparency));
584 return QString(start + ";-1=" + end);
587 void EffectStackEdit::collectAllParameters()
589 if (m_valueItems.isEmpty() || m_params.isNull()) return;
590 const QDomElement oldparam = m_params.cloneNode().toElement();
591 QDomElement newparam = oldparam.cloneNode().toElement();
592 QDomNodeList namenode = newparam.elementsByTagName("parameter");
594 for (int i = 0; i < namenode.count() ; i++) {
595 QDomNode pa = namenode.item(i);
596 QDomNode na = pa.firstChildElement("name");
597 QString type = pa.attributes().namedItem("type").nodeValue();
598 QString paramName = i18n(na.toElement().text().toUtf8().data());
599 if (type == "complex")
600 paramName.append("complex");
601 else if (type == "position")
602 paramName.append("position");
603 else if (type == "geometry")
604 paramName.append("geometry");
605 else if (type == "keyframe")
606 paramName.append("keyframe");
607 if (type != "simplekeyframe" && !m_valueItems.contains(paramName)) {
608 kDebug() << "// Param: " << paramName << " NOT FOUND";
613 if (type == "double" || type == "constant") {
614 DoubleParameterWidget *doubleparam = (DoubleParameterWidget*)m_valueItems.value(paramName);
615 setValue = QString::number(doubleparam->getValue());
616 } else if (type == "list") {
617 KComboBox *box = ((Listval*)m_valueItems.value(paramName))->list;
618 setValue = box->itemData(box->currentIndex()).toString();
619 } else if (type == "bool") {
620 QCheckBox *box = ((Boolval*)m_valueItems.value(paramName))->checkBox;
621 setValue = box->checkState() == Qt::Checked ? "1" : "0" ;
622 } else if (type == "color") {
623 ChooseColorWidget *choosecolor = ((ChooseColorWidget*)m_valueItems.value(paramName));
624 setValue = choosecolor->getColor().name();
625 } else if (type == "complex") {
626 ComplexParameter *complex = ((ComplexParameter*)m_valueItems.value(paramName));
627 namenode.item(i) = complex->getParamDesc();
628 } else if (type == "geometry") {
629 if (KdenliveSettings::on_monitor_effects()) {
630 GeometryWidget *geometry = ((GeometryWidget*)m_valueItems.value(paramName));
631 namenode.item(i).toElement().setAttribute("value", geometry->getValue());
633 Geometryval *geom = ((Geometryval*)m_valueItems.value(paramName));
634 namenode.item(i).toElement().setAttribute("value", geom->getValue());
636 } else if (type == "position") {
637 PositionEdit *pedit = ((PositionEdit*)m_valueItems.value(paramName));
638 int pos = pedit->getPosition();
639 setValue = QString::number(pos);
640 if (newparam.attribute("id") == "fadein" || newparam.attribute("id") == "fade_from_black") {
641 // Make sure duration is not longer than clip
644 pedit->setPosition(pos);
646 EffectsList::setParameter(newparam, "in", QString::number(m_in));
647 EffectsList::setParameter(newparam, "out", QString::number(m_in + pos));
649 } else if (newparam.attribute("id") == "fadeout" || newparam.attribute("id") == "fade_to_black") {
650 // Make sure duration is not longer than clip
653 pedit->setPosition(pos);
655 EffectsList::setParameter(newparam, "in", QString::number(m_out - pos));
656 EffectsList::setParameter(newparam, "out", QString::number(m_out));
659 } else if (type == "curve") {
660 KisCurveWidget *curve = ((KisCurveWidget*)m_valueItems.value(paramName));
661 QList<QPointF> points = curve->curve().points();
662 QString number = pa.attributes().namedItem("number").nodeValue();
663 QString inName = pa.attributes().namedItem("inpoints").nodeValue();
664 QString outName = pa.attributes().namedItem("outpoints").nodeValue();
665 int off = pa.attributes().namedItem("min").nodeValue().toInt();
666 int end = pa.attributes().namedItem("max").nodeValue().toInt();
667 EffectsList::setParameter(newparam, number, QString::number(points.count()));
668 for (int j = 0; (j < points.count() && j + off <= end); j++) {
670 in.replace("%i", QString::number(j + off));
671 QString out = outName;
672 out.replace("%i", QString::number(j + off));
673 EffectsList::setParameter(newparam, in, QString::number(points.at(j).x()));
674 EffectsList::setParameter(newparam, out, QString::number(points.at(j).y()));
676 QString depends = pa.attributes().namedItem("depends").nodeValue();
677 if (!depends.isEmpty())
678 meetDependency(paramName, type, EffectsList::parameter(newparam, depends));
679 } else if (type == "bezier_spline") {
680 BezierSplineWidget *widget = (BezierSplineWidget*)m_valueItems.value(paramName);
681 setValue = widget->spline();
682 QString depends = pa.attributes().namedItem("depends").nodeValue();
683 if (!depends.isEmpty())
684 meetDependency(paramName, type, EffectsList::parameter(newparam, depends));
685 } else if (type == "roto-spline") {
686 RotoWidget *widget = static_cast<RotoWidget *>(m_valueItems.value(paramName));
687 setValue = widget->getSpline();
688 } else if (type == "wipe") {
689 Wipeval *wp = (Wipeval*)m_valueItems.value(paramName);
691 if (wp->start_left->isChecked())
693 else if (wp->start_right->isChecked())
695 else if (wp->start_up->isChecked())
697 else if (wp->start_down->isChecked())
699 else if (wp->start_center->isChecked())
703 info.startTransparency = wp->start_transp->value();
705 if (wp->end_left->isChecked())
707 else if (wp->end_right->isChecked())
709 else if (wp->end_up->isChecked())
711 else if (wp->end_down->isChecked())
713 else if (wp->end_center->isChecked())
717 info.endTransparency = wp->end_transp->value();
719 setValue = getWipeString(info);
720 } else if ((type == "simplekeyframe" || type == "keyframe") && m_keyframeEditor) {
721 QDomElement elem = pa.toElement();
722 QString realName = i18n(na.toElement().text().toUtf8().data());
723 QString val = m_keyframeEditor->getValue(realName);
724 elem.setAttribute("keyframes", val);
726 if (m_keyframeEditor->isVisibleParam(realName))
727 elem.setAttribute("intimeline", "1");
728 else if (elem.hasAttribute("intimeline"))
729 elem.removeAttribute("intimeline");
730 } else if (type == "url") {
731 KUrlRequester *req = ((Urlval*)m_valueItems.value(paramName))->urlwidget;
732 setValue = req->url().path();
735 if (!setValue.isNull())
736 pa.attributes().namedItem("value").setNodeValue(setValue);
739 emit parameterChanged(oldparam, newparam);
742 void EffectStackEdit::clearAllItems()
745 m_valueItems.clear();
747 /*while (!m_items.isEmpty()) {
748 QWidget *die = m_items.takeFirst();
752 //qDeleteAll(m_uiItems);
754 while ((child = m_vbox->takeAt(0)) != 0) {
755 QWidget *wid = child->widget();
759 m_keyframeEditor = NULL;
763 void EffectStackEdit::slotSyncEffectsPos(int pos)
765 emit syncEffectsPos(pos);