mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
56 lines
1.1 KiB
C
56 lines
1.1 KiB
C
|
#ifndef FANCYBUTTON_H
|
||
|
#define FANCYBUTTON_H
|
||
|
|
||
|
#include <QMouseEvent>
|
||
|
#include <QPainter>
|
||
|
#include <QPoint>
|
||
|
#include <QTimer>
|
||
|
#include <QWidget>
|
||
|
|
||
|
namespace chatterino {
|
||
|
namespace widgets {
|
||
|
class FancyButton : public QWidget
|
||
|
{
|
||
|
struct ClickEffect {
|
||
|
float progress;
|
||
|
QPoint position;
|
||
|
|
||
|
ClickEffect(QPoint position)
|
||
|
: progress()
|
||
|
, position(position)
|
||
|
{
|
||
|
}
|
||
|
};
|
||
|
|
||
|
public:
|
||
|
FancyButton(QWidget *parent = nullptr);
|
||
|
|
||
|
void setMouseEffectColor(QColor color);
|
||
|
|
||
|
protected:
|
||
|
void paintEvent(QPaintEvent *) override;
|
||
|
void enterEvent(QEvent *) override;
|
||
|
void leaveEvent(QEvent *) override;
|
||
|
void mousePressEvent(QMouseEvent *event) override;
|
||
|
void mouseReleaseEvent(QMouseEvent *event) override;
|
||
|
void mouseMoveEvent(QMouseEvent *event) override;
|
||
|
|
||
|
void fancyPaint(QPainter &painter);
|
||
|
|
||
|
private:
|
||
|
bool _selected;
|
||
|
bool _mouseOver;
|
||
|
bool _mouseDown;
|
||
|
QPoint _mousePos;
|
||
|
float _hoverMultiplier;
|
||
|
QTimer _effectTimer;
|
||
|
std::vector<ClickEffect> _clickEffects;
|
||
|
QColor _mouseEffectColor;
|
||
|
|
||
|
void onMouseEffectTimeout();
|
||
|
};
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endif // FANCYBUTTON_H
|