Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquickparticlepainter_p.h
Go to the documentation of this file.
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 PARTICLE_H
5#define PARTICLE_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 <QObject>
19#include <QDebug>
20#include <utility>
22
24
26{
27 Q_OBJECT
28 Q_PROPERTY(QQuickParticleSystem* system READ system WRITE setSystem NOTIFY systemChanged)
29 Q_PROPERTY(QStringList groups READ groups WRITE setGroups NOTIFY groupsChanged)
30
31 QML_NAMED_ELEMENT(ParticlePainter)
32 QML_ADDED_IN_VERSION(2, 0)
33 QML_UNCREATABLE("Abstract type. Use one of the inheriting types instead.")
34
35public: // data
36 typedef QQuickParticleVarLengthArray<QQuickParticleGroupData::ID, 4> GroupIDs;
37
38public:
39 explicit QQuickParticlePainter(QQuickItem *parent = nullptr);
40 ~QQuickParticlePainter() override;
41 //Data Interface to system
42 void load(QQuickParticleData*);
43 void reload(QQuickParticleData*);
44 void setCount(int c);
45
46 int count() const
47 {
48 return m_count;
49 }
50
51 void performPendingCommits();//Called from updatePaintNode
52 QQuickParticleSystem* system() const
53 {
54 return m_system;
55 }
56
57 QStringList groups() const
58 {
59 return m_groups;
60 }
61
62 const GroupIDs &groupIds() const
63 {
64 if (m_groupIdsNeedRecalculation) {
65 recalculateGroupIds();
66 }
67 return m_groupIds;
68 }
69
70 void itemChange(ItemChange, const ItemChangeData &) override;
71
72Q_SIGNALS:
73 void countChanged();
74 void systemChanged(QQuickParticleSystem* arg);
75
76 void groupsChanged(const QStringList &arg);
77
78public Q_SLOTS:
79 void setSystem(QQuickParticleSystem* arg);
80
81 void setGroups(const QStringList &arg);
82
83 void calcSystemOffset(bool resetPending = false);
84
85private Q_SLOTS:
86 virtual void sceneGraphInvalidated() {}
87
88protected:
89 /* Reset resets all your internal data structures. But anything attached to a particle should
90 be in attached data. So reset + reloads should have no visible effect.
91 ###Hunt down all cases where we do a complete reset for convenience and be more targeted
92 */
93 virtual void reset();
94
95 void componentComplete() override;
96 virtual void initialize(int gIdx, int pIdx){//Called from main thread
97 Q_UNUSED(gIdx);
98 Q_UNUSED(pIdx);
99 }
100 virtual void commit(int gIdx, int pIdx){//Called in Render Thread
101 //###If you need to do something on size changed, check m_data size in this? Or we reset you every time?
102 Q_UNUSED(gIdx);
103 Q_UNUSED(pIdx);
104 }
105
106 QQuickParticleSystem* m_system;
107 friend class QQuickParticleSystem;
108 int m_count;
109 bool m_pleaseReset;//Used by subclasses, but it's a nice optimization to know when stuff isn't going to matter.
110 QPointF m_systemOffset;
111
112 QQuickWindow *m_window;
113 bool m_windowChanged;
114
115private: // methods
116 void recalculateGroupIds() const;
117
118private: // data
119 QStringList m_groups;
120 QSet<std::pair<int,int> > m_pendingCommits;
121 mutable GroupIDs m_groupIds;
122 mutable bool m_groupIdsNeedRecalculation;
123};
124
125QT_END_NAMESPACE
126#endif // PARTICLE_H
virtual ImageMaterialData * state()=0
Combined button and popup list for selecting options.