2017-06-07 10:09:24 +02:00
|
|
|
#pragma once
|
2017-04-12 17:46:44 +02:00
|
|
|
|
|
|
|
#include <QMouseEvent>
|
|
|
|
#include <QPainter>
|
|
|
|
#include <QPoint>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QWidget>
|
|
|
|
|
2017-04-14 17:52:22 +02:00
|
|
|
namespace chatterino {
|
|
|
|
namespace widgets {
|
2017-06-07 10:09:24 +02:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
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();
|
|
|
|
};
|
|
|
|
|
2017-06-07 10:09:24 +02:00
|
|
|
} // namespace widgets
|
|
|
|
} // namespace chatterino
|