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 QQUICKVALUETYPES_P_H |
5 | #define QQUICKVALUETYPES_P_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 <qqml.h> |
19 | #include <private/qtquickglobal_p.h> |
20 | #include <private/qqmlvaluetype_p.h> |
21 | |
22 | #include <QtGui/QColor> |
23 | #include <QtGui/QColorSpace> |
24 | #include <QtGui/QVector2D> |
25 | #include <QtGui/QVector3D> |
26 | #include <QtGui/QVector4D> |
27 | #include <QtGui/QQuaternion> |
28 | #include <QtGui/QMatrix4x4> |
29 | #include <QtGui/QFont> |
30 | |
31 | QT_BEGIN_NAMESPACE |
32 | |
33 | class Q_QUICK_PRIVATE_EXPORT QQuickColorValueType |
34 | { |
35 | QColor v; |
36 | Q_PROPERTY(qreal r READ r WRITE setR FINAL) |
37 | Q_PROPERTY(qreal g READ g WRITE setG FINAL) |
38 | Q_PROPERTY(qreal b READ b WRITE setB FINAL) |
39 | Q_PROPERTY(qreal a READ a WRITE setA FINAL) |
40 | Q_PROPERTY(qreal hsvHue READ hsvHue WRITE setHsvHue FINAL) |
41 | Q_PROPERTY(qreal hsvSaturation READ hsvSaturation WRITE setHsvSaturation FINAL) |
42 | Q_PROPERTY(qreal hsvValue READ hsvValue WRITE setHsvValue FINAL) |
43 | Q_PROPERTY(qreal hslHue READ hslHue WRITE setHslHue FINAL) |
44 | Q_PROPERTY(qreal hslSaturation READ hslSaturation WRITE setHslSaturation FINAL) |
45 | Q_PROPERTY(qreal hslLightness READ hslLightness WRITE setHslLightness FINAL) |
46 | Q_PROPERTY(bool valid READ isValid FINAL) |
47 | Q_GADGET |
48 | QML_ADDED_IN_VERSION(2, 0) |
49 | QML_FOREIGN(QColor) |
50 | QML_VALUE_TYPE(color) |
51 | QML_EXTENDED(QQuickColorValueType) |
52 | QML_STRUCTURED_VALUE |
53 | |
54 | public: |
55 | static QVariant create(const QJSValue ¶ms); |
56 | |
57 | Q_INVOKABLE QQuickColorValueType(const QString &string); |
58 | Q_INVOKABLE QString toString() const; |
59 | |
60 | Q_INVOKABLE QVariant alpha(qreal value) const; |
61 | Q_INVOKABLE QVariant lighter(qreal factor = 1.5) const; |
62 | Q_INVOKABLE QVariant darker(qreal factor = 2.0) const; |
63 | Q_INVOKABLE QVariant tint(QVariant factor) const; |
64 | |
65 | qreal r() const; |
66 | qreal g() const; |
67 | qreal b() const; |
68 | qreal a() const; |
69 | qreal hsvHue() const; |
70 | qreal hsvSaturation() const; |
71 | qreal hsvValue() const; |
72 | qreal hslHue() const; |
73 | qreal hslSaturation() const; |
74 | qreal hslLightness() const; |
75 | bool isValid() const; |
76 | void setR(qreal); |
77 | void setG(qreal); |
78 | void setB(qreal); |
79 | void setA(qreal); |
80 | void setHsvHue(qreal); |
81 | void setHsvSaturation(qreal); |
82 | void setHsvValue(qreal); |
83 | void setHslHue(qreal); |
84 | void setHslSaturation(qreal); |
85 | void setHslLightness(qreal); |
86 | |
87 | operator QColor() const { return v; } |
88 | }; |
89 | |
90 | class Q_QUICK_PRIVATE_EXPORT QQuickVector2DValueType |
91 | { |
92 | QVector2D v; |
93 | Q_PROPERTY(qreal x READ x WRITE setX FINAL) |
94 | Q_PROPERTY(qreal y READ y WRITE setY FINAL) |
95 | Q_GADGET |
96 | QML_ADDED_IN_VERSION(2, 0) |
97 | QML_FOREIGN(QVector2D) |
98 | QML_VALUE_TYPE(vector2d) |
99 | QML_EXTENDED(QQuickVector2DValueType) |
100 | QML_STRUCTURED_VALUE |
101 | |
102 | public: |
103 | static QVariant create(const QJSValue ¶ms); |
104 | |
105 | Q_INVOKABLE QString toString() const; |
106 | |
107 | qreal x() const; |
108 | qreal y() const; |
109 | void setX(qreal); |
110 | void setY(qreal); |
111 | |
112 | Q_INVOKABLE qreal dotProduct(const QVector2D &vec) const; |
113 | Q_INVOKABLE QVector2D times(const QVector2D &vec) const; |
114 | Q_INVOKABLE QVector2D times(qreal scalar) const; |
115 | Q_INVOKABLE QVector2D plus(const QVector2D &vec) const; |
116 | Q_INVOKABLE QVector2D minus(const QVector2D &vec) const; |
117 | Q_INVOKABLE QVector2D normalized() const; |
118 | Q_INVOKABLE qreal length() const; |
119 | Q_INVOKABLE QVector3D toVector3d() const; |
120 | Q_INVOKABLE QVector4D toVector4d() const; |
121 | Q_INVOKABLE bool fuzzyEquals(const QVector2D &vec, qreal epsilon) const; |
122 | Q_INVOKABLE bool fuzzyEquals(const QVector2D &vec) const; |
123 | |
124 | operator QVector2D() const { return v; } |
125 | }; |
126 | |
127 | class Q_QUICK_PRIVATE_EXPORT QQuickVector3DValueType |
128 | { |
129 | QVector3D v; |
130 | Q_PROPERTY(qreal x READ x WRITE setX FINAL) |
131 | Q_PROPERTY(qreal y READ y WRITE setY FINAL) |
132 | Q_PROPERTY(qreal z READ z WRITE setZ FINAL) |
133 | Q_GADGET |
134 | QML_ADDED_IN_VERSION(2, 0) |
135 | QML_FOREIGN(QVector3D) |
136 | QML_VALUE_TYPE(vector3d) |
137 | QML_EXTENDED(QQuickVector3DValueType) |
138 | QML_STRUCTURED_VALUE |
139 | |
140 | public: |
141 | static QVariant create(const QJSValue ¶ms); |
142 | |
143 | Q_INVOKABLE QString toString() const; |
144 | |
145 | qreal x() const; |
146 | qreal y() const; |
147 | qreal z() const; |
148 | void setX(qreal); |
149 | void setY(qreal); |
150 | void setZ(qreal); |
151 | |
152 | Q_INVOKABLE QVector3D crossProduct(const QVector3D &vec) const; |
153 | Q_INVOKABLE qreal dotProduct(const QVector3D &vec) const; |
154 | Q_INVOKABLE QVector3D times(const QMatrix4x4 &m) const; |
155 | Q_INVOKABLE QVector3D times(const QVector3D &vec) const; |
156 | Q_INVOKABLE QVector3D times(qreal scalar) const; |
157 | Q_INVOKABLE QVector3D plus(const QVector3D &vec) const; |
158 | Q_INVOKABLE QVector3D minus(const QVector3D &vec) const; |
159 | Q_INVOKABLE QVector3D normalized() const; |
160 | Q_INVOKABLE qreal length() const; |
161 | Q_INVOKABLE QVector2D toVector2d() const; |
162 | Q_INVOKABLE QVector4D toVector4d() const; |
163 | Q_INVOKABLE bool fuzzyEquals(const QVector3D &vec, qreal epsilon) const; |
164 | Q_INVOKABLE bool fuzzyEquals(const QVector3D &vec) const; |
165 | |
166 | operator QVector3D() const { return v; } |
167 | }; |
168 | |
169 | class Q_QUICK_PRIVATE_EXPORT QQuickVector4DValueType |
170 | { |
171 | QVector4D v; |
172 | Q_PROPERTY(qreal x READ x WRITE setX FINAL) |
173 | Q_PROPERTY(qreal y READ y WRITE setY FINAL) |
174 | Q_PROPERTY(qreal z READ z WRITE setZ FINAL) |
175 | Q_PROPERTY(qreal w READ w WRITE setW FINAL) |
176 | Q_GADGET |
177 | QML_ADDED_IN_VERSION(2, 0) |
178 | QML_FOREIGN(QVector4D) |
179 | QML_VALUE_TYPE(vector4d) |
180 | QML_EXTENDED(QQuickVector4DValueType) |
181 | QML_STRUCTURED_VALUE |
182 | |
183 | public: |
184 | static QVariant create(const QJSValue ¶ms); |
185 | |
186 | Q_INVOKABLE QString toString() const; |
187 | |
188 | qreal x() const; |
189 | qreal y() const; |
190 | qreal z() const; |
191 | qreal w() const; |
192 | void setX(qreal); |
193 | void setY(qreal); |
194 | void setZ(qreal); |
195 | void setW(qreal); |
196 | |
197 | Q_INVOKABLE qreal dotProduct(const QVector4D &vec) const; |
198 | Q_INVOKABLE QVector4D times(const QVector4D &vec) const; |
199 | Q_INVOKABLE QVector4D times(const QMatrix4x4 &m) const; |
200 | Q_INVOKABLE QVector4D times(qreal scalar) const; |
201 | Q_INVOKABLE QVector4D plus(const QVector4D &vec) const; |
202 | Q_INVOKABLE QVector4D minus(const QVector4D &vec) const; |
203 | Q_INVOKABLE QVector4D normalized() const; |
204 | Q_INVOKABLE qreal length() const; |
205 | Q_INVOKABLE QVector2D toVector2d() const; |
206 | Q_INVOKABLE QVector3D toVector3d() const; |
207 | Q_INVOKABLE bool fuzzyEquals(const QVector4D &vec, qreal epsilon) const; |
208 | Q_INVOKABLE bool fuzzyEquals(const QVector4D &vec) const; |
209 | |
210 | operator QVector4D() const { return v; } |
211 | }; |
212 | |
213 | class Q_QUICK_PRIVATE_EXPORT QQuickQuaternionValueType |
214 | { |
215 | QQuaternion v; |
216 | Q_PROPERTY(qreal scalar READ scalar WRITE setScalar FINAL) |
217 | Q_PROPERTY(qreal x READ x WRITE setX FINAL) |
218 | Q_PROPERTY(qreal y READ y WRITE setY FINAL) |
219 | Q_PROPERTY(qreal z READ z WRITE setZ FINAL) |
220 | Q_GADGET |
221 | QML_ADDED_IN_VERSION(2, 0) |
222 | QML_FOREIGN(QQuaternion) |
223 | QML_VALUE_TYPE(quaternion) |
224 | QML_EXTENDED(QQuickQuaternionValueType) |
225 | QML_STRUCTURED_VALUE |
226 | |
227 | public: |
228 | static QVariant create(const QJSValue ¶ms); |
229 | |
230 | Q_INVOKABLE QString toString() const; |
231 | |
232 | qreal scalar() const; |
233 | qreal x() const; |
234 | qreal y() const; |
235 | qreal z() const; |
236 | void setScalar(qreal); |
237 | void setX(qreal); |
238 | void setY(qreal); |
239 | void setZ(qreal); |
240 | |
241 | Q_INVOKABLE qreal dotProduct(const QQuaternion &q) const; |
242 | Q_INVOKABLE QQuaternion times(const QQuaternion &q) const; |
243 | Q_INVOKABLE QVector3D times(const QVector3D &vec) const; |
244 | Q_INVOKABLE QQuaternion times(qreal factor) const; |
245 | Q_INVOKABLE QQuaternion plus(const QQuaternion &q) const; |
246 | Q_INVOKABLE QQuaternion minus(const QQuaternion &q) const; |
247 | |
248 | Q_INVOKABLE QQuaternion normalized() const; |
249 | Q_INVOKABLE QQuaternion inverted() const; |
250 | Q_INVOKABLE QQuaternion conjugated() const; |
251 | Q_INVOKABLE qreal length() const; |
252 | |
253 | Q_INVOKABLE QVector3D toEulerAngles() const; |
254 | Q_INVOKABLE QVector4D toVector4d() const; |
255 | |
256 | Q_INVOKABLE bool fuzzyEquals(const QQuaternion &q, qreal epsilon) const; |
257 | Q_INVOKABLE bool fuzzyEquals(const QQuaternion &q) const; |
258 | |
259 | operator QQuaternion() const { return v; } |
260 | }; |
261 | |
262 | class Q_QUICK_PRIVATE_EXPORT QQuickMatrix4x4ValueType |
263 | { |
264 | QMatrix4x4 v; |
265 | Q_PROPERTY(qreal m11 READ m11 WRITE setM11 FINAL) |
266 | Q_PROPERTY(qreal m12 READ m12 WRITE setM12 FINAL) |
267 | Q_PROPERTY(qreal m13 READ m13 WRITE setM13 FINAL) |
268 | Q_PROPERTY(qreal m14 READ m14 WRITE setM14 FINAL) |
269 | Q_PROPERTY(qreal m21 READ m21 WRITE setM21 FINAL) |
270 | Q_PROPERTY(qreal m22 READ m22 WRITE setM22 FINAL) |
271 | Q_PROPERTY(qreal m23 READ m23 WRITE setM23 FINAL) |
272 | Q_PROPERTY(qreal m24 READ m24 WRITE setM24 FINAL) |
273 | Q_PROPERTY(qreal m31 READ m31 WRITE setM31 FINAL) |
274 | Q_PROPERTY(qreal m32 READ m32 WRITE setM32 FINAL) |
275 | Q_PROPERTY(qreal m33 READ m33 WRITE setM33 FINAL) |
276 | Q_PROPERTY(qreal m34 READ m34 WRITE setM34 FINAL) |
277 | Q_PROPERTY(qreal m41 READ m41 WRITE setM41 FINAL) |
278 | Q_PROPERTY(qreal m42 READ m42 WRITE setM42 FINAL) |
279 | Q_PROPERTY(qreal m43 READ m43 WRITE setM43 FINAL) |
280 | Q_PROPERTY(qreal m44 READ m44 WRITE setM44 FINAL) |
281 | Q_GADGET |
282 | QML_ADDED_IN_VERSION(2, 0) |
283 | QML_FOREIGN(QMatrix4x4) |
284 | QML_VALUE_TYPE(matrix4x4) |
285 | QML_EXTENDED(QQuickMatrix4x4ValueType) |
286 | QML_STRUCTURED_VALUE |
287 | |
288 | public: |
289 | static QVariant create(const QJSValue ¶ms); |
290 | |
291 | qreal m11() const { return v(0, 0); } |
292 | qreal m12() const { return v(0, 1); } |
293 | qreal m13() const { return v(0, 2); } |
294 | qreal m14() const { return v(0, 3); } |
295 | qreal m21() const { return v(1, 0); } |
296 | qreal m22() const { return v(1, 1); } |
297 | qreal m23() const { return v(1, 2); } |
298 | qreal m24() const { return v(1, 3); } |
299 | qreal m31() const { return v(2, 0); } |
300 | qreal m32() const { return v(2, 1); } |
301 | qreal m33() const { return v(2, 2); } |
302 | qreal m34() const { return v(2, 3); } |
303 | qreal m41() const { return v(3, 0); } |
304 | qreal m42() const { return v(3, 1); } |
305 | qreal m43() const { return v(3, 2); } |
306 | qreal m44() const { return v(3, 3); } |
307 | |
308 | void setM11(qreal value) { v(0, 0) = value; } |
309 | void setM12(qreal value) { v(0, 1) = value; } |
310 | void setM13(qreal value) { v(0, 2) = value; } |
311 | void setM14(qreal value) { v(0, 3) = value; } |
312 | void setM21(qreal value) { v(1, 0) = value; } |
313 | void setM22(qreal value) { v(1, 1) = value; } |
314 | void setM23(qreal value) { v(1, 2) = value; } |
315 | void setM24(qreal value) { v(1, 3) = value; } |
316 | void setM31(qreal value) { v(2, 0) = value; } |
317 | void setM32(qreal value) { v(2, 1) = value; } |
318 | void setM33(qreal value) { v(2, 2) = value; } |
319 | void setM34(qreal value) { v(2, 3) = value; } |
320 | void setM41(qreal value) { v(3, 0) = value; } |
321 | void setM42(qreal value) { v(3, 1) = value; } |
322 | void setM43(qreal value) { v(3, 2) = value; } |
323 | void setM44(qreal value) { v(3, 3) = value; } |
324 | |
325 | Q_INVOKABLE void translate(const QVector3D &t) { v.translate(vector: t); } |
326 | Q_INVOKABLE void rotate(float angle, const QVector3D &axis) { v.rotate(angle, vector: axis); } |
327 | Q_INVOKABLE void rotate(const QQuaternion &q) { v.rotate(quaternion: q); } |
328 | Q_INVOKABLE void scale(float s) { v.scale(factor: s); } |
329 | Q_INVOKABLE void scale(float sx, float sy, float sz) { v.scale(x: sx, y: sy, z: sz); } |
330 | Q_INVOKABLE void scale(const QVector3D &s) { v.scale(vector: s); } |
331 | Q_INVOKABLE void lookAt(const QVector3D &eye, const QVector3D ¢er, const QVector3D &up) { v.lookAt(eye, center, up); } |
332 | |
333 | Q_INVOKABLE QMatrix4x4 times(const QMatrix4x4 &m) const; |
334 | Q_INVOKABLE QVector4D times(const QVector4D &vec) const; |
335 | Q_INVOKABLE QVector3D times(const QVector3D &vec) const; |
336 | Q_INVOKABLE QMatrix4x4 times(qreal factor) const; |
337 | Q_INVOKABLE QMatrix4x4 plus(const QMatrix4x4 &m) const; |
338 | Q_INVOKABLE QMatrix4x4 minus(const QMatrix4x4 &m) const; |
339 | |
340 | Q_INVOKABLE QVector4D row(int n) const; |
341 | Q_INVOKABLE QVector4D column(int m) const; |
342 | |
343 | Q_INVOKABLE qreal determinant() const; |
344 | Q_INVOKABLE QMatrix4x4 inverted() const; |
345 | Q_INVOKABLE QMatrix4x4 transposed() const; |
346 | |
347 | Q_INVOKABLE QPointF map(const QPointF p) const; |
348 | Q_INVOKABLE QRectF mapRect(const QRectF r) const; |
349 | |
350 | Q_INVOKABLE bool fuzzyEquals(const QMatrix4x4 &m, qreal epsilon) const; |
351 | Q_INVOKABLE bool fuzzyEquals(const QMatrix4x4 &m) const; |
352 | |
353 | operator QMatrix4x4() const { return v; } |
354 | }; |
355 | |
356 | namespace QQuickFontEnums |
357 | { |
358 | Q_NAMESPACE_EXPORT(Q_QUICK_PRIVATE_EXPORT) |
359 | |
360 | QML_NAMED_ELEMENT(Font) |
361 | QML_ADDED_IN_VERSION(2, 0) |
362 | |
363 | enum FontWeight { Thin = QFont::Thin, |
364 | = QFont::ExtraLight, |
365 | Light = QFont::Light, |
366 | Normal = QFont::Normal, |
367 | Medium = QFont::Medium, |
368 | DemiBold = QFont::DemiBold, |
369 | Bold = QFont::Bold, |
370 | = QFont::ExtraBold, |
371 | Black = QFont::Black }; |
372 | Q_ENUM_NS(FontWeight) |
373 | enum Capitalization { MixedCase = QFont::MixedCase, |
374 | AllUppercase = QFont::AllUppercase, |
375 | AllLowercase = QFont::AllLowercase, |
376 | SmallCaps = QFont::SmallCaps, |
377 | Capitalize = QFont::Capitalize }; |
378 | Q_ENUM_NS(Capitalization) |
379 | |
380 | enum HintingPreference { |
381 | PreferDefaultHinting = QFont::PreferDefaultHinting, |
382 | PreferNoHinting = QFont::PreferNoHinting, |
383 | PreferVerticalHinting = QFont::PreferVerticalHinting, |
384 | PreferFullHinting = QFont::PreferFullHinting |
385 | }; |
386 | Q_ENUM_NS(HintingPreference) |
387 | }; |
388 | |
389 | class Q_QUICK_PRIVATE_EXPORT QQuickFontValueType |
390 | { |
391 | QFont v; |
392 | Q_GADGET |
393 | |
394 | Q_PROPERTY(QString family READ family WRITE setFamily FINAL) |
395 | Q_PROPERTY(QString styleName READ styleName WRITE setStyleName FINAL) |
396 | Q_PROPERTY(bool bold READ bold WRITE setBold FINAL) |
397 | Q_PROPERTY(int weight READ weight WRITE setWeight FINAL) |
398 | Q_PROPERTY(bool italic READ italic WRITE setItalic FINAL) |
399 | Q_PROPERTY(bool underline READ underline WRITE setUnderline FINAL) |
400 | Q_PROPERTY(bool overline READ overline WRITE setOverline FINAL) |
401 | Q_PROPERTY(bool strikeout READ strikeout WRITE setStrikeout FINAL) |
402 | Q_PROPERTY(qreal pointSize READ pointSize WRITE setPointSize FINAL) |
403 | Q_PROPERTY(int pixelSize READ pixelSize WRITE setPixelSize FINAL) |
404 | Q_PROPERTY(QQuickFontEnums::Capitalization capitalization READ capitalization WRITE setCapitalization FINAL) |
405 | Q_PROPERTY(qreal letterSpacing READ letterSpacing WRITE setLetterSpacing FINAL) |
406 | Q_PROPERTY(qreal wordSpacing READ wordSpacing WRITE setWordSpacing FINAL) |
407 | Q_PROPERTY(QQuickFontEnums::HintingPreference hintingPreference READ hintingPreference WRITE setHintingPreference FINAL) |
408 | Q_PROPERTY(bool kerning READ kerning WRITE setKerning FINAL) |
409 | Q_PROPERTY(bool preferShaping READ preferShaping WRITE setPreferShaping FINAL) |
410 | Q_PROPERTY(QVariantMap features READ features WRITE setFeatures FINAL) |
411 | |
412 | QML_VALUE_TYPE(font) |
413 | QML_FOREIGN(QFont) |
414 | QML_ADDED_IN_VERSION(2, 0) |
415 | QML_EXTENDED(QQuickFontValueType) |
416 | QML_STRUCTURED_VALUE |
417 | |
418 | public: |
419 | static QVariant create(const QJSValue &value); |
420 | |
421 | Q_INVOKABLE QString toString() const; |
422 | |
423 | QString family() const; |
424 | void setFamily(const QString &); |
425 | |
426 | QString styleName() const; |
427 | void setStyleName(const QString &); |
428 | |
429 | bool bold() const; |
430 | void setBold(bool b); |
431 | |
432 | int weight() const; |
433 | void setWeight(int); |
434 | |
435 | bool italic() const; |
436 | void setItalic(bool b); |
437 | |
438 | bool underline() const; |
439 | void setUnderline(bool b); |
440 | |
441 | bool overline() const; |
442 | void setOverline(bool b); |
443 | |
444 | bool strikeout() const; |
445 | void setStrikeout(bool b); |
446 | |
447 | qreal pointSize() const; |
448 | void setPointSize(qreal size); |
449 | |
450 | int pixelSize() const; |
451 | void setPixelSize(int size); |
452 | |
453 | QQuickFontEnums::Capitalization capitalization() const; |
454 | void setCapitalization(QQuickFontEnums::Capitalization); |
455 | |
456 | qreal letterSpacing() const; |
457 | void setLetterSpacing(qreal spacing); |
458 | |
459 | qreal wordSpacing() const; |
460 | void setWordSpacing(qreal spacing); |
461 | |
462 | QQuickFontEnums::HintingPreference hintingPreference() const; |
463 | void setHintingPreference(QQuickFontEnums::HintingPreference); |
464 | |
465 | bool kerning() const; |
466 | void setKerning(bool b); |
467 | |
468 | bool preferShaping() const; |
469 | void setPreferShaping(bool b); |
470 | |
471 | QVariantMap features() const; |
472 | void setFeatures(const QVariantMap &features); |
473 | |
474 | operator QFont() const { return v; } |
475 | }; |
476 | |
477 | namespace QQuickColorSpaceEnums |
478 | { |
479 | Q_NAMESPACE_EXPORT(Q_QUICK_PRIVATE_EXPORT) |
480 | QML_NAMED_ELEMENT(ColorSpace) |
481 | QML_ADDED_IN_VERSION(2, 15) |
482 | Q_CLASSINFO("RegisterEnumClassesUnscoped" , "false" ) |
483 | |
484 | enum NamedColorSpace { |
485 | Unknown = 0, |
486 | SRgb, |
487 | SRgbLinear, |
488 | AdobeRgb, |
489 | DisplayP3, |
490 | ProPhotoRgb |
491 | }; |
492 | Q_ENUM_NS(NamedColorSpace) |
493 | |
494 | enum class Primaries { |
495 | Custom = 0, |
496 | SRgb, |
497 | AdobeRgb, |
498 | DciP3D65, |
499 | ProPhotoRgb |
500 | }; |
501 | Q_ENUM_NS(Primaries) |
502 | enum class TransferFunction { |
503 | Custom = 0, |
504 | Linear, |
505 | Gamma, |
506 | SRgb, |
507 | ProPhotoRgb |
508 | }; |
509 | Q_ENUM_NS(TransferFunction) |
510 | } |
511 | |
512 | class Q_QUICK_PRIVATE_EXPORT QQuickColorSpaceValueType |
513 | { |
514 | QColorSpace v; |
515 | Q_GADGET |
516 | |
517 | Q_PROPERTY(QQuickColorSpaceEnums::NamedColorSpace namedColorSpace READ namedColorSpace WRITE setNamedColorSpace FINAL) |
518 | Q_PROPERTY(QQuickColorSpaceEnums::Primaries primaries READ primaries WRITE setPrimaries FINAL) |
519 | Q_PROPERTY(QQuickColorSpaceEnums::TransferFunction transferFunction READ transferFunction WRITE setTransferFunction FINAL) |
520 | Q_PROPERTY(float gamma READ gamma WRITE setGamma FINAL) |
521 | |
522 | QML_ANONYMOUS |
523 | QML_FOREIGN(QColorSpace) |
524 | QML_ADDED_IN_VERSION(2, 15) |
525 | QML_EXTENDED(QQuickColorSpaceValueType) |
526 | QML_STRUCTURED_VALUE |
527 | |
528 | public: |
529 | static QVariant create(const QJSValue ¶ms); |
530 | |
531 | QQuickColorSpaceEnums::NamedColorSpace namedColorSpace() const noexcept; |
532 | void setNamedColorSpace(QQuickColorSpaceEnums::NamedColorSpace namedColorSpace); |
533 | QQuickColorSpaceEnums::Primaries primaries() const noexcept; |
534 | void setPrimaries(QQuickColorSpaceEnums::Primaries primariesId); |
535 | QQuickColorSpaceEnums::TransferFunction transferFunction() const noexcept; |
536 | void setTransferFunction(QQuickColorSpaceEnums::TransferFunction transferFunction); |
537 | float gamma() const noexcept; |
538 | void setGamma(float gamma); |
539 | |
540 | operator QColorSpace() const { return v; } |
541 | }; |
542 | |
543 | QT_END_NAMESPACE |
544 | |
545 | #endif // QQUICKVALUETYPES_P_H |
546 | |