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
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{
25 Q_GADGET
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
52
53 // Undocumented?
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
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:
97 QQuickV4ParticleData(QQuickParticleData *datum, QQuickParticleSystem *system)
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
124QT_END_NAMESPACE
125
126
127#endif
QQuickV4ParticleData(QQuickParticleData *datum, QQuickParticleSystem *system)
static QT_BEGIN_NAMESPACE int roundedTime(qreal a)
A system which includes particle painter, emitter, and affector types.
#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_BOOL_CONFIG_OPTION(forceDiskCache, QML_FORCE_DISK_CACHE)