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"
39 #include "rotoscoping/rotowidget.h"
44 #include <KFileDialog>
46 #include <QVBoxLayout>
48 #include <QPushButton>
50 #include <QScrollArea>
53 class Boolval: public QWidget, public Ui::Boolval_UI
57 class Listval: public QWidget, public Ui::Listval_UI
61 class Wipeval: public QWidget, public Ui::Wipeval_UI
65 class Urlval: public QWidget, public Ui::Urlval_UI
69 QMap<QString, QImage> EffectStackEdit::iconCache;
71 EffectStackEdit::EffectStackEdit(Monitor *monitor, QWidget *parent) :
75 m_frameSize(QPoint()),
76 m_keyframeEditor(NULL),
79 m_baseWidget = new QWidget(this);
80 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
81 setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
82 setFrameStyle(QFrame::NoFrame);
83 setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding));
85 setWidget(m_baseWidget);
86 setWidgetResizable(true);
87 m_vbox = new QVBoxLayout(m_baseWidget);
88 m_vbox->setContentsMargins(0, 0, 0, 0);
89 m_vbox->setSpacing(0);
93 EffectStackEdit::~EffectStackEdit()
99 void EffectStackEdit::setFrameSize(QPoint p)
102 QDomNodeList namenode = m_params.elementsByTagName("parameter");
103 for (int i = 0; i < namenode.count() ; i++) {
104 QDomNode pa = namenode.item(i);
105 QDomNode na = pa.firstChildElement("name");
106 QString type = pa.attributes().namedItem("type").nodeValue();
107 QString paramName = i18n(na.toElement().text().toUtf8().data());
109 if (type == "geometry" && !KdenliveSettings::on_monitor_effects()) {
110 Geometryval *geom = ((Geometryval*)m_valueItems[paramName+"geometry"]);
111 geom->setFrameSize(m_frameSize);
117 void EffectStackEdit::updateTimecodeFormat()
119 if (m_keyframeEditor)
120 m_keyframeEditor->updateTimecodeFormat();
122 QDomNodeList namenode = m_params.elementsByTagName("parameter");
123 for (int i = 0; i < namenode.count() ; i++) {
124 QDomNode pa = namenode.item(i);
125 QDomNode na = pa.firstChildElement("name");
126 QString type = pa.attributes().namedItem("type").nodeValue();
127 QString paramName = i18n(na.toElement().text().toUtf8().data());
129 if (type == "geometry") {
130 if (KdenliveSettings::on_monitor_effects()) {
131 GeometryWidget *geom = (GeometryWidget*)m_valueItems[paramName+"geometry"];
132 geom->updateTimecodeFormat();
134 Geometryval *geom = ((Geometryval*)m_valueItems[paramName+"geometry"]);
135 geom->updateTimecodeFormat();
139 if (type == "position") {
140 PositionEdit *posi = ((PositionEdit*)m_valueItems[paramName+"position"]);
141 posi->updateTimecodeFormat();
147 void EffectStackEdit::meetDependency(const QString& name, QString type, QString value)
149 if (type == "curve") {
150 KisCurveWidget *curve = (KisCurveWidget*)m_valueItems[name];
152 int color = value.toInt();
153 curve->setPixmap(QPixmap::fromImage(ColorTools::rgbCurvePlane(curve->size(), (ColorTools::ColorsRGB)(color == 3 ? 4 : color), 0.8)));
155 } else if (type == "bezier_spline") {
156 BezierSplineWidget *widget = (BezierSplineWidget*)m_valueItems[name];
158 widget->setMode((BezierSplineWidget::CurveModes)((int)(value.toDouble() * 10)));
163 void EffectStackEdit::updateProjectFormat(MltVideoProfile profile, Timecode t)
169 void EffectStackEdit::updateParameter(const QString &name, const QString &value)
171 m_params.setAttribute(name, value);
173 if (name == "disable") {
174 // if effect is disabled, disable parameters widget
175 bool enabled = value.toInt() == 0 || !KdenliveSettings::disable_effect_parameters();
177 emit effectStateChanged(enabled);
181 void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, int out, bool isEffect)
184 if (m_keyframeEditor) delete m_keyframeEditor;
185 m_keyframeEditor = NULL;
189 if (m_params.isNull()) {
190 kDebug() << "// EMPTY EFFECT STACK";
194 QDomNodeList namenode = m_params.elementsByTagName("parameter");
195 QDomElement e = m_params.toElement();
196 const int minFrame = e.attribute("start").toInt();
197 const int maxFrame = e.attribute("end").toInt();
199 bool disable = d.attribute("disable") == "1" && KdenliveSettings::disable_effect_parameters();
200 setEnabled(!disable);
205 for (int i = 0; i < namenode.count() ; i++) {
206 QDomElement pa = namenode.item(i).toElement();
207 QDomElement na = pa.firstChildElement("name");
208 QDomElement commentElem = pa.firstChildElement("comment");
209 QString type = pa.attribute("type");
210 QString paramName = i18n(na.text().toUtf8().data());
212 if (!commentElem.isNull())
213 comment = i18n(commentElem.text().toUtf8().data());
214 QWidget * toFillin = new QWidget(m_baseWidget);
215 QString value = pa.attribute("value").isNull() ?
216 pa.attribute("default") : pa.attribute("value");
218 /** Currently supported parameter types are:
219 * constant (=double): a slider with an integer value (use the "factor" attribute to divide the value so that you can get a double
220 * list: a combobox containing a list of values to choose
222 * complex: designed for keyframe parameters, but old and not finished, do not use
223 * geometry: a rectangle that can be moved & resized, with possible keyframes, used in composite transition
224 * keyframe: a list widget with a list of entries (position and value)
225 * color: a color chooser button
226 * position: a slider representing the position of a frame in the current clip
227 * curve: a single curve representing multiple points
228 * wipe: a widget designed for the wipe transition, allowing to choose a position (left, right, top,...)
231 if (type == "double" || type == "constant") {
234 if (pa.attribute("min").startsWith('%'))
235 min = (int) ProfilesDialog::getStringEval(m_profile, pa.attribute("min"));
237 min = pa.attribute("min").toInt();
238 if (pa.attribute("max").startsWith('%'))
239 max = (int) ProfilesDialog::getStringEval(m_profile, pa.attribute("max"));
241 max = pa.attribute("max").toInt();
243 DoubleParameterWidget *doubleparam = new DoubleParameterWidget(paramName, (int)(value.toDouble() + 0.5), min, max,
244 pa.attribute("default").toInt(), comment, pa.attribute("suffix"), this);
245 m_vbox->addWidget(doubleparam);
246 m_valueItems[paramName] = doubleparam;
247 connect(doubleparam, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
248 connect(this, SIGNAL(showComments(bool)), doubleparam, SLOT(slotShowComment(bool)));
249 } else if (type == "list") {
250 Listval *lsval = new Listval;
251 lsval->setupUi(toFillin);
252 QStringList listitems = pa.attribute("paramlist").split(',');
253 QDomElement list = pa.firstChildElement("paramlistdisplay");
254 QStringList listitemsdisplay;
255 if (!list.isNull()) listitemsdisplay = i18n(list.text().toUtf8().data()).split(',');
256 else listitemsdisplay = i18n(pa.attribute("paramlistdisplay").toUtf8().data()).split(',');
257 if (listitemsdisplay.count() != listitems.count())
258 listitemsdisplay = listitems;
259 lsval->list->setIconSize(QSize(30, 30));
260 for (int i = 0; i < listitems.count(); i++) {
261 lsval->list->addItem(listitemsdisplay.at(i), listitems.at(i));
262 QString entry = listitems.at(i);
263 if (!entry.isEmpty() && (entry.endsWith(".png") || entry.endsWith(".pgm"))) {
264 if (!EffectStackEdit::iconCache.contains(entry)) {
266 EffectStackEdit::iconCache[entry] = pix.scaled(30, 30);
268 lsval->list->setItemIcon(i, QPixmap::fromImage(iconCache[entry]));
271 if (!value.isEmpty()) lsval->list->setCurrentIndex(listitems.indexOf(value));
272 lsval->name->setText(paramName);
273 lsval->labelComment->setText(comment);
274 lsval->widgetComment->setHidden(true);
275 m_valueItems[paramName] = lsval;
276 connect(lsval->list, SIGNAL(currentIndexChanged(int)) , this, SLOT(collectAllParameters()));
277 if (!comment.isEmpty())
278 connect(this, SIGNAL(showComments(bool)), lsval->widgetComment, SLOT(setVisible(bool)));
279 m_uiItems.append(lsval);
280 } else if (type == "bool") {
281 Boolval *bval = new Boolval;
282 bval->setupUi(toFillin);
283 bval->checkBox->setCheckState(value == "0" ? Qt::Unchecked : Qt::Checked);
284 bval->name->setText(paramName);
285 bval->labelComment->setText(comment);
286 bval->widgetComment->setHidden(true);
287 m_valueItems[paramName] = bval;
288 connect(bval->checkBox, SIGNAL(stateChanged(int)) , this, SLOT(collectAllParameters()));
289 if (!comment.isEmpty())
290 connect(this, SIGNAL(showComments(bool)), bval->widgetComment, SLOT(setVisible(bool)));
291 m_uiItems.append(bval);
292 } else if (type == "complex") {
293 ComplexParameter *pl = new ComplexParameter;
294 pl->setupParam(d, pa.attribute("name"), 0, 100);
295 m_vbox->addWidget(pl);
296 m_valueItems[paramName+"complex"] = pl;
297 connect(pl, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
298 } else if (type == "geometry") {
299 if (KdenliveSettings::on_monitor_effects()) {
300 GeometryWidget *geometry = new GeometryWidget(m_monitor, m_timecode, pos, isEffect, this);
301 geometry->slotShowScene(!disable);
302 // connect this before setupParam to make sure the monitor scene shows up at startup
303 connect(geometry, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
304 connect(geometry, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
305 if (minFrame == maxFrame)
306 geometry->setupParam(pa, m_in, m_out);
308 geometry->setupParam(pa, minFrame, maxFrame);
309 m_vbox->addWidget(geometry);
310 m_valueItems[paramName+"geometry"] = geometry;
311 connect(geometry, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
312 connect(this, SIGNAL(syncEffectsPos(int)), geometry, SLOT(slotSyncPosition(int)));
313 connect(this, SIGNAL(effectStateChanged(bool)), geometry, SLOT(slotShowScene(bool)));
315 Geometryval *geo = new Geometryval(m_profile, m_timecode, m_frameSize, pos);
316 if (minFrame == maxFrame)
317 geo->setupParam(pa, m_in, m_out);
319 geo->setupParam(pa, minFrame, maxFrame);
320 m_vbox->addWidget(geo);
321 m_valueItems[paramName+"geometry"] = geo;
322 connect(geo, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
323 connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
324 connect(this, SIGNAL(syncEffectsPos(int)), geo, SLOT(slotSyncPosition(int)));
326 } else if (type == "keyframe" || type == "simplekeyframe") {
327 // keyframe editor widget
328 if (m_keyframeEditor == NULL) {
330 if (pa.attribute("widget") == "corners") {
331 // we want a corners-keyframe-widget
332 CornersWidget *corners = new CornersWidget(m_monitor, pa, m_in, m_in + m_out, m_timecode, e.attribute("active_keyframe", "-1").toInt(), this);
333 corners->slotShowScene(!disable);
334 connect(corners, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
335 connect(this, SIGNAL(effectStateChanged(bool)), corners, SLOT(slotShowScene(bool)));
336 connect(this, SIGNAL(syncEffectsPos(int)), corners, SLOT(slotSyncPosition(int)));
337 geo = static_cast<KeyframeEdit *>(corners);
339 geo = new KeyframeEdit(pa, m_in, m_in + m_out, m_timecode, e.attribute("active_keyframe", "-1").toInt());
341 m_vbox->addWidget(geo);
342 m_valueItems[paramName+"keyframe"] = geo;
343 m_keyframeEditor = geo;
344 connect(geo, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
345 connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
346 connect(this, SIGNAL(showComments(bool)), geo, SIGNAL(showComments(bool)));
348 // we already have a keyframe editor, so just add another column for the new param
349 m_keyframeEditor->addParameter(pa);
351 } else if (type == "color") {
352 if (value.startsWith('#'))
353 value = value.replace('#', "0x");
355 ChooseColorWidget *choosecolor = new ChooseColorWidget(paramName, QColor(value.toUInt(&ok, 16)), this);
356 m_vbox->addWidget(choosecolor);
357 m_valueItems[paramName] = choosecolor;
358 connect(choosecolor, SIGNAL(displayMessage(const QString&, int)), this, SIGNAL(displayMessage(const QString&, int)));
359 connect(choosecolor, SIGNAL(modified()) , this, SLOT(collectAllParameters()));
360 } else if (type == "position") {
361 int pos = value.toInt();
362 if (d.attribute("id") == "fadein" || d.attribute("id") == "fade_from_black") {
364 } else if (d.attribute("id") == "fadeout" || d.attribute("id") == "fade_to_black") {
365 // fadeout position starts from clip end
368 PositionEdit *posedit = new PositionEdit(paramName, pos, 0, m_out - m_in, m_timecode);
369 m_vbox->addWidget(posedit);
370 m_valueItems[paramName+"position"] = posedit;
371 connect(posedit, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
372 } else if (type == "curve") {
373 KisCurveWidget *curve = new KisCurveWidget(this);
374 curve->setMaxPoints(pa.attribute("max").toInt());
375 QList<QPointF> points;
376 int number = EffectsList::parameter(e, pa.attribute("number")).toInt();
377 QString inName = pa.attribute("inpoints");
378 QString outName = pa.attribute("outpoints");
379 int start = pa.attribute("min").toInt();
380 for (int j = start; j <= number; j++) {
382 in.replace("%i", QString::number(j));
383 QString out = outName;
384 out.replace("%i", QString::number(j));
385 points << QPointF(EffectsList::parameter(e, in).toDouble(), EffectsList::parameter(e, out).toDouble());
387 if (!points.isEmpty())
388 curve->setCurve(KisCubicCurve(points));
389 QSpinBox *spinin = new QSpinBox();
390 spinin->setRange(0, 1000);
391 QSpinBox *spinout = new QSpinBox();
392 spinout->setRange(0, 1000);
393 curve->setupInOutControls(spinin, spinout, 0, 1000);
394 m_vbox->addWidget(curve);
395 m_vbox->addWidget(spinin);
396 m_vbox->addWidget(spinout);
398 connect(curve, SIGNAL(modified()), this, SLOT(collectAllParameters()));
399 m_valueItems[paramName] = curve;
401 QString depends = pa.attribute("depends");
402 if (!depends.isEmpty())
403 meetDependency(paramName, type, EffectsList::parameter(e, depends));
404 } else if (type == "bezier_spline") {
405 BezierSplineWidget *widget = new BezierSplineWidget(value, this);
407 m_vbox->addWidget(widget);
408 m_valueItems[paramName] = widget;
409 connect(widget, SIGNAL(modified()), this, SLOT(collectAllParameters()));
410 QString depends = pa.attribute("depends");
411 if (!depends.isEmpty())
412 meetDependency(paramName, type, EffectsList::parameter(e, depends));
414 } else if (type == "roto-spline") {
415 RotoWidget *roto = new RotoWidget(value, m_monitor, m_in, m_out, this);
416 roto->slotShowScene(!disable);
417 connect(roto, SIGNAL(valueChanged()), this, SLOT(collectAllParameters()));
418 connect(roto, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
419 connect(this, SIGNAL(syncEffectsPos(int)), roto, SLOT(slotSyncPosition(int)));
420 connect(this, SIGNAL(effectStateChanged(bool)), roto, SLOT(slotShowScene(bool)));
421 m_vbox->addWidget(roto);
422 m_valueItems[paramName] = roto;
424 } else if (type == "wipe") {
425 Wipeval *wpval = new Wipeval;
426 wpval->setupUi(toFillin);
427 wipeInfo w = getWipeInfo(value);
430 wpval->start_up->setChecked(true);
433 wpval->start_down->setChecked(true);
436 wpval->start_right->setChecked(true);
439 wpval->start_left->setChecked(true);
442 wpval->start_center->setChecked(true);
447 wpval->end_up->setChecked(true);
450 wpval->end_down->setChecked(true);
453 wpval->end_right->setChecked(true);
456 wpval->end_left->setChecked(true);
459 wpval->end_center->setChecked(true);
462 wpval->start_transp->setValue(w.startTransparency);
463 wpval->end_transp->setValue(w.endTransparency);
464 m_valueItems[paramName] = wpval;
465 connect(wpval->end_up, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
466 connect(wpval->end_down, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
467 connect(wpval->end_left, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
468 connect(wpval->end_right, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
469 connect(wpval->end_center, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
470 connect(wpval->start_up, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
471 connect(wpval->start_down, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
472 connect(wpval->start_left, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
473 connect(wpval->start_right, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
474 connect(wpval->start_center, SIGNAL(clicked()), this, SLOT(collectAllParameters()));
475 connect(wpval->start_transp, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
476 connect(wpval->end_transp, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
477 //wpval->title->setTitle(na.toElement().text());
478 m_uiItems.append(wpval);
479 } else if (type == "url") {
480 Urlval *cval = new Urlval;
481 cval->setupUi(toFillin);
482 cval->label->setText(paramName);
483 cval->urlwidget->fileDialog()->setFilter(ProjectList::getExtensions());
484 m_valueItems[paramName] = cval;
485 cval->urlwidget->setUrl(KUrl(value));
486 connect(cval->urlwidget, SIGNAL(returnPressed()) , this, SLOT(collectAllParameters()));
487 connect(cval->urlwidget, SIGNAL(urlSelected(const KUrl&)) , this, SLOT(collectAllParameters()));
488 m_uiItems.append(cval);
495 m_vbox->addWidget(toFillin);
499 m_vbox->addStretch();
501 if (m_keyframeEditor)
502 m_keyframeEditor->checkVisibleParam();
505 wipeInfo EffectStackEdit::getWipeInfo(QString value)
508 QString start = value.section(';', 0, 0);
509 QString end = value.section(';', 1, 1).section('=', 1, 1);
511 if (start.startsWith("-100%,0"))
513 else if (start.startsWith("100%,0"))
515 else if (start.startsWith("0%,100%"))
517 else if (start.startsWith("0%,-100%"))
522 if (start.count(':') == 2)
523 info.startTransparency = start.section(':', -1).toInt();
525 info.startTransparency = 100;
527 if (end.startsWith("-100%,0"))
529 else if (end.startsWith("100%,0"))
531 else if (end.startsWith("0%,100%"))
533 else if (end.startsWith("0%,-100%"))
538 if (end.count(':') == 2)
539 info.endTransparency = end.section(':', -1).toInt();
541 info.endTransparency = 100;
546 QString EffectStackEdit::getWipeString(wipeInfo info)
551 switch (info.start) {
553 start = "-100%,0%:100%x100%";
556 start = "100%,0%:100%x100%";
559 start = "0%,100%:100%x100%";
562 start = "0%,-100%:100%x100%";
565 start = "0%,0%:100%x100%";
568 start.append(':' + QString::number(info.startTransparency));
572 end = "-100%,0%:100%x100%";
575 end = "100%,0%:100%x100%";
578 end = "0%,100%:100%x100%";
581 end = "0%,-100%:100%x100%";
584 end = "0%,0%:100%x100%";
587 end.append(':' + QString::number(info.endTransparency));
588 return QString(start + ";-1=" + end);
591 void EffectStackEdit::collectAllParameters()
593 if (m_valueItems.isEmpty() || m_params.isNull()) return;
594 const QDomElement oldparam = m_params.cloneNode().toElement();
595 QDomElement newparam = oldparam.cloneNode().toElement();
596 QDomNodeList namenode = newparam.elementsByTagName("parameter");
598 for (int i = 0; i < namenode.count() ; i++) {
599 QDomNode pa = namenode.item(i);
600 QDomNode na = pa.firstChildElement("name");
601 QString type = pa.attributes().namedItem("type").nodeValue();
602 QString paramName = i18n(na.toElement().text().toUtf8().data());
603 if (type == "complex")
604 paramName.append("complex");
605 else if (type == "position")
606 paramName.append("position");
607 else if (type == "geometry")
608 paramName.append("geometry");
609 else if (type == "keyframe")
610 paramName.append("keyframe");
611 if (type != "simplekeyframe" && !m_valueItems.contains(paramName)) {
612 kDebug() << "// Param: " << paramName << " NOT FOUND";
617 if (type == "double" || type == "constant") {
618 DoubleParameterWidget *doubleparam = (DoubleParameterWidget*)m_valueItems.value(paramName);
619 setValue = QString::number(doubleparam->getValue());
620 } else if (type == "list") {
621 KComboBox *box = ((Listval*)m_valueItems.value(paramName))->list;
622 setValue = box->itemData(box->currentIndex()).toString();
623 } else if (type == "bool") {
624 QCheckBox *box = ((Boolval*)m_valueItems.value(paramName))->checkBox;
625 setValue = box->checkState() == Qt::Checked ? "1" : "0" ;
626 } else if (type == "color") {
627 ChooseColorWidget *choosecolor = ((ChooseColorWidget*)m_valueItems.value(paramName));
628 setValue = choosecolor->getColor().name();
629 } else if (type == "complex") {
630 ComplexParameter *complex = ((ComplexParameter*)m_valueItems.value(paramName));
631 namenode.item(i) = complex->getParamDesc();
632 } else if (type == "geometry") {
633 if (KdenliveSettings::on_monitor_effects()) {
634 GeometryWidget *geometry = ((GeometryWidget*)m_valueItems.value(paramName));
635 namenode.item(i).toElement().setAttribute("value", geometry->getValue());
637 Geometryval *geom = ((Geometryval*)m_valueItems.value(paramName));
638 namenode.item(i).toElement().setAttribute("value", geom->getValue());
640 } else if (type == "position") {
641 PositionEdit *pedit = ((PositionEdit*)m_valueItems.value(paramName));
642 int pos = pedit->getPosition();
643 setValue = QString::number(pos);
644 if (newparam.attribute("id") == "fadein" || newparam.attribute("id") == "fade_from_black") {
645 // Make sure duration is not longer than clip
648 pedit->setPosition(pos);
650 EffectsList::setParameter(newparam, "in", QString::number(m_in));
651 EffectsList::setParameter(newparam, "out", QString::number(m_in + pos));
653 } else if (newparam.attribute("id") == "fadeout" || newparam.attribute("id") == "fade_to_black") {
654 // Make sure duration is not longer than clip
657 pedit->setPosition(pos);
659 EffectsList::setParameter(newparam, "in", QString::number(m_out - pos));
660 EffectsList::setParameter(newparam, "out", QString::number(m_out));
663 } else if (type == "curve") {
664 KisCurveWidget *curve = ((KisCurveWidget*)m_valueItems.value(paramName));
665 QList<QPointF> points = curve->curve().points();
666 QString number = pa.attributes().namedItem("number").nodeValue();
667 QString inName = pa.attributes().namedItem("inpoints").nodeValue();
668 QString outName = pa.attributes().namedItem("outpoints").nodeValue();
669 int off = pa.attributes().namedItem("min").nodeValue().toInt();
670 int end = pa.attributes().namedItem("max").nodeValue().toInt();
671 EffectsList::setParameter(newparam, number, QString::number(points.count()));
672 for (int j = 0; (j < points.count() && j + off <= end); j++) {
674 in.replace("%i", QString::number(j + off));
675 QString out = outName;
676 out.replace("%i", QString::number(j + off));
677 EffectsList::setParameter(newparam, in, QString::number(points.at(j).x()));
678 EffectsList::setParameter(newparam, out, QString::number(points.at(j).y()));
680 QString depends = pa.attributes().namedItem("depends").nodeValue();
681 if (!depends.isEmpty())
682 meetDependency(paramName, type, EffectsList::parameter(newparam, depends));
683 } else if (type == "bezier_spline") {
684 BezierSplineWidget *widget = (BezierSplineWidget*)m_valueItems.value(paramName);
685 setValue = widget->spline();
686 QString depends = pa.attributes().namedItem("depends").nodeValue();
687 if (!depends.isEmpty())
688 meetDependency(paramName, type, EffectsList::parameter(newparam, depends));
690 } else if (type == "roto-spline") {
691 RotoWidget *widget = static_cast<RotoWidget *>(m_valueItems.value(paramName));
692 setValue = widget->getSpline();
694 } else if (type == "wipe") {
695 Wipeval *wp = (Wipeval*)m_valueItems.value(paramName);
697 if (wp->start_left->isChecked())
699 else if (wp->start_right->isChecked())
701 else if (wp->start_up->isChecked())
703 else if (wp->start_down->isChecked())
705 else if (wp->start_center->isChecked())
709 info.startTransparency = wp->start_transp->value();
711 if (wp->end_left->isChecked())
713 else if (wp->end_right->isChecked())
715 else if (wp->end_up->isChecked())
717 else if (wp->end_down->isChecked())
719 else if (wp->end_center->isChecked())
723 info.endTransparency = wp->end_transp->value();
725 setValue = getWipeString(info);
726 } else if ((type == "simplekeyframe" || type == "keyframe") && m_keyframeEditor) {
727 QDomElement elem = pa.toElement();
728 QString realName = i18n(na.toElement().text().toUtf8().data());
729 QString val = m_keyframeEditor->getValue(realName);
730 elem.setAttribute("keyframes", val);
732 if (m_keyframeEditor->isVisibleParam(realName))
733 elem.setAttribute("intimeline", "1");
734 else if (elem.hasAttribute("intimeline"))
735 elem.removeAttribute("intimeline");
736 } else if (type == "url") {
737 KUrlRequester *req = ((Urlval*)m_valueItems.value(paramName))->urlwidget;
738 setValue = req->url().path();
741 if (!setValue.isNull())
742 pa.attributes().namedItem("value").setNodeValue(setValue);
745 emit parameterChanged(oldparam, newparam);
748 void EffectStackEdit::clearAllItems()
751 m_valueItems.clear();
753 /*while (!m_items.isEmpty()) {
754 QWidget *die = m_items.takeFirst();
758 //qDeleteAll(m_uiItems);
760 while ((child = m_vbox->takeAt(0)) != 0) {
761 QWidget *wid = child->widget();
765 m_keyframeEditor = NULL;
769 void EffectStackEdit::slotSyncEffectsPos(int pos)
771 emit syncEffectsPos(pos);