summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Buhr <andreas@andreasbuhr.de>2021-01-14 16:03:32 +0100
committerAndreas Buhr <andreas@andreasbuhr.de>2021-03-31 15:22:22 +0200
commit7f24570af4dc7e2386ae4831460b85f2f32a2d57 (patch)
treebb8447a58250543b745ba26fa96a9c07b4bb27f2
parent9c3acc74ed4798f037fd58a9dad996040fc3f5d8 (diff)
Consistent naming for (to|from)Is(Defined|Sourced) in animations
To store whether "from" and "to" values are defined and/or sourced, QQuickPathAnimationUpdater used fromDefined format, QQuickAbstractAnimationPrivate used fromIsDefined format, QQuickAnimationPropertyUpdater used fromIsDefined format, QQuickAnimatorPrivate used isFromDefined format, QQuickBulkValueAnimator used fromDefined format, QQuickAnimationPropertyUpdater used fromDefined format. This patch changes all these to use the variable names "fromIsDefined", "fromIsSourced", and "toIsDefined". This makes the code more readable. Change-Id: Ia6c228208eb651247b0ba70f83afadb5b1027049 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit 702b00bc8bfdc51592a01c9b7ed5939d85a7e192)
-rw-r--r--src/quick/items/qquickitemanimation.cpp27
-rw-r--r--src/quick/items/qquickitemanimation_p_p.h8
-rw-r--r--src/quick/util/qquickanimation.cpp16
-rw-r--r--src/quick/util/qquickanimation_p_p.h10
-rw-r--r--src/quick/util/qquickanimator.cpp12
-rw-r--r--src/quick/util/qquickanimator_p_p.h8
6 files changed, 40 insertions, 41 deletions
diff --git a/src/quick/items/qquickitemanimation.cpp b/src/quick/items/qquickitemanimation.cpp
index dfb56ccc00..63359a7683 100644
--- a/src/quick/items/qquickitemanimation.cpp
+++ b/src/quick/items/qquickitemanimation.cpp
@@ -529,8 +529,8 @@ QAbstractAnimationJob* QQuickAnchorAnimation::transition(QQuickStateActions &act
data->interpolatorType = QMetaType::QReal;
data->interpolator = d->interpolator;
data->reverse = direction == Backward ? true : false;
- data->fromSourced = false;
- data->fromDefined = false;
+ data->fromIsSourced = false;
+ data->fromIsDefined = false;
for (int ii = 0; ii < actions.count(); ++ii) {
QQuickStateAction &action = actions[ii];
@@ -543,7 +543,7 @@ QAbstractAnimationJob* QQuickAnchorAnimation::transition(QQuickStateActions &act
QQuickBulkValueAnimator *animator = new QQuickBulkValueAnimator;
if (data->actions.count()) {
animator->setAnimValue(data);
- animator->setFromSourcedValue(&data->fromSourced);
+ animator->setFromIsSourcedValue(&data->fromIsSourced);
} else {
delete data;
}
@@ -864,9 +864,9 @@ QAbstractAnimationJob* QQuickPathAnimation::transition(QQuickStateActions &actio
data->exitInterval = d->duration ? qreal(d->exitDuration) / d->duration : qreal(0);
data->endRotation = d->endRotation;
data->reverse = direction == Backward ? true : false;
- data->fromSourced = false;
- data->fromDefined = (d->path && d->path->hasStartX() && d->path->hasStartY()) ? true : false;
- data->toDefined = d->path ? true : false;
+ data->fromIsSourced = false;
+ data->fromIsDefined = (d->path && d->path->hasStartX() && d->path->hasStartY()) ? true : false;
+ data->toIsDefined = d->path ? true : false;
int origModifiedSize = modified.count();
for (int i = 0; i < actions.count(); ++i) {
@@ -885,8 +885,7 @@ QAbstractAnimationJob* QQuickPathAnimation::transition(QQuickStateActions &actio
}
}
- if (target && d->path &&
- (modified.count() > origModifiedSize || data->toDefined)) {
+ if (target && d->path && (modified.count() > origModifiedSize || data->toIsDefined)) {
data->target = target;
data->path = d->path;
data->path->invalidateSequentialHistory();
@@ -897,13 +896,13 @@ QAbstractAnimationJob* QQuickPathAnimation::transition(QQuickStateActions &actio
// treat interruptions specially, otherwise we end up with strange paths
if ((data->reverse || prevData.reverse) && prevData.currentV > 0 && prevData.currentV < 1) {
- if (!data->fromDefined && !data->toDefined && !prevData.painterPath.isEmpty()) {
+ if (!data->fromIsDefined && !data->toIsDefined && !prevData.painterPath.isEmpty()) {
QPointF pathPos = QQuickPath::sequentialPointAt(prevData.painterPath, prevData.pathLength, prevData.attributePoints, prevData.prevBez, prevData.currentV);
if (!prevData.anchorPoint.isNull())
pathPos -= prevData.anchorPoint;
if (pathPos == data->target->position()) { //only treat as interruption if we interrupted ourself
data->painterPath = prevData.painterPath;
- data->toDefined = data->fromDefined = data->fromSourced = true;
+ data->toIsDefined = data->fromIsDefined = data->fromIsSourced = true;
data->prevBez.isValid = false;
data->interruptStart = prevData.currentV;
data->startRotation = prevData.startRotation;
@@ -913,13 +912,13 @@ QAbstractAnimationJob* QQuickPathAnimation::transition(QQuickStateActions &actio
}
}
}
- pa->setFromSourcedValue(&data->fromSourced);
+ pa->setFromIsSourcedValue(&data->fromIsSourced);
pa->setAnimValue(data);
pa->setDuration(d->duration);
pa->setEasingCurve(d->easingCurve);
return initInstance(pa);
} else {
- pa->setFromSourcedValue(nullptr);
+ pa->setFromIsSourcedValue(nullptr);
pa->setAnimValue(nullptr);
delete pa;
delete data;
@@ -939,7 +938,7 @@ void QQuickPathAnimationUpdater::setValue(qreal v)
}
currentV = v;
bool atStart = ((reverse && v == 1.0) || (!reverse && v == 0.0));
- if (!fromSourced && (!fromDefined || !toDefined)) {
+ if (!fromIsSourced && (!fromIsDefined || !toIsDefined)) {
qreal startX = reverse ? toX + anchorPoint.x() : target->x() + anchorPoint.x();
qreal startY = reverse ? toY + anchorPoint.y() : target->y() + anchorPoint.y();
qreal endX = reverse ? target->x() + anchorPoint.x() : toX + anchorPoint.x();
@@ -947,7 +946,7 @@ void QQuickPathAnimationUpdater::setValue(qreal v)
prevBez.isValid = false;
painterPath = path->createPath(QPointF(startX, startY), QPointF(endX, endY), QStringList(), pathLength, attributePoints);
- fromSourced = true;
+ fromIsSourced = true;
}
qreal angle;
diff --git a/src/quick/items/qquickitemanimation_p_p.h b/src/quick/items/qquickitemanimation_p_p.h
index 83b9899197..351a0cb2bc 100644
--- a/src/quick/items/qquickitemanimation_p_p.h
+++ b/src/quick/items/qquickitemanimation_p_p.h
@@ -92,7 +92,7 @@ class QQuickPathAnimationUpdater : public QQuickBulkValueUpdater
{
public:
QQuickPathAnimationUpdater() : path(nullptr), pathLength(0), target(nullptr), reverse(false),
- fromSourced(false), fromDefined(false), toDefined(false),
+ fromIsSourced(false), fromIsDefined(false), toIsDefined(false),
toX(0), toY(0), currentV(0), orientation(QQuickPathAnimation::Fixed),
entryInterval(0), exitInterval(0) {}
~QQuickPathAnimationUpdater() {}
@@ -108,9 +108,9 @@ public:
QQuickItem *target;
bool reverse;
- bool fromSourced;
- bool fromDefined;
- bool toDefined;
+ bool fromIsSourced;
+ bool fromIsDefined;
+ bool toIsDefined;
qreal toX;
qreal toY;
qreal currentV;
diff --git a/src/quick/util/qquickanimation.cpp b/src/quick/util/qquickanimation.cpp
index bfdc863d10..44e796f75b 100644
--- a/src/quick/util/qquickanimation.cpp
+++ b/src/quick/util/qquickanimation.cpp
@@ -1996,7 +1996,7 @@ void QQuickPropertyAnimationPrivate::convertVariant(QVariant &variant, QMetaType
}
QQuickBulkValueAnimator::QQuickBulkValueAnimator()
- : QAbstractAnimationJob(), animValue(nullptr), fromSourced(nullptr), m_duration(250)
+ : QAbstractAnimationJob(), animValue(nullptr), fromIsSourced(nullptr), m_duration(250)
{
}
@@ -2026,8 +2026,8 @@ void QQuickBulkValueAnimator::updateCurrentTime(int currentTime)
void QQuickBulkValueAnimator::topLevelAnimationLoopChanged()
{
//check for new from every top-level loop (when the top level animation is started and all subsequent loops)
- if (fromSourced)
- *fromSourced = false;
+ if (fromIsSourced)
+ *fromIsSourced = false;
QAbstractAnimationJob::topLevelAnimationLoopChanged();
}
@@ -2596,7 +2596,7 @@ void QQuickAnimationPropertyUpdater::setValue(qreal v)
if (v == 1.) {
QQmlPropertyPrivate::write(action.property, action.toValue, QQmlPropertyData::BypassInterceptor | QQmlPropertyData::DontRemoveBinding);
} else {
- if (!fromSourced && !fromDefined) {
+ if (!fromIsSourced && !fromIsDefined) {
action.fromValue = action.property.read();
if (interpolatorType) {
QQuickPropertyAnimationPrivate::convertVariant(action.fromValue, QMetaType(interpolatorType));
@@ -2616,7 +2616,7 @@ void QQuickAnimationPropertyUpdater::setValue(qreal v)
return;
}
wasDeleted = nullptr;
- fromSourced = true;
+ fromIsSourced = true;
}
void QQuickAnimationPropertyUpdater::debugUpdater(QDebug d, int indentLevel) const
@@ -2760,11 +2760,11 @@ QAbstractAnimationJob* QQuickPropertyAnimation::transition(QQuickStateActions &a
data->interpolatorType = d->interpolatorType;
data->interpolator = d->interpolator;
data->reverse = direction == Backward ? true : false;
- data->fromSourced = false;
- data->fromDefined = d->fromIsDefined;
+ data->fromIsSourced = false;
+ data->fromIsDefined = d->fromIsDefined;
data->actions = dataActions;
animator->setAnimValue(data);
- animator->setFromSourcedValue(&data->fromSourced);
+ animator->setFromIsSourcedValue(&data->fromIsSourced);
d->actions = &data->actions; //remove this?
}
diff --git a/src/quick/util/qquickanimation_p_p.h b/src/quick/util/qquickanimation_p_p.h
index f04026326b..b37680e92a 100644
--- a/src/quick/util/qquickanimation_p_p.h
+++ b/src/quick/util/qquickanimation_p_p.h
@@ -135,7 +135,7 @@ public:
void setAnimValue(QQuickBulkValueUpdater *value);
QQuickBulkValueUpdater *getAnimValue() const { return animValue; }
- void setFromSourcedValue(bool *value) { fromSourced = value; }
+ void setFromIsSourcedValue(bool *value) { fromIsSourced = value; }
int duration() const override { return m_duration; }
void setDuration(int msecs) { m_duration = msecs; }
@@ -150,7 +150,7 @@ protected:
private:
QQuickBulkValueUpdater *animValue;
- bool *fromSourced;
+ bool *fromIsSourced;
int m_duration;
QEasingCurve easing;
};
@@ -310,7 +310,7 @@ public:
class Q_AUTOTEST_EXPORT QQuickAnimationPropertyUpdater : public QQuickBulkValueUpdater
{
public:
- QQuickAnimationPropertyUpdater() : interpolatorType(0), interpolator(nullptr), prevInterpolatorType(0), reverse(false), fromSourced(false), fromDefined(false), wasDeleted(nullptr) {}
+ QQuickAnimationPropertyUpdater() : interpolatorType(0), interpolator(nullptr), prevInterpolatorType(0), reverse(false), fromIsSourced(false), fromIsDefined(false), wasDeleted(nullptr) {}
~QQuickAnimationPropertyUpdater() override;
void setValue(qreal v) override;
@@ -322,8 +322,8 @@ public:
QVariantAnimation::Interpolator interpolator;
int prevInterpolatorType; //for generic
bool reverse;
- bool fromSourced;
- bool fromDefined;
+ bool fromIsSourced;
+ bool fromIsDefined;
bool *wasDeleted;
};
diff --git a/src/quick/util/qquickanimator.cpp b/src/quick/util/qquickanimator.cpp
index f6cc4f3c54..cea23f374e 100644
--- a/src/quick/util/qquickanimator.cpp
+++ b/src/quick/util/qquickanimator.cpp
@@ -176,7 +176,7 @@ void QQuickAnimator::setTo(qreal to)
Q_D(QQuickAnimator);
if (to == d->to)
return;
- d->isToDefined = true;
+ d->toIsDefined = true;
d->to = to;
Q_EMIT toChanged(d->to);
}
@@ -202,7 +202,7 @@ qreal QQuickAnimator::to() const
void QQuickAnimator::setFrom(qreal from)
{
Q_D(QQuickAnimator);
- d->isFromDefined = true;
+ d->fromIsDefined = true;
if (from == d->from)
return;
d->from = from;
@@ -231,14 +231,14 @@ void QQuickAnimatorPrivate::apply(QQuickAnimatorJob *job,
job->setTarget(qobject_cast<QQuickItem *>(action.property.object()));
- if (isFromDefined)
+ if (fromIsDefined)
job->setFrom(from);
else if (action.fromValue.isValid())
job->setFrom(action.fromValue.toReal());
else
job->setFrom(action.property.read().toReal());
- if (isToDefined)
+ if (toIsDefined)
job->setTo(to);
else if (action.toValue.isValid())
job->setTo(action.toValue.toReal());
@@ -255,7 +255,7 @@ void QQuickAnimatorPrivate::apply(QQuickAnimatorJob *job,
if (modified.isEmpty()) {
job->setTarget(target);
- if (isFromDefined)
+ if (fromIsDefined)
job->setFrom(from);
job->setTo(to);
}
@@ -267,7 +267,7 @@ void QQuickAnimatorPrivate::apply(QQuickAnimatorJob *job,
job->setTarget(qobject_cast<QQuickItem *>(defaultTarget));
}
- if (modified.isEmpty() && !isFromDefined && job->target())
+ if (modified.isEmpty() && !fromIsDefined && job->target())
job->setFrom(job->target()->property(propertyName.toLatin1()).toReal());
job->setDuration(duration);
diff --git a/src/quick/util/qquickanimator_p_p.h b/src/quick/util/qquickanimator_p_p.h
index b176119c70..33e202c522 100644
--- a/src/quick/util/qquickanimator_p_p.h
+++ b/src/quick/util/qquickanimator_p_p.h
@@ -68,8 +68,8 @@ public:
, duration(250)
, from(0)
, to(0)
- , isFromDefined(false)
- , isToDefined(false)
+ , fromIsDefined(false)
+ , toIsDefined(false)
{
}
@@ -79,8 +79,8 @@ public:
qreal from;
qreal to;
- uint isFromDefined : 1;
- uint isToDefined : 1;
+ uint fromIsDefined : 1;
+ uint toIsDefined : 1;
void apply(QQuickAnimatorJob *job, const QString &propertyName, QQuickStateActions &actions, QQmlProperties &modified, QObject *defaultTarget);
};