QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskGraduationRenderer.h
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#ifndef QSK_GRADUATION_RENDERER_H
7#define QSK_GRADUATION_RENDERER_H
8
9#include "QskGlobal.h"
10
11#include <qnamespace.h>
12#include <qfont.h>
13#include <qcolor.h>
14
15#include <memory>
16
17class QskSkinnable;
18class QskIntervalF;
20class QskTickmarks;
21class QskTextColors;
22class QskColorFilter;
23
24class QSGNode;
25class QVariant;
26class QRectF;
27class QPointF;
28class QSizeF;
29class QTransform;
30
31class QSK_EXPORT QskGraduationRenderer
32{
33 Q_GADGET
34
35 public:
36 enum Flag
37 {
38 Backbone = 1 << 0,
39 CenteredTickmarks = 1 << 1,
40 ClampedLabels = 1 << 2
41 };
42
43 Q_ENUM( Flag )
44 Q_DECLARE_FLAGS( Flags, Flag )
45
47 virtual ~QskGraduationRenderer();
48
49 void setEdge( Qt::Edge );
50 Qt::Edge edge() const;
51
52 void setFlags( Flags );
53 Flags flags() const;
54
55 void setFlag( Flag, bool );
56
57 // scale coordinates
58 void setBoundaries( qreal lowerBound, qreal upperBound );
59 void setBoundaries( const QskIntervalF& );
60 QskIntervalF boundaries() const;
61
62 // item coordiates
63 qreal position() const;
64 void setPosition( qreal );
65
66 void setRange( qreal from, qreal to );
67 void setRange( const QskIntervalF& );
68 QskIntervalF range() const;
69
70 void setTickmarks( const QskTickmarks& );
71 const QskTickmarks& tickmarks() const;
72
73 void setSpacing( qreal );
74 qreal spacing() const;
75
76 void setTickColor( const QColor& );
77 QColor tickColor() const;
78
79 void setTickMetrics( const QskGraduationMetrics& );
80 const QskGraduationMetrics& tickMetrics() const;
81
82 void setFont( const QFont& );
83 QFont font() const;
84
85 void setTextColors( const QskTextColors& );
86 QskTextColors textColors() const;
87
88 void setColorFilter( const QskColorFilter& );
89 const QskColorFilter& colorFilter() const;
90
91 QSGNode* updateNode( const QskSkinnable*, QSGNode* );
92
93 virtual QVariant labelAt( qreal pos ) const;
94 QSizeF boundingLabelSize() const;
95
96 protected:
97 virtual QSGNode* updateTicksNode( const QTransform&, QSGNode* ) const;
98
99 virtual QSGNode* updateLabelsNode(
100 const QskSkinnable*, const QTransform&, QSGNode* ) const;
101
102 private:
103 Q_DISABLE_COPY( QskGraduationRenderer )
104
105 QRectF labelRect( const QTransform&, qreal, const QSizeF& ) const;
106
107 QSGNode* updateTickLabelNode( const QskSkinnable*,
108 QSGNode*, const QVariant&, const QRectF& ) const;
109
110 class PrivateData;
111 std::unique_ptr< PrivateData > m_data;
112};
113
114Q_DECLARE_OPERATORS_FOR_FLAGS( QskGraduationRenderer::Flags )
115
116#endif