42 #include "private/qdeclarativespringanimation_p.h" 44 #include "private/qdeclarativeanimation_p_p.h" 47 #include <QtCore/qdebug.h> 49 #include <private/qobject_p.h> 94 : maxVelocity(0), velocityms(0), lastTime(0)
95 , mass(1.0), spring(0.), damping(0.), epsilon(0.01)
121 int count = elapsed / 16;
122 lastTime = time - (elapsed - count * 16);
128 while (it.hasNext()) {
146 srcVal = fmod(srcVal,
modulus);
151 int count = elapsed / 16;
152 for (
int i = 0; i < count; ++i) {
213 return (stop && old_to == animation.
to);
292 return d->maxVelocity;
299 d->velocityms = velocity / 1000.0;
403 if (
d->modulus != modulus) {
404 d->haveModulus = modulus != 0.0;
432 if (
d->mass != mass && mass > 0.0) {
433 d->useMass = mass != 1.0;
455 if (!
d->actions->isEmpty()) {
456 for (
int i = 0; i <
d->actions->size(); ++i) {
460 animation.
to =
d->actions->at(i).toValue.toReal();
461 animation.
start =
d->lastTime;
462 if (
d->fromIsDefined)
463 animation.
currentValue =
d->actions->at(i).fromValue.toReal();
468 if (
d->haveModulus && dist >
d->modulus / 2)
469 dist =
d->modulus - fmod(dist,
d->modulus);
470 animation.
duration = dist /
d->velocityms;
static double elapsed(qint64 after, qint64 before)
QTickAnimationProxy< QDeclarativeSpringAnimationPrivate, &QDeclarativeSpringAnimationPrivate::tick > Clock
#define QT_END_NAMESPACE
This macro expands to.
QDeclarativeParserStatus ** d
void setEpsilon(qreal epsilon)
QDeclarativeSpringAnimationPrivate()
#define it(className, varName)
virtual void transition(QDeclarativeStateActions &actions, QDeclarativeProperties &modified, TransitionDirection direction)
~QDeclarativeSpringAnimation()
void setSpring(qreal spring)
virtual QAbstractAnimation * qtAnimation()
The QHash class is a template class that provides a hash-table-based dictionary.
Q_DECL_CONSTEXPR T qAbs(const T &t)
The QObject class is the base class of all Qt objects.
void stop()
Stops the animation.
QDeclarativeSpringAnimation(QObject *parent=0)
#define QT_BEGIN_NAMESPACE
This macro expands to.
qreal velocity
This property holds the maximum velocity allowed when tracking the source.
void setModulus(qreal modulus)
void setDamping(qreal damping)
The QAbstractAnimation class is the base of all animations.
void setMass(qreal modulus)
#define Q_DECLARE_PUBLIC(Class)
virtual void transition(QDeclarativeStateActions &actions, QDeclarativeProperties &modified, TransitionDirection direction)
The QHash::iterator class provides an STL-style non-const iterator for QHash and QMultiHash.
bool animate(const QDeclarativeProperty &property, SpringAnimation &animation, int elapsed)
The QDeclarativeProperty class abstracts accessing properties on objects created from QML...
void setVelocity(qreal velocity)
QHash< QDeclarativeProperty, SpringAnimation > activeAnimations
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
static bool write(QObject *, const QDeclarativePropertyCache::Data &, const QVariant &, QDeclarativeContextData *, WriteFlags flags=0)
Qt::LayoutDirection direction