1 | // Copyright (C) 2016 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 QQUICKSPRITESEQUENCE_P_H |
5 | #define QQUICKSPRITESEQUENCE_P_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 <private/qtquickglobal_p.h> |
19 | |
20 | QT_REQUIRE_CONFIG(quick_sprite); |
21 | |
22 | #include <QtQuick/QQuickItem> |
23 | |
24 | QT_BEGIN_NAMESPACE |
25 | |
26 | class QSGContext; |
27 | class QQuickSprite; |
28 | class QQuickSpriteEngine; |
29 | class QQuickSpriteSequencePrivate; |
30 | class QSGSpriteNode; |
31 | class Q_QUICK_PRIVATE_EXPORT QQuickSpriteSequence : public QQuickItem |
32 | { |
33 | Q_OBJECT |
34 | Q_PROPERTY(bool running READ running WRITE setRunning NOTIFY runningChanged FINAL) |
35 | Q_PROPERTY(bool interpolate READ interpolate WRITE setInterpolate NOTIFY interpolateChanged FINAL) |
36 | Q_PROPERTY(QString goalSprite READ goalSprite WRITE setGoalSprite NOTIFY goalSpriteChanged FINAL) |
37 | Q_PROPERTY(QString currentSprite READ currentSprite NOTIFY currentSpriteChanged FINAL) |
38 | //###try to share similar spriteEngines for less overhead? |
39 | Q_PROPERTY(QQmlListProperty<QQuickSprite> sprites READ sprites FINAL) |
40 | Q_CLASSINFO("DefaultProperty", "sprites") |
41 | QML_NAMED_ELEMENT(SpriteSequence) |
42 | QML_ADDED_IN_VERSION(2, 0) |
43 | |
44 | public: |
45 | explicit QQuickSpriteSequence(QQuickItem *parent = nullptr); |
46 | |
47 | QQmlListProperty<QQuickSprite> sprites(); |
48 | |
49 | bool running() const; |
50 | bool interpolate() const; |
51 | QString goalSprite() const; |
52 | QString currentSprite() const; |
53 | |
54 | Q_SIGNALS: |
55 | |
56 | void runningChanged(bool arg); |
57 | void interpolateChanged(bool arg); |
58 | void goalSpriteChanged(const QString &arg); |
59 | void currentSpriteChanged(const QString &arg); |
60 | |
61 | public Q_SLOTS: |
62 | |
63 | void jumpTo(const QString &sprite); |
64 | void setGoalSprite(const QString &sprite); |
65 | void setRunning(bool arg); |
66 | void setInterpolate(bool arg); |
67 | |
68 | private Q_SLOTS: |
69 | void createEngine(); |
70 | |
71 | protected: |
72 | void reset(); |
73 | QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override; |
74 | private: |
75 | void prepareNextFrame(QSGSpriteNode *node); |
76 | QSGSpriteNode* initNode(); |
77 | |
78 | private: |
79 | Q_DECLARE_PRIVATE(QQuickSpriteSequence) |
80 | }; |
81 | |
82 | QT_END_NAMESPACE |
83 | |
84 | #endif // QQUICKSPRITESEQUENCE_P_H |
85 |