Commit 7f5e10cc authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fix mix crossfade sometimes using wrong order (starting at 100% and ending at...

Fix mix crossfade sometimes using wrong order (starting at 100% and ending at 0%) instead of reverse
parent 4cd22b23
...@@ -1882,9 +1882,6 @@ bool TrackModel::requestClipMix(std::pair<int, int> clipIds, int mixDuration, bo ...@@ -1882,9 +1882,6 @@ bool TrackModel::requestClipMix(std::pair<int, int> clipIds, int mixDuration, bo
t->set("kdenlive:mixcut", secondClipCut); t->set("kdenlive:mixcut", secondClipCut);
t->set("start", -1); t->set("start", -1);
t->set("accepts_blanks", 1); t->set("accepts_blanks", 1);
if (dest_track == 0) {
t->set("reverse", 1);
}
m_track->plant_transition(*t.get(), 0, 1); m_track->plant_transition(*t.get(), 0, 1);
assetName = QStringLiteral("mix"); assetName = QStringLiteral("mix");
} else { } else {
...@@ -1892,13 +1889,16 @@ bool TrackModel::requestClipMix(std::pair<int, int> clipIds, int mixDuration, bo ...@@ -1892,13 +1889,16 @@ bool TrackModel::requestClipMix(std::pair<int, int> clipIds, int mixDuration, bo
t->set_in_and_out(mixPosition, mixPosition + mixDuration); t->set_in_and_out(mixPosition, mixPosition + mixDuration);
t->set("kdenlive:mixcut", secondClipCut); t->set("kdenlive:mixcut", secondClipCut);
t->set("kdenlive_id", "luma"); t->set("kdenlive_id", "luma");
m_track->plant_transition(*t.get(), 0, 1);
if (dest_track == 0) { if (dest_track == 0) {
t->set("reverse", 1); t->set("reverse", 1);
} }
m_track->plant_transition(*t.get(), 0, 1);
assetName = QStringLiteral("luma"); assetName = QStringLiteral("luma");
} }
QDomElement xml = TransitionsRepository::get()->getXml(assetName); QDomElement xml = TransitionsRepository::get()->getXml(assetName);
if (dest_track == 0 && Xml::hasXmlParameter(xml, QStringLiteral("reverse"))) {
Xml::setXmlParameter(xml, QStringLiteral("reverse"), QStringLiteral("1"));
}
std::shared_ptr<AssetParameterModel> asset(new AssetParameterModel(std::move(t), xml, assetName, {ObjectType::TimelineMix, clipIds.second}, QString())); std::shared_ptr<AssetParameterModel> asset(new AssetParameterModel(std::move(t), xml, assetName, {ObjectType::TimelineMix, clipIds.second}, QString()));
m_sameCompositions[clipIds.second] = asset; m_sameCompositions[clipIds.second] = asset;
m_mixList.insert(clipIds.first, clipIds.second); m_mixList.insert(clipIds.first, clipIds.second);
......
...@@ -134,6 +134,33 @@ void Xml::setXmlProperty(QDomElement element, const QString &propertyName, const ...@@ -134,6 +134,33 @@ void Xml::setXmlProperty(QDomElement element, const QString &propertyName, const
} }
} }
void Xml::setXmlParameter(QDomElement element, const QString &propertyName, const QString &value)
{
QDomNodeList params = element.elementsByTagName(QStringLiteral("parameter"));
// Update property if it already exists
bool found = false;
for (int i = 0; i < params.count(); ++i) {
QDomElement e = params.item(i).toElement();
if (e.attribute(QStringLiteral("name")) == propertyName) {
e.setAttribute(QStringLiteral("value"), value);
found = true;
break;
}
}
}
bool Xml::hasXmlParameter(QDomElement element, const QString &propertyName)
{
QDomNodeList params = element.elementsByTagName(QStringLiteral("parameter"));
for (int i = 0; i < params.count(); ++i) {
QDomElement e = params.item(i).toElement();
if (e.attribute(QStringLiteral("name")) == propertyName) {
return true;
}
}
return false;
}
bool Xml::hasXmlProperty(QDomElement element, const QString &propertyName) bool Xml::hasXmlProperty(QDomElement element, const QString &propertyName)
{ {
QDomNodeList params = element.elementsByTagName(QStringLiteral("property")); QDomNodeList params = element.elementsByTagName(QStringLiteral("property"));
......
...@@ -64,6 +64,7 @@ QString getXmlParameter(const QDomElement &element, const QString &propertyName, ...@@ -64,6 +64,7 @@ QString getXmlParameter(const QDomElement &element, const QString &propertyName,
/** @brief Returns true if the element contains a named property /** @brief Returns true if the element contains a named property
*/ */
bool hasXmlProperty(QDomElement element, const QString &propertyName); bool hasXmlProperty(QDomElement element, const QString &propertyName);
bool hasXmlParameter(QDomElement element, const QString &propertyName);
/** @brief Add properties to the given xml element /** @brief Add properties to the given xml element
For each element (n, v) in the properties map, it creates a sub element of the form : <property name="n">v</property> For each element (n, v) in the properties map, it creates a sub element of the form : <property name="n">v</property>
...@@ -75,6 +76,7 @@ void addXmlProperties(QDomElement &producer, const QMap<QString, QString> &prope ...@@ -75,6 +76,7 @@ void addXmlProperties(QDomElement &producer, const QMap<QString, QString> &prope
/** @brief Edit or add a property /** @brief Edit or add a property
*/ */
void setXmlProperty(QDomElement element, const QString &propertyName, const QString &value); void setXmlProperty(QDomElement element, const QString &propertyName, const QString &value);
void setXmlParameter(QDomElement element, const QString &propertyName, const QString &value);
/** @brief Remove a property /** @brief Remove a property
*/ */
void removeXmlProperty(QDomElement effect, const QString &name); void removeXmlProperty(QDomElement effect, const QString &name);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment