1 /***************************************************************************
2 effecstackedit.cpp - description
5 copyright : (C) 2008 by Marco Gittler
6 email : g.marco@freenet.de
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
18 #include "effectstackedit.h"
19 #include "ui_listval_ui.h"
20 #include "ui_boolval_ui.h"
21 #include "ui_wipeval_ui.h"
22 #include "ui_urlval_ui.h"
23 #include "complexparameter.h"
24 #include "geometryval.h"
25 #include "positionedit.h"
26 #include "projectlist.h"
27 #include "effectslist.h"
28 #include "kdenlivesettings.h"
29 #include "profilesdialog.h"
30 #include "kis_curve_widget.h"
31 #include "kis_cubic_curve.h"
32 #include "choosecolorwidget.h"
33 #include "geometrywidget.h"
34 #include "colortools.h"
35 #include "doubleparameterwidget.h"
36 #include "cornerswidget.h"
37 #include "beziercurve/beziersplinewidget.h"
41 #include <KFileDialog>
43 #include <QVBoxLayout>
45 #include <QPushButton>
47 #include <QScrollArea>
50 class Boolval: public QWidget, public Ui::Boolval_UI
54 class Listval: public QWidget, public Ui::Listval_UI
58 class Wipeval: public QWidget, public Ui::Wipeval_UI
62 class Urlval: public QWidget, public Ui::Urlval_UI
66 QMap<QString, QImage> EffectStackEdit::iconCache;
68 EffectStackEdit::EffectStackEdit(Monitor *monitor, QWidget *parent) :
72 m_frameSize(QPoint()),
73 m_keyframeEditor(NULL),
76 m_baseWidget = new QWidget(this);
77 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
78 setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
79 setFrameStyle(QFrame::NoFrame);
80 setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding));
82 setWidget(m_baseWidget);
83 setWidgetResizable(true);
84 m_vbox = new QVBoxLayout(m_baseWidget);
85 m_vbox->setContentsMargins(0, 0, 0, 0);
86 m_vbox->setSpacing(0);
90 EffectStackEdit::~EffectStackEdit()
96 void EffectStackEdit::setFrameSize(QPoint p)
99 QDomNodeList namenode = m_params.elementsByTagName("parameter");
100 for (int i = 0; i < namenode.count() ; i++) {
101 QDomNode pa = namenode.item(i);
102 QDomNode na = pa.firstChildElement("name");
103 QString type = pa.attributes().namedItem("type").nodeValue();
104 QString paramName = i18n(na.toElement().text().toUtf8().data());
106 if (type == "geometry" && !KdenliveSettings::on_monitor_effects()) {
107 Geometryval *geom = ((Geometryval*)m_valueItems[paramName+"geometry"]);
108 geom->setFrameSize(m_frameSize);
114 void EffectStackEdit::updateTimecodeFormat()
116 if (m_keyframeEditor)
117 m_keyframeEditor->updateTimecodeFormat();
119 QDomNodeList namenode = m_params.elementsByTagName("parameter");
120 for (int i = 0; i < namenode.count() ; i++) {
121 QDomNode pa = namenode.item(i);
122 QDomNode na = pa.firstChildElement("name");
123 QString type = pa.attributes().namedItem("type").nodeValue();
124 QString paramName = i18n(na.toElement().text().toUtf8().data());
126 if (type == "geometry") {
127 if (KdenliveSettings::on_monitor_effects()) {
128 GeometryWidget *geom = (GeometryWidget*)m_valueItems[paramName+"geometry"];
129 geom->updateTimecodeFormat();
131 Geometryval *geom = ((Geometryval*)m_valueItems[paramName+"geometry"]);
132 geom->updateTimecodeFormat();
136 if (type == "position") {
137 PositionEdit *posi = ((PositionEdit*)m_valueItems[paramName+"position"]);
138 posi->updateTimecodeFormat();
144 void EffectStackEdit::meetDependency(const QString& name, QString type, QString value)
146 if (type == "curve") {
147 KisCurveWidget *curve = (KisCurveWidget*)m_valueItems[name];
149 int color = value.toInt();
150 curve->setPixmap(QPixmap::fromImage(ColorTools::rgbCurvePlane(curve->size(), (ColorTools::ColorsRGB)(color == 3 ? 4 : color), 0.8)));
152 } else if (type == "bezier_spline") {
153 BezierSplineWidget *widget = (BezierSplineWidget*)m_valueItems[name];
155 widget->setMode((BezierSplineWidget::CurveModes)((int)(value.toDouble() * 10)));
160 void EffectStackEdit::updateProjectFormat(MltVideoProfile profile, Timecode t)
166 void EffectStackEdit::updateParameter(const QString &name, const QString &value)
168 m_params.setAttribute(name, value);
170 if (name == "disable") {
171 // if effect is disabled, disable parameters widget
172 bool enabled = value.toInt() == 0 || !KdenliveSettings::disable_effect_parameters();
174 emit effectStateChanged(enabled);
178 void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, int out, bool isEffect)
181 if (m_keyframeEditor) delete m_keyframeEditor;
182 m_keyframeEditor = NULL;
186 if (m_params.isNull()) {
187 kDebug() << "// EMPTY EFFECT STACK";
191 QDomNodeList namenode = m_params.elementsByTagName("parameter");
192 QDomElement e = m_params.toElement();
193 const int minFrame = e.attribute("start").toInt();
194 const int maxFrame = e.attribute("end").toInt();
196 bool disable = d.attribute("disable") == "1" && KdenliveSettings::disable_effect_parameters();
197 setEnabled(!disable);
202 for (int i = 0; i < namenode.count() ; i++) {
203 QDomElement pa = namenode.item(i).toElement();
204 QDomElement na = pa.firstChildElement("name");
205 QDomElement commentElem = pa.firstChildElement("comment");
206 QString type = pa.attribute("type");
207 QString paramName = i18n(na.text().toUtf8().data());
209 if (!commentElem.isNull())
210 comment = i18n(commentElem.text().toUtf8().data());
211 QWidget * toFillin = new QWidget(m_baseWidget);
212 QString value = pa.attribute("value").isNull() ?
213 pa.attribute("default") : pa.attribute("value");
215 /** Currently supported parameter types are:
216 * constant (=double): a slider with an integer value (use the "factor" attribute to divide the value so that you can get a double
217 * list: a combobox containing a list of values to choose
219 * complex: designed for keyframe parameters, but old and not finished, do not use
220 * geometry: a rectangle that can be moved & resized, with possible keyframes, used in composite transition
221 * keyframe: a list widget with a list of entries (position and value)
222 * color: a color chooser button
223 * position: a slider representing the position of a frame in the current clip
224 * curve: a single curve representing multiple points
225 * wipe: a widget designed for the wipe transition, allowing to choose a position (left, right, top,...)
228 if (type == "double" || type == "constant") {
231 if (pa.attribute("min").startsWith('%'))
232 min = (int) ProfilesDialog::getStringEval(m_profile, pa.attribute("min"));
234 min = pa.attribute("min").toInt();
235 if (pa.attribute("max").startsWith('%'))
236 max = (int) ProfilesDialog::getStringEval(m_profile, pa.attribute("max"));
238 max = pa.attribute("max").toInt();
240 DoubleParameterWidget *doubleparam = new DoubleParameterWidget(paramName, (int)(value.toDouble() + 0.5), min, max,
241 pa.attribute("default").toInt(), comment, pa.attribute("suffix"), this);
242 m_vbox->addWidget(doubleparam);
243 m_valueItems[paramName] = doubleparam;
244 connect(doubleparam, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters()));
245 connect(this, SIGNAL(showComments()), doubleparam, SLOT(slotShowComment()));
246 } else if (type == "list") {
247 Listval *lsval = new Listval;
248 lsval->setupUi(toFillin);
249 QStringList listitems = pa.attribute("paramlist").split(',');
250 QDomElement list = pa.firstChildElement("paramlistdisplay");
251 QStringList listitemsdisplay;
252 if (!list.isNull()) listitemsdisplay = i18n(list.text().toUtf8().data()).split(',');
253 else listitemsdisplay = i18n(pa.attribute("paramlistdisplay").toUtf8().data()).split(',');
254 if (listitemsdisplay.count() != listitems.count())
255 listitemsdisplay = listitems;
256 lsval->list->setIconSize(QSize(30, 30));
257 for (int i = 0; i < listitems.count(); i++) {
258 lsval->list->addItem(listitemsdisplay.at(i), listitems.at(i));
259 QString entry = listitems.at(i);
260 if (!entry.isEmpty() && (entry.endsWith(".png") || entry.endsWith(".pgm"))) {
261 if (!EffectStackEdit::iconCache.contains(entry)) {
263 EffectStackEdit::iconCache[entry] = pix.scaled(30, 30);
265 lsval->list->setItemIcon(i, QPixmap::fromImage(iconCache[entry]));
268 if (!value.isEmpty()) lsval->list->setCurrentIndex(listitems.indexOf(value));
269 lsval->name->setText(paramName);
270 m_valueItems[paramName] = lsval;
271 connect(lsval->list, SIGNAL(currentIndexChanged(int)) , this, SLOT(collectAllParameters()));
272 m_uiItems.append(lsval);
273 } else if (type == "bool") {
274 Boolval *bval = new Boolval;
275 bval->setupUi(toFillin);
276 bval->checkBox->setCheckState(value == "0" ? Qt::Unchecked : Qt::Checked);
277 bval->name->setText(paramName);
278 m_valueItems[paramName] = bval;
279 connect(bval->checkBox, SIGNAL(stateChanged(int)) , this, SLOT(collectAllParameters()));
280 m_uiItems.append(bval);
281 } else if (type == "complex") {
282 ComplexParameter *pl = new ComplexParameter;
283 pl->setupParam(d, pa.attribute("name"), 0, 100);
284 m_vbox->addWidget(pl);
285 m_valueItems[paramName+"complex"] = pl;
286 connect(pl, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
287 } else if (type == "geometry") {
288 if (KdenliveSettings::on_monitor_effects()) {
289 GeometryWidget *geometry = new GeometryWidget(m_monitor, m_timecode, pos, isEffect, this);
290 geometry->slotShowScene(!disable);
291 // connect this before setupParam to make sure the monitor scene shows up at startup
292 connect(geometry, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
293 connect(geometry, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
294 if (minFrame == maxFrame)
295 geometry->setupParam(pa, m_in, m_out);
297 geometry->setupParam(pa, minFrame, maxFrame);
298 m_vbox->addWidget(geometry);
299 m_valueItems[paramName+"geometry"] = geometry;
300 connect(geometry, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
301 connect(this, SIGNAL(syncEffectsPos(int)), geometry, SLOT(slotSyncPosition(int)));
302 connect(this, SIGNAL(effectStateChanged(bool)), geometry, SLOT(slotShowScene(bool)));
304 Geometryval *geo = new Geometryval(m_profile, m_timecode, m_frameSize, pos);
305 if (minFrame == maxFrame)
306 geo->setupParam(pa, m_in, m_out);
308 geo->setupParam(pa, minFrame, maxFrame);
309 m_vbox->addWidget(geo);
310 m_valueItems[paramName+"geometry"] = geo;
311 connect(geo, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
312 connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
313 connect(this, SIGNAL(syncEffectsPos(int)), geo, SLOT(slotSyncPosition(int)));
315 } else if (type == "keyframe" || type == "simplekeyframe") {
316 // keyframe editor widget
317 if (m_keyframeEditor == NULL) {
318 KeyframeEdit *geo = new KeyframeEdit(pa, m_in, m_in + m_out, m_timecode, e.attribute("active_keyframe", "-1").toInt());
319 m_vbox->addWidget(geo);
320 m_valueItems[paramName+"keyframe"] = geo;
321 m_keyframeEditor = geo;
322 connect(geo, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
323 connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int)));
324 connect(this, SIGNAL(showComments()), geo, SIGNAL(showComments()));
326 // we already have a keyframe editor, so just add another column for the new param
327 m_keyframeEditor->addParameter(pa);
329 } else if (type == "color") {
330 if (value.startsWith('#'))
331 value = value.replace('#', "0x");
333 ChooseColorWidget *choosecolor = new ChooseColorWidget(paramName, QColor(value.toUInt(&ok, 16)), this);
334 m_vbox->addWidget(choosecolor);
335 m_valueItems[paramName] = choosecolor;
336 connect(choosecolor, SIGNAL(displayMessage(const QString&, int)), this, SIGNAL(displayMessage(const QString&, int)));
337 connect(choosecolor, SIGNAL(modified()) , this, SLOT(collectAllParameters()));
338 } else if (type == "position") {
339 int pos = value.toInt();
340 if (d.attribute("id") == "fadein" || d.attribute("id") == "fade_from_black") {
342 } else if (d.attribute("id") == "fadeout" || d.attribute("id") == "fade_to_black") {
343 // fadeout position starts from clip end
346 PositionEdit *posedit = new PositionEdit(paramName, pos, 0, m_out - m_in, m_timecode);
347 m_vbox->addWidget(posedit);
348 m_valueItems[paramName+"position"] = posedit;
349 connect(posedit, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
350 } else if (type == "curve") {
351 KisCurveWidget *curve = new KisCurveWidget(this);
352 curve->setMaxPoints(pa.attribute("max").toInt());
353 QList<QPointF> points;
354 int number = EffectsList::parameter(e, pa.attribute("number")).toInt();
355 QString inName = pa.attribute("inpoints");
356 QString outName = pa.attribute("outpoints");
357 int start = pa.attribute("min").toInt();
358 for (int j = start; j <= number; j++) {
360 in.replace("%i", QString::number(j));
361 QString out = outName;
362 out.replace("%i", QString::number(j));
363 points << QPointF(EffectsList::parameter(e, in).toDouble(), EffectsList::parameter(e, out).toDouble());
365 if (!points.isEmpty())
366 curve->setCurve(KisCubicCurve(points));
367 QSpinBox *spinin = new QSpinBox();
368 spinin->setRange(0, 1000);
369 QSpinBox *spinout = new QSpinBox();
370 spinout->setRange(0, 1000);
371 curve->setupInOutControls(spinin, spinout, 0, 1000);
372 m_vbox->addWidget(curve);
373 m_vbox->addWidget(spinin);
374 m_vbox->addWidget(spinout);
376 connect(curve, SIGNAL(modified()), this, SLOT(collectAllParameters()));
377 m_valueItems[paramName] = curve;
379 QString depends = pa.attribute("depends");
380 if (!depends.isEmpty())
381 meetDependency(paramName, type, EffectsList::parameter(e, depends));
382 } else if (type == "bezier_spline") {
383 BezierSplineWidget *widget = new BezierSplineWidget(value, this);
385 m_vbox->addWidget(widget);
386 m_valueItems[paramName] = widget;
387 connect(widget, SIGNAL(modified()), this, SLOT(collectAllParameters()));
388 QString depends = pa.attribute("depends");
389 if (!depends.isEmpty())
390 meetDependency(paramName, type, EffectsList::parameter(e, depends));
391 } else if (type == "corners") {
392 CornersWidget *corners = new CornersWidget(m_monitor, pos, isEffect, pa.attribute("factor").toInt(), this);
393 corners->slotShowScene(!disable);
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);
410 m_vbox->addWidget(corners);
411 connect(corners, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
412 connect(this, SIGNAL(effectStateChanged(bool)), corners, SLOT(slotShowScene(bool)));
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);
489 m_vbox->addStretch();
491 if (m_keyframeEditor)
492 m_keyframeEditor->checkVisibleParam();
495 wipeInfo EffectStackEdit::getWipeInfo(QString value)
498 QString start = value.section(';', 0, 0);
499 QString end = value.section(';', 1, 1).section('=', 1, 1);
501 if (start.startsWith("-100%,0"))
503 else if (start.startsWith("100%,0"))
505 else if (start.startsWith("0%,100%"))
507 else if (start.startsWith("0%,-100%"))
512 if (start.count(':') == 2)
513 info.startTransparency = start.section(':', -1).toInt();
515 info.startTransparency = 100;
517 if (end.startsWith("-100%,0"))
519 else if (end.startsWith("100%,0"))
521 else if (end.startsWith("0%,100%"))
523 else if (end.startsWith("0%,-100%"))
528 if (end.count(':') == 2)
529 info.endTransparency = end.section(':', -1).toInt();
531 info.endTransparency = 100;
536 QString EffectStackEdit::getWipeString(wipeInfo info)
541 switch (info.start) {
543 start = "-100%,0%:100%x100%";
546 start = "100%,0%:100%x100%";
549 start = "0%,100%:100%x100%";
552 start = "0%,-100%:100%x100%";
555 start = "0%,0%:100%x100%";
558 start.append(':' + QString::number(info.startTransparency));
562 end = "-100%,0%:100%x100%";
565 end = "100%,0%:100%x100%";
568 end = "0%,100%:100%x100%";
571 end = "0%,-100%:100%x100%";
574 end = "0%,0%:100%x100%";
577 end.append(':' + QString::number(info.endTransparency));
578 return QString(start + ";-1=" + end);
581 void EffectStackEdit::collectAllParameters()
583 if (m_valueItems.isEmpty() || m_params.isNull()) return;
584 const QDomElement oldparam = m_params.cloneNode().toElement();
585 QDomElement newparam = oldparam.cloneNode().toElement();
586 QDomNodeList namenode = newparam.elementsByTagName("parameter");
588 for (int i = 0; i < namenode.count() ; i++) {
589 QDomNode pa = namenode.item(i);
590 QDomNode na = pa.firstChildElement("name");
591 QString type = pa.attributes().namedItem("type").nodeValue();
592 QString paramName = i18n(na.toElement().text().toUtf8().data());
593 if (type == "complex")
594 paramName.append("complex");
595 else if (type == "position")
596 paramName.append("position");
597 else if (type == "geometry")
598 paramName.append("geometry");
599 else if (type == "keyframe")
600 paramName.append("keyframe");
601 if (type != "simplekeyframe" && !m_valueItems.contains(paramName)) {
602 kDebug() << "// Param: " << paramName << " NOT FOUND";
607 if (type == "double" || type == "constant") {
608 DoubleParameterWidget *doubleparam = (DoubleParameterWidget*)m_valueItems.value(paramName);
609 setValue = QString::number(doubleparam->getValue());
610 } else if (type == "list") {
611 KComboBox *box = ((Listval*)m_valueItems.value(paramName))->list;
612 setValue = box->itemData(box->currentIndex()).toString();
613 } else if (type == "bool") {
614 QCheckBox *box = ((Boolval*)m_valueItems.value(paramName))->checkBox;
615 setValue = box->checkState() == Qt::Checked ? "1" : "0" ;
616 } else if (type == "color") {
617 ChooseColorWidget *choosecolor = ((ChooseColorWidget*)m_valueItems.value(paramName));
618 setValue = choosecolor->getColor().name();
619 } else if (type == "complex") {
620 ComplexParameter *complex = ((ComplexParameter*)m_valueItems.value(paramName));
621 namenode.item(i) = complex->getParamDesc();
622 } else if (type == "geometry") {
623 if (KdenliveSettings::on_monitor_effects()) {
624 GeometryWidget *geometry = ((GeometryWidget*)m_valueItems.value(paramName));
625 namenode.item(i).toElement().setAttribute("value", geometry->getValue());
627 Geometryval *geom = ((Geometryval*)m_valueItems.value(paramName));
628 namenode.item(i).toElement().setAttribute("value", geom->getValue());
630 } else if (type == "position") {
631 PositionEdit *pedit = ((PositionEdit*)m_valueItems.value(paramName));
632 int pos = pedit->getPosition();
633 setValue = QString::number(pos);
634 if (newparam.attribute("id") == "fadein" || newparam.attribute("id") == "fade_from_black") {
635 // Make sure duration is not longer than clip
638 pedit->setPosition(pos);
640 EffectsList::setParameter(newparam, "in", QString::number(m_in));
641 EffectsList::setParameter(newparam, "out", QString::number(m_in + pos));
643 } else if (newparam.attribute("id") == "fadeout" || newparam.attribute("id") == "fade_to_black") {
644 // Make sure duration is not longer than clip
647 pedit->setPosition(pos);
649 EffectsList::setParameter(newparam, "in", QString::number(m_out - pos));
650 EffectsList::setParameter(newparam, "out", QString::number(m_out));
653 } else if (type == "curve") {
654 KisCurveWidget *curve = ((KisCurveWidget*)m_valueItems.value(paramName));
655 QList<QPointF> points = curve->curve().points();
656 QString number = pa.attributes().namedItem("number").nodeValue();
657 QString inName = pa.attributes().namedItem("inpoints").nodeValue();
658 QString outName = pa.attributes().namedItem("outpoints").nodeValue();
659 int off = pa.attributes().namedItem("min").nodeValue().toInt();
660 int end = pa.attributes().namedItem("max").nodeValue().toInt();
661 EffectsList::setParameter(newparam, number, QString::number(points.count()));
662 for (int j = 0; (j < points.count() && j + off <= end); j++) {
664 in.replace("%i", QString::number(j + off));
665 QString out = outName;
666 out.replace("%i", QString::number(j + off));
667 EffectsList::setParameter(newparam, in, QString::number(points.at(j).x()));
668 EffectsList::setParameter(newparam, out, QString::number(points.at(j).y()));
670 QString depends = pa.attributes().namedItem("depends").nodeValue();
671 if (!depends.isEmpty())
672 meetDependency(paramName, type, EffectsList::parameter(newparam, depends));
673 } else if (type == "bezier_spline") {
674 BezierSplineWidget *widget = (BezierSplineWidget*)m_valueItems.value(paramName);
675 setValue = widget->spline();
676 QString depends = pa.attributes().namedItem("depends").nodeValue();
677 if (!depends.isEmpty())
678 meetDependency(paramName, type, EffectsList::parameter(newparam, depends));
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);