From 25dffe6b5367518486edf8a91d5674be4852c50e Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 31 Aug 2009 13:02:02 +1000 Subject: More robust AnchorChanges. Still not completely reliable -- doesn't handle cancellations well, and checking if one Anchor change overrides another isn't reliable. --- src/declarative/util/qmlanimation.cpp | 4 ++-- src/declarative/util/qmlstateoperations.cpp | 32 ++++++++++++++++++++++++++++- src/declarative/util/qmlstateoperations.h | 1 + 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index 02b747f..d224388 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -1425,11 +1425,11 @@ void QmlParallelAnimation::transition(QmlStateActions &actions, { Q_D(QmlAnimationGroup); - //needed for Behavior + //needed for Behavior if (d->userProperty.isValid() && d->propertyName.isEmpty() && !target()) { for (int i = 0; i < d->animations.count(); ++i) d->animations.at(i)->setTarget(d->userProperty); - } + } for (int ii = 0; ii < d->animations.count(); ++ii) { d->animations.at(ii)->transition(actions, modified, direction); diff --git a/src/declarative/util/qmlstateoperations.cpp b/src/declarative/util/qmlstateoperations.cpp index b17b80b..e10c9ab 100644 --- a/src/declarative/util/qmlstateoperations.cpp +++ b/src/declarative/util/qmlstateoperations.cpp @@ -439,7 +439,6 @@ void QmlAnchorChanges::reverse() d->target->anchors()->setTop(d->origTop); if (d->origBottom.anchorLine != QFxAnchorLine::Invalid) d->target->anchors()->setBottom(d->origBottom); - } QString QmlAnchorChanges::typeName() const @@ -503,6 +502,16 @@ void QmlAnchorChanges::clearForwardBindings() d->target->anchors()->resetTop(); if (d->resetList.contains(QLatin1String("bottom"))) d->target->anchors()->resetBottom(); + + //reset any anchors that we'll be setting in the state + if (d->left.anchorLine != QFxAnchorLine::Invalid) + d->target->anchors()->resetLeft(); + if (d->right.anchorLine != QFxAnchorLine::Invalid) + d->target->anchors()->resetRight(); + if (d->top.anchorLine != QFxAnchorLine::Invalid) + d->target->anchors()->resetTop(); + if (d->bottom.anchorLine != QFxAnchorLine::Invalid) + d->target->anchors()->resetBottom(); } void QmlAnchorChanges::clearReverseBindings() @@ -522,6 +531,27 @@ void QmlAnchorChanges::clearReverseBindings() d->target->anchors()->resetTop(); if (d->bottom.anchorLine != QFxAnchorLine::Invalid) d->target->anchors()->resetBottom(); + + //reset any anchors that were set in the original state + if (d->origLeft.anchorLine != QFxAnchorLine::Invalid) + d->target->anchors()->resetLeft(); + if (d->origRight.anchorLine != QFxAnchorLine::Invalid) + d->target->anchors()->resetRight(); + if (d->origTop.anchorLine != QFxAnchorLine::Invalid) + d->target->anchors()->resetTop(); + if (d->origBottom.anchorLine != QFxAnchorLine::Invalid) + d->target->anchors()->resetBottom(); +} + +bool QmlAnchorChanges::override(ActionEvent*other) +{ + if (other->typeName() != QLatin1String("AnchorChanges")) + return false; + if (static_cast(this) == other) + return true; + //### can we do any other meaningful comparison? Do we need to attempt to merge the two + // somehow if they have the same target and some of the same anchors? + return false; } QT_END_NAMESPACE diff --git a/src/declarative/util/qmlstateoperations.h b/src/declarative/util/qmlstateoperations.h index 3018b44..afe0bd5 100644 --- a/src/declarative/util/qmlstateoperations.h +++ b/src/declarative/util/qmlstateoperations.h @@ -144,6 +144,7 @@ public: virtual bool isReversable(); virtual void reverse(); virtual QString typeName() const; + virtual bool override(ActionEvent*other); virtual QList extraActions(); virtual bool changesBindings(); virtual void clearForwardBindings(); -- cgit v0.12