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
qquickcustomaffector_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 CUSTOMAFFECTOR_H
5#define CUSTOMAFFECTOR_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 <QtQml/qqml.h>
23#include "qquickdirection_p.h"
24
26
27class Q_QUICKPARTICLES_EXPORT QQuickCustomAffector : public QQuickParticleAffector
28{
30 Q_PROPERTY(bool relative READ relative WRITE setRelative NOTIFY relativeChanged)
31 Q_PROPERTY(QQuickDirection *position READ position WRITE setPosition NOTIFY positionChanged RESET positionReset)
32 Q_PROPERTY(QQuickDirection *velocity READ velocity WRITE setVelocity NOTIFY velocityChanged RESET velocityReset)
33 Q_PROPERTY(QQuickDirection *acceleration READ acceleration WRITE setAcceleration NOTIFY accelerationChanged RESET accelerationReset)
34 QML_NAMED_ELEMENT(Affector)
36
37public:
38 explicit QQuickCustomAffector(QQuickItem *parent = nullptr);
39 void affectSystem(qreal dt) override;
40
42 {
43 return m_position;
44 }
45
47 {
48 return m_velocity;
49 }
50
52 {
53 return m_acceleration;
54 }
55
57 {
58 m_position = &m_nullVector;
59 }
60
62 {
63 m_velocity = &m_nullVector;
64 }
65
67 {
68 m_acceleration = &m_nullVector;
69 }
70
71 bool relative() const
72 {
73 return m_relative;
74 }
75
76
78 void affectParticles(const QList<QQuickV4ParticleData> &particles, qreal dt);
79
81
83
85
86 void relativeChanged(bool arg);
87
88public Q_SLOTS:
90 {
91 if (m_position != arg) {
92 m_position = arg;
93 Q_EMIT positionChanged(arg);
94 }
95 }
96
98 {
99 if (m_velocity != arg) {
100 m_velocity = arg;
101 Q_EMIT velocityChanged(arg);
102 }
103 }
104
106 {
107 if (m_acceleration != arg) {
108 m_acceleration = arg;
109 Q_EMIT accelerationChanged(arg);
110 }
111 }
112
113 void setRelative(bool arg)
114 {
115 if (m_relative != arg) {
116 m_relative = arg;
117 Q_EMIT relativeChanged(arg);
118 }
119 }
120
121protected:
122 bool isAffectConnected();
123 bool affectParticle(QQuickParticleData *d, qreal dt) override;
124
125private:
126 void affectProperties(const QList<QQuickParticleData*> &particles, qreal dt);
127 QQuickDirection * m_position;
128 QQuickDirection * m_velocity;
129 QQuickDirection * m_acceleration;
130
131 QQuickDirection m_nullVector;
132 bool m_relative;
133};
134
136#endif // CUSTOMAFFECTOR_H
void setVelocity(QQuickDirection *arg)
void setPosition(QQuickDirection *arg)
void affectParticles(const QList< QQuickV4ParticleData > &particles, qreal dt)
void accelerationChanged(QQuickDirection *arg)
void setAcceleration(QQuickDirection *arg)
void relativeChanged(bool arg)
void velocityChanged(QQuickDirection *arg)
void positionChanged(QQuickDirection *arg)
QQuickDirection * acceleration() const
QQuickDirection * velocity() const
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
Combined button and popup list for selecting options.
n void setPosition(void) \n\
#define QML_NAMED_ELEMENT(NAME)
#define QML_ADDED_IN_VERSION(MAJOR, MINOR)
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
SSL_CTX int void * arg
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_EMIT
#define Q_SLOTS
#define Q_SIGNALS
double qreal
Definition qtypes.h:187
#define explicit