Offset will be added to values coming from MLT after the attribute "factor" is applied.
svn path=/trunk/kdenlive/; revision=5910
- number
- represented by a slider
- additional parameter attributes:
- - "factor": (optional) values coming from MLT will be multiplied with factor, values from the GUI divided by factor
+ - "factor": (optional) values coming from MLT will be multiplied with factor
+ - "offset": (optional) will be added to values coming from MLT after "factor" is applied
- "min": smallest value possible (after multiplying with "factor")
- "max": largest value possible (after multiplying with "factor")
- "suffix": (optional) displayed unit of the values
if (e.attribute("type") == "simplekeyframe") {
QStringList values = e.attribute("keyframes").split(";", QString::SkipEmptyParts);
double factor = locale.toDouble(e.attribute("factor", "1"));
- if (factor != 1) {
+ double offset = e.attribute("offset", "0").toDouble();
+ if (factor != 1 || offset != 0) {
for (int j = 0; j < values.count(); j++) {
QString pos = values.at(j).section(':', 0, 0);
- double val = locale.toDouble(values.at(j).section(':', 1, 1)) / factor;
+ double val = (locale.toDouble(values.at(j).section(':', 1, 1)) - offset) / factor;
values[j] = pos + "=" + locale.toString(val);
}
}
parameters.addParam("max", e.attribute("max"));
parameters.addParam("min", e.attribute("min"));
parameters.addParam("factor", e.attribute("factor", "1"));
+ parameters.addParam("offset", e.attribute("offset", "0"));
parameters.addParam("starttag", e.attribute("starttag", "start"));
parameters.addParam("endtag", e.attribute("endtag", "end"));
- } else if (e.attribute("factor", "1") == "1") {
+ } else if (e.attribute("factor", "1") == "1" && e.attribute("offset", "0") == "0") {
parameters.addParam(e.attribute("name"), e.attribute("value"));
// check if it is a fade effect
double fact;
if (e.attribute("factor").contains('%')) {
fact = ProfilesDialog::getStringEval(projectScene()->profile(), e.attribute("factor"));
- } else fact = locale.toDouble(e.attribute("factor", "1"));
- parameters.addParam(e.attribute("name"), locale.toString(locale.toDouble(e.attribute("value")) / fact));
+ } else {
+ fact = locale.toDouble(e.attribute("factor", "1"));
+ }
+ double offset = e.attribute("offset", "0").toDouble();
+ parameters.addParam(e.attribute("name"), locale.toString((locale.toDouble(e.attribute("value")) - offset) / fact));
}
}
}
QStringList values = e.attribute("keyframes").split(";", QString::SkipEmptyParts);
double factor = e.attribute("factor", "1").toDouble();
+ double offset = e.attribute("offset", "0").toDouble();
for (int j = 0; j < values.count(); j++) {
QString pos = values.at(j).section(':', 0, 0);
- double val = values.at(j).section(':', 1, 1).toDouble() / factor;
+ double val = (values.at(j).section(':', 1, 1).toDouble() - offset) / factor;
values[j] = pos + "=" + locale.toString(val);
}
// kDebug() << "/ / / /SENDING KEYFR:" << values;
parameters.addParam("max", e.attribute("max"));
parameters.addParam("min", e.attribute("min"));
parameters.addParam("factor", e.attribute("factor", "1"));
+ parameters.addParam("offset", e.attribute("offset", "0"));
parameters.addParam("starttag", e.attribute("starttag", "start"));
parameters.addParam("endtag", e.attribute("endtag", "end"));
} else if (e.attribute("namedesc").contains(';')) {
}
parameters.addParam("start", neu);
} else {
- if (e.attribute("factor", "1") != "1") {
+ if (e.attribute("factor", "1") != "1" || e.attribute("offset", "0") != "0") {
double fact;
if (e.attribute("factor").contains('%')) {
fact = ProfilesDialog::getStringEval(m_document->mltProfile(), e.attribute("factor"));
- } else fact = e.attribute("factor", "1").toDouble();
- parameters.addParam(e.attribute("name"), locale.toString(e.attribute("value").toDouble() / fact));
+ } else {
+ fact = e.attribute("factor", "1").toDouble();
+ }
+ double offset = e.attribute("offset", "0").toDouble();
+ parameters.addParam(e.attribute("name"), locale.toString((e.attribute("value").toDouble() - offset) / fact));
} else {
parameters.addParam(e.attribute("name"), e.attribute("value"));
}
//double max = params.paramValue("max").toDouble();
double min = params.paramValue("min").toDouble();
double factor = params.paramValue("factor", "1").toDouble();
+ double paramOffset = params.paramValue("offset", "0").toDouble();
params.removeParam("starttag");
params.removeParam("endtag");
params.removeParam("keyframes");
params.removeParam("min");
params.removeParam("max");
params.removeParam("factor");
+ params.removeParam("offset");
int offset = 0;
// Special case, only one keyframe, means we want a constant value
if (keyFrames.count() == 1) {
}
filter->set("in", x1);
//kDebug() << "// ADDING KEYFRAME vals: " << min<<" / "<<max<<", "<<y1<<", factor: "<<factor;
- filter->set(starttag, m_locale.toString((min + y1) / factor).toUtf8().data());
+ filter->set(starttag, m_locale.toString(((min + y1) - paramOffset) / factor).toUtf8().data());
service.attach(*filter);
}
} else for (int i = 0; i < keyFrames.size() - 1; ++i) {
filter->set("in", x1);
filter->set("out", x2);
//kDebug() << "// ADDING KEYFRAME vals: " << min<<" / "<<max<<", "<<y1<<", factor: "<<factor;
- filter->set(starttag, m_locale.toString((min + y1) / factor).toUtf8().data());
- filter->set(endtag, m_locale.toString((min + y2) / factor).toUtf8().data());
+ filter->set(starttag, m_locale.toString(((min + y1) - paramOffset) / factor).toUtf8().data());
+ filter->set(endtag, m_locale.toString(((min + y2) - paramOffset) / factor).toUtf8().data());
service.attach(*filter);
offset = 1;
}
if (!e.attribute("value").isEmpty()) {
map[name] = e.attribute("value");
}
- if (e.attribute("type") != "addedgeometry" && !e.attribute("factor").isEmpty() && e.attribute("factor").toDouble() > 0) {
- map[name] = m_locale.toString(map.value(name).toDouble() / e.attribute("factor").toDouble());
+ if (e.attribute("type") != "addedgeometry" && (e.attribute("factor", "1") != "1" || e.attribute("offset", "0") != "0")) {
+ map[name] = m_locale.toString((map.value(name).toDouble() - e.attribute("offset", "0").toDouble()) / e.attribute("factor", "1").toDouble());
//map[name]=map[name].replace(".",","); //FIXME how to solve locale conversion of . ,
}
if (!e.isNull() && e.attribute("tag") == paramName) {
if (e.attribute("type") == "double") {
QString factor = e.attribute("factor", "1");
- if (factor != "1") {
+ double offset = e.attribute("offset", "0").toDouble();
+ if (factor != "1" || offset != 0) {
double fact;
if (factor.contains('%')) {
fact = ProfilesDialog::getStringEval(m_doc->mltProfile(), factor);
- } else fact = factor.toDouble();
- double val = paramValue.toDouble() * fact;
- paramValue = QString::number(val);
+ } else {
+ fact = factor.toDouble();
+ }
+ paramValue = QLocale().toString(offset + paramValue.toDouble() * fact);
}
}
e.setAttribute("value", paramValue);
QString factor;
QString starttag;
QString endtag;
+ double offset = 0;
QDomNodeList params = currenteffect.elementsByTagName("parameter");
for (int i = 0; i < params.count(); i++) {
QDomElement e = params.item(i).toElement();
starttag = e.attribute("starttag", "start");
endtag = e.attribute("endtag", "end");
factor = e.attribute("factor", "1");
+ offset = e.attribute("offset", "0").toDouble();
break;
}
}
double startvalue = 0;
double endvalue = 0;
double fact;
- if (factor.isEmpty()) fact = 1;
- else if (factor.contains('%')) {
+ if (factor.contains('%')) {
fact = ProfilesDialog::getStringEval(m_doc->mltProfile(), factor);
- } else fact = factor.toDouble();
+ } 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() * fact;
+ startvalue = offset + effectparam.text().toDouble() * fact;
if (effectparam.attribute("name") == endtag)
- endvalue = effectparam.text().toDouble() * fact;
+ endvalue = offset + effectparam.text().toDouble() * fact;
}
// add first keyframe
if (effectout <= effectin) {
continueParsing = false;
break;
} else if (subeffectparam.attribute("name") == endtag) {
- endvalue = subeffectparam.text().toDouble() * fact;
+ endvalue = offset + subeffectparam.text().toDouble() * fact;
break;
}
}
} else {
fact = factor.toDouble();
}
+ double offset = e.attribute("offset", "0").toDouble();
if (type == "simplekeyframe") {
QStringList kfrs = paramvalue.split(";");
for (int l = 0; l < kfrs.count(); l++) {
QString fr = kfrs.at(l).section('=', 0, 0);
double val = locale.toDouble(kfrs.at(l).section('=', 1, 1));
//kfrs[l] = fr + ":" + locale.toString((int)(val * fact));
- kfrs[l] = fr + ":" + QString::number((int) (val * fact));
+ kfrs[l] = fr + ":" + QString::number((int) (offset + val * fact));
}
e.setAttribute("keyframes", kfrs.join(";"));
} else if (type == "double" || type == "constant") {
bool ok;
- e.setAttribute("value", locale.toDouble(paramvalue, &ok) * fact);
+ e.setAttribute("value", offset + locale.toDouble(paramvalue, &ok) * fact);
if (!ok)
e.setAttribute("value", paramvalue);
} else {