From 886bdd0fa43a2fcdeca306648b643b623af99f88 Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Tue, 9 Feb 2016 17:38:28 -0200 Subject: Added TransitionControl and plot rewinding. New component overlays main view and handles middle clicks/drags to performing rewinding. Also sports smooth transitioning back to current projection whenever the mouse button is lifted. Next up, the same kind of transitions in the displayed values. --- transitioncontrol.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 transitioncontrol.h (limited to 'transitioncontrol.h') diff --git a/transitioncontrol.h b/transitioncontrol.h new file mode 100644 index 0000000..ac84786 --- /dev/null +++ b/transitioncontrol.h @@ -0,0 +1,41 @@ +#ifndef TRANSITIONCONTROL_H +#define TRANSITIONCONTROL_H + +#include + +/* + * This component emits signals indicating how far from its left edge is the + * mouse since the mouse button was pressed (starting from t == 1.0 with 0.0 + * being exactly at the left edge). As the mouse is released, it emits periodic + * signals incrementing the value until it is restored to the default. + */ +class TransitionControl : + public QQuickItem +{ + Q_OBJECT +public: + TransitionControl(); + double t() const { return m_t; } + +signals: + void tChanged(double t) const; + +public slots: + void setT(double t); + +protected: + void mousePressEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + +private: + double m_t; + + // The x pos where interaction started + int m_startPos; + + // Controls the smooth rewind transition + QThread *m_rewindThread; +}; + +#endif // TRANSITIONCONTROL_H -- cgit v1.2.3