QmlMaterial 0.1.0
Loading...
Searching...
No Matches
corner.hpp
1#pragma once
2#include <QQmlEngine>
3#include <QVector4D>
4#include "qml_material/export.hpp"
5
6namespace qml_material
7{
8class CornersGroup {
9 Q_GADGET_EXPORT(QML_MATERIAL_API)
10 QML_VALUE_TYPE(corners)
11 QML_CONSTRUCTIBLE_VALUE
12
13 Q_PROPERTY(qreal topLeft READ topLeft WRITE setTopLeft FINAL)
14 Q_PROPERTY(qreal topRight READ topRight WRITE setTopRight FINAL)
15 Q_PROPERTY(qreal bottomLeft READ bottomLeft WRITE setBottomLeft FINAL)
16 Q_PROPERTY(qreal bottomRight READ bottomRight WRITE setBottomRight FINAL)
17
18public:
19 QML_MATERIAL_API Q_INVOKABLE CornersGroup() noexcept;
20 QML_MATERIAL_API ~CornersGroup();
21
22 Q_INVOKABLE CornersGroup(qreal) noexcept;
23 Q_INVOKABLE CornersGroup(qreal bottomRight, qreal topRight, qreal bottomLeft,
24 qreal topLeft) noexcept;
25 Q_INVOKABLE CornersGroup(QVector4D vec4) noexcept;
26
27 CornersGroup(const CornersGroup&) = default;
28 CornersGroup(CornersGroup&&) = default;
29 CornersGroup& operator=(const CornersGroup&) = default;
30 CornersGroup& operator=(CornersGroup&&) = default;
31
32 Q_INVOKABLE qreal radius() const noexcept;
33 void setRadius(qreal) noexcept;
34
35 qreal& operator[](int index) noexcept;
36 qreal operator[](int index) const noexcept;
37
38 CornersGroup operator+(const CornersGroup& other) const noexcept;
39 CornersGroup operator-(const CornersGroup& other) const noexcept;
40 CornersGroup operator*(qreal scalar) const noexcept;
41 CornersGroup operator/(qreal scalar) const noexcept;
42
43 CornersGroup& operator+=(const CornersGroup& other) noexcept;
44 CornersGroup& operator-=(const CornersGroup& other) noexcept;
45 CornersGroup& operator*=(qreal scalar) noexcept;
46 CornersGroup& operator/=(qreal scalar) noexcept;
47
48 qreal topLeft() const noexcept;
49 void setTopLeft(qreal newTopLeft) noexcept;
50
51 qreal topRight() const noexcept;
52 void setTopRight(qreal newTopRight) noexcept;
53
54 qreal bottomLeft() const noexcept;
55 void setBottomLeft(qreal newBottomLeft) noexcept;
56
57 qreal bottomRight() const noexcept;
58 void setBottomRight(qreal newBottomRight) noexcept;
59
60 Q_INVOKABLE QVector4D toVector4D() const noexcept;
61 Q_INVOKABLE bool isUniform() const noexcept;
62
63 QML_MATERIAL_API operator QVector4D() const noexcept;
64
65 QML_MATERIAL_API static auto interpolated(const CornersGroup& from, const CornersGroup& to,
66 qreal progress) -> QVariant;
67
68private:
69 qreal m_bottomRight;
70 qreal m_topRight;
71 qreal m_bottomLeft;
72 qreal m_topLeft;
73};
74
75} // namespace qml_material