-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstepped_animation.h
52 lines (38 loc) · 1.12 KB
/
stepped_animation.h
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
43
44
45
46
47
48
49
50
51
52
#pragma once
#include <QPropertyAnimation>
namespace fv
{
//! Wrapper for animation which allows to run infinite loop of changing values from 0. to 1. or from 0. to -1.
class stepped_animation : public QObject
{
Q_OBJECT
Q_PROPERTY(qreal animation_value READ animation_value WRITE set_animation_value)
public:
stepped_animation(QObject* parent = nullptr);
virtual ~stepped_animation();
//! Run animation with specified direction
void start(bool forward);
//! Delayed stop until current cycle finishes
void stop();
//! Instant stop of animation
void interrupt();
//! Is animation stopped
bool stopped() const;
//! Get directino of running animation
bool forward() const;
//! Get current animation value
qreal animation_value() const;
//! Set current animation value
void set_animation_value(qreal value);
signals:
//! Signal which is emitted every time current animation value is changed
void value_changed(qreal value);
//! Signal which is emitted every time current cycle finishes
void step(bool forward);
private:
QPropertyAnimation animation_;
bool running_;
qreal value_;
bool forward_;
};
}