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 KILLAFFECTOR_H |
5 | #define KILLAFFECTOR_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 | #include "qquickparticleaffector_p.h" |
18 | |
19 | QT_BEGIN_NAMESPACE |
20 | |
21 | class Q_QUICKPARTICLES_PRIVATE_EXPORT QQuickAgeAffector : public QQuickParticleAffector |
22 | { |
23 | Q_OBJECT |
24 | Q_PROPERTY(int lifeLeft READ lifeLeft WRITE setLifeLeft NOTIFY lifeLeftChanged FINAL) |
25 | Q_PROPERTY(bool advancePosition READ advancePosition WRITE setAdvancePosition NOTIFY advancePositionChanged FINAL) |
26 | QML_NAMED_ELEMENT(Age) |
27 | QML_ADDED_IN_VERSION(2, 0) |
28 | |
29 | public: |
30 | explicit QQuickAgeAffector(QQuickItem *parent = nullptr); |
31 | |
32 | int lifeLeft() const |
33 | { |
34 | return m_lifeLeft; |
35 | } |
36 | |
37 | bool advancePosition() const |
38 | { |
39 | return m_advancePosition; |
40 | } |
41 | |
42 | protected: |
43 | bool affectParticle(QQuickParticleData *d, qreal dt) override; |
44 | |
45 | Q_SIGNALS: |
46 | void lifeLeftChanged(int arg); |
47 | void advancePositionChanged(bool arg); |
48 | |
49 | public Q_SLOTS: |
50 | void setLifeLeft(int arg) |
51 | { |
52 | if (m_lifeLeft != arg) { |
53 | m_lifeLeft = arg; |
54 | Q_EMIT lifeLeftChanged(arg); |
55 | } |
56 | } |
57 | |
58 | void setAdvancePosition(bool arg) |
59 | { |
60 | if (m_advancePosition != arg) { |
61 | m_advancePosition = arg; |
62 | Q_EMIT advancePositionChanged(arg); |
63 | } |
64 | } |
65 | |
66 | private: |
67 | int m_lifeLeft; |
68 | bool m_advancePosition; |
69 | }; |
70 | |
71 | QT_END_NAMESPACE |
72 | #endif // KILLAFFECTOR_H |
73 |