1 #ifndef _RIVE_LINEAR_ANIMATION_BASE_HPP_
2 #define _RIVE_LINEAR_ANIMATION_BASE_HPP_
3 #include "animation/animation.hpp"
4 #include "core/field_types/core_bool_type.hpp"
5 #include "core/field_types/core_double_type.hpp"
6 #include "core/field_types/core_uint_type.hpp"
9 class LinearAnimationBase : public Animation
12 typedef Animation Super;
15 static const uint16_t typeKey = 31;
17 /// Helper to quickly determine if a core object extends another without
19 bool isTypeOf(uint16_t typeKey) const override
23 case LinearAnimationBase::typeKey:
24 case AnimationBase::typeKey:
31 uint16_t coreType() const override { return typeKey; }
33 static const uint16_t fpsPropertyKey = 56;
34 static const uint16_t durationPropertyKey = 57;
35 static const uint16_t speedPropertyKey = 58;
36 static const uint16_t loopValuePropertyKey = 59;
37 static const uint16_t workStartPropertyKey = 60;
38 static const uint16_t workEndPropertyKey = 61;
39 static const uint16_t enableWorkAreaPropertyKey = 62;
48 bool m_EnableWorkArea = false;
50 inline int fps() const { return m_Fps; }
61 inline int duration() const { return m_Duration; }
62 void duration(int value)
64 if (m_Duration == value)
72 inline float speed() const { return m_Speed; }
73 void speed(float value)
83 inline int loopValue() const { return m_LoopValue; }
84 void loopValue(int value)
86 if (m_LoopValue == value)
94 inline int workStart() const { return m_WorkStart; }
95 void workStart(int value)
97 if (m_WorkStart == value)
105 inline int workEnd() const { return m_WorkEnd; }
106 void workEnd(int value)
108 if (m_WorkEnd == value)
116 inline bool enableWorkArea() const { return m_EnableWorkArea; }
117 void enableWorkArea(bool value)
119 if (m_EnableWorkArea == value)
123 m_EnableWorkArea = value;
124 enableWorkAreaChanged();
127 bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
132 m_Fps = CoreUintType::deserialize(reader);
134 case durationPropertyKey:
135 m_Duration = CoreUintType::deserialize(reader);
137 case speedPropertyKey:
138 m_Speed = CoreDoubleType::deserialize(reader);
140 case loopValuePropertyKey:
141 m_LoopValue = CoreUintType::deserialize(reader);
143 case workStartPropertyKey:
144 m_WorkStart = CoreUintType::deserialize(reader);
146 case workEndPropertyKey:
147 m_WorkEnd = CoreUintType::deserialize(reader);
149 case enableWorkAreaPropertyKey:
150 m_EnableWorkArea = CoreBoolType::deserialize(reader);
153 return Animation::deserialize(propertyKey, reader);
157 virtual void fpsChanged() {}
158 virtual void durationChanged() {}
159 virtual void speedChanged() {}
160 virtual void loopValueChanged() {}
161 virtual void workStartChanged() {}
162 virtual void workEndChanged() {}
163 virtual void enableWorkAreaChanged() {}