QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskAnimator.h
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#ifndef QSK_ANIMATOR_H
7#define QSK_ANIMATOR_H
8
9#include "QskGlobal.h"
10
11#include <qeasingcurve.h>
12#include <qobjectdefs.h>
13
14class QQuickWindow;
15class QObject;
16class QDebug;
17
18class QSK_EXPORT QskAnimator
19{
20 public:
22 virtual ~QskAnimator();
23
24 QQuickWindow* window() const;
25 void setWindow( QQuickWindow* );
26
27 void setEasingCurve( QEasingCurve::Type type );
28 void setEasingCurve( const QEasingCurve& );
29
30 const QEasingCurve& easingCurve() const;
31
32 void setAutoRepeat( bool );
33 bool autoRepeat() const;
34
35 void setDuration( int ms );
36 int duration() const;
37
38 bool isRunning() const;
39 qint64 elapsed() const;
40
41 void start();
42 void stop();
43 void update();
44
45 static QMetaObject::Connection addCleanupHandler(
46 QObject* receiver, const char* method,
47 Qt::ConnectionType type = Qt::AutoConnection );
48
49 static QMetaObject::Connection addAdvanceHandler(
50 QObject* receiver, const char* method,
51 Qt::ConnectionType type = Qt::AutoConnection );
52
53#ifndef QT_NO_DEBUG_STREAM
54 static void debugStatistics( QDebug );
55#endif
56
57 protected:
58 virtual void setup();
59 virtual void advance( qreal value ) = 0;
60 virtual void done();
61
62 private:
63 QQuickWindow* m_window;
64
65 int m_duration;
66 QEasingCurve m_easingCurve;
67 qint64 m_startTime; // quint32 might be enough
68
69 bool m_autoRepeat = false;
70};
71
72inline bool QskAnimator::isRunning() const
73{
74 return m_startTime >= 0;
75}
76
77inline int QskAnimator::duration() const
78{
79 return m_duration;
80}
81
82inline bool QskAnimator::autoRepeat() const
83{
84 return m_autoRepeat;
85}
86
87#endif