diff options
author | Samuel Fadel <samuelfadel@gmail.com> | 2016-02-09 17:38:28 -0200 |
---|---|---|
committer | Samuel Fadel <samuelfadel@gmail.com> | 2016-02-09 17:38:28 -0200 |
commit | 886bdd0fa43a2fcdeca306648b643b623af99f88 (patch) | |
tree | 7ffa1e622724862b8b99387199fb1ef7cbf79b28 /transitioncontrol.h | |
parent | 962114b867c044240919ebc558c0b25f105db963 (diff) |
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.
Diffstat (limited to 'transitioncontrol.h')
-rw-r--r-- | transitioncontrol.h | 41 |
1 files changed, 41 insertions, 0 deletions
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 <QQuickItem> + +/* + * 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 |