diff --git a/inc/rlottie.h b/inc/rlottie.h index 11e1e7c2a0..d3a48a9495 100644 --- a/inc/rlottie.h +++ b/inc/rlottie.h @@ -83,6 +83,12 @@ enum class Property { TrOpacity /*!< Transform Opacity property of Layer and Group object , value type is float [ 0 .. 100] */ }; +struct Color_Type{}; +struct Point_Type{}; +struct Size_Type{}; +struct Float_Type{}; +template struct MapType; + class LOT_EXPORT Surface { public: /** @@ -388,7 +394,7 @@ public: template void setValue(const std::string &keypath, AnyValue value) { - setValue(std::integral_constant{}, prop, keypath, value); + setValue(MapType>{}, prop, keypath, value); } /** @@ -399,34 +405,10 @@ public: ~Animation(); private: - enum class ValueType {Color,Point,Size,Float}; - static constexpr ValueType mapType(Property prop) { - switch (prop) { - case Property::FillColor: - case Property::StrokeColor: - return ValueType::Color; - case Property::FillOpacity: - case Property::StrokeOpacity: - case Property::StrokeWidth: - case Property::TrOpacity: - case Property::TrRotation: - return ValueType::Float; - case Property::TrAnchor: - case Property::TrPosition: - return ValueType::Point; - case Property::TrScale: - return ValueType::Size; - } - } - - void setValue(std::integral_constant, - Property, const std::string &, Color); - void setValue(std::integral_constant, - Property, const std::string &, float); - void setValue(std::integral_constant, - Property, const std::string &, Size); - void setValue(std::integral_constant, - Property, const std::string &, Point); + void setValue(Color_Type, Property, const std::string &, Color); + void setValue(Float_Type, Property, const std::string &, float); + void setValue(Size_Type, Property, const std::string &, Size); + void setValue(Point_Type, Property, const std::string &, Point); /** * @brief default constructor * @@ -437,6 +419,18 @@ private: std::unique_ptr d; }; +//Map Property to Value type +template<> struct MapType>: Color_Type{}; +template<> struct MapType>: Color_Type{}; +template<> struct MapType>: Float_Type{}; +template<> struct MapType>: Float_Type{}; +template<> struct MapType>: Float_Type{}; +template<> struct MapType>: Float_Type{}; +template<> struct MapType>: Float_Type{}; +template<> struct MapType>: Point_Type{}; +template<> struct MapType>: Point_Type{}; +template<> struct MapType>: Size_Type{}; + } // namespace lotplayer diff --git a/src/lottie/lottieanimation.cpp b/src/lottie/lottieanimation.cpp index d5376eaea1..08ed5dc48a 100644 --- a/src/lottie/lottieanimation.cpp +++ b/src/lottie/lottieanimation.cpp @@ -314,28 +314,28 @@ const LayerInfoList& Animation::layers() const return d->layerInfoList(); } -void Animation::setValue(std::integral_constant,Property prop, +void Animation::setValue(Color_Type,Property prop, const std::string &keypath, Color value) { d->setValue(keypath, LOTVariant(prop, value)); } -void Animation::setValue(std::integral_constant, Property prop, +void Animation::setValue(Float_Type, Property prop, const std::string &keypath, float value) { d->setValue(keypath, LOTVariant(prop, value)); } -void Animation::setValue(std::integral_constant,Property prop, +void Animation::setValue(Size_Type,Property prop, const std::string &keypath, Size value) { d->setValue(keypath, LOTVariant(prop, value)); } -void Animation::setValue(std::integral_constant, Property prop, +void Animation::setValue(Point_Type, Property prop, const std::string &keypath, Point value) {