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 Core* clone() const override;
128 void copy(const LinearAnimationBase& object)
130 m_Fps = object.m_Fps;
131 m_Duration = object.m_Duration;
132 m_Speed = object.m_Speed;
133 m_LoopValue = object.m_LoopValue;
134 m_WorkStart = object.m_WorkStart;
135 m_WorkEnd = object.m_WorkEnd;
136 m_EnableWorkArea = object.m_EnableWorkArea;
137 Animation::copy(object);
140 bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
145 m_Fps = CoreUintType::deserialize(reader);
147 case durationPropertyKey:
148 m_Duration = CoreUintType::deserialize(reader);
150 case speedPropertyKey:
151 m_Speed = CoreDoubleType::deserialize(reader);
153 case loopValuePropertyKey:
154 m_LoopValue = CoreUintType::deserialize(reader);
156 case workStartPropertyKey:
157 m_WorkStart = CoreUintType::deserialize(reader);
159 case workEndPropertyKey:
160 m_WorkEnd = CoreUintType::deserialize(reader);
162 case enableWorkAreaPropertyKey:
163 m_EnableWorkArea = CoreBoolType::deserialize(reader);
166 return Animation::deserialize(propertyKey, reader);
170 virtual void fpsChanged() {}
171 virtual void durationChanged() {}
172 virtual void speedChanged() {}
173 virtual void loopValueChanged() {}
174 virtual void workStartChanged() {}
175 virtual void workEndChanged() {}
176 virtual void enableWorkAreaChanged() {}