QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskPainterCommand.h
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#ifndef QSK_PAINTER_COMMAND_H
7#define QSK_PAINTER_COMMAND_H
8
9#include "QskGlobal.h"
10
11#include <qimage.h>
12#include <qpaintengine.h>
13#include <qpainterpath.h>
14#include <qpixmap.h>
15
16class QSK_EXPORT QskPainterCommand
17{
18 public:
20 enum Type
21 {
23 Invalid = -1,
24
27
30
33
35 State
36 };
37
39 struct PixmapData
40 {
41 QRectF rect;
42 QPixmap pixmap;
43 QRectF subRect;
44 };
45
47 struct ImageData
48 {
49 QRectF rect;
50 QImage image;
51 QRectF subRect;
52 Qt::ImageConversionFlags flags;
53 };
54
56 struct StateData
57 {
58 QPaintEngine::DirtyFlags flags;
59
60 QPen pen;
61 QBrush brush;
62 QPointF brushOrigin;
63 QBrush backgroundBrush;
64 Qt::BGMode backgroundMode = Qt::TransparentMode;
65 QFont font;
66 QTransform transform;
67
68 Qt::ClipOperation clipOperation = Qt::NoClip;
69 QRegion clipRegion;
70 QPainterPath clipPath;
71 bool isClipEnabled = false;
72
73 QPainter::RenderHints renderHints;
74 QPainter::CompositionMode compositionMode = QPainter::CompositionMode_SourceOver;
75 qreal opacity;
76 };
77
78 constexpr QskPainterCommand() noexcept;
80
81 explicit QskPainterCommand( const QPainterPath& );
82
83 QskPainterCommand( const QRectF& rect,
84 const QPixmap&, const QRectF& subRect );
85
86 QskPainterCommand( const QRectF& rect,
87 const QImage&, const QRectF& subRect,
88 Qt::ImageConversionFlags );
89
90 explicit QskPainterCommand( const QskPainterCommand::StateData& data );
91 explicit QskPainterCommand( const QPaintEngineState& );
92
94
95 QskPainterCommand& operator=( const QskPainterCommand& );
96
97 bool operator==( const QskPainterCommand& other ) const noexcept;
98 bool operator!=( const QskPainterCommand& other ) const noexcept;
99
100 Type type() const noexcept;
101
102 QPainterPath* path() noexcept;
103 const QPainterPath* path() const noexcept;
104
105 PixmapData* pixmapData() noexcept;
106 const PixmapData* pixmapData() const noexcept;
107
108 ImageData* imageData() noexcept;
109 const ImageData* imageData() const noexcept;
110
111 StateData* stateData() noexcept;
112 const StateData* stateData() const noexcept;
113
114 private:
115 void copy( const QskPainterCommand& );
116 void reset();
117
118 Type m_type;
119
120 union
121 {
122 QPainterPath* m_path;
123 PixmapData* m_pixmapData;
124 ImageData* m_imageData;
125 StateData* m_stateData;
126 };
127};
128
129constexpr inline QskPainterCommand::QskPainterCommand() noexcept
130 : m_type( Invalid )
131 , m_path( nullptr )
132{
133}
134
135inline bool QskPainterCommand::operator!=( const QskPainterCommand& other ) const noexcept
136{
137 return !( *this == other );
138}
139
142{
143 return m_type;
144}
145
147inline const QPainterPath* QskPainterCommand::path() const noexcept
148{
149 return m_path;
150}
151
153inline const QskPainterCommand::PixmapData*
154QskPainterCommand::pixmapData() const noexcept
155{
156 return m_pixmapData;
157}
158
160inline const QskPainterCommand::ImageData*
161QskPainterCommand::imageData() const noexcept
162{
163 return m_imageData;
164}
165
167inline const QskPainterCommand::StateData*
168QskPainterCommand::stateData() const noexcept
169{
170 return m_stateData;
171}
172
173#endif
Type
Type of the paint command.
@ Path
Draw a QPainterPath.
@ Image
Draw a QImage.
@ Pixmap
Draw a QPixmap.
Type type() const noexcept