mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 02:01:40 -05:00
QtLottie: Drop expressions.
This commit is contained in:
parent
c1ae825d98
commit
21eaa35d8c
5 changed files with 23 additions and 64 deletions
2
Telegram/ThirdParty/qtlottie
vendored
2
Telegram/ThirdParty/qtlottie
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 2a529ab07bd105e0cac1a58ad5cb77f2fdc8f20d
|
||||
Subproject commit 18b8ae7d9980f7e46980abfb275439782fc4c239
|
|
@ -69,14 +69,11 @@ public:
|
|||
virtual bool setProperty(BMLiteral::PropertyType propertyType, QVariant value);
|
||||
|
||||
QString name() const;
|
||||
void setName(const QString &name);
|
||||
|
||||
int type() const;
|
||||
void setType(int type);
|
||||
virtual void parse(const QJsonObject &definition);
|
||||
|
||||
const QJsonObject& definition() const;
|
||||
|
||||
virtual bool active(int frame) const;
|
||||
bool hidden() const;
|
||||
|
||||
|
@ -96,11 +93,9 @@ public:
|
|||
protected:
|
||||
virtual BMScene *resolveTopRoot() const;
|
||||
BMScene *topRoot() const;
|
||||
const QJsonObject resolveExpression(const QJsonObject& definition);
|
||||
|
||||
protected:
|
||||
QJsonObject m_definition;
|
||||
int m_type;
|
||||
int m_type = 0;
|
||||
bool m_hidden = false;
|
||||
QString m_name;
|
||||
QString m_matchName;
|
||||
|
|
|
@ -91,7 +91,6 @@ public:
|
|||
qCWarning(lcLottieQtBodymovinParser)
|
||||
<< "Property is split into separate x and y but it is not supported";
|
||||
|
||||
bool fromExpression = definition.value(QLatin1String("fromExpression")).toBool();
|
||||
m_animated = definition.value(QLatin1String("a")).toDouble() > 0;
|
||||
if (m_animated) {
|
||||
QJsonArray keyframes = definition.value(QLatin1String("k")).toArray();
|
||||
|
@ -99,15 +98,13 @@ public:
|
|||
QJsonArray::const_iterator previous;
|
||||
while (it != keyframes.constEnd()) {
|
||||
QJsonObject keyframe = (*it).toObject();
|
||||
EasingSegment<T> easing = parseKeyframe(keyframe,
|
||||
fromExpression);
|
||||
EasingSegment<T> easing = parseKeyframe(keyframe);
|
||||
addEasing(easing);
|
||||
|
||||
if (m_easingCurves.length() > 1) {
|
||||
postprocessEasingCurve(
|
||||
m_easingCurves[m_easingCurves.length() - 2],
|
||||
(*previous).toObject(),
|
||||
fromExpression);
|
||||
(*previous).toObject());
|
||||
}
|
||||
previous = it;
|
||||
++it;
|
||||
|
@ -118,8 +115,7 @@ public:
|
|||
if (last.state == EasingSegmentState::Complete) {
|
||||
postprocessEasingCurve(
|
||||
last,
|
||||
(*previous).toObject(),
|
||||
fromExpression);
|
||||
(*previous).toObject());
|
||||
}
|
||||
}
|
||||
m_value = T();
|
||||
|
@ -214,11 +210,8 @@ protected:
|
|||
return m_currentEasing;
|
||||
}
|
||||
|
||||
virtual EasingSegment<T> parseKeyframe(const QJsonObject keyframe,
|
||||
bool fromExpression)
|
||||
virtual EasingSegment<T> parseKeyframe(const QJsonObject keyframe)
|
||||
{
|
||||
Q_UNUSED(fromExpression);
|
||||
|
||||
EasingSegment<T> easing;
|
||||
|
||||
int startTime = keyframe.value(QLatin1String("t")).toVariant().toInt();
|
||||
|
@ -274,8 +267,7 @@ protected:
|
|||
|
||||
virtual void postprocessEasingCurve(
|
||||
EasingSegment<T> &easing,
|
||||
const QJsonObject keyframe,
|
||||
bool fromExpression) {
|
||||
const QJsonObject keyframe) {
|
||||
}
|
||||
|
||||
virtual T getValue(const QJsonValue &value)
|
||||
|
@ -327,8 +319,7 @@ protected:
|
|||
return T();
|
||||
}
|
||||
|
||||
EasingSegment<T> parseKeyframe(const QJsonObject keyframe,
|
||||
bool fromExpression) override
|
||||
EasingSegment<T> parseKeyframe(const QJsonObject keyframe) override
|
||||
{
|
||||
QJsonArray startValues = keyframe.value(QLatin1String("s")).toArray();
|
||||
QJsonArray endValues = keyframe.value(QLatin1String("e")).toArray();
|
||||
|
@ -363,15 +354,8 @@ protected:
|
|||
this->m_startFrame = startTime;
|
||||
|
||||
qreal xs, ys;
|
||||
// Keyframes originating from an expression use only scalar values.
|
||||
// They must be expanded for both x and y coordinates
|
||||
if (fromExpression) {
|
||||
xs = startValues.at(0).toDouble();
|
||||
ys = startValues.at(0).toDouble();
|
||||
} else {
|
||||
xs = startValues.at(0).toDouble();
|
||||
ys = startValues.at(1).toDouble();
|
||||
}
|
||||
xs = startValues.at(0).toDouble();
|
||||
ys = startValues.at(1).toDouble();
|
||||
T s(xs, ys);
|
||||
|
||||
QJsonObject easingIn = keyframe.value(QLatin1String("i")).toObject();
|
||||
|
@ -381,15 +365,8 @@ protected:
|
|||
easingCurve.startValue = s;
|
||||
if (!endValues.isEmpty()) {
|
||||
qreal xe, ye;
|
||||
// Keyframes originating from an expression use only scalar values.
|
||||
// They must be expanded for both x and y coordinates
|
||||
if (fromExpression) {
|
||||
xe = endValues.at(0).toDouble();
|
||||
ye = endValues.at(0).toDouble();
|
||||
} else {
|
||||
xe = endValues.at(0).toDouble();
|
||||
ye = endValues.at(1).toDouble();
|
||||
}
|
||||
xe = endValues.at(0).toDouble();
|
||||
ye = endValues.at(1).toDouble();
|
||||
T e(xe, ye);
|
||||
easingCurve.endValue = e;
|
||||
easingCurve.state = EasingSegmentState::Complete;
|
||||
|
|
|
@ -94,6 +94,9 @@ private:
|
|||
|
||||
bool _unsupported = false;
|
||||
|
||||
// Parsing stage.
|
||||
bool _parsing = false;
|
||||
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
@ -59,37 +59,21 @@ public:
|
|||
|
||||
virtual void postprocessEasingCurve(
|
||||
EasingSegment<QPointF> &easing,
|
||||
const QJsonObject keyframe,
|
||||
bool fromExpression) override {
|
||||
const QJsonObject keyframe) override {
|
||||
// No need to parse further incomplete keyframes (i.e. last keyframes)
|
||||
if (easing.state != EasingSegmentState::Complete) {
|
||||
return;
|
||||
}
|
||||
|
||||
qreal tix = 0, tiy = 0, tox = 0, toy = 0;
|
||||
if (fromExpression) {
|
||||
// If spatial property definition originates from
|
||||
// an expression (specifically Slider), it contains scalar
|
||||
// property. It must be expanded to both x and y coordinates
|
||||
QJsonArray iArr = keyframe.value(QLatin1String("i")).toArray();
|
||||
QJsonArray oArr = keyframe.value(QLatin1String("o")).toArray();
|
||||
QJsonArray tiArr = keyframe.value(QLatin1String("ti")).toArray();
|
||||
QJsonArray toArr = keyframe.value(QLatin1String("to")).toArray();
|
||||
|
||||
if (iArr.count() && oArr.count()) {
|
||||
tix = iArr.at(0).toDouble();
|
||||
tiy = tix;
|
||||
tox = oArr.at(0).toDouble();
|
||||
toy = tox;
|
||||
}
|
||||
} else {
|
||||
QJsonArray tiArr = keyframe.value(QLatin1String("ti")).toArray();
|
||||
QJsonArray toArr = keyframe.value(QLatin1String("to")).toArray();
|
||||
|
||||
if (tiArr.count() && toArr.count()) {
|
||||
tix = tiArr.at(0).toDouble();
|
||||
tiy = tiArr.at(1).toDouble();
|
||||
tox = toArr.at(0).toDouble();
|
||||
toy = toArr.at(1).toDouble();
|
||||
}
|
||||
if (tiArr.count() && toArr.count()) {
|
||||
tix = tiArr.at(0).toDouble();
|
||||
tiy = tiArr.at(1).toDouble();
|
||||
tox = toArr.at(0).toDouble();
|
||||
toy = toArr.at(1).toDouble();
|
||||
}
|
||||
QPointF s(easing.startValue);
|
||||
QPointF e(easing.endValue);
|
||||
|
|
Loading…
Add table
Reference in a new issue