matrixion/include/ui/Ripple.h

147 lines
2.6 KiB
C
Raw Normal View History

#pragma once
2017-04-06 02:06:42 +03:00
#include <QBrush>
#include <QEasingCurve>
#include <QParallelAnimationGroup>
#include <QPoint>
#include <QPropertyAnimation>
class RippleOverlay;
class Ripple : public QParallelAnimationGroup
{
Q_OBJECT
Q_PROPERTY(qreal radius WRITE setRadius READ radius)
Q_PROPERTY(qreal opacity WRITE setOpacity READ opacity)
public:
explicit Ripple(const QPoint &center, QObject *parent = 0);
Ripple(const QPoint &center, RippleOverlay *overlay, QObject *parent = 0);
~Ripple();
inline void setOverlay(RippleOverlay *overlay);
void setRadius(qreal radius);
void setOpacity(qreal opacity);
void setColor(const QColor &color);
void setBrush(const QBrush &brush);
inline qreal radius() const;
inline qreal opacity() const;
inline QColor color() const;
inline QBrush brush() const;
inline QPoint center() const;
inline QPropertyAnimation *radiusAnimation() const;
inline QPropertyAnimation *opacityAnimation() const;
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);
protected slots:
void destroy();
private:
Q_DISABLE_COPY(Ripple)
QPropertyAnimation *animate(const QByteArray &property,
const QEasingCurve &easing = QEasingCurve::OutQuad,
int duration = 800);
void init();
RippleOverlay *overlay_;
QPropertyAnimation *const radius_anim_;
QPropertyAnimation *const opacity_anim_;
qreal radius_;
qreal opacity_;
QPoint center_;
QBrush brush_;
};
2017-08-20 13:47:22 +03:00
inline void
Ripple::setOverlay(RippleOverlay *overlay)
2017-04-06 02:06:42 +03:00
{
overlay_ = overlay;
}
2017-08-20 13:47:22 +03:00
inline qreal
Ripple::radius() const
2017-04-06 02:06:42 +03:00
{
return radius_;
}
2017-08-20 13:47:22 +03:00
inline qreal
Ripple::opacity() const
2017-04-06 02:06:42 +03:00
{
return opacity_;
}
2017-08-20 13:47:22 +03:00
inline QColor
Ripple::color() const
2017-04-06 02:06:42 +03:00
{
return brush_.color();
}
2017-08-20 13:47:22 +03:00
inline QBrush
Ripple::brush() const
2017-04-06 02:06:42 +03:00
{
return brush_;
}
2017-08-20 13:47:22 +03:00
inline QPoint
Ripple::center() const
2017-04-06 02:06:42 +03:00
{
return center_;
}
2017-08-20 13:47:22 +03:00
inline QPropertyAnimation *
Ripple::radiusAnimation() const
2017-04-06 02:06:42 +03:00
{
return radius_anim_;
}
2017-08-20 13:47:22 +03:00
inline QPropertyAnimation *
Ripple::opacityAnimation() const
2017-04-06 02:06:42 +03:00
{
return opacity_anim_;
}
2017-08-20 13:47:22 +03:00
inline void
Ripple::setOpacityStartValue(qreal value)
2017-04-06 02:06:42 +03:00
{
opacity_anim_->setStartValue(value);
}
2017-08-20 13:47:22 +03:00
inline void
Ripple::setOpacityEndValue(qreal value)
2017-04-06 02:06:42 +03:00
{
opacity_anim_->setEndValue(value);
}
2017-08-20 13:47:22 +03:00
inline void
Ripple::setRadiusStartValue(qreal value)
2017-04-06 02:06:42 +03:00
{
radius_anim_->setStartValue(value);
}
2017-08-20 13:47:22 +03:00
inline void
Ripple::setRadiusEndValue(qreal value)
2017-04-06 02:06:42 +03:00
{
radius_anim_->setEndValue(value);
}
2017-08-20 13:47:22 +03:00
inline void
Ripple::setDuration(int msecs)
2017-04-06 02:06:42 +03:00
{
radius_anim_->setDuration(msecs);
opacity_anim_->setDuration(msecs);
}