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 QML_MATERIAL_API CornersGroup {
9 Q_GADGET
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 bool operator==(const CornersGroup&) const = default;
20 Q_INVOKABLE CornersGroup() noexcept;
21 ~CornersGroup();
22
23 Q_INVOKABLE CornersGroup(qreal) noexcept;
24 Q_INVOKABLE CornersGroup(qreal bottomRight, qreal topRight, qreal bottomLeft,
25 qreal topLeft) noexcept;
26 Q_INVOKABLE CornersGroup(QVector4D vec4) noexcept;
27
28 CornersGroup(const CornersGroup&) = default;
29 CornersGroup(CornersGroup&&) = default;
30 CornersGroup& operator=(const CornersGroup&) = default;
31 CornersGroup& operator=(CornersGroup&&) = default;
32
33 Q_INVOKABLE qreal radius() const noexcept;
34 void setRadius(qreal) noexcept;
35
36 qreal& operator[](int index) noexcept;
37 qreal operator[](int index) const noexcept;
38
39 CornersGroup operator+(const CornersGroup& other) const noexcept;
40 CornersGroup operator-(const CornersGroup& other) const noexcept;
41 CornersGroup operator*(qreal scalar) const noexcept;
42 CornersGroup operator/(qreal scalar) const noexcept;
43
44 CornersGroup& operator+=(const CornersGroup& other) noexcept;
45 CornersGroup& operator-=(const CornersGroup& other) noexcept;
46 CornersGroup& operator*=(qreal scalar) noexcept;
47 CornersGroup& operator/=(qreal scalar) noexcept;
48
49 qreal topLeft() const noexcept;
50 void setTopLeft(qreal newTopLeft) noexcept;
51
52 qreal topRight() const noexcept;
53 void setTopRight(qreal newTopRight) noexcept;
54
55 qreal bottomLeft() const noexcept;
56 void setBottomLeft(qreal newBottomLeft) noexcept;
57
58 qreal bottomRight() const noexcept;
59 void setBottomRight(qreal newBottomRight) noexcept;
60
61 Q_INVOKABLE QVector4D toVector4D() const noexcept;
62 Q_INVOKABLE bool isUniform() const noexcept;
63
64 operator QVector4D() const noexcept;
65
66 static auto interpolated(const CornersGroup& from, const CornersGroup& to, qreal progress)
67 -> QVariant;
68
69private:
70 qreal m_bottomRight;
71 qreal m_topRight;
72 qreal m_bottomLeft;
73 qreal m_topLeft;
74};
75
76} // namespace qml_material