1 | // Copyright (C) 2022 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QQUICKFRAMEANIMATION_H |
5 | #define QQUICKFRAMEANIMATION_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <qqml.h> |
19 | #include <QtCore/qobject.h> |
20 | #include <private/qtqmlglobal_p.h> |
21 | #include <private/qtquickglobal_p.h> |
22 | |
23 | QT_BEGIN_NAMESPACE |
24 | |
25 | class QQuickFrameAnimationPrivate; |
26 | class Q_QUICK_PRIVATE_EXPORT QQuickFrameAnimation : public QObject, public QQmlParserStatus |
27 | { |
28 | Q_OBJECT |
29 | Q_DECLARE_PRIVATE(QQuickFrameAnimation) |
30 | Q_INTERFACES(QQmlParserStatus) |
31 | Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged FINAL) |
32 | Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged FINAL) |
33 | Q_PROPERTY(int currentFrame READ currentFrame NOTIFY currentFrameChanged FINAL) |
34 | Q_PROPERTY(qreal frameTime READ frameTime NOTIFY frameTimeChanged FINAL) |
35 | Q_PROPERTY(qreal smoothFrameTime READ smoothFrameTime NOTIFY smoothFrameTimeChanged FINAL) |
36 | Q_PROPERTY(qreal elapsedTime READ elapsedTime NOTIFY elapsedTimeChanged FINAL) |
37 | QML_NAMED_ELEMENT(FrameAnimation) |
38 | QML_ADDED_IN_VERSION(6, 4) |
39 | |
40 | public: |
41 | QQuickFrameAnimation(QObject *parent = nullptr); |
42 | |
43 | bool isRunning() const; |
44 | void setRunning(bool running); |
45 | |
46 | bool isPaused() const; |
47 | void setPaused(bool paused); |
48 | |
49 | int currentFrame() const; |
50 | qreal frameTime() const; |
51 | qreal smoothFrameTime() const; |
52 | qreal elapsedTime() const; |
53 | |
54 | protected: |
55 | void classBegin() override; |
56 | void componentComplete() override; |
57 | |
58 | public Q_SLOTS: |
59 | void start(); |
60 | void stop(); |
61 | void restart(); |
62 | void pause(); |
63 | void resume(); |
64 | void reset(); |
65 | |
66 | Q_SIGNALS: |
67 | void triggered(); |
68 | void runningChanged(); |
69 | void pausedChanged(); |
70 | void currentFrameChanged(); |
71 | void frameTimeChanged(); |
72 | void smoothFrameTimeChanged(); |
73 | void elapsedTimeChanged(); |
74 | |
75 | private: |
76 | void setCurrentFrame(int frame); |
77 | void setElapsedTime(qreal elapsedTime); |
78 | |
79 | }; |
80 | |
81 | QT_END_NAMESPACE |
82 | |
83 | QML_DECLARE_TYPE(QQuickFrameAnimation) |
84 | |
85 | #endif |
86 |