QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskSkinlet.h
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#ifndef QSK_SKINLET_H
7#define QSK_SKINLET_H
8
9#include "QskAspect.h"
10#include "QskNamespace.h"
11
12#include <qnamespace.h>
13#include <qrect.h>
14
15#include <memory>
16
17class QskArcMetrics;
18class QskSkin;
19class QskControl;
20class QskSkinnable;
21class QskGradient;
22class QskColorFilter;
23class QskGraphic;
24class QskTextOptions;
25class QskTextColors;
29class QskBoxHints;
30
31class QSGNode;
32
33class QSK_EXPORT QskSkinlet
34{
35 Q_GADGET
36
37 public:
38 Q_INVOKABLE QskSkinlet( QskSkin* = nullptr );
39 virtual ~QskSkinlet();
40
41 QskSkin* skin() const;
42
43 virtual void updateNode( QskSkinnable*, QSGNode* parent ) const;
44
45 virtual QSizeF sizeHint( const QskSkinnable*,
46 Qt::SizeHint, const QSizeF& ) const;
47
48 virtual QRectF subControlRect( const QskSkinnable*,
49 const QRectF&, QskAspect::Subcontrol ) const;
50
51 /*
52 When having more than one instance for the
53 same QskAspect::Subcontrol it is called a sample
54 */
55 virtual QRectF sampleRect( const QskSkinnable*,
56 const QRectF&, QskAspect::Subcontrol, int index ) const;
57
58 virtual int sampleIndexAt( const QskSkinnable*,
59 const QRectF&, QskAspect::Subcontrol, const QPointF& ) const;
60
61 virtual int sampleCount( const QskSkinnable*, QskAspect::Subcontrol ) const;
62
63 virtual QskAspect::States sampleStates( const QskSkinnable*,
64 QskAspect::Subcontrol, int index ) const;
65
66 virtual QVariant sampleAt( const QskSkinnable*,
67 QskAspect::Subcontrol, int index ) const;
68
69 const QVector< quint8 >& nodeRoles() const;
70
71 void setOwnedBySkinnable( bool on );
72 bool isOwnedBySkinnable() const;
73
74 // Helper functions for creating nodes
75
76 static QSGNode* updateBoxNode( const QskSkinnable*, QSGNode*,
77 const QRectF&, QskAspect::Subcontrol );
78
79 static QSGNode* updateBoxNode( const QskSkinnable*, QSGNode*,
80 const QRectF&, const QskGradient&, QskAspect::Subcontrol );
81
82 static QSGNode* updateBoxNode( const QskSkinnable*, QSGNode*,
83 const QRectF&, const QskBoxShapeMetrics&, const QskBoxBorderMetrics&,
84 const QskBoxBorderColors&, const QskGradient& );
85
86 static QSGNode* updateBoxNode( const QskSkinnable*, QSGNode*,
87 const QRectF&, const QskBoxHints& );
88
89 static QSGNode* updateInterpolatedBoxNode(
90 const QskSkinnable*, QSGNode*, const QRectF&,
91 QskAspect aspect1, QskAspect aspect2, qreal ratio );
92
93 static QSGNode* updateArcNode( const QskSkinnable*, QSGNode*,
94 const QRectF&, QskAspect::Subcontrol );
95
96 static QSGNode* updateArcNode( const QskSkinnable*, QSGNode*,
97 const QRectF&, const QskGradient&, QskAspect::Subcontrol );
98
99 static QSGNode* updateArcNode( const QskSkinnable*, QSGNode*,
100 const QRectF&, qreal borderWidth, const QColor& borderColor,
101 const QskGradient&, const QskArcMetrics& );
102
103 static QSGNode* updateArcNode( const QskSkinnable*, QSGNode*,
104 const QRectF&, qreal startAngle, qreal spanAngle, QskAspect::Subcontrol );
105
106 static QSGNode* updateArcNode( const QskSkinnable*, QSGNode*,
107 const QRectF&, const QskGradient&, qreal startAngle, qreal spanAngle,
109
110 static QSGNode* updateLineNode( const QskSkinnable*, QSGNode*,
111 const QLineF&, QskAspect::Subcontrol );
112
113 static QSGNode* updateLinesNode( const QskSkinnable*,
114 QSGNode*, const QVector< QLineF >&, QskAspect::Subcontrol );
115
116 static QSGNode* updateTextNode( const QskSkinnable*, QSGNode*,
117 const QRectF&, Qt::Alignment, const QString&, QskAspect::Subcontrol );
118
119 static QSGNode* updateTextNode( const QskSkinnable*, QSGNode*,
120 const QRectF&, Qt::Alignment, const QString&, const QFont&,
121 const QskTextOptions&, const QskTextColors&, Qsk::TextStyle );
122
123 // keeping the aspect ratio
124 static QSGNode* updateGraphicNode( const QskSkinnable*, QSGNode*,
125 const QskGraphic&, const QskColorFilter&, const QRectF&,
126 Qt::Alignment, Qt::Orientations mirrored = Qt::Orientations() );
127
128 // stretching to fit
129 static QSGNode* updateGraphicNode( const QskSkinnable*, QSGNode*,
130 const QskGraphic&, const QskColorFilter&, const QRectF&,
131 Qt::Orientations mirrored = Qt::Orientations() );
132
133 static QSGNode* updateBoxClipNode( const QskSkinnable*, QSGNode*,
134 const QRectF&, QskAspect::Subcontrol );
135
136 protected:
137 void setNodeRoles( const QVector< quint8 >& );
138 void appendNodeRoles( const QVector< quint8 >& );
139
140 virtual QSGNode* updateSubNode( const QskSkinnable*,
141 quint8 nodeRole, QSGNode* ) const;
142
143 virtual QSGNode* updateBackgroundNode(
144 const QskControl*, QSGNode* ) const;
145
146 virtual QSGNode* updateDebugNode(
147 const QskControl*, QSGNode* node ) const;
148
149 QSGNode* updateBoxNode( const QskSkinnable*, QSGNode*,
150 QskAspect::Subcontrol ) const;
151
152 QSGNode* updateArcNode( const QskSkinnable*, QSGNode*,
153 QskAspect::Subcontrol ) const;
154
155 QSGNode* updateArcNode( const QskSkinnable*, QSGNode*,
156 qreal startAngle, qreal spanAngle,
157 QskAspect::Subcontrol ) const;
158
159 QSGNode* updateBoxClipNode( const QskSkinnable*, QSGNode*,
160 QskAspect::Subcontrol ) const;
161
162 QSGNode* updateTextNode( const QskSkinnable*, QSGNode*,
163 const QString&, QskAspect::Subcontrol ) const;
164
165 QSGNode* updateSymbolNode( const QskSkinnable*, QSGNode*,
166 QskAspect::Subcontrol ) const;
167
168 QSGNode* updateGraphicNode( const QskSkinnable*, QSGNode*,
170 Qt::Orientations mirrored = Qt::Orientations() ) const;
171
172 QSGNode* updateSeriesNode( const QskSkinnable*,
173 QskAspect::Subcontrol, QSGNode* ) const;
174
175 virtual QSGNode* updateSampleNode( const QskSkinnable*,
176 QskAspect::Subcontrol, int index, QSGNode* ) const;
177
178 void replaceChildNode( quint8 nodeRole, QSGNode* parentNode,
179 QSGNode* oldNode, QSGNode* newNode ) const;
180
181 QSizeF hintWithoutConstraint(
182 const QSizeF& hint, const QSizeF& constraint ) const;
183
184 private:
185 Q_DISABLE_COPY( QskSkinlet )
186
187 class PrivateData;
188 std::unique_ptr< PrivateData > m_data;
189};
190
191inline QRectF QskSkinlet::subControlRect(
192 const QskSkinnable*, const QRectF&, QskAspect::Subcontrol ) const
193{
194 return QRectF();
195}
196
197inline QSGNode* QskSkinlet::updateSubNode(
198 const QskSkinnable*, quint8, QSGNode*) const
199{
200 return nullptr;
201}
202
203inline QSizeF QskSkinlet::sizeHint(
204 const QskSkinnable*, Qt::SizeHint, const QSizeF& ) const
205{
206 return QSizeF();
207}
208
209inline QRectF QskSkinlet::sampleRect( const QskSkinnable*,
210 const QRectF&, QskAspect::Subcontrol, int index ) const
211{
212 Q_UNUSED( index )
213 return QRectF();
214}
215
216inline int QskSkinlet::sampleCount(
217 const QskSkinnable*, QskAspect::Subcontrol ) const
218{
219 return 0;
220}
221
222#endif
Lookup key for a QskSkinHintTable.
Definition QskAspect.h:15
Subcontrol
For use within the rendering or lay-outing of a specific QskSkinnable.
Definition QskAspect.h:104
Base class of all controls.
Definition QskControl.h:23
A paint device for scalable graphics.
Definition QskGraphic.h:28
Describes the rendering interface of a QskControl. Change the skinlet to change the appearance of the...
Definition QskSkinlet.h:34