aboutsummaryrefslogtreecommitdiff
path: root/transitionworkerthread.cpp
diff options
context:
space:
mode:
authorSamuel Fadel <samuelfadel@gmail.com>2016-02-11 16:12:21 -0200
committerSamuel Fadel <samuelfadel@gmail.com>2016-02-11 16:12:21 -0200
commit7d96918246b866a0b4aac6b4dc70e4c049c0ada9 (patch)
tree0fabeec2a9dbef56478a3d07c5728e81b8c384dc /transitionworkerthread.cpp
parent5f22fd080bb62a9242d1452415f5073bcfd69c49 (diff)
RewindWorkerThread renamed to TransitionWorkerThread.
Also, added easing curve customization.
Diffstat (limited to 'transitionworkerthread.cpp')
-rw-r--r--transitionworkerthread.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/transitionworkerthread.cpp b/transitionworkerthread.cpp
new file mode 100644
index 0000000..2ee1d0e
--- /dev/null
+++ b/transitionworkerthread.cpp
@@ -0,0 +1,35 @@
+#include "transitionworkerthread.h"
+
+// The full duration (usecs) of the restoration animation
+static const double DURATION = 250000;
+
+// The time to wait (usecs) before the next animation tick
+static const double TICK_TIME = DURATION / 60.0;
+
+// The amount to increase 't' per time step
+static const double TICK_SIZE = TICK_TIME / DURATION;
+
+TransitionWorkerThread::TransitionWorkerThread(TransitionControl *control)
+ : m_control(control)
+{
+}
+
+TransitionWorkerThread::TransitionWorkerThread(TransitionControl *control,
+ const QEasingCurve &easing)
+ : m_control(control)
+ , m_easing(easing)
+{
+}
+
+void TransitionWorkerThread::run()
+{
+ double t = m_control->t();
+
+ while (t + TICK_SIZE < 1.0) {
+ t += TICK_SIZE;
+ m_control->setT(m_easing.valueForProgress(t));
+ QThread::usleep(TICK_TIME);
+ }
+
+ m_control->setT(1.0);
+}