1 | /**************************************************************************** |
---|---|
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the QtQuick module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
24 | ** |
25 | ** GNU General Public License Usage |
26 | ** Alternatively, this file may be used under the terms of the GNU |
27 | ** General Public License version 2.0 or (at your option) the GNU General |
28 | ** Public license version 3 or any later version approved by the KDE Free |
29 | ** Qt Foundation. The licenses are as published by the Free Software |
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
31 | ** included in the packaging of this file. Please review the following |
32 | ** information to ensure the GNU General Public License requirements will |
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
35 | ** |
36 | ** $QT_END_LICENSE$ |
37 | ** |
38 | ****************************************************************************/ |
39 | |
40 | #ifndef DIRECTEDVECTOR_H |
41 | #define DIRECTEDVECTOR_H |
42 | |
43 | // |
44 | // W A R N I N G |
45 | // ------------- |
46 | // |
47 | // This file is not part of the Qt API. It exists purely as an |
48 | // implementation detail. This header file may change from version to |
49 | // version without notice, or even be removed. |
50 | // |
51 | // We mean it. |
52 | // |
53 | #include "qquickdirection_p.h" |
54 | #include <QtQml/qqml.h> |
55 | |
56 | QT_BEGIN_NAMESPACE |
57 | |
58 | class QQuickItem; |
59 | class QQuickTargetDirection : public QQuickDirection |
60 | { |
61 | Q_OBJECT |
62 | Q_PROPERTY(qreal targetX READ targetX WRITE setTargetX NOTIFY targetXChanged) |
63 | Q_PROPERTY(qreal targetY READ targetY WRITE setTargetY NOTIFY targetYChanged) |
64 | //If targetItem is set, X/Y are ignored. Aims at middle of item, use variation for variation |
65 | Q_PROPERTY(QQuickItem* targetItem READ targetItem WRITE setTargetItem NOTIFY targetItemChanged) |
66 | |
67 | Q_PROPERTY(qreal targetVariation READ targetVariation WRITE setTargetVariation NOTIFY targetVariationChanged) |
68 | |
69 | //TODO: An enum would be better |
70 | Q_PROPERTY(bool proportionalMagnitude READ proportionalMagnitude WRITE setProportionalMagnitude NOTIFY proprotionalMagnitudeChanged) |
71 | Q_PROPERTY(qreal magnitude READ magnitude WRITE setMagnitude NOTIFY magnitudeChanged) |
72 | Q_PROPERTY(qreal magnitudeVariation READ magnitudeVariation WRITE setMagnitudeVariation NOTIFY magnitudeVariationChanged) |
73 | QML_NAMED_ELEMENT(TargetDirection) |
74 | |
75 | public: |
76 | explicit QQuickTargetDirection(QObject *parent = 0); |
77 | QPointF sample(const QPointF &from) override; |
78 | |
79 | qreal targetX() const |
80 | { |
81 | return m_targetX; |
82 | } |
83 | |
84 | qreal targetY() const |
85 | { |
86 | return m_targetY; |
87 | } |
88 | |
89 | qreal targetVariation() const |
90 | { |
91 | return m_targetVariation; |
92 | } |
93 | |
94 | qreal magnitude() const |
95 | { |
96 | return m_magnitude; |
97 | } |
98 | |
99 | bool proportionalMagnitude() const |
100 | { |
101 | return m_proportionalMagnitude; |
102 | } |
103 | |
104 | qreal magnitudeVariation() const |
105 | { |
106 | return m_magnitudeVariation; |
107 | } |
108 | |
109 | QQuickItem* targetItem() const |
110 | { |
111 | return m_targetItem; |
112 | } |
113 | |
114 | Q_SIGNALS: |
115 | |
116 | void targetXChanged(qreal arg); |
117 | |
118 | void targetYChanged(qreal arg); |
119 | |
120 | void targetVariationChanged(qreal arg); |
121 | |
122 | void magnitudeChanged(qreal arg); |
123 | |
124 | void proprotionalMagnitudeChanged(bool arg); |
125 | |
126 | void magnitudeVariationChanged(qreal arg); |
127 | |
128 | void targetItemChanged(QQuickItem* arg); |
129 | |
130 | public Q_SLOTS: |
131 | void setTargetX(qreal arg) |
132 | { |
133 | if (m_targetX != arg) { |
134 | m_targetX = arg; |
135 | Q_EMIT targetXChanged(arg); |
136 | } |
137 | } |
138 | |
139 | void setTargetY(qreal arg) |
140 | { |
141 | if (m_targetY != arg) { |
142 | m_targetY = arg; |
143 | Q_EMIT targetYChanged(arg); |
144 | } |
145 | } |
146 | |
147 | void setTargetVariation(qreal arg) |
148 | { |
149 | if (m_targetVariation != arg) { |
150 | m_targetVariation = arg; |
151 | Q_EMIT targetVariationChanged(arg); |
152 | } |
153 | } |
154 | |
155 | void setMagnitude(qreal arg) |
156 | { |
157 | if (m_magnitude != arg) { |
158 | m_magnitude = arg; |
159 | Q_EMIT magnitudeChanged(arg); |
160 | } |
161 | } |
162 | |
163 | void setProportionalMagnitude(bool arg) |
164 | { |
165 | if (m_proportionalMagnitude != arg) { |
166 | m_proportionalMagnitude = arg; |
167 | Q_EMIT proprotionalMagnitudeChanged(arg); |
168 | } |
169 | } |
170 | |
171 | void setMagnitudeVariation(qreal arg) |
172 | { |
173 | if (m_magnitudeVariation != arg) { |
174 | m_magnitudeVariation = arg; |
175 | Q_EMIT magnitudeVariationChanged(arg); |
176 | } |
177 | } |
178 | |
179 | void setTargetItem(QQuickItem* arg) |
180 | { |
181 | if (m_targetItem != arg) { |
182 | m_targetItem = arg; |
183 | Q_EMIT targetItemChanged(arg); |
184 | } |
185 | } |
186 | |
187 | private: |
188 | qreal m_targetX; |
189 | qreal m_targetY; |
190 | qreal m_targetVariation; |
191 | bool m_proportionalMagnitude; |
192 | qreal m_magnitude; |
193 | qreal m_magnitudeVariation; |
194 | QQuickItem *m_targetItem; |
195 | }; |
196 | |
197 | QT_END_NAMESPACE |
198 | #endif // DIRECTEDVECTOR_H |
199 |