Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qgraphicseffect_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QGRAPHICSEFFECT_P_H
5#define QGRAPHICSEFFECT_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header
13// file may change from version to version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtWidgets/private/qtwidgetsglobal_p.h>
19#include "qgraphicseffect.h"
20
21#include <QPixmapCache>
22
23#include <private/qobject_p.h>
24#include <private/qpixmapfilter_p.h>
25
26QT_REQUIRE_CONFIG(graphicseffect);
27
29
31class Q_WIDGETS_EXPORT QGraphicsEffectSource : public QObject
32{
34public:
36 const QGraphicsItem *graphicsItem() const;
37 const QWidget *widget() const;
38 const QStyleOption *styleOption() const;
39
40 bool isPixmap() const;
41 void draw(QPainter *painter);
42 void update();
43
47 QPoint *offset = nullptr,
49
50protected:
52
53private:
54 Q_DECLARE_PRIVATE(QGraphicsEffectSource)
55 Q_DISABLE_COPY_MOVE(QGraphicsEffectSource)
56 friend class QGraphicsEffect;
59 friend class QGraphicsItem;
61 friend class QWidget;
62 friend class QWidgetPrivate;
63};
64
66{
67 Q_DECLARE_PUBLIC(QGraphicsEffectSource)
68public:
71 , m_cachedSystem(Qt::DeviceCoordinates)
72 , m_cachedMode(QGraphicsEffect::PadToTransparentBorder)
73 {}
74
81
83 virtual void detach() = 0;
84 virtual QRectF boundingRect(Qt::CoordinateSystem system) const = 0;
85 virtual QRect deviceRect() const = 0;
86 virtual const QGraphicsItem *graphicsItem() const = 0;
87 virtual const QWidget *widget() const = 0;
88 virtual const QStyleOption *styleOption() const = 0;
89 virtual void draw(QPainter *p) = 0;
90 virtual void update() = 0;
91 virtual bool isPixmap() const = 0;
92 virtual QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset = nullptr,
94 virtual void effectBoundingRectChanged() = 0;
95
96 void setCachedOffset(const QPoint &offset);
97 void invalidateCache(InvalidateReason reason = SourceChanged) const;
98 Qt::CoordinateSystem currentCachedSystem() const { return m_cachedSystem; }
99 QGraphicsEffect::PixmapPadMode currentCachedMode() const { return m_cachedMode; }
100
102 friend class QGraphicsItem;
104
105private:
106 mutable Qt::CoordinateSystem m_cachedSystem;
107 mutable QGraphicsEffect::PixmapPadMode m_cachedMode;
108 mutable QPoint m_cachedOffset;
109 mutable QPixmapCache::Key m_cacheKey;
110};
111
112class Q_WIDGETS_EXPORT QGraphicsEffectPrivate : public QObjectPrivate
113{
114 Q_DECLARE_PUBLIC(QGraphicsEffect)
115public:
118
120 {
121 QGraphicsEffect::ChangeFlags flags;
122 if (source) {
124 source->d_func()->effectBoundingRectChanged();
125 source->d_func()->invalidateCache();
126 source->d_func()->detach();
127 delete source;
128 }
129 source = newSource;
130 if (newSource)
132 q_func()->sourceChanged(flags);
133 }
134
138 quint32 padding : 31; // feel free to use
139};
140
141
157
167
177
192
194
195#endif // QGRAPHICSEFFECT_P_H
\inmodule QtGui
Definition qbrush.h:30
The QGraphicsBlurEffect class provides a blur effect.
QPixmapColorizeFilter * filter
The QGraphicsColorizeEffect class provides a colorize effect.
QPixmapDropShadowFilter * filter
The QGraphicsDropShadowEffect class provides a drop shadow effect.
QGraphicsEffectSource * source
void setGraphicsEffectSource(QGraphicsEffectSource *newSource)
virtual const QGraphicsItem * graphicsItem() const =0
virtual bool isPixmap() const =0
virtual QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset=nullptr, QGraphicsEffect::PixmapPadMode mode=QGraphicsEffect::PadToTransparentBorder) const =0
QGraphicsEffect::PixmapPadMode currentCachedMode() const
virtual QRectF boundingRect(Qt::CoordinateSystem system) const =0
Qt::CoordinateSystem currentCachedSystem() const
virtual const QStyleOption * styleOption() const =0
virtual void draw(QPainter *p)=0
virtual QRect deviceRect() const =0
virtual void effectBoundingRectChanged()=0
virtual const QWidget * widget() const =0
The QGraphicsEffectSource class represents the source on which a QGraphicsEffect is installed on.
QRect deviceRect() const
The QGraphicsEffect class is the base class for all graphics effects.
PixmapPadMode
This enum describes how the pixmap returned from sourcePixmap should be padded.
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
The QGraphicsOpacityEffect class provides an opacity effect.
\inmodule QtCore
Definition qobject.h:103
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
The QPixmapBlurFilter class provides blur filtering for pixmaps.
The QPixmapCache::Key class can be used for efficient access to the QPixmapCache.
The QPixmapColorizeFilter class provides colorizing filtering for pixmaps.
The QPixmapDropShadowFilter class is a convenience class for drawing pixmaps with drop shadows.
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
\inmodule QtCore\reentrant
Definition qpoint.h:25
\inmodule QtCore\reentrant
Definition qrect.h:484
\inmodule QtCore\reentrant
Definition qrect.h:30
The QStyleOption class stores the parameters used by QStyle functions.
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
QOpenGLWidget * widget
[1]
Combined button and popup list for selecting options.
Definition qcompare.h:63
CoordinateSystem
@ LogicalCoordinates
GLenum mode
GLbitfield flags
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
GLenum GLuint GLintptr offset
GLsizei GLsizei GLchar * source
GLfloat GLfloat p
[1]
static const QRectF boundingRect(const QPointF *points, int pointCount)
#define QT_REQUIRE_CONFIG(feature)
#define Q_OBJECT
unsigned int quint32
Definition qtypes.h:50
unsigned int uint
Definition qtypes.h:34
double qreal
Definition qtypes.h:187
static bool isFullyOpaque(const QWindowsThemeData &themeData)
QObject::connect nullptr
myFilter draw(painter, QPoint(0, 0), originalPixmap)
widget render & pixmap
QPainter painter(this)
[7]