5#ifndef QGRAPHICSEFFECT_H
6#define QGRAPHICSEFFECT_H
8#include <QtWidgets/qtwidgetsglobal.h>
9#include <QtCore/qobject.h>
10#include <QtCore/qpoint.h>
11#include <QtCore/qrect.h>
12#include <QtGui/qcolor.h>
13#include <QtGui/qbrush.h>
24class QGraphicsEffectSource;
26class QGraphicsEffectPrivate;
30 Q_PROPERTY(
bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
35 SourceBoundingRectChanged = 0x4,
36 SourceInvalidated = 0x8
38 Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)
43 PadToTransparentBorder,
44 PadToEffectiveBoundingRect
47 QGraphicsEffect(QObject *parent =
nullptr);
48 virtual ~QGraphicsEffect();
50 virtual QRectF boundingRectFor(
const QRectF &sourceRect)
const;
51 QRectF boundingRect()
const;
53 bool isEnabled()
const;
56 void setEnabled(
bool enable);
60 void enabledChanged(
bool enabled);
63 QGraphicsEffect(QGraphicsEffectPrivate &d, QObject *parent =
nullptr);
64 virtual void draw(QPainter *painter) = 0;
65 virtual void sourceChanged(ChangeFlags flags);
66 void updateBoundingRect();
68 bool sourceIsPixmap()
const;
69 QRectF sourceBoundingRect(Qt::CoordinateSystem system = Qt::LogicalCoordinates)
const;
70 void drawSource(QPainter *painter);
71 QPixmap sourcePixmap(Qt::CoordinateSystem system = Qt::LogicalCoordinates,
72 QPoint *offset =
nullptr,
73 PixmapPadMode mode = PadToEffectiveBoundingRect)
const;
76 Q_DECLARE_PRIVATE(QGraphicsEffect)
77 Q_DISABLE_COPY(QGraphicsEffect)
78 friend class QGraphicsItem;
79 friend class QGraphicsItemPrivate;
80 friend class QGraphicsScenePrivate;
82 friend class QWidgetPrivate;
85 QGraphicsEffectSource *source()
const;
88Q_DECLARE_OPERATORS_FOR_FLAGS(QGraphicsEffect::ChangeFlags)
90class QGraphicsColorizeEffectPrivate;
94 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
95 Q_PROPERTY(qreal strength READ strength WRITE setStrength NOTIFY strengthChanged)
97 QGraphicsColorizeEffect(QObject *parent =
nullptr);
98 ~QGraphicsColorizeEffect();
100 QColor color()
const;
101 qreal strength()
const;
104 void setColor(
const QColor &c);
105 void setStrength(qreal strength);
108 void colorChanged(
const QColor &color);
109 void strengthChanged(qreal strength);
112 void draw(QPainter *painter) override;
115 Q_DECLARE_PRIVATE(QGraphicsColorizeEffect)
116 Q_DISABLE_COPY(QGraphicsColorizeEffect)
123 Q_PROPERTY(qreal blurRadius READ blurRadius WRITE setBlurRadius NOTIFY blurRadiusChanged)
124 Q_PROPERTY(BlurHints blurHints READ blurHints WRITE setBlurHints NOTIFY blurHintsChanged)
127 PerformanceHint = 0x00,
132 Q_DECLARE_FLAGS(BlurHints, BlurHint)
135 QGraphicsBlurEffect(QObject *parent =
nullptr);
136 ~QGraphicsBlurEffect();
138 QRectF boundingRectFor(
const QRectF &rect)
const override;
139 qreal blurRadius()
const;
140 BlurHints blurHints()
const;
143 void setBlurRadius(qreal blurRadius);
144 void setBlurHints(BlurHints hints);
147 void blurRadiusChanged(qreal blurRadius);
148 void blurHintsChanged(BlurHints hints);
151 void draw(QPainter *painter) override;
154 Q_DECLARE_PRIVATE(QGraphicsBlurEffect)
155 Q_DISABLE_COPY(QGraphicsBlurEffect)
158Q_DECLARE_OPERATORS_FOR_FLAGS(QGraphicsBlurEffect::BlurHints)
160class QGraphicsDropShadowEffectPrivate;
164 Q_PROPERTY(QPointF offset READ offset WRITE setOffset NOTIFY offsetChanged)
165 Q_PROPERTY(qreal xOffset READ xOffset WRITE setXOffset NOTIFY offsetChanged)
166 Q_PROPERTY(qreal yOffset READ yOffset WRITE setYOffset NOTIFY offsetChanged)
167 Q_PROPERTY(qreal blurRadius READ blurRadius WRITE setBlurRadius NOTIFY blurRadiusChanged)
168 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
170 QGraphicsDropShadowEffect(QObject *parent =
nullptr);
171 ~QGraphicsDropShadowEffect();
173 QRectF boundingRectFor(
const QRectF &rect)
const override;
174 QPointF offset()
const;
176 inline qreal xOffset()
const
177 {
return offset().x(); }
179 inline qreal yOffset()
const
180 {
return offset().y(); }
182 qreal blurRadius()
const;
183 QColor color()
const;
186 void setOffset(
const QPointF &ofs);
188 inline void setOffset(qreal dx, qreal dy)
189 { setOffset(QPointF(dx, dy)); }
191 inline void setOffset(qreal d)
192 { setOffset(QPointF(d, d)); }
194 inline void setXOffset(qreal dx)
195 { setOffset(QPointF(dx, yOffset())); }
197 inline void setYOffset(qreal dy)
198 { setOffset(QPointF(xOffset(), dy)); }
200 void setBlurRadius(qreal blurRadius);
201 void setColor(
const QColor &color);
204 void offsetChanged(
const QPointF &offset);
205 void blurRadiusChanged(qreal blurRadius);
206 void colorChanged(
const QColor &color);
209 void draw(QPainter *painter) override;
212 Q_DECLARE_PRIVATE(QGraphicsDropShadowEffect)
213 Q_DISABLE_COPY(QGraphicsDropShadowEffect)
220 Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged)
221 Q_PROPERTY(QBrush opacityMask READ opacityMask WRITE setOpacityMask NOTIFY opacityMaskChanged)
223 QGraphicsOpacityEffect(QObject *parent =
nullptr);
224 ~QGraphicsOpacityEffect();
226 qreal opacity()
const;
227 QBrush opacityMask()
const;
230 void setOpacity(qreal opacity);
231 void setOpacityMask(
const QBrush &mask);
234 void opacityChanged(qreal opacity);
235 void opacityMaskChanged(
const QBrush &mask);
238 void draw(QPainter *painter) override;
241 Q_DECLARE_PRIVATE(QGraphicsOpacityEffect)
242 Q_DISABLE_COPY(QGraphicsOpacityEffect)
The QGraphicsBlurEffect class provides a blur effect.
The QGraphicsColorizeEffect class provides a colorize effect.
The QGraphicsDropShadowEffect class provides a drop shadow effect.
virtual ~QGraphicsEffectSourcePrivate()
void setCachedOffset(const QPoint &offset)
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
void invalidateCache(InvalidateReason reason=SourceChanged) 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.
The QGraphicsEffect class is the base class for all graphics effects.
The QGraphicsOpacityEffect class provides an opacity effect.
QT_REQUIRE_CONFIG(animation)
QT_REQUIRE_CONFIG(graphicseffect)