1 #ifndef _RIVE_LINEAR_ANIMATION_BASE_HPP_
2 #define _RIVE_LINEAR_ANIMATION_BASE_HPP_
3 #include "rive/animation/animation.hpp"
4 #include "rive/core/field_types/core_bool_type.hpp"
5 #include "rive/core/field_types/core_double_type.hpp"
6 #include "rive/core/field_types/core_uint_type.hpp"
8 class LinearAnimationBase : public Animation {
10 typedef Animation Super;
13 static const uint16_t typeKey = 31;
15 /// Helper to quickly determine if a core object extends another without RTTI
17 bool isTypeOf(uint16_t typeKey) const override {
19 case LinearAnimationBase::typeKey:
20 case AnimationBase::typeKey:
27 uint16_t coreType() const override { return typeKey; }
29 static const uint16_t fpsPropertyKey = 56;
30 static const uint16_t durationPropertyKey = 57;
31 static const uint16_t speedPropertyKey = 58;
32 static const uint16_t loopValuePropertyKey = 59;
33 static const uint16_t workStartPropertyKey = 60;
34 static const uint16_t workEndPropertyKey = 61;
35 static const uint16_t enableWorkAreaPropertyKey = 62;
39 uint32_t m_Duration = 60;
41 uint32_t m_LoopValue = 0;
42 uint32_t m_WorkStart = -1;
43 uint32_t m_WorkEnd = -1;
44 bool m_EnableWorkArea = false;
47 inline uint32_t fps() const { return m_Fps; }
48 void fps(uint32_t value) {
56 inline uint32_t duration() const { return m_Duration; }
57 void duration(uint32_t value) {
58 if (m_Duration == value) {
65 inline float speed() const { return m_Speed; }
66 void speed(float value) {
67 if (m_Speed == value) {
74 inline uint32_t loopValue() const { return m_LoopValue; }
75 void loopValue(uint32_t value) {
76 if (m_LoopValue == value) {
83 inline uint32_t workStart() const { return m_WorkStart; }
84 void workStart(uint32_t value) {
85 if (m_WorkStart == value) {
92 inline uint32_t workEnd() const { return m_WorkEnd; }
93 void workEnd(uint32_t value) {
94 if (m_WorkEnd == value) {
101 inline bool enableWorkArea() const { return m_EnableWorkArea; }
102 void enableWorkArea(bool value) {
103 if (m_EnableWorkArea == value) {
106 m_EnableWorkArea = value;
107 enableWorkAreaChanged();
110 Core* clone() const override;
111 void copy(const LinearAnimationBase& object) {
112 m_Fps = object.m_Fps;
113 m_Duration = object.m_Duration;
114 m_Speed = object.m_Speed;
115 m_LoopValue = object.m_LoopValue;
116 m_WorkStart = object.m_WorkStart;
117 m_WorkEnd = object.m_WorkEnd;
118 m_EnableWorkArea = object.m_EnableWorkArea;
119 Animation::copy(object);
122 bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
123 switch (propertyKey) {
125 m_Fps = CoreUintType::deserialize(reader);
127 case durationPropertyKey:
128 m_Duration = CoreUintType::deserialize(reader);
130 case speedPropertyKey:
131 m_Speed = CoreDoubleType::deserialize(reader);
133 case loopValuePropertyKey:
134 m_LoopValue = CoreUintType::deserialize(reader);
136 case workStartPropertyKey:
137 m_WorkStart = CoreUintType::deserialize(reader);
139 case workEndPropertyKey:
140 m_WorkEnd = CoreUintType::deserialize(reader);
142 case enableWorkAreaPropertyKey:
143 m_EnableWorkArea = CoreBoolType::deserialize(reader);
146 return Animation::deserialize(propertyKey, reader);
150 virtual void fpsChanged() {}
151 virtual void durationChanged() {}
152 virtual void speedChanged() {}
153 virtual void loopValueChanged() {}
154 virtual void workStartChanged() {}
155 virtual void workEndChanged() {}
156 virtual void enableWorkAreaChanged() {}