diff options
author | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2020-02-25 12:29:04 +0200 |
---|---|---|
committer | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2020-02-26 18:15:23 +0200 |
commit | e55a46e5d19178a04b8244f7077ac71f12df639d (patch) | |
tree | 5a46ccacccfbb2b42f0dd82cb1fc54bebb0d50c1 /include/mbgl | |
parent | 8785f77cd633be92123464310f85ea671689473c (diff) | |
download | qtlocation-mapboxgl-e55a46e5d19178a04b8244f7077ac71f12df639d.tar.gz |
[core] Fix Color serialization
Diffstat (limited to 'include/mbgl')
-rw-r--r-- | include/mbgl/style/conversion_impl.hpp | 9 | ||||
-rw-r--r-- | include/mbgl/util/color.hpp | 1 |
2 files changed, 7 insertions, 3 deletions
diff --git a/include/mbgl/style/conversion_impl.hpp b/include/mbgl/style/conversion_impl.hpp index 73d83302a0..30aa132ce0 100644 --- a/include/mbgl/style/conversion_impl.hpp +++ b/include/mbgl/style/conversion_impl.hpp @@ -318,7 +318,7 @@ struct ValueFactory<TransitionOptions> { template <> struct ValueFactory<Color> { - static Value make(const Color& color) { return color.toObject(); } + static Value make(const Color& color) { return color.serialize(); } }; template <typename T> @@ -358,11 +358,14 @@ Value makeValue(T&& arg) { template <typename T> StyleProperty makeStyleProperty(const PropertyValue<T>& value) { return value.match([](const Undefined&) -> StyleProperty { return {}; }, - [](const T& t) -> StyleProperty { - return {makeValue(t), StyleProperty::Kind::Constant}; + [](const Color& c) -> StyleProperty { + return {makeValue(c), StyleProperty::Kind::Expression}; }, [](const PropertyExpression<T>& fn) -> StyleProperty { return {fn.getExpression().serialize(), StyleProperty::Kind::Expression}; + }, + [](const auto& t) -> StyleProperty { + return {makeValue(t), StyleProperty::Kind::Constant}; }); } diff --git a/include/mbgl/util/color.hpp b/include/mbgl/util/color.hpp index 1ff44ce085..8a03abfcdb 100644 --- a/include/mbgl/util/color.hpp +++ b/include/mbgl/util/color.hpp @@ -41,6 +41,7 @@ public: std::string stringify() const; std::array<double, 4> toArray() const; mbgl::Value toObject() const; + mbgl::Value serialize() const; }; inline bool operator==(const Color& colorA, const Color& colorB) { |