-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathanimation.cpp
More file actions
41 lines (33 loc) · 1.26 KB
/
Copy pathanimation.cpp
File metadata and controls
41 lines (33 loc) · 1.26 KB
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
/**
* @file animation.cpp
* @brief Implementation file for ICFAbstractAnimation to enable MOC processing
*
* This file exists to trigger Qt's Meta-Object Compiler (MOC) for the
* ICFAbstractAnimation class which uses Q_OBJECT.
*/
#include "animation.h"
namespace cf::ui::components {
// =============================================================================
// Protected Methods
// =============================================================================
void ICFAbstractAnimation::setTargetFps(float fps) {
if (fps > 0.0f) {
targetFps_ = fps;
}
}
int ICFAbstractAnimation::calculateInterval() const {
return static_cast<int>(1000.0f / targetFps_);
}
// =============================================================================
// Constructor / Destructor
// =============================================================================
ICFAbstractAnimation::ICFAbstractAnimation(QObject* parent) : QObject(parent) {
driven_internal_timer = new QTimer(this);
// Connect timer timeout to tick slot for driving animation updates
connect(driven_internal_timer, &QTimer::timeout, this, [this]() {
if (m_state == State::Running) {
tick(calculateInterval());
}
});
}
} // namespace cf::ui::components