You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nheko/include/ui/Ripple.h

146 lines
2.9 KiB

#pragma once
8 years ago
#include <QBrush>
#include <QEasingCurve>
#include <QParallelAnimationGroup>
#include <QPoint>
#include <QPropertyAnimation>
class RippleOverlay;
class Ripple : public QParallelAnimationGroup
{
Q_OBJECT
8 years ago
Q_PROPERTY(qreal radius WRITE setRadius READ radius)
Q_PROPERTY(qreal opacity WRITE setOpacity READ opacity)
8 years ago
public:
explicit Ripple(const QPoint &center, QObject *parent = 0);
Ripple(const QPoint &center, RippleOverlay *overlay, QObject *parent = 0);
8 years ago
inline void setOverlay(RippleOverlay *overlay);
8 years ago
void setRadius(qreal radius);
void setOpacity(qreal opacity);
void setColor(const QColor &color);
void setBrush(const QBrush &brush);
8 years ago
inline qreal radius() const;
inline qreal opacity() const;
inline QColor color() const;
inline QBrush brush() const;
inline QPoint center() const;
8 years ago
inline QPropertyAnimation *radiusAnimation() const;
inline QPropertyAnimation *opacityAnimation() const;
8 years ago
inline void setOpacityStartValue(qreal value);
inline void setOpacityEndValue(qreal value);
inline void setRadiusStartValue(qreal value);
inline void setRadiusEndValue(qreal value);
inline void setDuration(int msecs);
8 years ago
protected slots:
void destroy();
8 years ago
private:
Q_DISABLE_COPY(Ripple)
8 years ago
QPropertyAnimation *animate(const QByteArray &property,
const QEasingCurve &easing = QEasingCurve::OutQuad,
int duration = 800);
8 years ago
void init();
8 years ago
RippleOverlay *overlay_;
8 years ago
QPropertyAnimation *const radius_anim_;
QPropertyAnimation *const opacity_anim_;
8 years ago
qreal radius_;
qreal opacity_;
8 years ago
QPoint center_;
QBrush brush_;
8 years ago
};
inline void
Ripple::setOverlay(RippleOverlay *overlay)
8 years ago
{
overlay_ = overlay;
8 years ago
}
inline qreal
Ripple::radius() const
8 years ago
{
return radius_;
8 years ago
}
inline qreal
Ripple::opacity() const
8 years ago
{
return opacity_;
8 years ago
}
inline QColor
Ripple::color() const
8 years ago
{
return brush_.color();
8 years ago
}
inline QBrush
Ripple::brush() const
8 years ago
{
return brush_;
8 years ago
}
inline QPoint
Ripple::center() const
8 years ago
{
return center_;
8 years ago
}
inline QPropertyAnimation *
Ripple::radiusAnimation() const
8 years ago
{
return radius_anim_;
8 years ago
}
inline QPropertyAnimation *
Ripple::opacityAnimation() const
8 years ago
{
return opacity_anim_;
8 years ago
}
inline void
Ripple::setOpacityStartValue(qreal value)
8 years ago
{
opacity_anim_->setStartValue(value);
8 years ago
}
inline void
Ripple::setOpacityEndValue(qreal value)
8 years ago
{
opacity_anim_->setEndValue(value);
8 years ago
}
inline void
Ripple::setRadiusStartValue(qreal value)
8 years ago
{
radius_anim_->setStartValue(value);
8 years ago
}
inline void
Ripple::setRadiusEndValue(qreal value)
8 years ago
{
radius_anim_->setEndValue(value);
8 years ago
}
inline void
Ripple::setDuration(int msecs)
8 years ago
{
radius_anim_->setDuration(msecs);
opacity_anim_->setDuration(msecs);
8 years ago
}