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 indeterminateAnimationTypeChanged FINAL)
23 Q_PROPERTY(
24 IndeterminateAnimationType indeterminateAnimationType READ indeterminateAnimationType WRITE
25 setIndeterminateAnimationType NOTIFY indeterminateAnimationTypeChanged FINAL)
26
27public:
28 CircularIndicatorUpdator(QObject* parent = nullptr);
29
30 enum class IndeterminateAnimationType
31 {
32 Advance = 0,
33 Reteat,
34 };
35 Q_ENUM(IndeterminateAnimationType)
36
37 auto startFraction() const noexcept -> double;
38 auto endFraction() const noexcept -> double;
39 auto rotation() const noexcept -> double;
40
41 auto progress() const noexcept -> double;
42 auto completeEndProgress() const noexcept -> double;
43 auto duration() const noexcept -> double;
44 auto completeEndDuration() const noexcept -> double;
45
46 auto indeterminateAnimationType() const noexcept -> IndeterminateAnimationType;
47 void setIndeterminateAnimationType(IndeterminateAnimationType t);
48
49 void updateAdvance(double progress) noexcept;
50 void updateRetreat(double progress) noexcept;
51
52 Q_SLOT void update(double progress);
53 Q_SLOT void updateCompleteEndProgress(double progress);
54 Q_SIGNAL void updated();
55 Q_SIGNAL void indeterminateAnimationTypeChanged();
56
57private:
58 IndeterminateAnimationType m_type;
59 QEasingCurve m_curve;
60 double m_progress;
61
62 float m_start_fraction;
63 float m_end_fraction;
64 float m_rotation_degree;
65
66 float m_complete_end_progress;
67};
68} // namespace qml_material