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 DIRECTEDVECTOR_H |
5 | #define DIRECTEDVECTOR_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 | #include "qquickdirection_p.h" |
18 | #include <QtQml/qqml.h> |
19 | |
20 | QT_BEGIN_NAMESPACE |
21 | |
22 | class QQuickItem; |
23 | class Q_QUICKPARTICLES_PRIVATE_EXPORT QQuickTargetDirection : public QQuickDirection |
24 | { |
25 | Q_OBJECT |
26 | Q_PROPERTY(qreal targetX READ targetX WRITE setTargetX NOTIFY targetXChanged FINAL) |
27 | Q_PROPERTY(qreal targetY READ targetY WRITE setTargetY NOTIFY targetYChanged FINAL) |
28 | //If targetItem is set, X/Y are ignored. Aims at middle of item, use variation for variation |
29 | Q_PROPERTY(QQuickItem* targetItem READ targetItem WRITE setTargetItem NOTIFY targetItemChanged FINAL) |
30 | |
31 | Q_PROPERTY(qreal targetVariation READ targetVariation WRITE setTargetVariation NOTIFY targetVariationChanged FINAL) |
32 | |
33 | //TODO: An enum would be better |
34 | Q_PROPERTY(bool proportionalMagnitude READ proportionalMagnitude WRITE setProportionalMagnitude NOTIFY proprotionalMagnitudeChanged FINAL) |
35 | Q_PROPERTY(qreal magnitude READ magnitude WRITE setMagnitude NOTIFY magnitudeChanged FINAL) |
36 | Q_PROPERTY(qreal magnitudeVariation READ magnitudeVariation WRITE setMagnitudeVariation NOTIFY magnitudeVariationChanged FINAL) |
37 | QML_NAMED_ELEMENT(TargetDirection) |
38 | QML_ADDED_IN_VERSION(2, 0) |
39 | |
40 | public: |
41 | explicit QQuickTargetDirection(QObject *parent = nullptr); |
42 | QPointF sample(const QPointF &from) override; |
43 | |
44 | qreal targetX() const |
45 | { |
46 | return m_targetX; |
47 | } |
48 | |
49 | qreal targetY() const |
50 | { |
51 | return m_targetY; |
52 | } |
53 | |
54 | qreal targetVariation() const |
55 | { |
56 | return m_targetVariation; |
57 | } |
58 | |
59 | qreal magnitude() const |
60 | { |
61 | return m_magnitude; |
62 | } |
63 | |
64 | bool proportionalMagnitude() const |
65 | { |
66 | return m_proportionalMagnitude; |
67 | } |
68 | |
69 | qreal magnitudeVariation() const |
70 | { |
71 | return m_magnitudeVariation; |
72 | } |
73 | |
74 | QQuickItem* targetItem() const |
75 | { |
76 | return m_targetItem; |
77 | } |
78 | |
79 | Q_SIGNALS: |
80 | |
81 | void targetXChanged(qreal arg); |
82 | |
83 | void targetYChanged(qreal arg); |
84 | |
85 | void targetVariationChanged(qreal arg); |
86 | |
87 | void magnitudeChanged(qreal arg); |
88 | |
89 | void proprotionalMagnitudeChanged(bool arg); |
90 | |
91 | void magnitudeVariationChanged(qreal arg); |
92 | |
93 | void targetItemChanged(QQuickItem* arg); |
94 | |
95 | public Q_SLOTS: |
96 | void setTargetX(qreal arg) |
97 | { |
98 | if (m_targetX != arg) { |
99 | m_targetX = arg; |
100 | Q_EMIT targetXChanged(arg); |
101 | } |
102 | } |
103 | |
104 | void setTargetY(qreal arg) |
105 | { |
106 | if (m_targetY != arg) { |
107 | m_targetY = arg; |
108 | Q_EMIT targetYChanged(arg); |
109 | } |
110 | } |
111 | |
112 | void setTargetVariation(qreal arg) |
113 | { |
114 | if (m_targetVariation != arg) { |
115 | m_targetVariation = arg; |
116 | Q_EMIT targetVariationChanged(arg); |
117 | } |
118 | } |
119 | |
120 | void setMagnitude(qreal arg) |
121 | { |
122 | if (m_magnitude != arg) { |
123 | m_magnitude = arg; |
124 | Q_EMIT magnitudeChanged(arg); |
125 | } |
126 | } |
127 | |
128 | void setProportionalMagnitude(bool arg) |
129 | { |
130 | if (m_proportionalMagnitude != arg) { |
131 | m_proportionalMagnitude = arg; |
132 | Q_EMIT proprotionalMagnitudeChanged(arg); |
133 | } |
134 | } |
135 | |
136 | void setMagnitudeVariation(qreal arg) |
137 | { |
138 | if (m_magnitudeVariation != arg) { |
139 | m_magnitudeVariation = arg; |
140 | Q_EMIT magnitudeVariationChanged(arg); |
141 | } |
142 | } |
143 | |
144 | void setTargetItem(QQuickItem* arg) |
145 | { |
146 | if (m_targetItem != arg) { |
147 | m_targetItem = arg; |
148 | Q_EMIT targetItemChanged(arg); |
149 | } |
150 | } |
151 | |
152 | private: |
153 | qreal m_targetX; |
154 | qreal m_targetY; |
155 | qreal m_targetVariation; |
156 | bool m_proportionalMagnitude; |
157 | qreal m_magnitude; |
158 | qreal m_magnitudeVariation; |
159 | QQuickItem *m_targetItem; |
160 | }; |
161 | |
162 | QT_END_NAMESPACE |
163 | #endif // DIRECTEDVECTOR_H |
164 |