summaryrefslogtreecommitdiff
path: root/include/mbgl/style/conversion/property_setter.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/mbgl/style/conversion/property_setter.hpp')
-rw-r--r--include/mbgl/style/conversion/property_setter.hpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/include/mbgl/style/conversion/property_setter.hpp b/include/mbgl/style/conversion/property_setter.hpp
index 1a601c7c1b..6a15c64026 100644
--- a/include/mbgl/style/conversion/property_setter.hpp
+++ b/include/mbgl/style/conversion/property_setter.hpp
@@ -4,6 +4,8 @@
#include <mbgl/style/conversion.hpp>
#include <mbgl/style/conversion/constant.hpp>
#include <mbgl/style/conversion/property_value.hpp>
+#include <mbgl/style/conversion/data_driven_property_value.hpp>
+#include <mbgl/style/conversion/transition_options.hpp>
#include <functional>
#include <string>
@@ -18,15 +20,15 @@ using LayoutPropertySetter = std::function<optional<Error> (Layer&, const V&)>;
template <class V>
using PaintPropertySetter = std::function<optional<Error> (Layer&, const V&, const optional<std::string>&)>;
-template <class V, class L, class T, class...Args>
-auto makePropertySetter(void (L::*setter)(PropertyValue<T>, const Args&...args)) {
+template <class V, class L, class PropertyValue, class...Args>
+auto makePropertySetter(void (L::*setter)(PropertyValue, const Args&...args)) {
return [setter] (Layer& layer, const V& value, const Args&...args) -> optional<Error> {
L* typedLayer = layer.as<L>();
if (!typedLayer) {
return Error { "layer doesn't support this property" };
}
- Result<PropertyValue<T>> typedValue = convert<PropertyValue<T>>(value);
+ Result<PropertyValue> typedValue = convert<PropertyValue>(value);
if (!typedValue) {
return typedValue.error();
}
@@ -36,6 +38,24 @@ auto makePropertySetter(void (L::*setter)(PropertyValue<T>, const Args&...args))
};
}
+template <class V, class L, class...Args>
+auto makeTransitionSetter(void (L::*setter)(const TransitionOptions&, const Args&...args)) {
+ return [setter] (Layer& layer, const V& value, const Args&...args) -> optional<Error> {
+ L* typedLayer = layer.as<L>();
+ if (!typedLayer) {
+ return Error { "layer doesn't support this property" };
+ }
+
+ Result<TransitionOptions> transition = convert<TransitionOptions>(value);
+ if (!transition) {
+ return transition.error();
+ }
+
+ (typedLayer->*setter)(*transition, args...);
+ return {};
+ };
+}
+
template <class V>
optional<Error> setVisibility(Layer& layer, const V& value) {
if (isUndefined(value)) {