diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-05-01 01:22:38 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-05-01 01:22:38 (GMT) |
commit | e93e5076e11a7a9cfdd4b9cb1a2d4dbf1f579177 (patch) | |
tree | 9a214273e5ec3b0eb3f4a0bc0f8ecd7f3762eb28 /src/declarative/util/qmlfollow.cpp | |
parent | 1206e9fb0c9a21e60b1e6841bb3071daa1f0da8a (diff) | |
parent | 4eb455e6e109052ec39b10bfe36f7649c3c7cf0b (diff) | |
download | Qt-e93e5076e11a7a9cfdd4b9cb1a2d4dbf1f579177.zip Qt-e93e5076e11a7a9cfdd4b9cb1a2d4dbf1f579177.tar.gz Qt-e93e5076e11a7a9cfdd4b9cb1a2d4dbf1f579177.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative/util/qmlfollow.cpp')
-rw-r--r-- | src/declarative/util/qmlfollow.cpp | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/declarative/util/qmlfollow.cpp b/src/declarative/util/qmlfollow.cpp index 998166a..8e5ae69 100644 --- a/src/declarative/util/qmlfollow.cpp +++ b/src/declarative/util/qmlfollow.cpp @@ -55,7 +55,7 @@ class QmlFollowPrivate : public QObjectPrivate public: QmlFollowPrivate() : sourceValue(0), maxVelocity(0), lastTime(0) - , mass(1.0), spring(0.), damping(0.), velocity(0), enabled(true), mode(Track), clock(this) {} + , mass(1.0), spring(0.), damping(0.), velocity(0), epsilon(0.005), enabled(true), mode(Track), clock(this) {} QmlMetaProperty property; qreal currentValue; @@ -67,6 +67,7 @@ public: qreal spring; qreal damping; qreal velocity; + qreal epsilon; bool enabled; enum Mode { @@ -111,7 +112,7 @@ void QmlFollowPrivate::tick(int time) } currentValue += velocity * 10.0 / 1000.0; } - if (qAbs(velocity) < 0.5 && qAbs(sourceValue - currentValue) < 0.5) { + if (qAbs(velocity) < epsilon && qAbs(sourceValue - currentValue) < epsilon) { velocity = 0.0; currentValue = sourceValue; clock.stop(); @@ -300,6 +301,30 @@ void QmlFollow::setDamping(qreal damping) d->damping = damping; } + +/*! + \qmlproperty qreal Follow::epsilon + This property holds the spring epsilon + + The epsilon is the rate and amount of change in the value which is close enough + to 0 to be considered equal to zero. This will depend on the usage of the value. + For pixel positions, 0.25 would suffice. For scale, 0.005 will suffice. + + The default is 0.005. Small performance improvements can result in tuning this + value. +*/ +qreal QmlFollow::epsilon() const +{ + Q_D(const QmlFollow); + return d->epsilon; +} + +void QmlFollow::setEpsilon(qreal epsilon) +{ + Q_D(QmlFollow); + d->epsilon = epsilon; +} + /*! \qmlproperty qreal Follow::followValue The current value. |