diff options
author | Andreas Buhr <andreas@andreasbuhr.de> | 2021-01-14 16:03:32 +0100 |
---|---|---|
committer | Andreas Buhr <andreas@andreasbuhr.de> | 2021-03-31 13:59:45 +0200 |
commit | c0e595d6bde600552e3910b796c6945dabbe2e30 (patch) | |
tree | a8e2a4ea6aba343d6d00ff49ede6ca502d4de3ec | |
parent | 52feae162b305d70f3009bfd30913fa458ec628e (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)
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
-rw-r--r-- | src/quick/items/qquickitemanimation.cpp | 27 | ||||
-rw-r--r-- | src/quick/items/qquickitemanimation_p_p.h | 8 | ||||
-rw-r--r-- | src/quick/util/qquickanimation.cpp | 16 | ||||
-rw-r--r-- | src/quick/util/qquickanimation_p_p.h | 10 | ||||
-rw-r--r-- | src/quick/util/qquickanimator.cpp | 8 | ||||
-rw-r--r-- | src/quick/util/qquickanimator_p_p.h | 8 |
6 files changed, 38 insertions, 39 deletions
diff --git a/src/quick/items/qquickitemanimation.cpp b/src/quick/items/qquickitemanimation.cpp index 23694e2de3..a4fccc46d0 100644 --- a/src/quick/items/qquickitemanimation.cpp +++ b/src/quick/items/qquickitemanimation.cpp @@ -532,8 +532,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]; @@ -546,7 +546,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; } @@ -867,9 +867,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) { @@ -888,8 +888,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(); @@ -900,13 +899,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; @@ -916,13 +915,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; @@ -942,7 +941,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(); @@ -950,7 +949,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 cfa8d3a51a..32e96fd3d9 100644 --- a/src/quick/util/qquickanimation.cpp +++ b/src/quick/util/qquickanimation.cpp @@ -1996,7 +1996,7 @@ void QQuickPropertyAnimationPrivate::convertVariant(QVariant &variant, int type) } 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, 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 98d4751d1f..1dd71056f7 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; }; @@ -311,7 +311,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; @@ -323,8 +323,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 fee0802881..49af5ac7fa 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); } @@ -204,7 +204,7 @@ void QQuickAnimator::setFrom(qreal from) Q_D(QQuickAnimator); if (from == d->from) return; - d->isFromDefined = true; + d->fromIsDefined = true; d->from = from; Q_EMIT fromChanged(d->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()); 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); }; |