mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
f8e4d9a737
- fixed light colored text being too bright - fixed the ripple effect being white on grey
64 lines
1.3 KiB
C++
64 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include <boost/optional.hpp>
|
|
|
|
#include "widgets/basewidget.hpp"
|
|
|
|
#include <QMouseEvent>
|
|
#include <QPainter>
|
|
#include <QPoint>
|
|
#include <QTimer>
|
|
#include <QWidget>
|
|
|
|
namespace chatterino {
|
|
namespace widgets {
|
|
|
|
class RippleEffectButton : public BaseWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
struct ClickEffect {
|
|
double progress = 0.0;
|
|
QPoint position;
|
|
|
|
ClickEffect(QPoint _position)
|
|
: position(_position)
|
|
{
|
|
}
|
|
};
|
|
|
|
public:
|
|
RippleEffectButton(BaseWidget *parent);
|
|
|
|
void setMouseEffectColor(boost::optional<QColor> color);
|
|
|
|
signals:
|
|
void clicked();
|
|
|
|
protected:
|
|
bool selected = false;
|
|
bool mouseOver = false;
|
|
bool mouseDown = false;
|
|
|
|
virtual void paintEvent(QPaintEvent *) override;
|
|
virtual void enterEvent(QEvent *) override;
|
|
virtual void leaveEvent(QEvent *) override;
|
|
virtual void mousePressEvent(QMouseEvent *event) override;
|
|
virtual void mouseReleaseEvent(QMouseEvent *event) override;
|
|
virtual void mouseMoveEvent(QMouseEvent *event) override;
|
|
|
|
void fancyPaint(QPainter &painter);
|
|
|
|
private:
|
|
QPoint mousePos;
|
|
double hoverMultiplier = 0.0;
|
|
QTimer effectTimer;
|
|
std::vector<ClickEffect> clickEffects;
|
|
boost::optional<QColor> mouseEffectColor = boost::none;
|
|
|
|
void onMouseEffectTimeout();
|
|
};
|
|
|
|
} // namespace widgets
|
|
} // namespace chatterino
|