Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickv4particledata_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 QQuickV8PARTICLEDATA_H
5#define QQuickV8PARTICLEDATA_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/qquickparticlesystem_p.h>
19#include <QtQml/qqml.h>
20
22
24{
26 QML_VALUE_TYPE(particle)
28
29#define Q_QUICK_PARTICLE_ACCESSOR(TYPE, VARIABLE, NAME) \
30 Q_PROPERTY(TYPE NAME READ NAME WRITE set_ ## NAME FINAL) \
31 TYPE NAME() const { return datum ? datum->VARIABLE : TYPE(); } \
32 void set_ ## NAME(TYPE a) { if (datum) datum->VARIABLE = a; }
33
34 Q_QUICK_PARTICLE_ACCESSOR(float, x, initialX)
35 Q_QUICK_PARTICLE_ACCESSOR(float, vx, initialVX)
36 Q_QUICK_PARTICLE_ACCESSOR(float, ax, initialAX)
37 Q_QUICK_PARTICLE_ACCESSOR(float, y, initialY)
38 Q_QUICK_PARTICLE_ACCESSOR(float, vy, initialVY)
39 Q_QUICK_PARTICLE_ACCESSOR(float, ay, initialAY)
41 Q_QUICK_PARTICLE_ACCESSOR(float, size, startSize)
42 Q_QUICK_PARTICLE_ACCESSOR(float, endSize, endSize)
43 Q_QUICK_PARTICLE_ACCESSOR(float, lifeSpan, lifeSpan)
44 Q_QUICK_PARTICLE_ACCESSOR(float, rotation, rotation)
45 Q_QUICK_PARTICLE_ACCESSOR(float, rotationVelocity, rotationVelocity)
46 Q_QUICK_PARTICLE_ACCESSOR(bool, autoRotate, autoRotate)
47 Q_QUICK_PARTICLE_ACCESSOR(bool, update, update)
48 Q_QUICK_PARTICLE_ACCESSOR(float, xx, xDeformationVectorX)
49 Q_QUICK_PARTICLE_ACCESSOR(float, yx, yDeformationVectorX)
50 Q_QUICK_PARTICLE_ACCESSOR(float, xy, xDeformationVectorY)
51 Q_QUICK_PARTICLE_ACCESSOR(float, yy, yDeformationVectorY)
52
53 // Undocumented?
54 Q_QUICK_PARTICLE_ACCESSOR(float, animIdx, animationIndex)
55 Q_QUICK_PARTICLE_ACCESSOR(float, frameDuration, frameDuration)
56 Q_QUICK_PARTICLE_ACCESSOR(float, frameAt, frameAt)
57 Q_QUICK_PARTICLE_ACCESSOR(float, frameCount, frameCount)
58 Q_QUICK_PARTICLE_ACCESSOR(float, animT, animationT)
59
60#undef Q_QUICK_PARTICLE_ACCESSOR
61
62#define Q_QUICK_PARTICLE_SYSTEM_ACCESSOR(GETTER, SETTER, NAME) \
63 Q_PROPERTY(float NAME READ NAME WRITE set_ ## NAME) \
64 float NAME() const { return (datum && particleSystem) ? datum->GETTER(particleSystem) : 0; } \
65 void set_ ## NAME(float a) { if (datum && particleSystem) datum->SETTER(a, particleSystem); }
66
67 Q_QUICK_PARTICLE_SYSTEM_ACCESSOR(curX, setInstantaneousX, x)
68 Q_QUICK_PARTICLE_SYSTEM_ACCESSOR(curVX, setInstantaneousVX, vx)
69 Q_QUICK_PARTICLE_SYSTEM_ACCESSOR(curAX, setInstantaneousAX, ax)
70 Q_QUICK_PARTICLE_SYSTEM_ACCESSOR(curY, setInstantaneousY, y)
71 Q_QUICK_PARTICLE_SYSTEM_ACCESSOR(curVY, setInstantaneousVY, vy)
72 Q_QUICK_PARTICLE_SYSTEM_ACCESSOR(curAY, setInstantaneousAY, ay)
73
74#undef Q_QUICK_PARTICLE_SYSTEM_ACCESSOR
75
76#define Q_QUICK_PARTICLE_COLOR_ACCESSOR(VAR, NAME) \
77 Q_PROPERTY(float NAME READ NAME WRITE set_ ## NAME) \
78 float NAME() const { return datum ? datum->color.VAR / 255.0 : 0.0; } \
79 void set_ ## NAME(float a)\
80 {\
81 if (datum)\
82 datum->color.VAR = qMin(255, qMax(0, (int)::floor(a * 255.0)));\
83 }
84
89
90#undef Q_QUICK_PARTICLE_COLOR_ACCESSOR
91
94
95public:
98 : datum(datum)
99 , particleSystem(system)
100 {}
101
103 {
104 if (datum)
105 datum->lifeSpan = 0;
106 }
107
108 float lifeLeft() const
109 {
110 return (datum && particleSystem) ? datum->lifeLeft(particleSystem) : 0.0;
111 }
112
113 float currentSize() const
114 {
115 return (datum && particleSystem) ? datum->curSize(particleSystem) : 0.0;
116 }
117
118private:
119 QQuickParticleData *datum = nullptr;
120 QQuickParticleSystem *particleSystem = nullptr;
121};
122
123
125
126
127#endif
float lifeLeft(QQuickParticleSystem *particleSystem) const
float curSize(QQuickParticleSystem *particleSystem) const
Combined button and popup list for selecting options.
GLboolean GLboolean GLboolean b
GLint GLint GLint GLint GLint x
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLboolean r
[2]
GLboolean GLboolean g
GLint y
GLbyte GLbyte blue
Definition qopenglext.h:385
GLdouble GLdouble t
Definition qopenglext.h:243
GLfloat GLfloat GLfloat alpha
Definition qopenglext.h:418
GLbyte green
Definition qopenglext.h:385
#define QML_VALUE_TYPE(NAME)
#define QML_ADDED_IN_VERSION(MAJOR, MINOR)
#define Q_QUICK_PARTICLE_SYSTEM_ACCESSOR(GETTER, SETTER, NAME)
#define Q_QUICK_PARTICLE_ACCESSOR(TYPE, VARIABLE, NAME)
#define Q_QUICK_PARTICLE_COLOR_ACCESSOR(VAR, NAME)
#define Q_PROPERTY(...)
#define Q_INVOKABLE
#define Q_GADGET
QGraphicsSvgItem * red