aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pm.pro4
-rw-r--r--transitioncontrol.cpp4
-rw-r--r--transitionworkerthread.cpp (renamed from rewindworkerthread.cpp)18
-rw-r--r--transitionworkerthread.h (renamed from rewindworkerthread.h)9
4 files changed, 26 insertions, 9 deletions
diff --git a/pm.pro b/pm.pro
index 426cb23..5b91bc0 100644
--- a/pm.pro
+++ b/pm.pro
@@ -29,7 +29,7 @@ HEADERS += main.h \
historygraph.h \
barchart.h \
transitioncontrol.h \
- rewindworkerthread.h \
+ transitionworkerthread.h \
manipulationhandler.h \
mapscalehandler.h \
numericrange.h \
@@ -51,7 +51,7 @@ SOURCES += main.cpp \
historygraph.cpp \
barchart.cpp \
transitioncontrol.cpp \
- rewindworkerthread.cpp \
+ transitionworkerthread.cpp \
manipulationhandler.cpp \
mapscalehandler.cpp \
selectionhandler.cpp \
diff --git a/transitioncontrol.cpp b/transitioncontrol.cpp
index bd85405..6d3f298 100644
--- a/transitioncontrol.cpp
+++ b/transitioncontrol.cpp
@@ -3,7 +3,7 @@
#include <QObject>
#include <QThread>
-#include "rewindworkerthread.h"
+#include "transitionworkerthread.h"
// The mouse button used for interaction
static const Qt::MouseButton MOUSE_BUTTON = Qt::MiddleButton;
@@ -60,7 +60,7 @@ void TransitionControl::mouseReleaseEvent(QMouseEvent *event)
m_shouldRewind = false;
// We now have to smoothly go back to m_t == 1.0
- m_rewindThread = new RewindWorkerThread(this);
+ m_rewindThread = new TransitionWorkerThread(this);
connect(m_rewindThread, &QThread::finished, m_rewindThread, &QObject::deleteLater);
m_rewindThread->start();
}
diff --git a/rewindworkerthread.cpp b/transitionworkerthread.cpp
index f9fa999..2ee1d0e 100644
--- a/rewindworkerthread.cpp
+++ b/transitionworkerthread.cpp
@@ -1,4 +1,4 @@
-#include "rewindworkerthread.h"
+#include "transitionworkerthread.h"
// The full duration (usecs) of the restoration animation
static const double DURATION = 250000;
@@ -9,13 +9,25 @@ static const double TICK_TIME = DURATION / 60.0;
// The amount to increase 't' per time step
static const double TICK_SIZE = TICK_TIME / DURATION;
-void RewindWorkerThread::run()
+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(t);
+ m_control->setT(m_easing.valueForProgress(t));
QThread::usleep(TICK_TIME);
}
diff --git a/rewindworkerthread.h b/transitionworkerthread.h
index 0bbaeb6..b4d3e95 100644
--- a/rewindworkerthread.h
+++ b/transitionworkerthread.h
@@ -5,17 +5,22 @@
#include <QObject>
#include <QThread>
+#include <QEasingCurve>
-class RewindWorkerThread
+class TransitionWorkerThread
: public QThread
{
Q_OBJECT
public:
- RewindWorkerThread(TransitionControl *control) { m_control = control; }
+ TransitionWorkerThread(TransitionControl *control);
+ TransitionWorkerThread(TransitionControl *control, const QEasingCurve &easing);
+
+ void setEasing(const QEasingCurve &easing);
void run();
private:
TransitionControl *m_control;
+ QEasingCurve m_easing;
};
#endif // REWINDWORKERTHREAD_H