#include "transition.h"
#include "kdenlivesettings.h"
#include "kthumb.h"
+#include "profilesdialog.h"
#include <KDebug>
#include <KIcon>
for (int i = 0; i < params.count(); i++) {
QDomElement e = params.item(i).toElement();
kDebug() << "// init eff: " << e.attribute("name");
+
+ // Check if this effect has a variable parameter
+ if (e.attribute("default").startsWith('%')) {
+ double evaluatedValue = ProfilesDialog::getStringEval(projectScene()->profile(), e.attribute("default"));
+ e.setAttribute("default", evaluatedValue);
+ if (e.hasAttribute("value") && e.attribute("value").startsWith('%')) {
+ e.setAttribute("value", evaluatedValue);
+ }
+ }
+
if (!e.isNull() && e.attribute("type") == "keyframe") {
QString def = e.attribute("default");
// Effect has a keyframe type parameter, we need to set the values
kDebug() << "Invalid effect index: " << ix;
return;
}
- kDebug() << "CHange EFFECT AT: " << ix << ", CURR: " << m_effectList.at(ix).attribute("tag") << ", NEW: " << effect.attribute("tag");
+ //kDebug() << "CHange EFFECT AT: " << ix << ", CURR: " << m_effectList.at(ix).attribute("tag") << ", NEW: " << effect.attribute("tag");
effect.setAttribute("kdenlive_ix", ix + 1);
m_effectList.insert(ix, effect);
m_effectList.removeAt(ix + 1);
parameters.addParam("endtag", e.attribute("endtag", "end"));
}
- double f = e.attribute("factor", "1").toDouble();
-
- if (f == 1) {
+ if (e.attribute("factor", "1") == "1") {
parameters.addParam(e.attribute("name"), e.attribute("value"));
// check if it is a fade effect
}
}
} else {
- parameters.addParam(e.attribute("name"), QString::number(e.attribute("value").toDouble() / f));
+ double fact;
+ if (e.attribute("factor").startsWith('%')) {
+ fact = ProfilesDialog::getStringEval(projectScene()->profile(), e.attribute("factor"));
+ } else fact = e.attribute("factor", "1").toDouble();
+ parameters.addParam(e.attribute("name"), QString::number(e.attribute("value").toDouble() / fact));
}
}
}
parameters.addParam("start", neu);
} else {
if (e.attribute("factor", "1") != "1") {
- parameters.addParam(e.attribute("name"), QString::number(e.attribute("value").toDouble() / e.attribute("factor").toDouble()));
+ double fact;
+ if (e.attribute("factor").startsWith('%')) {
+ fact = ProfilesDialog::getStringEval(projectScene()->profile(), e.attribute("factor"));
+ } else fact = e.attribute("factor", "1").toDouble();
+ parameters.addParam(e.attribute("name"), QString::number(e.attribute("value").toDouble() / fact));
} else {
parameters.addParam(e.attribute("name"), e.attribute("value"));
}
return m_document->tracksCount();
}
+MltVideoProfile CustomTrackScene::profile() const
+{
+ return m_document->mltProfile();
+}
+
#include "customtrackscene.moc"
#include "gentime.h"
class KdenliveDoc;
+class MltVideoProfile;
/** This class holds all properties that need to be used by clip items */
QPointF scale() const;
int tracksCount() const;
QPixmap m_transitionPixmap;
+ MltVideoProfile profile() const;
private:
KdenliveDoc *m_document;
#include "keyframeedit.h"
#include "effectslist.h"
#include "kdenlivesettings.h"
+#include "profilesdialog.h"
#include <KDebug>
#include <KLocale>
QWidget * toFillin = new QWidget;
QString value = pa.attribute("value").isNull() ?
pa.attribute("default") : pa.attribute("value");
+
if (type == "geometry") {
/*pa.setAttribute("namedesc", "X;Y;Width;Height;Transparency");
pa.setAttribute("format", "%d%,%d%:%d%x%d%:%d");
//TODO constant, list, bool, complex , color, geometry, position
if (type == "double" || type == "constant") {
- createSliderItem(paramName, value.toInt(), pa.attribute("min").toInt(), pa.attribute("max").toInt());
+ int min;
+ int max;
+ if (pa.attribute("min").startsWith('%')) {
+ min = (int) ProfilesDialog::getStringEval(m_profile, pa.attribute("min"));
+ }
+ else min = pa.attribute("min").toInt();
+ if (pa.attribute("max").startsWith('%')) {
+ max = (int) ProfilesDialog::getStringEval(m_profile, pa.attribute("max"));
+ }
+ else max = pa.attribute("max").toInt();
+ createSliderItem(paramName, (int)(value.toDouble() + 0.5) , min, max);
delete toFillin;
toFillin = NULL;
} else if (type == "list") {
QWidget* toFillin = new QWidget;
Constval *ctval = new Constval;
ctval->setupUi(toFillin);
-
ctval->horizontalSlider->setMinimum(min);
ctval->horizontalSlider->setMaximum(max);
ctval->spinBox->setMinimum(min);
if (m_activeDocument->profilePath() != profile) {
// Profile was changed
double dar = m_activeDocument->dar();
+
+ // Deselect current effect / transition
+ m_effectStack->slotClipItemSelected(NULL, 0);
+ m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
+
m_activeDocument->setProfilePath(profile);
KdenliveSettings::setCurrent_profile(profile);
KdenliveSettings::setProject_fps(m_activeDocument->fps());
setCaption(m_activeDocument->description(), m_activeDocument->isModified());
m_monitorManager->resetProfiles(m_activeDocument->timecode());
+ m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeTimeline->tracksNumber());
+ m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
return result;
}
+// static
+double ProfilesDialog::getStringEval(const MltVideoProfile &profile, QString eval)
+{
+ double result;
+ eval.replace("%width", QString::number(profile.width));
+ eval.replace("%height", QString::number(profile.height));
+ if (eval.contains('/')) result = (double) eval.section('/', 0, 0).toInt() / eval.section('/', 1, 1).toInt();
+ else if (eval.contains('*')) result = (double) eval.section('*', 0, 0).toInt() * eval.section('*', 1, 1).toInt();
+ else if (eval.contains('+')) result = (double) eval.section('+', 0, 0).toInt() + eval.section('+', 1, 1).toInt();
+ else if (eval.contains('-')) result = (double) eval.section('-', 0, 0).toInt() - eval.section('-', 1, 1).toInt();
+ else result = eval.toDouble();
+ return result;
+}
+
// static
bool ProfilesDialog::existingProfileDescription(const QString &desc)
static void saveProfile(MltVideoProfile &profile);
static QString existingProfile(MltVideoProfile profile);
static bool existingProfileDescription(const QString &desc);
+ static double getStringEval(const MltVideoProfile &profile, QString eval);
protected:
virtual void closeEvent(QCloseEvent *event);
#include "mainwindow.h"
#include "customtrackview.h"
#include "initeffects.h"
+#include "profilesdialog.h"
#include <KDebug>
#include <KMessageBox>
QDomElement e = params.item(i).toElement();
if (!e.isNull() && e.attribute("tag") == paramName) {
if (e.attribute("type") == "double") {
- QString factor = e.attribute("factor", "1");
+ QString factor = e.attribute("factor", "1");
if (factor != "1") {
- double val = paramValue.toDouble() * factor.toDouble();
+ double fact;
+ if (factor.startsWith('%')) {
+ fact = ProfilesDialog::getStringEval(m_doc->mltProfile(), factor);
+ }
+ else fact = factor.toDouble();
+ double val = paramValue.toDouble() * fact;
paramValue = QString::number(val);
}
}
if (MainWindow::videoEffects.hasKeyFrames(currenteffect)) {
//kDebug() << " * * * * * * * * * * ** CLIP EFF WITH KFR FND * * * * * * * * * * *";
// effect is key-framable, read all effects to retrieve keyframes
- double factor = 0;
+ QString factor;
QString starttag;
QString endtag;
QDomNodeList params = currenteffect.elementsByTagName("parameter");
if (e.attribute("type") == "keyframe") {
starttag = e.attribute("starttag", "start");
endtag = e.attribute("endtag", "end");
- factor = e.attribute("factor", "1").toDouble();
+ factor = e.attribute("factor", "1");
break;
}
}
int effectout = effect.attribute("out").toInt();
double startvalue = 0;
double endvalue = 0;
+ double fact;
+ if (factor.isEmpty()) fact = 1;
+ else if (factor.startsWith('%')) {
+ fact = ProfilesDialog::getStringEval(m_doc->mltProfile(), factor);
+ } else fact = factor.toDouble();
for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
// parse effect parameters
QDomElement effectparam = n3.toElement();
if (effectparam.attribute("name") == starttag)
- startvalue = effectparam.text().toDouble() * factor;
+ startvalue = effectparam.text().toDouble() * fact;
if (effectparam.attribute("name") == endtag)
- endvalue = effectparam.text().toDouble() * factor;
+ endvalue = effectparam.text().toDouble() * fact;
}
// add first keyframe
keyframes.append(QString::number(effectin) + ':' + QString::number(startvalue) + ';' + QString::number(effectout) + ':' + QString::number(endvalue) + ';');
continueParsing = false;
break;
} else if (subeffectparam.attribute("name") == endtag) {
- endvalue = subeffectparam.text().toDouble() * factor;
+ endvalue = subeffectparam.text().toDouble() * fact;
break;
}
}
for (int k = 0; k < clipeffectparams.count(); k++) {
e = clipeffectparams.item(k).toElement();
if (!e.isNull() && e.tagName() == "parameter" && e.attribute("name") == paramname) {
- double factor = e.attribute("factor", "1").toDouble();
- if (factor != 1) {
- e.setAttribute("value", paramvalue.toDouble() * factor);
+ if (e.attribute("factor", "1") != "1") {
+ QString factor = e.attribute("factor", "1");
+ double fact;
+ if (factor.startsWith('%')) {
+ fact = ProfilesDialog::getStringEval(m_doc->mltProfile(), factor);
+ } else fact = factor.toDouble();
+ e.setAttribute("value", paramvalue.toDouble() * fact);
} else e.setAttribute("value", paramvalue);
break;
}