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.hpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/mbgl/style/conversion/property_setter.hpp b/include/mbgl/style/conversion/property_setter.hpp
index 52fb160fde..6a15c64026 100644
--- a/include/mbgl/style/conversion/property_setter.hpp
+++ b/include/mbgl/style/conversion/property_setter.hpp
@@ -5,6 +5,7 @@
#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>
@@ -37,6 +38,24 @@ auto makePropertySetter(void (L::*setter)(PropertyValue, 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)) {