summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles/qstyleanimation.cpp
diff options
context:
space:
mode:
authorJerome Pasion <jerome.pasion@digia.com>2012-11-02 14:41:27 +0100
committerJerome Pasion <jerome.pasion@digia.com>2012-11-02 14:41:27 +0100
commitc808dd27459e030fde0577feb8ba06e3bd465526 (patch)
tree4bf898dc4a88e2b03c9716f940638a2e01c6c0ce /src/widgets/styles/qstyleanimation.cpp
parentd9d8845d507a6bdbc9c9f24c0d9d86dca513461d (diff)
parent300534fc214f2547a63594ce0891e9a54c8f33ca (diff)
Merge branch 'master' of ssh://codereview.qt-project.org/qt/qtbase into newdocs
Diffstat (limited to 'src/widgets/styles/qstyleanimation.cpp')
-rw-r--r--src/widgets/styles/qstyleanimation.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/widgets/styles/qstyleanimation.cpp b/src/widgets/styles/qstyleanimation.cpp
index d81532f8a5..0138996e33 100644
--- a/src/widgets/styles/qstyleanimation.cpp
+++ b/src/widgets/styles/qstyleanimation.cpp
@@ -163,4 +163,49 @@ bool QProgressStyleAnimation::isUpdateNeeded() const
return false;
}
+QNumberStyleAnimation::QNumberStyleAnimation(QObject *target) :
+ QStyleAnimation(target), _start(0.0), _end(1.0), _prev(0.0)
+{
+ setDuration(250);
+}
+
+qreal QNumberStyleAnimation::startValue() const
+{
+ return _start;
+}
+
+void QNumberStyleAnimation::setStartValue(qreal value)
+{
+ _start = value;
+}
+
+qreal QNumberStyleAnimation::endValue() const
+{
+ return _end;
+}
+
+void QNumberStyleAnimation::setEndValue(qreal value)
+{
+ _end = value;
+}
+
+qreal QNumberStyleAnimation::currentValue() const
+{
+ qreal step = qreal(currentTime() - delay()) / (duration() - delay());
+ return _start + qMax(qreal(0), step) * (_end - _start);
+}
+
+bool QNumberStyleAnimation::isUpdateNeeded() const
+{
+ if (QStyleAnimation::isUpdateNeeded()) {
+ qreal current = currentValue();
+ if (!qFuzzyCompare(_prev, current))
+ {
+ _prev = current;
+ return true;
+ }
+ }
+ return false;
+}
+
QT_END_NAMESPACE