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 | #include <private/qquickvaluetypes_p.h> |
41 | |
42 | #include <qtquickglobal.h> |
43 | #include <private/qqmlvaluetype_p.h> |
44 | #include <private/qcolorspace_p.h> |
45 | #include <private/qfont_p.h> |
46 | |
47 | |
48 | QT_BEGIN_NAMESPACE |
49 | |
50 | namespace QQuickValueTypes { |
51 | void registerValueTypes() |
52 | { |
53 | QQmlValueTypeFactory::registerValueTypes(uri: "QtQuick" , versionMajor: 2, versionMinor: 0); |
54 | } |
55 | } |
56 | |
57 | QString QQuickColorValueType::toString() const |
58 | { |
59 | return v.name(format: v.alpha() != 255 ? QColor::HexArgb : QColor::HexRgb); |
60 | } |
61 | |
62 | qreal QQuickColorValueType::r() const |
63 | { |
64 | return v.redF(); |
65 | } |
66 | |
67 | qreal QQuickColorValueType::g() const |
68 | { |
69 | return v.greenF(); |
70 | } |
71 | |
72 | qreal QQuickColorValueType::b() const |
73 | { |
74 | return v.blueF(); |
75 | } |
76 | |
77 | qreal QQuickColorValueType::a() const |
78 | { |
79 | return v.alphaF(); |
80 | } |
81 | |
82 | qreal QQuickColorValueType::hsvHue() const |
83 | { |
84 | return v.hsvHueF(); |
85 | } |
86 | |
87 | qreal QQuickColorValueType::hsvSaturation() const |
88 | { |
89 | return v.hsvSaturationF(); |
90 | } |
91 | |
92 | qreal QQuickColorValueType::hsvValue() const |
93 | { |
94 | return v.valueF(); |
95 | } |
96 | |
97 | qreal QQuickColorValueType::hslHue() const |
98 | { |
99 | return v.hslHueF(); |
100 | } |
101 | |
102 | qreal QQuickColorValueType::hslSaturation() const |
103 | { |
104 | return v.hslSaturationF(); |
105 | } |
106 | |
107 | qreal QQuickColorValueType::hslLightness() const |
108 | { |
109 | return v.lightnessF(); |
110 | } |
111 | |
112 | bool QQuickColorValueType::isValid() const |
113 | { |
114 | return v.isValid(); |
115 | } |
116 | |
117 | void QQuickColorValueType::setR(qreal r) |
118 | { |
119 | v.setRedF(r); |
120 | } |
121 | |
122 | void QQuickColorValueType::setG(qreal g) |
123 | { |
124 | v.setGreenF(g); |
125 | } |
126 | |
127 | void QQuickColorValueType::setB(qreal b) |
128 | { |
129 | v.setBlueF(b); |
130 | } |
131 | |
132 | void QQuickColorValueType::setA(qreal a) |
133 | { |
134 | v.setAlphaF(a); |
135 | } |
136 | |
137 | void QQuickColorValueType::setHsvHue(qreal hsvHue) |
138 | { |
139 | qreal hue, saturation, value, alpha; |
140 | v.getHsvF(h: &hue, s: &saturation, v: &value, a: &alpha); |
141 | v.setHsvF(h: hsvHue, s: saturation, v: value, a: alpha); |
142 | } |
143 | |
144 | void QQuickColorValueType::setHsvSaturation(qreal hsvSaturation) |
145 | { |
146 | qreal hue, saturation, value, alpha; |
147 | v.getHsvF(h: &hue, s: &saturation, v: &value, a: &alpha); |
148 | v.setHsvF(h: hue, s: hsvSaturation, v: value, a: alpha); |
149 | } |
150 | |
151 | void QQuickColorValueType::setHsvValue(qreal hsvValue) |
152 | { |
153 | qreal hue, saturation, value, alpha; |
154 | v.getHsvF(h: &hue, s: &saturation, v: &value, a: &alpha); |
155 | v.setHsvF(h: hue, s: saturation, v: hsvValue, a: alpha); |
156 | } |
157 | |
158 | void QQuickColorValueType::setHslHue(qreal hslHue) |
159 | { |
160 | qreal hue, saturation, lightness, alpha; |
161 | v.getHslF(h: &hue, s: &saturation, l: &lightness, a: &alpha); |
162 | v.setHslF(h: hslHue, s: saturation, l: lightness, a: alpha); |
163 | } |
164 | |
165 | void QQuickColorValueType::setHslSaturation(qreal hslSaturation) |
166 | { |
167 | qreal hue, saturation, lightness, alpha; |
168 | v.getHslF(h: &hue, s: &saturation, l: &lightness, a: &alpha); |
169 | v.setHslF(h: hue, s: hslSaturation, l: lightness, a: alpha); |
170 | } |
171 | |
172 | void QQuickColorValueType::setHslLightness(qreal hslLightness) |
173 | { |
174 | qreal hue, saturation, lightness, alpha; |
175 | v.getHslF(h: &hue, s: &saturation, l: &lightness, a: &alpha); |
176 | v.setHslF(h: hue, s: saturation, l: hslLightness, a: alpha); |
177 | } |
178 | |
179 | QString QQuickVector2DValueType::toString() const |
180 | { |
181 | return QString(QLatin1String("QVector2D(%1, %2)" )).arg(a: v.x()).arg(a: v.y()); |
182 | } |
183 | |
184 | qreal QQuickVector2DValueType::x() const |
185 | { |
186 | return v.x(); |
187 | } |
188 | |
189 | qreal QQuickVector2DValueType::y() const |
190 | { |
191 | return v.y(); |
192 | } |
193 | |
194 | void QQuickVector2DValueType::setX(qreal x) |
195 | { |
196 | v.setX(x); |
197 | } |
198 | |
199 | void QQuickVector2DValueType::setY(qreal y) |
200 | { |
201 | v.setY(y); |
202 | } |
203 | |
204 | qreal QQuickVector2DValueType::dotProduct(const QVector2D &vec) const |
205 | { |
206 | return QVector2D::dotProduct(v1: v, v2: vec); |
207 | } |
208 | |
209 | QVector2D QQuickVector2DValueType::times(const QVector2D &vec) const |
210 | { |
211 | return v * vec; |
212 | } |
213 | |
214 | QVector2D QQuickVector2DValueType::times(qreal scalar) const |
215 | { |
216 | return v * scalar; |
217 | } |
218 | |
219 | QVector2D QQuickVector2DValueType::plus(const QVector2D &vec) const |
220 | { |
221 | return v + vec; |
222 | } |
223 | |
224 | QVector2D QQuickVector2DValueType::minus(const QVector2D &vec) const |
225 | { |
226 | return v - vec; |
227 | } |
228 | |
229 | QVector2D QQuickVector2DValueType::normalized() const |
230 | { |
231 | return v.normalized(); |
232 | } |
233 | |
234 | qreal QQuickVector2DValueType::length() const |
235 | { |
236 | return v.length(); |
237 | } |
238 | |
239 | QVector3D QQuickVector2DValueType::toVector3d() const |
240 | { |
241 | return v.toVector3D(); |
242 | } |
243 | |
244 | QVector4D QQuickVector2DValueType::toVector4d() const |
245 | { |
246 | return v.toVector4D(); |
247 | } |
248 | |
249 | bool QQuickVector2DValueType::fuzzyEquals(const QVector2D &vec, qreal epsilon) const |
250 | { |
251 | qreal absEps = qAbs(t: epsilon); |
252 | if (qAbs(t: v.x() - vec.x()) > absEps) |
253 | return false; |
254 | if (qAbs(t: v.y() - vec.y()) > absEps) |
255 | return false; |
256 | return true; |
257 | } |
258 | |
259 | bool QQuickVector2DValueType::fuzzyEquals(const QVector2D &vec) const |
260 | { |
261 | return qFuzzyCompare(v1: v, v2: vec); |
262 | } |
263 | |
264 | QString QQuickVector3DValueType::toString() const |
265 | { |
266 | return QString(QLatin1String("QVector3D(%1, %2, %3)" )).arg(a: v.x()).arg(a: v.y()).arg(a: v.z()); |
267 | } |
268 | |
269 | qreal QQuickVector3DValueType::x() const |
270 | { |
271 | return v.x(); |
272 | } |
273 | |
274 | qreal QQuickVector3DValueType::y() const |
275 | { |
276 | return v.y(); |
277 | } |
278 | |
279 | qreal QQuickVector3DValueType::z() const |
280 | { |
281 | return v.z(); |
282 | } |
283 | |
284 | void QQuickVector3DValueType::setX(qreal x) |
285 | { |
286 | v.setX(x); |
287 | } |
288 | |
289 | void QQuickVector3DValueType::setY(qreal y) |
290 | { |
291 | v.setY(y); |
292 | } |
293 | |
294 | void QQuickVector3DValueType::setZ(qreal z) |
295 | { |
296 | v.setZ(z); |
297 | } |
298 | |
299 | QVector3D QQuickVector3DValueType::crossProduct(const QVector3D &vec) const |
300 | { |
301 | return QVector3D::crossProduct(v1: v, v2: vec); |
302 | } |
303 | |
304 | qreal QQuickVector3DValueType::dotProduct(const QVector3D &vec) const |
305 | { |
306 | return QVector3D::dotProduct(v1: v, v2: vec); |
307 | } |
308 | |
309 | QVector3D QQuickVector3DValueType::times(const QMatrix4x4 &m) const |
310 | { |
311 | return v * m; |
312 | } |
313 | |
314 | QVector3D QQuickVector3DValueType::times(const QVector3D &vec) const |
315 | { |
316 | return v * vec; |
317 | } |
318 | |
319 | QVector3D QQuickVector3DValueType::times(qreal scalar) const |
320 | { |
321 | return v * scalar; |
322 | } |
323 | |
324 | QVector3D QQuickVector3DValueType::plus(const QVector3D &vec) const |
325 | { |
326 | return v + vec; |
327 | } |
328 | |
329 | QVector3D QQuickVector3DValueType::minus(const QVector3D &vec) const |
330 | { |
331 | return v - vec; |
332 | } |
333 | |
334 | QVector3D QQuickVector3DValueType::normalized() const |
335 | { |
336 | return v.normalized(); |
337 | } |
338 | |
339 | qreal QQuickVector3DValueType::length() const |
340 | { |
341 | return v.length(); |
342 | } |
343 | |
344 | QVector2D QQuickVector3DValueType::toVector2d() const |
345 | { |
346 | return v.toVector2D(); |
347 | } |
348 | |
349 | QVector4D QQuickVector3DValueType::toVector4d() const |
350 | { |
351 | return v.toVector4D(); |
352 | } |
353 | |
354 | bool QQuickVector3DValueType::fuzzyEquals(const QVector3D &vec, qreal epsilon) const |
355 | { |
356 | qreal absEps = qAbs(t: epsilon); |
357 | if (qAbs(t: v.x() - vec.x()) > absEps) |
358 | return false; |
359 | if (qAbs(t: v.y() - vec.y()) > absEps) |
360 | return false; |
361 | if (qAbs(t: v.z() - vec.z()) > absEps) |
362 | return false; |
363 | return true; |
364 | } |
365 | |
366 | bool QQuickVector3DValueType::fuzzyEquals(const QVector3D &vec) const |
367 | { |
368 | return qFuzzyCompare(v1: v, v2: vec); |
369 | } |
370 | |
371 | QString QQuickVector4DValueType::toString() const |
372 | { |
373 | return QString(QLatin1String("QVector4D(%1, %2, %3, %4)" )).arg(a: v.x()).arg(a: v.y()).arg(a: v.z()).arg(a: v.w()); |
374 | } |
375 | |
376 | qreal QQuickVector4DValueType::x() const |
377 | { |
378 | return v.x(); |
379 | } |
380 | |
381 | qreal QQuickVector4DValueType::y() const |
382 | { |
383 | return v.y(); |
384 | } |
385 | |
386 | qreal QQuickVector4DValueType::z() const |
387 | { |
388 | return v.z(); |
389 | } |
390 | |
391 | qreal QQuickVector4DValueType::w() const |
392 | { |
393 | return v.w(); |
394 | } |
395 | |
396 | void QQuickVector4DValueType::setX(qreal x) |
397 | { |
398 | v.setX(x); |
399 | } |
400 | |
401 | void QQuickVector4DValueType::setY(qreal y) |
402 | { |
403 | v.setY(y); |
404 | } |
405 | |
406 | void QQuickVector4DValueType::setZ(qreal z) |
407 | { |
408 | v.setZ(z); |
409 | } |
410 | |
411 | void QQuickVector4DValueType::setW(qreal w) |
412 | { |
413 | v.setW(w); |
414 | } |
415 | |
416 | qreal QQuickVector4DValueType::dotProduct(const QVector4D &vec) const |
417 | { |
418 | return QVector4D::dotProduct(v1: v, v2: vec); |
419 | } |
420 | |
421 | QVector4D QQuickVector4DValueType::times(const QVector4D &vec) const |
422 | { |
423 | return v * vec; |
424 | } |
425 | |
426 | QVector4D QQuickVector4DValueType::times(const QMatrix4x4 &m) const |
427 | { |
428 | return v * m; |
429 | } |
430 | |
431 | QVector4D QQuickVector4DValueType::times(qreal scalar) const |
432 | { |
433 | return v * scalar; |
434 | } |
435 | |
436 | QVector4D QQuickVector4DValueType::plus(const QVector4D &vec) const |
437 | { |
438 | return v + vec; |
439 | } |
440 | |
441 | QVector4D QQuickVector4DValueType::minus(const QVector4D &vec) const |
442 | { |
443 | return v - vec; |
444 | } |
445 | |
446 | QVector4D QQuickVector4DValueType::normalized() const |
447 | { |
448 | return v.normalized(); |
449 | } |
450 | |
451 | qreal QQuickVector4DValueType::length() const |
452 | { |
453 | return v.length(); |
454 | } |
455 | |
456 | QVector2D QQuickVector4DValueType::toVector2d() const |
457 | { |
458 | return v.toVector2D(); |
459 | } |
460 | |
461 | QVector3D QQuickVector4DValueType::toVector3d() const |
462 | { |
463 | return v.toVector3D(); |
464 | } |
465 | |
466 | bool QQuickVector4DValueType::fuzzyEquals(const QVector4D &vec, qreal epsilon) const |
467 | { |
468 | qreal absEps = qAbs(t: epsilon); |
469 | if (qAbs(t: v.x() - vec.x()) > absEps) |
470 | return false; |
471 | if (qAbs(t: v.y() - vec.y()) > absEps) |
472 | return false; |
473 | if (qAbs(t: v.z() - vec.z()) > absEps) |
474 | return false; |
475 | if (qAbs(t: v.w() - vec.w()) > absEps) |
476 | return false; |
477 | return true; |
478 | } |
479 | |
480 | bool QQuickVector4DValueType::fuzzyEquals(const QVector4D &vec) const |
481 | { |
482 | return qFuzzyCompare(v1: v, v2: vec); |
483 | } |
484 | |
485 | QString QQuickQuaternionValueType::toString() const |
486 | { |
487 | return QString(QLatin1String("QQuaternion(%1, %2, %3, %4)" )).arg(a: v.scalar()).arg(a: v.x()).arg(a: v.y()).arg(a: v.z()); |
488 | } |
489 | |
490 | qreal QQuickQuaternionValueType::scalar() const |
491 | { |
492 | return v.scalar(); |
493 | } |
494 | |
495 | qreal QQuickQuaternionValueType::x() const |
496 | { |
497 | return v.x(); |
498 | } |
499 | |
500 | qreal QQuickQuaternionValueType::y() const |
501 | { |
502 | return v.y(); |
503 | } |
504 | |
505 | qreal QQuickQuaternionValueType::z() const |
506 | { |
507 | return v.z(); |
508 | } |
509 | |
510 | void QQuickQuaternionValueType::setScalar(qreal scalar) |
511 | { |
512 | v.setScalar(scalar); |
513 | } |
514 | |
515 | void QQuickQuaternionValueType::setX(qreal x) |
516 | { |
517 | v.setX(x); |
518 | } |
519 | |
520 | void QQuickQuaternionValueType::setY(qreal y) |
521 | { |
522 | v.setY(y); |
523 | } |
524 | |
525 | void QQuickQuaternionValueType::setZ(qreal z) |
526 | { |
527 | v.setZ(z); |
528 | } |
529 | |
530 | QMatrix4x4 QQuickMatrix4x4ValueType::times(const QMatrix4x4 &m) const |
531 | { |
532 | return v * m; |
533 | } |
534 | |
535 | QVector4D QQuickMatrix4x4ValueType::times(const QVector4D &vec) const |
536 | { |
537 | return v * vec; |
538 | } |
539 | |
540 | QVector3D QQuickMatrix4x4ValueType::times(const QVector3D &vec) const |
541 | { |
542 | return v * vec; |
543 | } |
544 | |
545 | QMatrix4x4 QQuickMatrix4x4ValueType::times(qreal factor) const |
546 | { |
547 | return v * factor; |
548 | } |
549 | |
550 | QMatrix4x4 QQuickMatrix4x4ValueType::plus(const QMatrix4x4 &m) const |
551 | { |
552 | return v + m; |
553 | } |
554 | |
555 | QMatrix4x4 QQuickMatrix4x4ValueType::minus(const QMatrix4x4 &m) const |
556 | { |
557 | return v - m; |
558 | } |
559 | |
560 | QVector4D QQuickMatrix4x4ValueType::row(int n) const |
561 | { |
562 | return v.row(index: n); |
563 | } |
564 | |
565 | QVector4D QQuickMatrix4x4ValueType::column(int m) const |
566 | { |
567 | return v.column(index: m); |
568 | } |
569 | |
570 | qreal QQuickMatrix4x4ValueType::determinant() const |
571 | { |
572 | return v.determinant(); |
573 | } |
574 | |
575 | QMatrix4x4 QQuickMatrix4x4ValueType::inverted() const |
576 | { |
577 | return v.inverted(); |
578 | } |
579 | |
580 | QMatrix4x4 QQuickMatrix4x4ValueType::transposed() const |
581 | { |
582 | return v.transposed(); |
583 | } |
584 | |
585 | bool QQuickMatrix4x4ValueType::fuzzyEquals(const QMatrix4x4 &m, qreal epsilon) const |
586 | { |
587 | qreal absEps = qAbs(t: epsilon); |
588 | for (int i = 0; i < 4; ++i) { |
589 | for (int j = 0; j < 4; ++j) { |
590 | if (qAbs(t: v(i,j) - m(i,j)) > absEps) { |
591 | return false; |
592 | } |
593 | } |
594 | } |
595 | return true; |
596 | } |
597 | |
598 | bool QQuickMatrix4x4ValueType::fuzzyEquals(const QMatrix4x4 &m) const |
599 | { |
600 | return qFuzzyCompare(m1: v, m2: m); |
601 | } |
602 | |
603 | QString QQuickFontValueType::toString() const |
604 | { |
605 | return QString(QLatin1String("QFont(%1)" )).arg(a: v.toString()); |
606 | } |
607 | |
608 | QString QQuickFontValueType::family() const |
609 | { |
610 | return v.family(); |
611 | } |
612 | |
613 | void QQuickFontValueType::setFamily(const QString &family) |
614 | { |
615 | v.setFamily(family); |
616 | } |
617 | |
618 | QString QQuickFontValueType::styleName() const |
619 | { |
620 | return v.styleName(); |
621 | } |
622 | |
623 | void QQuickFontValueType::setStyleName(const QString &style) |
624 | { |
625 | v.setStyleName(style); |
626 | } |
627 | |
628 | bool QQuickFontValueType::bold() const |
629 | { |
630 | return v.bold(); |
631 | } |
632 | |
633 | void QQuickFontValueType::setBold(bool b) |
634 | { |
635 | v.setBold(b); |
636 | } |
637 | |
638 | QQuickFontValueType::FontWeight QQuickFontValueType::weight() const |
639 | { |
640 | return (QQuickFontValueType::FontWeight)v.weight(); |
641 | } |
642 | |
643 | void QQuickFontValueType::setWeight(QQuickFontValueType::FontWeight w) |
644 | { |
645 | v.setWeight((QFont::Weight)w); |
646 | } |
647 | |
648 | bool QQuickFontValueType::italic() const |
649 | { |
650 | return v.italic(); |
651 | } |
652 | |
653 | void QQuickFontValueType::setItalic(bool b) |
654 | { |
655 | v.setItalic(b); |
656 | } |
657 | |
658 | bool QQuickFontValueType::underline() const |
659 | { |
660 | return v.underline(); |
661 | } |
662 | |
663 | void QQuickFontValueType::setUnderline(bool b) |
664 | { |
665 | v.setUnderline(b); |
666 | } |
667 | |
668 | bool QQuickFontValueType::overline() const |
669 | { |
670 | return v.overline(); |
671 | } |
672 | |
673 | void QQuickFontValueType::setOverline(bool b) |
674 | { |
675 | v.setOverline(b); |
676 | } |
677 | |
678 | bool QQuickFontValueType::strikeout() const |
679 | { |
680 | return v.strikeOut(); |
681 | } |
682 | |
683 | void QQuickFontValueType::setStrikeout(bool b) |
684 | { |
685 | v.setStrikeOut(b); |
686 | } |
687 | |
688 | qreal QQuickFontValueType::pointSize() const |
689 | { |
690 | if (v.pointSizeF() == -1) { |
691 | return v.pixelSize() * qreal(72.) / qreal(qt_defaultDpi()); |
692 | } |
693 | return v.pointSizeF(); |
694 | } |
695 | |
696 | void QQuickFontValueType::setPointSize(qreal size) |
697 | { |
698 | if ((v.resolve() & QFont::SizeResolved) && v.pixelSize() != -1) { |
699 | qWarning() << "Both point size and pixel size set. Using pixel size." ; |
700 | return; |
701 | } |
702 | |
703 | if (size >= 0.0) { |
704 | v.setPointSizeF(size); |
705 | } |
706 | } |
707 | |
708 | int QQuickFontValueType::pixelSize() const |
709 | { |
710 | if (v.pixelSize() == -1) { |
711 | return (v.pointSizeF() * qt_defaultDpi()) / qreal(72.); |
712 | } |
713 | return v.pixelSize(); |
714 | } |
715 | |
716 | void QQuickFontValueType::setPixelSize(int size) |
717 | { |
718 | if (size >0) { |
719 | if ((v.resolve() & QFont::SizeResolved) && v.pointSizeF() != -1) |
720 | qWarning() << "Both point size and pixel size set. Using pixel size." ; |
721 | v.setPixelSize(size); |
722 | } |
723 | } |
724 | |
725 | QQuickFontValueType::Capitalization QQuickFontValueType::capitalization() const |
726 | { |
727 | return (QQuickFontValueType::Capitalization)v.capitalization(); |
728 | } |
729 | |
730 | void QQuickFontValueType::setCapitalization(QQuickFontValueType::Capitalization c) |
731 | { |
732 | v.setCapitalization((QFont::Capitalization)c); |
733 | } |
734 | |
735 | qreal QQuickFontValueType::letterSpacing() const |
736 | { |
737 | return v.letterSpacing(); |
738 | } |
739 | |
740 | void QQuickFontValueType::setLetterSpacing(qreal size) |
741 | { |
742 | v.setLetterSpacing(type: QFont::AbsoluteSpacing, spacing: size); |
743 | } |
744 | |
745 | qreal QQuickFontValueType::wordSpacing() const |
746 | { |
747 | return v.wordSpacing(); |
748 | } |
749 | |
750 | void QQuickFontValueType::setWordSpacing(qreal size) |
751 | { |
752 | v.setWordSpacing(size); |
753 | } |
754 | |
755 | QQuickFontValueType::HintingPreference QQuickFontValueType::hintingPreference() const |
756 | { |
757 | return QQuickFontValueType::HintingPreference(v.hintingPreference()); |
758 | } |
759 | |
760 | void QQuickFontValueType::setHintingPreference(QQuickFontValueType::HintingPreference hintingPreference) |
761 | { |
762 | v.setHintingPreference(QFont::HintingPreference(hintingPreference)); |
763 | } |
764 | |
765 | bool QQuickFontValueType::kerning() const |
766 | { |
767 | return v.kerning(); |
768 | } |
769 | |
770 | void QQuickFontValueType::setKerning(bool b) |
771 | { |
772 | v.setKerning(b); |
773 | } |
774 | |
775 | bool QQuickFontValueType::preferShaping() const |
776 | { |
777 | return (v.styleStrategy() & QFont::PreferNoShaping) == 0; |
778 | } |
779 | |
780 | void QQuickFontValueType::setPreferShaping(bool enable) |
781 | { |
782 | if (enable) |
783 | v.setStyleStrategy(static_cast<QFont::StyleStrategy>(v.styleStrategy() & ~QFont::PreferNoShaping)); |
784 | else |
785 | v.setStyleStrategy(static_cast<QFont::StyleStrategy>(v.styleStrategy() | QFont::PreferNoShaping)); |
786 | } |
787 | |
788 | QQuickColorSpaceValueType::NamedColorSpace QQuickColorSpaceValueType::namedColorSpace() const noexcept |
789 | { |
790 | if (const auto *p = QColorSpacePrivate::get(colorSpace: v)) |
791 | return (QQuickColorSpaceValueType::NamedColorSpace)p->namedColorSpace; |
792 | return QQuickColorSpaceValueType::Unknown; |
793 | } |
794 | void QQuickColorSpaceValueType::setNamedColorSpace(QQuickColorSpaceValueType::NamedColorSpace namedColorSpace) |
795 | { |
796 | v = { (QColorSpace::NamedColorSpace)namedColorSpace }; |
797 | } |
798 | |
799 | QQuickColorSpaceValueType::Primaries QQuickColorSpaceValueType::primaries() const noexcept |
800 | { |
801 | return (QQuickColorSpaceValueType::Primaries)v.primaries(); |
802 | } |
803 | |
804 | void QQuickColorSpaceValueType::setPrimaries(QQuickColorSpaceValueType::Primaries primariesId) |
805 | { |
806 | v.setPrimaries((QColorSpace::Primaries)primariesId); |
807 | } |
808 | |
809 | QQuickColorSpaceValueType::TransferFunction QQuickColorSpaceValueType::transferFunction() const noexcept |
810 | { |
811 | return (QQuickColorSpaceValueType::TransferFunction)v.transferFunction(); |
812 | } |
813 | |
814 | void QQuickColorSpaceValueType::setTransferFunction(QQuickColorSpaceValueType::TransferFunction transferFunction) |
815 | { |
816 | v.setTransferFunction(transferFunction: (QColorSpace::TransferFunction)transferFunction, gamma: v.gamma()); |
817 | } |
818 | |
819 | float QQuickColorSpaceValueType::gamma() const noexcept |
820 | { |
821 | return v.gamma(); |
822 | } |
823 | |
824 | void QQuickColorSpaceValueType::setGamma(float gamma) |
825 | { |
826 | v.setTransferFunction(transferFunction: v.transferFunction(), gamma); |
827 | } |
828 | |
829 | QT_END_NAMESPACE |
830 | |
831 | #include "moc_qquickvaluetypes_p.cpp" |
832 | |