Commit bef6aab3 authored by Martin Owens's avatar Martin Owens Committed by Julius Künzel
Browse files

Add content width and height keywords for assets (effects, transitions,…)

This allows sources with a different resolution than the profile to be animated with effects in a more automated way.

Fixes: #1429
parent 7997adcc
Pipeline #176884 passed with stage
in 7 minutes and 2 seconds
......@@ -82,14 +82,18 @@ The rest:
For double values these placeholders are available:
| placeholder | Header Two |
| :------------- | :------------- |
| `%maxWidth ` | width of the current profile |
| `%maxHeight` | height of the current profile |
| `%width` | synonym for `%maxWidth` |
| `%height` | synonym for `%maxHeight` |
| `%out` | the out position of the current item |
| `%fade"` | the default fade duration (can be configured by the user) |
| placeholder | description |
| :--------------------- | :---------- |
| `%maxWidth ` | width of the current profile |
| `%maxHeight` | height of the current profile |
| `%width` | synonym for `%maxWidth` |
| `%height` | synonym for `%maxHeight` |
| `%contentWidth` | width of the target clip |
| `%contentHeight` | height of the target clip |
| `%fittedContentWidth` | width of the target clip scaled to fit current profile |
| `%fittedContentHeight` | height of the target clip scaled to fit current profile |
| `%out` | the out position of the current item |
| `%fade"` | the default fade duration (can be configured by the user) |
......
......@@ -777,11 +777,17 @@ QVariant AssetParameterModel::parseAttribute(const ObjectId &owner, const QStrin
int in = pCore->getItemIn(owner);
int out = in + pCore->getItemDuration(owner) - 1;
int frame_duration = pCore->getDurationFromString(KdenliveSettings::fade_duration());
double fitScale = qMin(double(width) / double(frameSize.width()),
double(height) / double(frameSize.height()));
// replace symbols in the double parameter
content.replace(QLatin1String("%maxWidth"), QString::number(width))
.replace(QLatin1String("%maxHeight"), QString::number(height))
.replace(QLatin1String("%width"), QString::number(width))
.replace(QLatin1String("%height"), QString::number(height))
.replace(QLatin1String("%contentWidth"), QString::number(frameSize.width()))
.replace(QLatin1String("%contentHeight"), QString::number(frameSize.height()))
.replace(QLatin1String("%fittedContentWidth"), QString::number(frameSize.width() * fitScale))
.replace(QLatin1String("%fittedContentHeight"), QString::number(frameSize.height() * fitScale))
.replace(QLatin1String("%out"), QString::number(out))
.replace(QLatin1String("%fade"), QString::number(frame_duration));
if ((type == ParamType::AnimatedRect || type == ParamType::Geometry) && attribute == QLatin1String("default")) {
......
Supports Markdown
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