add support for clip region to Ripple
This commit is contained in:
parent
7b4ac5eb91
commit
369ed5adbb
|
@ -4,7 +4,8 @@
|
|||
#include "ripple.h"
|
||||
|
||||
RippleOverlay::RippleOverlay(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
: QWidget(parent),
|
||||
useClip(false)
|
||||
{
|
||||
setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
setAttribute(Qt::WA_NoSystemBackground);
|
||||
|
@ -44,6 +45,10 @@ void RippleOverlay::paintEvent(QPaintEvent *event)
|
|||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
painter.setPen(Qt::NoPen);
|
||||
|
||||
if (useClip) {
|
||||
painter.setClipRegion(clipRegion);
|
||||
}
|
||||
|
||||
QList<Ripple *>::const_iterator i;
|
||||
for (i = ripples.begin(); i != ripples.end(); ++i)
|
||||
{
|
||||
|
|
|
@ -18,6 +18,11 @@ public:
|
|||
|
||||
void setColor(const QColor &color);
|
||||
|
||||
inline void setClipping(bool enabled) { useClip = enabled; update(); }
|
||||
inline bool hasClipping() const { return useClip; }
|
||||
|
||||
inline void setClipRegion(const QRegion ®ion) { clipRegion = region; update(); }
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
|
||||
|
||||
|
@ -26,6 +31,8 @@ protected slots:
|
|||
|
||||
private:
|
||||
QList<Ripple *> ripples;
|
||||
QRegion clipRegion;
|
||||
bool useClip;
|
||||
};
|
||||
|
||||
#endif // RIPPLEOVERLAY_H
|
||||
|
|
Loading…
Reference in New Issue