QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskSkinHintTableEditor.h
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#ifndef QSK_SKIN_HINT_TABLE_EDITOR_H
7#define QSK_SKIN_HINT_TABLE_EDITOR_H
8
9#include "QskAspect.h"
10#include "QskSkinHintTable.h"
11#include "QskAnimationHint.h"
12#include "QskStateCombination.h"
13#include "QskTextOptions.h"
14
15#include <qcolor.h>
16#include <qvariant.h>
17#include <qvector.h>
18
19class QskArcMetrics;
20class QskMargins;
21class QskGradient;
28class QskGraphic;
29class QskFontRole;
30
31class QSK_EXPORT QskSkinHintTableEditor
32{
33 public:
35
36 void setTable( QskSkinHintTable* );
37 QskSkinHintTable* table() const;
38
39 // generic access
40
41 void setHint( QskAspect, const QVariant&,
43
44 template< typename T > void setHint(
46
47 const QVariant& hint( QskAspect ) const;
48 template< typename T > T hint( QskAspect ) const;
49
51 QVariant takeHint( QskAspect );
52
53 bool hasHint( QskAspect ) const;
54
55 // animation hints
56
57 void setAnimation( QskAspect, QskAnimationHint,
59
60 void setAnimation( QskAspect, uint duration, QEasingCurve::Type,
62
63 QskAnimationHint animation( QskAspect ) const;
64
65 // metric
66
67 void setMetricHint( QskAspect, const QVariant&,
69
70 template< typename T > void setMetricHint(
72
73 bool removeMetricHint( QskAspect, QskStateCombination = QskStateCombination() );
74
75 QVariant metricHint( QskAspect ) const;
76 template< typename T > T metricHint( QskAspect ) const;
77
78 // color
79
80 void setColorHint( QskAspect, const QVariant&,
82
83 template< typename T > void setColorHint(
85
86 bool removeColorHint( QskAspect, QskStateCombination = QskStateCombination() );
87
88 QVariant colorHint( QskAspect ) const;
89 template< typename T > T colorHint( QskAspect ) const;
90
91 // type specific
92
93 void setFlag( QskAspect, int, QskStateCombination = QskStateCombination() );
94 int flag( QskAspect ) const;
95
96 void setMetric( QskAspect, qreal metric, QskStateCombination = QskStateCombination() );
97 qreal metric( QskAspect ) const;
98
99 void setColor( QskAspect, Qt::GlobalColor, QskStateCombination = QskStateCombination() );
100 void setColor( QskAspect, QRgb, QskStateCombination = QskStateCombination() );
101 void setColor( QskAspect, const QColor&, QskStateCombination = QskStateCombination() );
102
103 QColor color( QskAspect ) const;
104
105 // gradients
106
107 void setHGradient( QskAspect, const QColor&, const QColor&,
109
110 void setVGradient( QskAspect, const QColor&, const QColor&,
112
113 void setGradient( QskAspect, const QColor&, const QColor&,
115
116 void setGradient( QskAspect, const QskGradient&,
118
119 QskGradient gradient( QskAspect ) const;
120
121 // position
122
123 void setPosition( QskAspect, qreal,
125
126 bool removePosition( QskAspect, QskStateCombination = QskStateCombination() );
127
128 qreal position( QskAspect ) const;
129
130 // strutSize
131
132 void setStrutSize( QskAspect, const QSizeF&,
134
135 void setStrutSize( QskAspect, qreal width, qreal height,
137
138 bool removeStrutSize( QskAspect, QskStateCombination = QskStateCombination() );
139
140 QSizeF strutSize( QskAspect ) const;
141
142 // margin
143
144 void setMargin( QskAspect, const QskMargins&,
146
147 void setMargin( QskAspect,
148 qreal left, qreal top, qreal right, qreal bottom,
150
151 bool removeMargin( QskAspect, QskStateCombination = QskStateCombination() );
152
153 QskMargins margin( QskAspect ) const;
154
155 // padding
156
157 void setPadding( QskAspect, const QskMargins&,
159
160 void setPadding( QskAspect,
161 qreal left, qreal top, qreal right, qreal bottom,
163
164 bool removePadding( QskAspect, QskStateCombination = QskStateCombination() );
165
166 QskMargins padding( QskAspect ) const;
167
168 // spacing
169
170 void setSpacing( QskAspect, qreal, QskStateCombination = QskStateCombination() );
171 bool removeSpacing( QskAspect, QskStateCombination = QskStateCombination() );
172 qreal spacing( QskAspect ) const;
173
174 // alignment
175
176 void setAlignment( QskAspect, Qt::Alignment, QskStateCombination = QskStateCombination() );
177 bool removeAlignment( QskAspect, QskStateCombination = QskStateCombination() );
178 Qt::Alignment alignment( QskAspect ) const;
179
180 // fontRole
181
182 void setFontRole( QskAspect, const QskFontRole&,
184 bool removeFontRole( QskAspect, QskStateCombination = QskStateCombination() );
185 QskFontRole fontRole( QskAspect ) const;
186
187 // graphicRole
188
189 void setGraphicRole( QskAspect, int, QskStateCombination = QskStateCombination() );
190 bool removeGraphicRole( QskAspect, QskStateCombination = QskStateCombination() );
191 int graphicRole( QskAspect ) const;
192
193 // boxShape
194
195 void setBoxShape( QskAspect, qreal radius, Qt::SizeMode = Qt::AbsoluteSize );
196
197 void setBoxShape( QskAspect, qreal topLeft, qreal topRight,
198 qreal bottomLeft, qreal bottomRight, Qt::SizeMode = Qt::AbsoluteSize );
199
200 void setBoxShape( QskAspect, const QskBoxShapeMetrics&,
202
203 bool removeBoxShape( QskAspect, QskStateCombination = QskStateCombination() );
204
205 QskBoxShapeMetrics boxShape( QskAspect ) const;
206
207 // boxBorderMetrics
208
209 void setBoxBorderMetrics( QskAspect,
210 qreal borderWidth, Qt::SizeMode = Qt::AbsoluteSize );
211
212 void setBoxBorderMetrics( QskAspect, qreal left, qreal top,
213 qreal right, qreal bottom, Qt::SizeMode = Qt::AbsoluteSize );
214
215 void setBoxBorderMetrics( QskAspect,
217
218 bool removeBoxBorderMetric( QskAspect, QskStateCombination = QskStateCombination() );
219
220 QskBoxBorderMetrics boxBorderMetrics( QskAspect ) const;
221
222 // boxBorderColors
223
224 void setBoxBorderColors( QskAspect,
226
227 void setBoxBorderColors( QskAspect,
228 const QskGradient& left, const QskGradient& top,
229 const QskGradient& right, const QskGradient& bottom,
231
232 bool removeBoxBorderColors( QskAspect, QskStateCombination = QskStateCombination() );
233 QskBoxBorderColors boxBorderColors( QskAspect ) const;
234
235 // shadowMetrics
236
237 void setShadowMetrics( QskAspect, qreal, qreal,
238 const QPointF&, Qt::SizeMode = Qt::AbsoluteSize );
239
240 void setShadowMetrics( QskAspect, const QskShadowMetrics&,
242
243 bool removeShadowMetric( QskAspect, QskStateCombination = QskStateCombination() );
244
245 QskShadowMetrics shadowMetrics( QskAspect ) const;
246
247 // shadowColor
248
249 void setShadowColor( QskAspect,
250 const QColor&, QskStateCombination = QskStateCombination() );
251
252 void setShadowColor( QskAspect,
253 Qt::GlobalColor, QskStateCombination = QskStateCombination() );
254
255 void setShadowColor( QskAspect,
257
258 bool removeShadowColor( QskAspect, QskStateCombination = QskStateCombination() );
259 QColor shadowColor( QskAspect ) const;
260
261 // arcMetrics
262
263 void setArcMetrics( QskAspect, qreal startAngle, qreal spanAngle,
264 qreal thickness, Qt::SizeMode = Qt::AbsoluteSize );
265
266 void setArcMetrics( QskAspect,
268
269 bool removeArcMetrics( QskAspect, QskStateCombination = QskStateCombination() );
270
271 QskArcMetrics arcMetrics( QskAspect ) const;
272
273 // lines
274
275 void setStippleMetrics( QskAspect, Qt::PenStyle,
277
278 void setStippleMetrics( QskAspect, const QVector< qreal >&,
280
281 void setStippleMetrics( QskAspect, const QskStippleMetrics&,
283
284 bool removeStippleMetrics( QskAspect, QskStateCombination = QskStateCombination() );
285
286 QskStippleMetrics stippleMetrics( QskAspect ) const;
287
288 // graduation metrics
289
290 void setGraduationMetrics( QskAspect, const QskGraduationMetrics&,
292
293 bool removeGraduationMetrics( QskAspect, QskStateCombination = QskStateCombination() );
294
295 QskGraduationMetrics graduationMetrics( QskAspect ) const;
296
297 // text options flag
298
299 void setTextOptions( QskAspect,
300 Qt::TextElideMode, QskTextOptions::WrapMode,
302
303 void setTextOptions( QskAspect,
305
306 bool removeTextOptions( QskAspect, QskStateCombination = QskStateCombination() );
307 QskTextOptions textOptions( QskAspect ) const;
308
309 // symbol
310
311 void setSymbol( QskAspect,
313
314 bool removeSymbol( QskAspect, QskStateCombination = QskStateCombination() );
315 QskGraphic symbol( QskAspect ) const;
316
317 private:
318 QskSkinHintTable* m_table = nullptr;
319};
320
321// --- generic access ---
322
323template< typename T >
324inline void QskSkinHintTableEditor::setHint(
325 QskAspect aspect, const T& hint, QskStateCombination combination )
326{
327 setHint( aspect, QVariant::fromValue( hint ), combination );
328}
329
330template< typename T >
331inline T QskSkinHintTableEditor::hint( QskAspect aspect ) const
332{
333 return hint( aspect ).value< T >();
334}
335
336inline const QVariant& QskSkinHintTableEditor::hint( QskAspect aspect ) const
337{
338 return m_table->hint( aspect );
339}
340
341inline QVariant QskSkinHintTableEditor::takeHint( QskAspect aspect )
342{
343 return m_table->takeHint( aspect );
344}
345
346inline bool QskSkinHintTableEditor::hasHint( QskAspect aspect ) const
347{
348 return m_table->hasHint( aspect );
349}
350
351// --- metric ---
352
353inline void QskSkinHintTableEditor::setMetricHint(
354 QskAspect aspect, const QVariant& hint, QskStateCombination combination )
355{
356 setHint( aspect | QskAspect::Metric, hint, combination );
357}
358
359template< typename T >
360inline void QskSkinHintTableEditor::setMetricHint(
361 QskAspect aspect, const T& hint, QskStateCombination combination )
362{
363 setHint( aspect | QskAspect::Metric, hint, combination );
364}
365
366inline bool QskSkinHintTableEditor::removeMetricHint(
367 QskAspect aspect, QskStateCombination combination )
368{
369 return removeHint( aspect | QskAspect::Metric, combination );
370}
371
372inline QVariant QskSkinHintTableEditor::metricHint( QskAspect aspect ) const
373{
374 return hint( aspect | QskAspect::Metric );
375}
376
377template< typename T >
378inline T QskSkinHintTableEditor::metricHint( QskAspect aspect ) const
379{
380 return hint< T >( aspect | QskAspect::Metric );
381}
382
383// --- color ---
384
385inline void QskSkinHintTableEditor::setColorHint(
386 QskAspect aspect, const QVariant& hint, QskStateCombination combination )
387{
388 setHint( aspect | QskAspect::Color, hint, combination );
389}
390
391template< typename T >
392inline void QskSkinHintTableEditor::setColorHint(
393 QskAspect aspect, const T& hint, QskStateCombination combination )
394{
395 setHint( aspect | QskAspect::Color, hint, combination );
396}
397
398inline bool QskSkinHintTableEditor::removeColorHint(
399 QskAspect aspect, QskStateCombination combination )
400{
401 return removeHint( aspect | QskAspect::Color, combination );
402}
403
404inline QVariant QskSkinHintTableEditor::colorHint( QskAspect aspect ) const
405{
406 return hint( aspect | QskAspect::Color );
407}
408
409template< typename T >
410inline T QskSkinHintTableEditor::colorHint( QskAspect aspect ) const
411{
412 return hint< T >( aspect | QskAspect::Color );
413}
414
415// --- animation ---
416
417inline QskAnimationHint QskSkinHintTableEditor::animation( QskAspect aspect ) const
418{
419 return m_table->animation( aspect );
420}
421
422inline void QskSkinHintTableEditor::setAnimation(
423 QskAspect aspect, QskAnimationHint hint, QskStateCombination combination )
424{
425 aspect.setAnimator( true );
426 setHint( aspect, hint, combination );
427}
428
429inline void QskSkinHintTableEditor::setAnimation( QskAspect aspect,
430 uint duration, QEasingCurve::Type curveType, QskStateCombination combination )
431{
432 setAnimation( aspect, QskAnimationHint( duration, curveType ), combination );
433}
434
435#endif
Lookup key for a QskSkinHintTable.
Definition QskAspect.h:15
void setAnimator(bool on) noexcept
Definition QskAspect.h:412
A paint device for scalable graphics.
Definition QskGraphic.h:28