aboutsummaryrefslogtreecommitdiff
path: root/src/AnimatingUiElement.h
blob: c02c7af7a5ff677d7e58e2b3d94a9e3a8dedae0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef AnimatingUiElement_h
#define AnimatingUiElement_h

#include <QObject>
#include <QGraphicsPixmapItem>

class QPropertyAnimation;

class AnimatingUiElement : public QObject, public QGraphicsPixmapItem
{
    Q_OBJECT

    Q_PROPERTY(qreal scale READ scale WRITE setScale)
public:
    AnimatingUiElement(const QString& text, QObject *parent = 0, QGraphicsItem* graphicsParent = 0);
    virtual ~AnimatingUiElement();

    void mousePressEvent(QGraphicsSceneMouseEvent *event);
    void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);

    void initialize();

signals:
    void clicked();

public slots:

private slots:
    void animationFinished();

private:
    QPropertyAnimation* m_animation;
    QString m_text;
    bool m_released;
    int m_durationPressed;
    int m_durationReleased;

    static QPixmap *s_tmpGfx;
    static int s_ref;
};

#endif // AnimatingUiElement_h