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
qquickparticlegroup.cpp
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
#
undef
QT_NO_FOREACH
// this file contains unported legacy Q_FOREACH uses
5
6
#
include
"qquickparticlegroup_p.h"
7
8
/*!
9
\qmltype ParticleGroup
10
\inqmlmodule QtQuick.Particles
11
\brief For setting attributes on a logical particle group.
12
\ingroup qtquick-particles
13
14
This element allows you to set timed transitions on particle groups.
15
16
You can also use this element to group particle system elements related to the logical
17
particle group. Emitters, Affectors and Painters set as direct children of a ParticleGroup
18
will automatically apply to that logical particle group. TrailEmitters will automatically follow
19
the group.
20
21
If a ParticleGroup element is not defined for a group, the group will function normally as if
22
none of the transition properties were set.
23
*/
24
/*!
25
\qmlproperty ParticleSystem QtQuick.Particles::ParticleGroup::system
26
This is the system which will contain the group.
27
28
If the ParticleGroup is a direct child of a ParticleSystem, it will automatically be associated with it.
29
*/
30
/*!
31
\qmlproperty string QtQuick.Particles::ParticleGroup::name
32
This is the name of the particle group, and how it is generally referred to by other elements.
33
34
If elements refer to a name which does not have an explicit ParticleGroup created, it will
35
work normally (with no transitions specified for the group). If you do not need to assign
36
duration based transitions to a group, you do not need to create a ParticleGroup with that name (although you may).
37
*/
38
/*!
39
\qmlproperty int QtQuick.Particles::ParticleGroup::duration
40
The time in milliseconds before the group will attempt to transition.
41
42
*/
43
/*!
44
\qmlproperty ParticleSystem QtQuick.Particles::ParticleGroup::durationVariation
45
The maximum number of milliseconds that the duration of the transition cycle varies per particle in the group.
46
47
Default value is zero.
48
*/
49
/*!
50
\qmlproperty ParticleSystem QtQuick.Particles::ParticleGroup::to
51
The weighted list of transitions valid for this group.
52
53
If the chosen transition stays in this group, another duration (+/- up to durationVariation)
54
milliseconds will occur before another transition is attempted.
55
*/
56
57
QQuickParticleGroup::QQuickParticleGroup(QObject* parent)
58
: QQuickStochasticState(parent)
59
, m_system(
nullptr
)
60
{
61
62
}
63
64
void
delayedRedirect
(QQmlListProperty<QObject> *prop, QObject *value)
65
{
66
QQuickParticleGroup* pg = qobject_cast<QQuickParticleGroup*>(prop->object);
67
if
(pg)
68
pg->delayRedirect(value);
69
}
70
71
QQmlListProperty<QObject> QQuickParticleGroup::particleChildren()
72
{
73
QQuickParticleSystem* system = qobject_cast<QQuickParticleSystem*>(parent());
74
if
(system) {
75
return
QQmlListProperty<QObject>(
this
,
nullptr
,
76
&QQuickParticleSystem::statePropertyRedirect,
nullptr
,
77
nullptr
,
nullptr
,
nullptr
,
nullptr
);
78
}
else
{
79
return
QQmlListProperty<QObject>(
this
,
nullptr
,
80
&delayedRedirect,
nullptr
,
nullptr
,
81
nullptr
,
nullptr
,
nullptr
);
82
}
83
}
84
85
void
QQuickParticleGroup::setSystem(QQuickParticleSystem* arg)
86
{
87
if
(m_system != arg) {
88
m_system = arg;
89
m_system->registerParticleGroup(
this
);
90
performDelayedRedirects();
91
emit systemChanged(arg);
92
}
93
}
94
95
void
QQuickParticleGroup::delayRedirect(QObject *obj)
96
{
97
m_delayedRedirects << obj;
98
}
99
100
void
QQuickParticleGroup::performDelayedRedirects()
101
{
102
if
(!m_system)
103
return
;
104
foreach (QObject* obj, m_delayedRedirects)
105
m_system->stateRedirect(
this
, m_system, obj);
106
107
m_delayedRedirects.clear();
108
}
109
110
void
QQuickParticleGroup::componentComplete(){
111
if
(!m_system && qobject_cast<QQuickParticleSystem*>(parent()))
112
setSystem(qobject_cast<QQuickParticleSystem*>(parent()));
113
}
114
115
#
include
"moc_qquickparticlegroup_p.cpp"
delayedRedirect
void delayedRedirect(QQmlListProperty< QObject > *prop, QObject *value)
Definition
qquickparticlegroup.cpp:64
qtdeclarative
src
particles
qquickparticlegroup.cpp
Generated on
for Qt by
1.14.0