X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Feffectstackedit.cpp;h=e3f86ea1fd8ec15d9f3d4daa3b1898df956488d9;hb=ebcca979cdf9fdfc8c8239fe1e4f64842cf5577d;hp=0a629559c91a6c51dd6e555aa8f37ffc87bc1467;hpb=df6b431f94b9fb4bb1d350ef8b66e3dcc6f00e85;p=kdenlive diff --git a/src/effectstackedit.cpp b/src/effectstackedit.cpp index 0a629559..e3f86ea1 100644 --- a/src/effectstackedit.cpp +++ b/src/effectstackedit.cpp @@ -35,10 +35,14 @@ #include "doubleparameterwidget.h" #include "cornerswidget.h" #include "beziercurve/beziersplinewidget.h" +#ifdef QJSON +#include "rotoscoping/rotowidget.h" +#endif #include #include #include +#include #include #include @@ -46,6 +50,9 @@ #include #include +// For QDomNode debugging (output into files); leaving here as sample code. +//#define DEBUG_ESE + class Boolval: public QWidget, public Ui::Boolval_UI { @@ -78,13 +85,22 @@ EffectStackEdit::EffectStackEdit(Monitor *monitor, QWidget *parent) : setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); setFrameStyle(QFrame::NoFrame); setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding)); - + + QPalette p = palette(); + KColorScheme scheme(p.currentColorGroup(), KColorScheme::View, KSharedConfig::openConfig(KdenliveSettings::colortheme())); + QColor dark_bg = scheme.shade(KColorScheme::DarkShade); + QColor selected_bg = scheme.decoration(KColorScheme::FocusColor).color(); + QColor hover_bg = scheme.decoration(KColorScheme::HoverColor).color(); + QColor light_bg = scheme.shade(KColorScheme::LightShade); + + QString stylesheet(QString("QProgressBar:horizontal {border: 1px solid %1;border-radius:0px;border-top-left-radius: 4px;border-bottom-left-radius: 4px;border-right: 0px;background:%4;padding: 0px;text-align:left center} QProgressBar:horizontal#dragOnly {background: %1} QProgressBar:horizontal:hover#dragOnly {background: %3} QProgressBar:horizontal:hover {border: 1px solid %3;border-right: 0px;} QProgressBar::chunk:horizontal {background: %1;} QProgressBar::chunk:horizontal:hover {background: %3;} QProgressBar:horizontal[inTimeline=\"true\"] { border: 1px solid %2;border-right: 0px;background: %4;padding: 0px;text-align:left center } QProgressBar::chunk:horizontal[inTimeline=\"true\"] {background: %2;} QAbstractSpinBox#dragBox {border: 1px solid %1;border-top-right-radius: 4px;border-bottom-right-radius: 4px;padding-right:0px;} QAbstractSpinBox::down-button#dragBox {width:0px;padding:0px;} QAbstractSpinBox::up-button#dragBox {width:0px;padding:0px;} QAbstractSpinBox[inTimeline=\"true\"]#dragBox { border: 1px solid %2;} QAbstractSpinBox:hover#dragBox {border: 1px solid %3;} ").arg(dark_bg.name()).arg(selected_bg.name()).arg(hover_bg.name()).arg(light_bg.name())); + setStyleSheet(stylesheet); + setWidget(m_baseWidget); setWidgetResizable(true); m_vbox = new QVBoxLayout(m_baseWidget); m_vbox->setContentsMargins(0, 0, 0, 0); - m_vbox->setSpacing(0); - //wid->show(); + m_vbox->setSpacing(2); } EffectStackEdit::~EffectStackEdit() @@ -103,10 +119,17 @@ void EffectStackEdit::setFrameSize(QPoint p) QString type = pa.attributes().namedItem("type").nodeValue(); QString paramName = i18n(na.toElement().text().toUtf8().data()); - if (type == "geometry" && !KdenliveSettings::on_monitor_effects()) { - Geometryval *geom = ((Geometryval*)m_valueItems[paramName+"geometry"]); - geom->setFrameSize(m_frameSize); - break; + if (type == "geometry") { + if (!KdenliveSettings::on_monitor_effects()) { + Geometryval *geom = ((Geometryval*)m_valueItems[paramName+"geometry"]); + geom->setFrameSize(m_frameSize); + break; + } + else { + GeometryWidget *geom = ((GeometryWidget*)m_valueItems[paramName+"geometry"]); + geom->setFrameSize(m_frameSize); + break; + } } } } @@ -147,7 +170,7 @@ void EffectStackEdit::meetDependency(const QString& name, QString type, QString KisCurveWidget *curve = (KisCurveWidget*)m_valueItems[name]; if (curve) { int color = value.toInt(); - curve->setPixmap(QPixmap::fromImage(ColorTools::rgbCurvePlane(curve->size(), (ColorTools::ColorsRGB)color, 0.8))); + curve->setPixmap(QPixmap::fromImage(ColorTools::rgbCurvePlane(curve->size(), (ColorTools::ColorsRGB)(color == 3 ? 4 : color), 0.8))); } } else if (type == "bezier_spline") { BezierSplineWidget *widget = (BezierSplineWidget*)m_valueItems[name]; @@ -169,22 +192,9 @@ void EffectStackEdit::updateParameter(const QString &name, const QString &value) if (name == "disable") { // if effect is disabled, disable parameters widget - setEnabled(value.toInt() == 0 || !KdenliveSettings::disable_effect_parameters()); - if (KdenliveSettings::on_monitor_effects()) { - // effect disabled, hide monitor scene if any - QDomNodeList namenode = m_params.elementsByTagName("parameter"); - for (int i = 0; i < namenode.count() ; i++) { - QDomNode pa = namenode.item(i); - QDomNode na = pa.firstChildElement("name"); - QString type = pa.attributes().namedItem("type").nodeValue(); - if (type == "geometry") { - QString paramName = i18n(na.toElement().text().toUtf8().data()); - paramName.append("geometry"); - GeometryWidget *geometry = ((GeometryWidget*)m_valueItems.value(paramName)); - geometry->slotShowScene(value.toInt() == 0 || !KdenliveSettings::disable_effect_parameters()); - } - } - } + bool enabled = value.toInt() == 0 || !KdenliveSettings::disable_effect_parameters(); + setEnabled(enabled); + emit effectStateChanged(enabled); } } @@ -202,6 +212,19 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, in } QDomNodeList namenode = m_params.elementsByTagName("parameter"); +#ifdef DEBUG_ESE + QFile debugFile("/tmp/namenodes.txt"); + if (debugFile.open(QFile::WriteOnly | QFile::Truncate)) { + QTextStream out(&debugFile); + QTextStream out2(stdout); + for (int i = 0; i < namenode.size(); i++) { + out << i << ": \n"; + namenode.at(i).save(out, 2); + out2 << i << ": \n"; + namenode.at(i).save(out2, 2); + } + } +#endif QDomElement e = m_params.toElement(); const int minFrame = e.attribute("start").toInt(); const int maxFrame = e.attribute("end").toInt(); @@ -251,16 +274,19 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, in max = pa.attribute("max").toInt(); DoubleParameterWidget *doubleparam = new DoubleParameterWidget(paramName, (int)(value.toDouble() + 0.5), min, max, - pa.attribute("default").toInt(), comment, pa.attribute("suffix"), this); + pa.attribute("default").toInt(), comment, -1, pa.attribute("suffix"), this); m_vbox->addWidget(doubleparam); m_valueItems[paramName] = doubleparam; connect(doubleparam, SIGNAL(valueChanged(int)), this, SLOT(collectAllParameters())); - connect(this, SIGNAL(showComments()), doubleparam, SLOT(slotShowComment())); + connect(this, SIGNAL(showComments(bool)), doubleparam, SLOT(slotShowComment(bool))); } else if (type == "list") { Listval *lsval = new Listval; lsval->setupUi(toFillin); QStringList listitems = pa.attribute("paramlist").split(','); - QStringList listitemsdisplay = pa.attribute("paramlistdisplay").split(','); + QDomElement list = pa.firstChildElement("paramlistdisplay"); + QStringList listitemsdisplay; + if (!list.isNull()) listitemsdisplay = i18n(list.text().toUtf8().data()).split(','); + else listitemsdisplay = i18n(pa.attribute("paramlistdisplay").toUtf8().data()).split(','); if (listitemsdisplay.count() != listitems.count()) listitemsdisplay = listitems; lsval->list->setIconSize(QSize(30, 30)); @@ -277,16 +303,24 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, in } if (!value.isEmpty()) lsval->list->setCurrentIndex(listitems.indexOf(value)); lsval->name->setText(paramName); + lsval->labelComment->setText(comment); + lsval->widgetComment->setHidden(true); m_valueItems[paramName] = lsval; connect(lsval->list, SIGNAL(currentIndexChanged(int)) , this, SLOT(collectAllParameters())); + if (!comment.isEmpty()) + connect(this, SIGNAL(showComments(bool)), lsval->widgetComment, SLOT(setVisible(bool))); m_uiItems.append(lsval); } else if (type == "bool") { Boolval *bval = new Boolval; bval->setupUi(toFillin); bval->checkBox->setCheckState(value == "0" ? Qt::Unchecked : Qt::Checked); bval->name->setText(paramName); + bval->labelComment->setText(comment); + bval->widgetComment->setHidden(true); m_valueItems[paramName] = bval; connect(bval->checkBox, SIGNAL(stateChanged(int)) , this, SLOT(collectAllParameters())); + if (!comment.isEmpty()) + connect(this, SIGNAL(showComments(bool)), bval->widgetComment, SLOT(setVisible(bool))); m_uiItems.append(bval); } else if (type == "complex") { ComplexParameter *pl = new ComplexParameter; @@ -296,7 +330,9 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, in connect(pl, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters())); } else if (type == "geometry") { if (KdenliveSettings::on_monitor_effects()) { - GeometryWidget *geometry = new GeometryWidget(m_monitor, m_timecode, pos, isEffect, disable, this); + GeometryWidget *geometry = new GeometryWidget(m_monitor, m_timecode, pos, isEffect, this); + geometry->setFrameSize(m_frameSize); + geometry->slotShowScene(!disable); // connect this before setupParam to make sure the monitor scene shows up at startup connect(geometry, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int))); connect(geometry, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters())); @@ -308,6 +344,7 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, in m_valueItems[paramName+"geometry"] = geometry; connect(geometry, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int))); connect(this, SIGNAL(syncEffectsPos(int)), geometry, SLOT(slotSyncPosition(int))); + connect(this, SIGNAL(effectStateChanged(bool)), geometry, SLOT(slotShowScene(bool))); } else { Geometryval *geo = new Geometryval(m_profile, m_timecode, m_frameSize, pos); if (minFrame == maxFrame) @@ -323,13 +360,24 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, in } else if (type == "keyframe" || type == "simplekeyframe") { // keyframe editor widget if (m_keyframeEditor == NULL) { - KeyframeEdit *geo = new KeyframeEdit(pa, m_in, m_in + m_out, m_timecode, e.attribute("active_keyframe", "-1").toInt()); + KeyframeEdit *geo; + if (pa.attribute("widget") == "corners") { + // we want a corners-keyframe-widget + CornersWidget *corners = new CornersWidget(m_monitor, pa, m_in, m_in + m_out, m_timecode, e.attribute("active_keyframe", "-1").toInt(), this); + corners->slotShowScene(!disable); + connect(corners, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int))); + connect(this, SIGNAL(effectStateChanged(bool)), corners, SLOT(slotShowScene(bool))); + connect(this, SIGNAL(syncEffectsPos(int)), corners, SLOT(slotSyncPosition(int))); + geo = static_cast(corners); + } else { + geo = new KeyframeEdit(pa, m_in, m_in + m_out, m_timecode, e.attribute("active_keyframe", "-1").toInt()); + } m_vbox->addWidget(geo); m_valueItems[paramName+"keyframe"] = geo; m_keyframeEditor = geo; connect(geo, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters())); connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int))); - connect(this, SIGNAL(showComments()), geo, SIGNAL(showComments())); + connect(this, SIGNAL(showComments(bool)), geo, SIGNAL(showComments(bool))); } else { // we already have a keyframe editor, so just add another column for the new param m_keyframeEditor->addParameter(pa); @@ -396,28 +444,18 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, in QString depends = pa.attribute("depends"); if (!depends.isEmpty()) meetDependency(paramName, type, EffectsList::parameter(e, depends)); - } else if (type == "corners") { - CornersWidget *corners = new CornersWidget(m_monitor, pos, isEffect, pa.attribute("factor").toInt(), this); - connect(corners, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int))); - if (minFrame == maxFrame) - corners->setRange(m_in, m_out); - else - corners->setRange(minFrame, maxFrame); - - QString xName = pa.attribute("xpoints"); - QString yName = pa.attribute("ypoints"); - QPolygon points; - int x, y; - for (int j = 1; j <= 4; ++j) { - x = EffectsList::parameter(e, QString(xName).replace("%i", QString::number(j))).toInt(); - y = EffectsList::parameter(e, QString(yName).replace("%i", QString::number(j))).toInt(); - points << QPoint(x, y); - } - corners->setValue(points); - - m_vbox->addWidget(corners); - connect(corners, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters())); - m_valueItems[paramName] = corners; +#ifdef QJSON + } else if (type == "roto-spline") { + RotoWidget *roto = new RotoWidget(value, m_monitor, m_in, m_out, m_timecode, this); + roto->slotShowScene(!disable); + connect(roto, SIGNAL(valueChanged()), this, SLOT(collectAllParameters())); + connect(roto, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int))); + connect(roto, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int))); + connect(this, SIGNAL(syncEffectsPos(int)), roto, SLOT(slotSyncPosition(int))); + connect(this, SIGNAL(effectStateChanged(bool)), roto, SLOT(slotShowScene(bool))); + m_vbox->addWidget(roto); + m_valueItems[paramName] = roto; +#endif } else if (type == "wipe") { Wipeval *wpval = new Wipeval; wpval->setupUi(toFillin); @@ -497,6 +535,16 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, in if (m_keyframeEditor) m_keyframeEditor->checkVisibleParam(); + + // Make sure all doubleparam spinboxes have the same width, looks much better + QList allWidgets = findChildren(); + int minSize = 0; + for (int i = 0; i < allWidgets.count(); i++) { + if (minSize < allWidgets.at(i)->spinSize()) minSize = allWidgets.at(i)->spinSize(); + } + for (int i = 0; i < allWidgets.count(); i++) { + allWidgets.at(i)->setSpinSize(minSize); + } } wipeInfo EffectStackEdit::getWipeInfo(QString value) @@ -683,17 +731,11 @@ void EffectStackEdit::collectAllParameters() QString depends = pa.attributes().namedItem("depends").nodeValue(); if (!depends.isEmpty()) meetDependency(paramName, type, EffectsList::parameter(newparam, depends)); - } else if (type == "corners") { - CornersWidget *corners = ((CornersWidget*)m_valueItems.value(paramName)); - QString xName = pa.attributes().namedItem("xpoints").nodeValue(); - QString yName = pa.attributes().namedItem("ypoints").nodeValue(); - QPolygon points = corners->getValue(); - QPoint p; - for (int j = 1; j <= 4; ++j) { - p = points.at(j - 1); - EffectsList::setParameter(newparam, QString(xName).replace("%i", QString::number(j)), QString::number(p.x())); - EffectsList::setParameter(newparam, QString(yName).replace("%i", QString::number(j)), QString::number(p.y())); - } +#ifdef QJSON + } else if (type == "roto-spline") { + RotoWidget *widget = static_cast(m_valueItems.value(paramName)); + setValue = widget->getSpline(); +#endif } else if (type == "wipe") { Wipeval *wp = (Wipeval*)m_valueItems.value(paramName); wipeInfo info;