QmlMaterial 0.1.0
Loading...
Searching...
No Matches
circular_indicator_updator.hpp
1#pragma once
2
3#include <QtCore/QEasingCurve>
4#include <QtQml/QQmlEngine>
5
6#include "qml_material/core.hpp"
7
8namespace qml_material
9{
10
11class CircularIndicatorUpdator : public QObject {
12 Q_OBJECT
13 QML_ELEMENT
14
15 Q_PROPERTY(double startFraction READ startFraction NOTIFY updated FINAL)
16 Q_PROPERTY(double endFraction READ endFraction NOTIFY updated FINAL)
17 Q_PROPERTY(double rotation READ rotation NOTIFY updated FINAL)
18 Q_PROPERTY(double progress READ progress WRITE update NOTIFY updated FINAL)
19 Q_PROPERTY(double completeEndProgress READ completeEndProgress WRITE updateCompleteEndProgress
20 NOTIFY updated FINAL)
21 Q_PROPERTY(double duration READ duration NOTIFY indeterminateAnimationTypeChanged FINAL)
22 Q_PROPERTY(double completeEndDuration READ completeEndDuration NOTIFY
23 indeterminateAnimationTypeChanged FINAL)
24 Q_PROPERTY(
25 IndeterminateAnimationType indeterminateAnimationType READ indeterminateAnimationType WRITE
26 setIndeterminateAnimationType NOTIFY indeterminateAnimationTypeChanged FINAL)
27
28public:
29 CircularIndicatorUpdator(QObject* parent = nullptr);
30
31 enum class IndeterminateAnimationType
32 {
33 Advance = 0,
34 Reteat,
35 };
36 Q_ENUM(IndeterminateAnimationType)
37
38 auto startFraction() const noexcept -> double;
39 auto endFraction() const noexcept -> double;
40 auto rotation() const noexcept -> double;
41
42 auto progress() const noexcept -> double;
43 auto completeEndProgress() const noexcept -> double;
44 auto duration() const noexcept -> double;
45 auto completeEndDuration() const noexcept -> double;
46
47 auto indeterminateAnimationType() const noexcept -> IndeterminateAnimationType;
48 void setIndeterminateAnimationType(IndeterminateAnimationType t);
49
50 void updateAdvance(double progress) noexcept;
51 void updateRetreat(double progress) noexcept;
52
53 Q_SLOT void update(double progress);
54 Q_SLOT void updateCompleteEndProgress(double progress);
55 Q_SIGNAL void updated();
56 Q_SIGNAL void indeterminateAnimationTypeChanged();
57
58private:
59 IndeterminateAnimationType m_type;
60 QEasingCurve m_curve;
61 double m_progress;
62
63 float m_start_fraction;
64 float m_end_fraction;
65 float m_rotation_degree;
66
67 float m_complete_end_progress;
68};
69} // namespace qml_material