Changeset View
Changeset View
Standalone View
Standalone View
src/scenegraph/shadowedrectanglenode.h
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | * SPDX-FileCopyrightText: 2020 Arjen Hiemstra <ahiemstra@heimr.nl> | 2 | * SPDX-FileCopyrightText: 2020 Arjen Hiemstra <ahiemstra@heimr.nl> | ||
3 | * | 3 | * | ||
4 | * SPDX-License-Identifier: LGPL-2.0-or-later | 4 | * SPDX-License-Identifier: LGPL-2.0-or-later | ||
5 | */ | 5 | */ | ||
6 | 6 | | |||
7 | #pragma once | 7 | #pragma once | ||
8 | 8 | | |||
9 | #include <QSGGeometryNode> | 9 | #include <QSGGeometryNode> | ||
10 | #include <QColor> | 10 | #include <QColor> | ||
11 | #include <QVector2D> | 11 | #include <QVector2D> | ||
12 | 12 | | |||
13 | class QSGMaterialType; | ||||
13 | class ShadowedRectangleMaterial; | 14 | class ShadowedRectangleMaterial; | ||
15 | class ShadowedBorderRectangleMaterial; | ||||
14 | 16 | | |||
15 | /** | 17 | /** | ||
16 | * Scene graph node for a shadowed rectangle. | 18 | * Scene graph node for a shadowed rectangle. | ||
17 | * | 19 | * | ||
18 | * This node will set up the geometry and materials for a shadowed rectangle, | 20 | * This node will set up the geometry and materials for a shadowed rectangle, | ||
19 | * optionally with rounded corners. | 21 | * optionally with rounded corners. | ||
20 | * | 22 | * | ||
21 | * \note You must call updateGeometry() after setting properties of this node, | 23 | * \note You must call updateGeometry() after setting properties of this node, | ||
Show All 26 Lines | 30 | public: | |||
48 | /** | 50 | /** | ||
49 | * Update the geometry for this node. | 51 | * Update the geometry for this node. | ||
50 | * | 52 | * | ||
51 | * This is done as an explicit step to avoid the geometry being recreated | 53 | * This is done as an explicit step to avoid the geometry being recreated | ||
52 | * multiple times while updating properties. | 54 | * multiple times while updating properties. | ||
53 | */ | 55 | */ | ||
54 | void updateGeometry(); | 56 | void updateGeometry(); | ||
55 | 57 | | |||
56 | private: | 58 | protected: | ||
59 | virtual ShadowedRectangleMaterial *createBorderlessMaterial(); | ||||
60 | virtual ShadowedBorderRectangleMaterial *createBorderMaterial(); | ||||
61 | virtual QSGMaterialType* borderMaterialType(); | ||||
62 | virtual QSGMaterialType* borderlessMaterialType(); | ||||
63 | | ||||
57 | QSGGeometry *m_geometry; | 64 | QSGGeometry *m_geometry; | ||
58 | ShadowedRectangleMaterial *m_material; | 65 | ShadowedRectangleMaterial *m_material = nullptr; | ||
59 | 66 | | |||
67 | private: | ||||
60 | QRectF m_rect; | 68 | QRectF m_rect; | ||
61 | qreal m_size = 0.0; | 69 | qreal m_size = 0.0; | ||
62 | qreal m_radius = 0.0; | 70 | qreal m_radius = 0.0; | ||
63 | QVector2D m_offset = QVector2D{0.0, 0.0}; | 71 | QVector2D m_offset = QVector2D{0.0, 0.0}; | ||
64 | QVector2D m_aspect = QVector2D{1.0, 1.0}; | 72 | QVector2D m_aspect = QVector2D{1.0, 1.0}; | ||
65 | qreal m_borderWidth = 0.0; | 73 | qreal m_borderWidth = 0.0; | ||
66 | QColor m_borderColor; | 74 | QColor m_borderColor; | ||
67 | }; | 75 | }; |