1 #ifndef _RIVE_LINEAR_GRADIENT_BASE_HPP_
2 #define _RIVE_LINEAR_GRADIENT_BASE_HPP_
3 #include "container_component.hpp"
4 #include "core/field_types/core_double_type.hpp"
7 class LinearGradientBase : public ContainerComponent
10 typedef ContainerComponent Super;
13 static const uint16_t typeKey = 22;
15 /// Helper to quickly determine if a core object extends another without
17 bool isTypeOf(uint16_t typeKey) const override
21 case LinearGradientBase::typeKey:
22 case ContainerComponentBase::typeKey:
23 case ComponentBase::typeKey:
30 uint16_t coreType() const override { return typeKey; }
32 static const uint16_t startXPropertyKey = 42;
33 static const uint16_t startYPropertyKey = 33;
34 static const uint16_t endXPropertyKey = 34;
35 static const uint16_t endYPropertyKey = 35;
36 static const uint16_t opacityPropertyKey = 46;
39 float m_StartX = 0.0f;
40 float m_StartY = 0.0f;
43 float m_Opacity = 1.0f;
45 inline float startX() const { return m_StartX; }
46 void startX(float value)
48 if (m_StartX == value)
56 inline float startY() const { return m_StartY; }
57 void startY(float value)
59 if (m_StartY == value)
67 inline float endX() const { return m_EndX; }
68 void endX(float value)
78 inline float endY() const { return m_EndY; }
79 void endY(float value)
89 inline float opacity() const { return m_Opacity; }
90 void opacity(float value)
92 if (m_Opacity == value)
100 Core* clone() const override;
101 void copy(const LinearGradientBase& object)
103 m_StartX = object.m_StartX;
104 m_StartY = object.m_StartY;
105 m_EndX = object.m_EndX;
106 m_EndY = object.m_EndY;
107 m_Opacity = object.m_Opacity;
108 ContainerComponent::copy(object);
111 bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
115 case startXPropertyKey:
116 m_StartX = CoreDoubleType::deserialize(reader);
118 case startYPropertyKey:
119 m_StartY = CoreDoubleType::deserialize(reader);
121 case endXPropertyKey:
122 m_EndX = CoreDoubleType::deserialize(reader);
124 case endYPropertyKey:
125 m_EndY = CoreDoubleType::deserialize(reader);
127 case opacityPropertyKey:
128 m_Opacity = CoreDoubleType::deserialize(reader);
131 return ContainerComponent::deserialize(propertyKey, reader);
135 virtual void startXChanged() {}
136 virtual void startYChanged() {}
137 virtual void endXChanged() {}
138 virtual void endYChanged() {}
139 virtual void opacityChanged() {}