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. Pick-to: 6.0 5.15 Change-Id: Ia6c228208eb651247b0ba70f83afadb5b1027049 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
parent
8deb1b279f
commit
702b00bc8b
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1990,7 +1990,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)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -2020,8 +2020,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();
|
||||
}
|
||||
|
||||
|
@ -2590,7 +2590,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));
|
||||
|
@ -2610,7 +2610,7 @@ void QQuickAnimationPropertyUpdater::setValue(qreal v)
|
|||
return;
|
||||
}
|
||||
wasDeleted = nullptr;
|
||||
fromSourced = true;
|
||||
fromIsSourced = true;
|
||||
}
|
||||
|
||||
void QQuickAnimationPropertyUpdater::debugUpdater(QDebug d, int indentLevel) const
|
||||
|
@ -2754,11 +2754,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?
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue