matrixion/src/ui/RippleOverlay.h

62 lines
1.2 KiB
C
Raw Normal View History

2021-03-05 02:35:15 +03:00
// SPDX-FileCopyrightText: 2021 Nheko Contributors
//
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
2017-04-06 02:06:42 +03:00
#include <QPainterPath>
#include "OverlayWidget.h"
class Ripple;
class RippleOverlay : public OverlayWidget
{
2017-09-10 12:59:21 +03:00
Q_OBJECT
2017-04-06 02:06:42 +03:00
public:
2020-02-04 06:58:43 +03:00
explicit RippleOverlay(QWidget *parent = nullptr);
2017-04-06 02:06:42 +03:00
2017-09-10 12:59:21 +03:00
void addRipple(Ripple *ripple);
void addRipple(const QPoint &position, qreal radius = 300);
2017-04-06 02:06:42 +03:00
2017-09-10 12:59:21 +03:00
void removeRipple(Ripple *ripple);
2017-04-06 02:06:42 +03:00
2017-09-10 12:59:21 +03:00
inline void setClipping(bool enable);
inline bool hasClipping() const;
2017-04-06 02:06:42 +03:00
2017-09-10 12:59:21 +03:00
inline void setClipPath(const QPainterPath &path);
2017-04-06 02:06:42 +03:00
protected:
2017-09-10 12:59:21 +03:00
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
2017-04-06 02:06:42 +03:00
private:
2017-09-10 12:59:21 +03:00
Q_DISABLE_COPY(RippleOverlay)
2017-04-06 02:06:42 +03:00
2017-09-10 12:59:21 +03:00
void paintRipple(QPainter *painter, Ripple *ripple);
2017-04-06 02:06:42 +03:00
2017-09-10 12:59:21 +03:00
QList<Ripple *> ripples_;
QPainterPath clip_path_;
bool use_clip_;
2017-04-06 02:06:42 +03:00
};
2017-08-20 13:47:22 +03:00
inline void
RippleOverlay::setClipping(bool enable)
2017-04-06 02:06:42 +03:00
{
2017-09-10 12:59:21 +03:00
use_clip_ = enable;
update();
2017-04-06 02:06:42 +03:00
}
2017-08-20 13:47:22 +03:00
inline bool
RippleOverlay::hasClipping() const
2017-04-06 02:06:42 +03:00
{
2017-09-10 12:59:21 +03:00
return use_clip_;
2017-04-06 02:06:42 +03:00
}
2017-08-20 13:47:22 +03:00
inline void
RippleOverlay::setClipPath(const QPainterPath &path)
2017-04-06 02:06:42 +03:00
{
2017-09-10 12:59:21 +03:00
clip_path_ = path;
update();
2017-04-06 02:06:42 +03:00
}