diff --git a/cmake/core-files.cmake b/cmake/core-files.cmake index 47e486571f6..2696d2bf3e8 100644 --- a/cmake/core-files.cmake +++ b/cmake/core-files.cmake @@ -296,12 +296,16 @@ set(MBGL_CORE_FILES include/mbgl/style/conversion/property_value.hpp include/mbgl/style/conversion/source.hpp include/mbgl/style/conversion/tileset.hpp + include/mbgl/style/conversion/transition_options.hpp src/mbgl/style/conversion/stringify.hpp # style/function include/mbgl/style/function/camera_function.hpp include/mbgl/style/function/categorical_stops.hpp + include/mbgl/style/function/composite_categorical_stops.hpp + include/mbgl/style/function/composite_exponential_stops.hpp include/mbgl/style/function/composite_function.hpp + include/mbgl/style/function/composite_interval_stops.hpp include/mbgl/style/function/exponential_stops.hpp include/mbgl/style/function/identity_stops.hpp include/mbgl/style/function/interval_stops.hpp diff --git a/cmake/test-files.cmake b/cmake/test-files.cmake index 9ab99181629..b2bff6c72a8 100644 --- a/cmake/test-files.cmake +++ b/cmake/test-files.cmake @@ -74,6 +74,7 @@ set(MBGL_TEST_FILES # style/conversion test/style/conversion/function.test.cpp test/style/conversion/geojson_options.test.cpp + test/style/conversion/layer.test.cpp test/style/conversion/stringify.test.cpp # style diff --git a/include/mbgl/style/conversion/make_property_setters.hpp b/include/mbgl/style/conversion/make_property_setters.hpp index e30359937e4..32fa810f0b1 100644 --- a/include/mbgl/style/conversion/make_property_setters.hpp +++ b/include/mbgl/style/conversion/make_property_setters.hpp @@ -77,69 +77,127 @@ auto makePaintPropertySetters() { std::unordered_map> result; result["fill-antialias"] = makePropertySetter(&FillLayer::setFillAntialias); + result["fill-antialias-transition"] = makeTransitionSetter(&FillLayer::setFillAntialiasTransition); result["fill-opacity"] = makePropertySetter(&FillLayer::setFillOpacity); + result["fill-opacity-transition"] = makeTransitionSetter(&FillLayer::setFillOpacityTransition); result["fill-color"] = makePropertySetter(&FillLayer::setFillColor); + result["fill-color-transition"] = makeTransitionSetter(&FillLayer::setFillColorTransition); result["fill-outline-color"] = makePropertySetter(&FillLayer::setFillOutlineColor); + result["fill-outline-color-transition"] = makeTransitionSetter(&FillLayer::setFillOutlineColorTransition); result["fill-translate"] = makePropertySetter(&FillLayer::setFillTranslate); + result["fill-translate-transition"] = makeTransitionSetter(&FillLayer::setFillTranslateTransition); result["fill-translate-anchor"] = makePropertySetter(&FillLayer::setFillTranslateAnchor); + result["fill-translate-anchor-transition"] = makeTransitionSetter(&FillLayer::setFillTranslateAnchorTransition); result["fill-pattern"] = makePropertySetter(&FillLayer::setFillPattern); + result["fill-pattern-transition"] = makeTransitionSetter(&FillLayer::setFillPatternTransition); result["line-opacity"] = makePropertySetter(&LineLayer::setLineOpacity); + result["line-opacity-transition"] = makeTransitionSetter(&LineLayer::setLineOpacityTransition); result["line-color"] = makePropertySetter(&LineLayer::setLineColor); + result["line-color-transition"] = makeTransitionSetter(&LineLayer::setLineColorTransition); result["line-translate"] = makePropertySetter(&LineLayer::setLineTranslate); + result["line-translate-transition"] = makeTransitionSetter(&LineLayer::setLineTranslateTransition); result["line-translate-anchor"] = makePropertySetter(&LineLayer::setLineTranslateAnchor); + result["line-translate-anchor-transition"] = makeTransitionSetter(&LineLayer::setLineTranslateAnchorTransition); result["line-width"] = makePropertySetter(&LineLayer::setLineWidth); + result["line-width-transition"] = makeTransitionSetter(&LineLayer::setLineWidthTransition); result["line-gap-width"] = makePropertySetter(&LineLayer::setLineGapWidth); + result["line-gap-width-transition"] = makeTransitionSetter(&LineLayer::setLineGapWidthTransition); result["line-offset"] = makePropertySetter(&LineLayer::setLineOffset); + result["line-offset-transition"] = makeTransitionSetter(&LineLayer::setLineOffsetTransition); result["line-blur"] = makePropertySetter(&LineLayer::setLineBlur); + result["line-blur-transition"] = makeTransitionSetter(&LineLayer::setLineBlurTransition); result["line-dasharray"] = makePropertySetter(&LineLayer::setLineDasharray); + result["line-dasharray-transition"] = makeTransitionSetter(&LineLayer::setLineDasharrayTransition); result["line-pattern"] = makePropertySetter(&LineLayer::setLinePattern); + result["line-pattern-transition"] = makeTransitionSetter(&LineLayer::setLinePatternTransition); result["icon-opacity"] = makePropertySetter(&SymbolLayer::setIconOpacity); + result["icon-opacity-transition"] = makeTransitionSetter(&SymbolLayer::setIconOpacityTransition); result["icon-color"] = makePropertySetter(&SymbolLayer::setIconColor); + result["icon-color-transition"] = makeTransitionSetter(&SymbolLayer::setIconColorTransition); result["icon-halo-color"] = makePropertySetter(&SymbolLayer::setIconHaloColor); + result["icon-halo-color-transition"] = makeTransitionSetter(&SymbolLayer::setIconHaloColorTransition); result["icon-halo-width"] = makePropertySetter(&SymbolLayer::setIconHaloWidth); + result["icon-halo-width-transition"] = makeTransitionSetter(&SymbolLayer::setIconHaloWidthTransition); result["icon-halo-blur"] = makePropertySetter(&SymbolLayer::setIconHaloBlur); + result["icon-halo-blur-transition"] = makeTransitionSetter(&SymbolLayer::setIconHaloBlurTransition); result["icon-translate"] = makePropertySetter(&SymbolLayer::setIconTranslate); + result["icon-translate-transition"] = makeTransitionSetter(&SymbolLayer::setIconTranslateTransition); result["icon-translate-anchor"] = makePropertySetter(&SymbolLayer::setIconTranslateAnchor); + result["icon-translate-anchor-transition"] = makeTransitionSetter(&SymbolLayer::setIconTranslateAnchorTransition); result["text-opacity"] = makePropertySetter(&SymbolLayer::setTextOpacity); + result["text-opacity-transition"] = makeTransitionSetter(&SymbolLayer::setTextOpacityTransition); result["text-color"] = makePropertySetter(&SymbolLayer::setTextColor); + result["text-color-transition"] = makeTransitionSetter(&SymbolLayer::setTextColorTransition); result["text-halo-color"] = makePropertySetter(&SymbolLayer::setTextHaloColor); + result["text-halo-color-transition"] = makeTransitionSetter(&SymbolLayer::setTextHaloColorTransition); result["text-halo-width"] = makePropertySetter(&SymbolLayer::setTextHaloWidth); + result["text-halo-width-transition"] = makeTransitionSetter(&SymbolLayer::setTextHaloWidthTransition); result["text-halo-blur"] = makePropertySetter(&SymbolLayer::setTextHaloBlur); + result["text-halo-blur-transition"] = makeTransitionSetter(&SymbolLayer::setTextHaloBlurTransition); result["text-translate"] = makePropertySetter(&SymbolLayer::setTextTranslate); + result["text-translate-transition"] = makeTransitionSetter(&SymbolLayer::setTextTranslateTransition); result["text-translate-anchor"] = makePropertySetter(&SymbolLayer::setTextTranslateAnchor); + result["text-translate-anchor-transition"] = makeTransitionSetter(&SymbolLayer::setTextTranslateAnchorTransition); result["circle-radius"] = makePropertySetter(&CircleLayer::setCircleRadius); + result["circle-radius-transition"] = makeTransitionSetter(&CircleLayer::setCircleRadiusTransition); result["circle-color"] = makePropertySetter(&CircleLayer::setCircleColor); + result["circle-color-transition"] = makeTransitionSetter(&CircleLayer::setCircleColorTransition); result["circle-blur"] = makePropertySetter(&CircleLayer::setCircleBlur); + result["circle-blur-transition"] = makeTransitionSetter(&CircleLayer::setCircleBlurTransition); result["circle-opacity"] = makePropertySetter(&CircleLayer::setCircleOpacity); + result["circle-opacity-transition"] = makeTransitionSetter(&CircleLayer::setCircleOpacityTransition); result["circle-translate"] = makePropertySetter(&CircleLayer::setCircleTranslate); + result["circle-translate-transition"] = makeTransitionSetter(&CircleLayer::setCircleTranslateTransition); result["circle-translate-anchor"] = makePropertySetter(&CircleLayer::setCircleTranslateAnchor); + result["circle-translate-anchor-transition"] = makeTransitionSetter(&CircleLayer::setCircleTranslateAnchorTransition); result["circle-pitch-scale"] = makePropertySetter(&CircleLayer::setCirclePitchScale); + result["circle-pitch-scale-transition"] = makeTransitionSetter(&CircleLayer::setCirclePitchScaleTransition); result["circle-stroke-width"] = makePropertySetter(&CircleLayer::setCircleStrokeWidth); + result["circle-stroke-width-transition"] = makeTransitionSetter(&CircleLayer::setCircleStrokeWidthTransition); result["circle-stroke-color"] = makePropertySetter(&CircleLayer::setCircleStrokeColor); + result["circle-stroke-color-transition"] = makeTransitionSetter(&CircleLayer::setCircleStrokeColorTransition); result["circle-stroke-opacity"] = makePropertySetter(&CircleLayer::setCircleStrokeOpacity); + result["circle-stroke-opacity-transition"] = makeTransitionSetter(&CircleLayer::setCircleStrokeOpacityTransition); result["fill-extrusion-opacity"] = makePropertySetter(&FillExtrusionLayer::setFillExtrusionOpacity); + result["fill-extrusion-opacity-transition"] = makeTransitionSetter(&FillExtrusionLayer::setFillExtrusionOpacityTransition); result["fill-extrusion-color"] = makePropertySetter(&FillExtrusionLayer::setFillExtrusionColor); + result["fill-extrusion-color-transition"] = makeTransitionSetter(&FillExtrusionLayer::setFillExtrusionColorTransition); result["fill-extrusion-translate"] = makePropertySetter(&FillExtrusionLayer::setFillExtrusionTranslate); + result["fill-extrusion-translate-transition"] = makeTransitionSetter(&FillExtrusionLayer::setFillExtrusionTranslateTransition); result["fill-extrusion-translate-anchor"] = makePropertySetter(&FillExtrusionLayer::setFillExtrusionTranslateAnchor); + result["fill-extrusion-translate-anchor-transition"] = makeTransitionSetter(&FillExtrusionLayer::setFillExtrusionTranslateAnchorTransition); result["fill-extrusion-pattern"] = makePropertySetter(&FillExtrusionLayer::setFillExtrusionPattern); + result["fill-extrusion-pattern-transition"] = makeTransitionSetter(&FillExtrusionLayer::setFillExtrusionPatternTransition); result["fill-extrusion-height"] = makePropertySetter(&FillExtrusionLayer::setFillExtrusionHeight); + result["fill-extrusion-height-transition"] = makeTransitionSetter(&FillExtrusionLayer::setFillExtrusionHeightTransition); result["fill-extrusion-base"] = makePropertySetter(&FillExtrusionLayer::setFillExtrusionBase); + result["fill-extrusion-base-transition"] = makeTransitionSetter(&FillExtrusionLayer::setFillExtrusionBaseTransition); result["raster-opacity"] = makePropertySetter(&RasterLayer::setRasterOpacity); + result["raster-opacity-transition"] = makeTransitionSetter(&RasterLayer::setRasterOpacityTransition); result["raster-hue-rotate"] = makePropertySetter(&RasterLayer::setRasterHueRotate); + result["raster-hue-rotate-transition"] = makeTransitionSetter(&RasterLayer::setRasterHueRotateTransition); result["raster-brightness-min"] = makePropertySetter(&RasterLayer::setRasterBrightnessMin); + result["raster-brightness-min-transition"] = makeTransitionSetter(&RasterLayer::setRasterBrightnessMinTransition); result["raster-brightness-max"] = makePropertySetter(&RasterLayer::setRasterBrightnessMax); + result["raster-brightness-max-transition"] = makeTransitionSetter(&RasterLayer::setRasterBrightnessMaxTransition); result["raster-saturation"] = makePropertySetter(&RasterLayer::setRasterSaturation); + result["raster-saturation-transition"] = makeTransitionSetter(&RasterLayer::setRasterSaturationTransition); result["raster-contrast"] = makePropertySetter(&RasterLayer::setRasterContrast); + result["raster-contrast-transition"] = makeTransitionSetter(&RasterLayer::setRasterContrastTransition); result["raster-fade-duration"] = makePropertySetter(&RasterLayer::setRasterFadeDuration); + result["raster-fade-duration-transition"] = makeTransitionSetter(&RasterLayer::setRasterFadeDurationTransition); result["background-color"] = makePropertySetter(&BackgroundLayer::setBackgroundColor); + result["background-color-transition"] = makeTransitionSetter(&BackgroundLayer::setBackgroundColorTransition); result["background-pattern"] = makePropertySetter(&BackgroundLayer::setBackgroundPattern); + result["background-pattern-transition"] = makeTransitionSetter(&BackgroundLayer::setBackgroundPatternTransition); result["background-opacity"] = makePropertySetter(&BackgroundLayer::setBackgroundOpacity); + result["background-opacity-transition"] = makeTransitionSetter(&BackgroundLayer::setBackgroundOpacityTransition); return result; } diff --git a/include/mbgl/style/conversion/make_property_setters.hpp.ejs b/include/mbgl/style/conversion/make_property_setters.hpp.ejs index ed8f6e891c4..65fbdea63e1 100644 --- a/include/mbgl/style/conversion/make_property_setters.hpp.ejs +++ b/include/mbgl/style/conversion/make_property_setters.hpp.ejs @@ -36,6 +36,7 @@ auto makePaintPropertySetters() { <% for (const layer of locals.layers) { -%> <% for (const property of layer.paintProperties) { -%> result["<%- property.name %>"] = makePropertySetter(&<%- camelize(layer.type) %>Layer::set<%- camelize(property.name) %>); + result["<%- property.name %>-transition"] = makeTransitionSetter(&<%- camelize(layer.type) %>Layer::set<%- camelize(property.name) %>Transition); <% } -%> <% } -%> diff --git a/include/mbgl/style/conversion/property_setter.hpp b/include/mbgl/style/conversion/property_setter.hpp index 52fb160fded..6a15c64026a 100644 --- a/include/mbgl/style/conversion/property_setter.hpp +++ b/include/mbgl/style/conversion/property_setter.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -37,6 +38,24 @@ auto makePropertySetter(void (L::*setter)(PropertyValue, const Args&...args)) { }; } +template +auto makeTransitionSetter(void (L::*setter)(const TransitionOptions&, const Args&...args)) { + return [setter] (Layer& layer, const V& value, const Args&...args) -> optional { + L* typedLayer = layer.as(); + if (!typedLayer) { + return Error { "layer doesn't support this property" }; + } + + Result transition = convert(value); + if (!transition) { + return transition.error(); + } + + (typedLayer->*setter)(*transition, args...); + return {}; + }; +} + template optional setVisibility(Layer& layer, const V& value) { if (isUndefined(value)) { diff --git a/include/mbgl/style/conversion/transition_options.hpp b/include/mbgl/style/conversion/transition_options.hpp new file mode 100644 index 00000000000..cdd65cfe9f3 --- /dev/null +++ b/include/mbgl/style/conversion/transition_options.hpp @@ -0,0 +1,45 @@ +#pragma once + +#include +#include + +namespace mbgl { +namespace style { +namespace conversion { + +template <> +struct Converter { +public: + template + Result operator()(const V& value) const { + if (!isObject(value)) { + return Error { "transition must be an object" }; + } + + TransitionOptions result; + + auto duration = objectMember(value, "duration"); + if (duration) { + auto number = toNumber(*duration); + if (!number) { + return Error { "duration must be a number" }; + } + result.duration = { std::chrono::milliseconds(int64_t(*number)) }; + } + + auto delay = objectMember(value, "delay"); + if (delay) { + auto number = toNumber(*delay); + if (!number) { + return Error { "delay must be a number" }; + } + result.delay = { std::chrono::milliseconds(int64_t(*number)) }; + } + + return result; + } +}; + +} // namespace conversion +} // namespace style +} // namespace mbgl diff --git a/include/mbgl/style/layers/background_layer.hpp b/include/mbgl/style/layers/background_layer.hpp index 050cb67df6b..94076931e74 100644 --- a/include/mbgl/style/layers/background_layer.hpp +++ b/include/mbgl/style/layers/background_layer.hpp @@ -12,6 +12,8 @@ namespace mbgl { namespace style { +class TransitionOptions; + class BackgroundLayer : public Layer { public: BackgroundLayer(const std::string& layerID); @@ -22,14 +24,17 @@ class BackgroundLayer : public Layer { static PropertyValue getDefaultBackgroundColor(); PropertyValue getBackgroundColor(const optional& klass = {}) const; void setBackgroundColor(PropertyValue, const optional& klass = {}); + void setBackgroundColorTransition(const TransitionOptions&, const optional& klass = {}); static PropertyValue getDefaultBackgroundPattern(); PropertyValue getBackgroundPattern(const optional& klass = {}) const; void setBackgroundPattern(PropertyValue, const optional& klass = {}); + void setBackgroundPatternTransition(const TransitionOptions&, const optional& klass = {}); static PropertyValue getDefaultBackgroundOpacity(); PropertyValue getBackgroundOpacity(const optional& klass = {}) const; void setBackgroundOpacity(PropertyValue, const optional& klass = {}); + void setBackgroundOpacityTransition(const TransitionOptions&, const optional& klass = {}); // Private implementation diff --git a/include/mbgl/style/layers/circle_layer.hpp b/include/mbgl/style/layers/circle_layer.hpp index 8ffea9946f3..35db4b3962c 100644 --- a/include/mbgl/style/layers/circle_layer.hpp +++ b/include/mbgl/style/layers/circle_layer.hpp @@ -12,6 +12,8 @@ namespace mbgl { namespace style { +class TransitionOptions; + class CircleLayer : public Layer { public: CircleLayer(const std::string& layerID, const std::string& sourceID); @@ -30,42 +32,52 @@ class CircleLayer : public Layer { static DataDrivenPropertyValue getDefaultCircleRadius(); DataDrivenPropertyValue getCircleRadius(const optional& klass = {}) const; void setCircleRadius(DataDrivenPropertyValue, const optional& klass = {}); + void setCircleRadiusTransition(const TransitionOptions&, const optional& klass = {}); static DataDrivenPropertyValue getDefaultCircleColor(); DataDrivenPropertyValue getCircleColor(const optional& klass = {}) const; void setCircleColor(DataDrivenPropertyValue, const optional& klass = {}); + void setCircleColorTransition(const TransitionOptions&, const optional& klass = {}); static DataDrivenPropertyValue getDefaultCircleBlur(); DataDrivenPropertyValue getCircleBlur(const optional& klass = {}) const; void setCircleBlur(DataDrivenPropertyValue, const optional& klass = {}); + void setCircleBlurTransition(const TransitionOptions&, const optional& klass = {}); static DataDrivenPropertyValue getDefaultCircleOpacity(); DataDrivenPropertyValue getCircleOpacity(const optional& klass = {}) const; void setCircleOpacity(DataDrivenPropertyValue, const optional& klass = {}); + void setCircleOpacityTransition(const TransitionOptions&, const optional& klass = {}); static PropertyValue> getDefaultCircleTranslate(); PropertyValue> getCircleTranslate(const optional& klass = {}) const; void setCircleTranslate(PropertyValue>, const optional& klass = {}); + void setCircleTranslateTransition(const TransitionOptions&, const optional& klass = {}); static PropertyValue getDefaultCircleTranslateAnchor(); PropertyValue getCircleTranslateAnchor(const optional& klass = {}) const; void setCircleTranslateAnchor(PropertyValue, const optional& klass = {}); + void setCircleTranslateAnchorTransition(const TransitionOptions&, const optional& klass = {}); static PropertyValue getDefaultCirclePitchScale(); PropertyValue getCirclePitchScale(const optional& klass = {}) const; void setCirclePitchScale(PropertyValue, const optional& klass = {}); + void setCirclePitchScaleTransition(const TransitionOptions&, const optional& klass = {}); static DataDrivenPropertyValue getDefaultCircleStrokeWidth(); DataDrivenPropertyValue getCircleStrokeWidth(const optional& klass = {}) const; void setCircleStrokeWidth(DataDrivenPropertyValue, const optional& klass = {}); + void setCircleStrokeWidthTransition(const TransitionOptions&, const optional& klass = {}); static DataDrivenPropertyValue getDefaultCircleStrokeColor(); DataDrivenPropertyValue getCircleStrokeColor(const optional& klass = {}) const; void setCircleStrokeColor(DataDrivenPropertyValue, const optional& klass = {}); + void setCircleStrokeColorTransition(const TransitionOptions&, const optional& klass = {}); static DataDrivenPropertyValue getDefaultCircleStrokeOpacity(); DataDrivenPropertyValue getCircleStrokeOpacity(const optional& klass = {}) const; void setCircleStrokeOpacity(DataDrivenPropertyValue, const optional& klass = {}); + void setCircleStrokeOpacityTransition(const TransitionOptions&, const optional& klass = {}); // Private implementation diff --git a/include/mbgl/style/layers/fill_extrusion_layer.hpp b/include/mbgl/style/layers/fill_extrusion_layer.hpp index 09a0040ff39..c19a4ee1686 100644 --- a/include/mbgl/style/layers/fill_extrusion_layer.hpp +++ b/include/mbgl/style/layers/fill_extrusion_layer.hpp @@ -12,6 +12,8 @@ namespace mbgl { namespace style { +class TransitionOptions; + class FillExtrusionLayer : public Layer { public: FillExtrusionLayer(const std::string& layerID, const std::string& sourceID); @@ -30,30 +32,37 @@ class FillExtrusionLayer : public Layer { static PropertyValue getDefaultFillExtrusionOpacity(); PropertyValue getFillExtrusionOpacity(const optional& klass = {}) const; void setFillExtrusionOpacity(PropertyValue, const optional& klass = {}); + void setFillExtrusionOpacityTransition(const TransitionOptions&, const optional& klass = {}); static DataDrivenPropertyValue getDefaultFillExtrusionColor(); DataDrivenPropertyValue getFillExtrusionColor(const optional& klass = {}) const; void setFillExtrusionColor(DataDrivenPropertyValue, const optional& klass = {}); + void setFillExtrusionColorTransition(const TransitionOptions&, const optional& klass = {}); static PropertyValue> getDefaultFillExtrusionTranslate(); PropertyValue> getFillExtrusionTranslate(const optional& klass = {}) const; void setFillExtrusionTranslate(PropertyValue>, const optional& klass = {}); + void setFillExtrusionTranslateTransition(const TransitionOptions&, const optional& klass = {}); static PropertyValue getDefaultFillExtrusionTranslateAnchor(); PropertyValue getFillExtrusionTranslateAnchor(const optional& klass = {}) const; void setFillExtrusionTranslateAnchor(PropertyValue, const optional& klass = {}); + void setFillExtrusionTranslateAnchorTransition(const TransitionOptions&, const optional& klass = {}); static PropertyValue getDefaultFillExtrusionPattern(); PropertyValue getFillExtrusionPattern(const optional& klass = {}) const; void setFillExtrusionPattern(PropertyValue, const optional& klass = {}); + void setFillExtrusionPatternTransition(const TransitionOptions&, const optional& klass = {}); static DataDrivenPropertyValue getDefaultFillExtrusionHeight(); DataDrivenPropertyValue getFillExtrusionHeight(const optional& klass = {}) const; void setFillExtrusionHeight(DataDrivenPropertyValue, const optional& klass = {}); + void setFillExtrusionHeightTransition(const TransitionOptions&, const optional& klass = {}); static DataDrivenPropertyValue getDefaultFillExtrusionBase(); DataDrivenPropertyValue getFillExtrusionBase(const optional& klass = {}) const; void setFillExtrusionBase(DataDrivenPropertyValue, const optional& klass = {}); + void setFillExtrusionBaseTransition(const TransitionOptions&, const optional& klass = {}); // Private implementation diff --git a/include/mbgl/style/layers/fill_layer.hpp b/include/mbgl/style/layers/fill_layer.hpp index 079541ec393..c064eab3505 100644 --- a/include/mbgl/style/layers/fill_layer.hpp +++ b/include/mbgl/style/layers/fill_layer.hpp @@ -12,6 +12,8 @@ namespace mbgl { namespace style { +class TransitionOptions; + class FillLayer : public Layer { public: FillLayer(const std::string& layerID, const std::string& sourceID); @@ -30,30 +32,37 @@ class FillLayer : public Layer { static PropertyValue getDefaultFillAntialias(); PropertyValue getFillAntialias(const optional& klass = {}) const; void setFillAntialias(PropertyValue, const optional& klass = {}); + void setFillAntialiasTransition(const TransitionOptions&, const optional& klass = {}); static DataDrivenPropertyValue getDefaultFillOpacity(); DataDrivenPropertyValue getFillOpacity(const optional& klass = {}) const; void setFillOpacity(DataDrivenPropertyValue, const optional& klass = {}); + void setFillOpacityTransition(const TransitionOptions&, const optional& klass = {}); static DataDrivenPropertyValue getDefaultFillColor(); DataDrivenPropertyValue getFillColor(const optional& klass = {}) const; void setFillColor(DataDrivenPropertyValue, const optional& klass = {}); + void setFillColorTransition(const TransitionOptions&, const optional& klass = {}); static DataDrivenPropertyValue getDefaultFillOutlineColor(); DataDrivenPropertyValue getFillOutlineColor(const optional& klass = {}) const; void setFillOutlineColor(DataDrivenPropertyValue, const optional& klass = {}); + void setFillOutlineColorTransition(const TransitionOptions&, const optional& klass = {}); static PropertyValue> getDefaultFillTranslate(); PropertyValue> getFillTranslate(const optional& klass = {}) const; void setFillTranslate(PropertyValue>, const optional& klass = {}); + void setFillTranslateTransition(const TransitionOptions&, const optional& klass = {}); static PropertyValue getDefaultFillTranslateAnchor(); PropertyValue getFillTranslateAnchor(const optional& klass = {}) const; void setFillTranslateAnchor(PropertyValue, const optional& klass = {}); + void setFillTranslateAnchorTransition(const TransitionOptions&, const optional& klass = {}); static PropertyValue getDefaultFillPattern(); PropertyValue getFillPattern(const optional& klass = {}) const; void setFillPattern(PropertyValue, const optional& klass = {}); + void setFillPatternTransition(const TransitionOptions&, const optional& klass = {}); // Private implementation diff --git a/include/mbgl/style/layers/layer.hpp.ejs b/include/mbgl/style/layers/layer.hpp.ejs index 0c902de5af4..d66eae8198d 100644 --- a/include/mbgl/style/layers/layer.hpp.ejs +++ b/include/mbgl/style/layers/layer.hpp.ejs @@ -21,6 +21,8 @@ namespace mbgl { namespace style { +class TransitionOptions; + class <%- camelize(type) %>Layer : public Layer { public: <% if (type === 'background') { -%> @@ -58,6 +60,7 @@ public: static <%- propertyValueType(property) %> getDefault<%- camelize(property.name) %>(); <%- propertyValueType(property) %> get<%- camelize(property.name) %>(const optional& klass = {}) const; void set<%- camelize(property.name) %>(<%- propertyValueType(property) %>, const optional& klass = {}); + void set<%- camelize(property.name) %>Transition(const TransitionOptions&, const optional& klass = {}); <% } -%> // Private implementation diff --git a/include/mbgl/style/layers/line_layer.hpp b/include/mbgl/style/layers/line_layer.hpp index c9413f10968..2ed269ae742 100644 --- a/include/mbgl/style/layers/line_layer.hpp +++ b/include/mbgl/style/layers/line_layer.hpp @@ -14,6 +14,8 @@ namespace mbgl { namespace style { +class TransitionOptions; + class LineLayer : public Layer { public: LineLayer(const std::string& layerID, const std::string& sourceID); @@ -50,42 +52,52 @@ class LineLayer : public Layer { static DataDrivenPropertyValue getDefaultLineOpacity(); DataDrivenPropertyValue getLineOpacity(const optional& klass = {}) const; void setLineOpacity(DataDrivenPropertyValue, const optional& klass = {}); + void setLineOpacityTransition(const TransitionOptions&, const optional& klass = {}); static DataDrivenPropertyValue getDefaultLineColor(); DataDrivenPropertyValue getLineColor(const optional& klass = {}) const; void setLineColor(DataDrivenPropertyValue, const optional& klass = {}); + void setLineColorTransition(const TransitionOptions&, const optional& klass = {}); static PropertyValue> getDefaultLineTranslate(); PropertyValue> getLineTranslate(const optional& klass = {}) const; void setLineTranslate(PropertyValue>, const optional& klass = {}); + void setLineTranslateTransition(const TransitionOptions&, const optional& klass = {}); static PropertyValue getDefaultLineTranslateAnchor(); PropertyValue getLineTranslateAnchor(const optional& klass = {}) const; void setLineTranslateAnchor(PropertyValue, const optional& klass = {}); + void setLineTranslateAnchorTransition(const TransitionOptions&, const optional& klass = {}); static PropertyValue getDefaultLineWidth(); PropertyValue getLineWidth(const optional& klass = {}) const; void setLineWidth(PropertyValue, const optional& klass = {}); + void setLineWidthTransition(const TransitionOptions&, const optional& klass = {}); static DataDrivenPropertyValue getDefaultLineGapWidth(); DataDrivenPropertyValue getLineGapWidth(const optional& klass = {}) const; void setLineGapWidth(DataDrivenPropertyValue, const optional& klass = {}); + void setLineGapWidthTransition(const TransitionOptions&, const optional& klass = {}); static DataDrivenPropertyValue getDefaultLineOffset(); DataDrivenPropertyValue getLineOffset(const optional& klass = {}) const; void setLineOffset(DataDrivenPropertyValue, const optional& klass = {}); + void setLineOffsetTransition(const TransitionOptions&, const optional& klass = {}); static DataDrivenPropertyValue getDefaultLineBlur(); DataDrivenPropertyValue getLineBlur(const optional& klass = {}) const; void setLineBlur(DataDrivenPropertyValue, const optional& klass = {}); + void setLineBlurTransition(const TransitionOptions&, const optional& klass = {}); static PropertyValue> getDefaultLineDasharray(); PropertyValue> getLineDasharray(const optional& klass = {}) const; void setLineDasharray(PropertyValue>, const optional& klass = {}); + void setLineDasharrayTransition(const TransitionOptions&, const optional& klass = {}); static PropertyValue getDefaultLinePattern(); PropertyValue getLinePattern(const optional& klass = {}) const; void setLinePattern(PropertyValue, const optional& klass = {}); + void setLinePatternTransition(const TransitionOptions&, const optional& klass = {}); // Private implementation diff --git a/include/mbgl/style/layers/raster_layer.hpp b/include/mbgl/style/layers/raster_layer.hpp index e998abf12a8..72665baa721 100644 --- a/include/mbgl/style/layers/raster_layer.hpp +++ b/include/mbgl/style/layers/raster_layer.hpp @@ -12,6 +12,8 @@ namespace mbgl { namespace style { +class TransitionOptions; + class RasterLayer : public Layer { public: RasterLayer(const std::string& layerID, const std::string& sourceID); @@ -25,30 +27,37 @@ class RasterLayer : public Layer { static PropertyValue getDefaultRasterOpacity(); PropertyValue getRasterOpacity(const optional& klass = {}) const; void setRasterOpacity(PropertyValue, const optional& klass = {}); + void setRasterOpacityTransition(const TransitionOptions&, const optional& klass = {}); static PropertyValue getDefaultRasterHueRotate(); PropertyValue getRasterHueRotate(const optional& klass = {}) const; void setRasterHueRotate(PropertyValue, const optional& klass = {}); + void setRasterHueRotateTransition(const TransitionOptions&, const optional& klass = {}); static PropertyValue getDefaultRasterBrightnessMin(); PropertyValue getRasterBrightnessMin(const optional& klass = {}) const; void setRasterBrightnessMin(PropertyValue, const optional& klass = {}); + void setRasterBrightnessMinTransition(const TransitionOptions&, const optional& klass = {}); static PropertyValue getDefaultRasterBrightnessMax(); PropertyValue getRasterBrightnessMax(const optional& klass = {}) const; void setRasterBrightnessMax(PropertyValue, const optional& klass = {}); + void setRasterBrightnessMaxTransition(const TransitionOptions&, const optional& klass = {}); static PropertyValue getDefaultRasterSaturation(); PropertyValue getRasterSaturation(const optional& klass = {}) const; void setRasterSaturation(PropertyValue, const optional& klass = {}); + void setRasterSaturationTransition(const TransitionOptions&, const optional& klass = {}); static PropertyValue getDefaultRasterContrast(); PropertyValue getRasterContrast(const optional& klass = {}) const; void setRasterContrast(PropertyValue, const optional& klass = {}); + void setRasterContrastTransition(const TransitionOptions&, const optional& klass = {}); static PropertyValue getDefaultRasterFadeDuration(); PropertyValue getRasterFadeDuration(const optional& klass = {}) const; void setRasterFadeDuration(PropertyValue, const optional& klass = {}); + void setRasterFadeDurationTransition(const TransitionOptions&, const optional& klass = {}); // Private implementation diff --git a/include/mbgl/style/layers/symbol_layer.hpp b/include/mbgl/style/layers/symbol_layer.hpp index 8826408e810..ad21a70698d 100644 --- a/include/mbgl/style/layers/symbol_layer.hpp +++ b/include/mbgl/style/layers/symbol_layer.hpp @@ -14,6 +14,8 @@ namespace mbgl { namespace style { +class TransitionOptions; + class SymbolLayer : public Layer { public: SymbolLayer(const std::string& layerID, const std::string& sourceID); @@ -170,58 +172,72 @@ class SymbolLayer : public Layer { static PropertyValue getDefaultIconOpacity(); PropertyValue getIconOpacity(const optional& klass = {}) const; void setIconOpacity(PropertyValue, const optional& klass = {}); + void setIconOpacityTransition(const TransitionOptions&, const optional& klass = {}); static PropertyValue getDefaultIconColor(); PropertyValue getIconColor(const optional& klass = {}) const; void setIconColor(PropertyValue, const optional& klass = {}); + void setIconColorTransition(const TransitionOptions&, const optional& klass = {}); static PropertyValue getDefaultIconHaloColor(); PropertyValue getIconHaloColor(const optional& klass = {}) const; void setIconHaloColor(PropertyValue, const optional& klass = {}); + void setIconHaloColorTransition(const TransitionOptions&, const optional& klass = {}); static PropertyValue getDefaultIconHaloWidth(); PropertyValue getIconHaloWidth(const optional& klass = {}) const; void setIconHaloWidth(PropertyValue, const optional& klass = {}); + void setIconHaloWidthTransition(const TransitionOptions&, const optional& klass = {}); static PropertyValue getDefaultIconHaloBlur(); PropertyValue getIconHaloBlur(const optional& klass = {}) const; void setIconHaloBlur(PropertyValue, const optional& klass = {}); + void setIconHaloBlurTransition(const TransitionOptions&, const optional& klass = {}); static PropertyValue> getDefaultIconTranslate(); PropertyValue> getIconTranslate(const optional& klass = {}) const; void setIconTranslate(PropertyValue>, const optional& klass = {}); + void setIconTranslateTransition(const TransitionOptions&, const optional& klass = {}); static PropertyValue getDefaultIconTranslateAnchor(); PropertyValue getIconTranslateAnchor(const optional& klass = {}) const; void setIconTranslateAnchor(PropertyValue, const optional& klass = {}); + void setIconTranslateAnchorTransition(const TransitionOptions&, const optional& klass = {}); static PropertyValue getDefaultTextOpacity(); PropertyValue getTextOpacity(const optional& klass = {}) const; void setTextOpacity(PropertyValue, const optional& klass = {}); + void setTextOpacityTransition(const TransitionOptions&, const optional& klass = {}); static PropertyValue getDefaultTextColor(); PropertyValue getTextColor(const optional& klass = {}) const; void setTextColor(PropertyValue, const optional& klass = {}); + void setTextColorTransition(const TransitionOptions&, const optional& klass = {}); static PropertyValue getDefaultTextHaloColor(); PropertyValue getTextHaloColor(const optional& klass = {}) const; void setTextHaloColor(PropertyValue, const optional& klass = {}); + void setTextHaloColorTransition(const TransitionOptions&, const optional& klass = {}); static PropertyValue getDefaultTextHaloWidth(); PropertyValue getTextHaloWidth(const optional& klass = {}) const; void setTextHaloWidth(PropertyValue, const optional& klass = {}); + void setTextHaloWidthTransition(const TransitionOptions&, const optional& klass = {}); static PropertyValue getDefaultTextHaloBlur(); PropertyValue getTextHaloBlur(const optional& klass = {}) const; void setTextHaloBlur(PropertyValue, const optional& klass = {}); + void setTextHaloBlurTransition(const TransitionOptions&, const optional& klass = {}); static PropertyValue> getDefaultTextTranslate(); PropertyValue> getTextTranslate(const optional& klass = {}) const; void setTextTranslate(PropertyValue>, const optional& klass = {}); + void setTextTranslateTransition(const TransitionOptions&, const optional& klass = {}); static PropertyValue getDefaultTextTranslateAnchor(); PropertyValue getTextTranslateAnchor(const optional& klass = {}) const; void setTextTranslateAnchor(PropertyValue, const optional& klass = {}); + void setTextTranslateAnchorTransition(const TransitionOptions&, const optional& klass = {}); // Private implementation diff --git a/src/mbgl/style/layers/background_layer.cpp b/src/mbgl/style/layers/background_layer.cpp index a75038bfa0b..5a903f1b6b0 100644 --- a/src/mbgl/style/layers/background_layer.cpp +++ b/src/mbgl/style/layers/background_layer.cpp @@ -55,6 +55,10 @@ void BackgroundLayer::setBackgroundColor(PropertyValue value, const optio impl->observer->onLayerPaintPropertyChanged(*this); } +void BackgroundLayer::setBackgroundColorTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + PropertyValue BackgroundLayer::getDefaultBackgroundPattern() { return { "" }; } @@ -70,6 +74,10 @@ void BackgroundLayer::setBackgroundPattern(PropertyValue value, con impl->observer->onLayerPaintPropertyChanged(*this); } +void BackgroundLayer::setBackgroundPatternTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + PropertyValue BackgroundLayer::getDefaultBackgroundOpacity() { return { 1 }; } @@ -85,5 +93,9 @@ void BackgroundLayer::setBackgroundOpacity(PropertyValue value, const opt impl->observer->onLayerPaintPropertyChanged(*this); } +void BackgroundLayer::setBackgroundOpacityTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + } // namespace style } // namespace mbgl diff --git a/src/mbgl/style/layers/circle_layer.cpp b/src/mbgl/style/layers/circle_layer.cpp index f8d06e26441..53248e93979 100644 --- a/src/mbgl/style/layers/circle_layer.cpp +++ b/src/mbgl/style/layers/circle_layer.cpp @@ -84,6 +84,10 @@ void CircleLayer::setCircleRadius(DataDrivenPropertyValue value, const op } } +void CircleLayer::setCircleRadiusTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + DataDrivenPropertyValue CircleLayer::getDefaultCircleColor() { return { Color::black() }; } @@ -103,6 +107,10 @@ void CircleLayer::setCircleColor(DataDrivenPropertyValue value, const opt } } +void CircleLayer::setCircleColorTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + DataDrivenPropertyValue CircleLayer::getDefaultCircleBlur() { return { 0 }; } @@ -122,6 +130,10 @@ void CircleLayer::setCircleBlur(DataDrivenPropertyValue value, const opti } } +void CircleLayer::setCircleBlurTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + DataDrivenPropertyValue CircleLayer::getDefaultCircleOpacity() { return { 1 }; } @@ -141,6 +153,10 @@ void CircleLayer::setCircleOpacity(DataDrivenPropertyValue value, const o } } +void CircleLayer::setCircleOpacityTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + PropertyValue> CircleLayer::getDefaultCircleTranslate() { return { {{ 0, 0 }} }; } @@ -156,6 +172,10 @@ void CircleLayer::setCircleTranslate(PropertyValue> value, impl->observer->onLayerPaintPropertyChanged(*this); } +void CircleLayer::setCircleTranslateTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + PropertyValue CircleLayer::getDefaultCircleTranslateAnchor() { return { TranslateAnchorType::Map }; } @@ -171,6 +191,10 @@ void CircleLayer::setCircleTranslateAnchor(PropertyValue va impl->observer->onLayerPaintPropertyChanged(*this); } +void CircleLayer::setCircleTranslateAnchorTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + PropertyValue CircleLayer::getDefaultCirclePitchScale() { return { CirclePitchScaleType::Map }; } @@ -186,6 +210,10 @@ void CircleLayer::setCirclePitchScale(PropertyValue value, impl->observer->onLayerPaintPropertyChanged(*this); } +void CircleLayer::setCirclePitchScaleTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + DataDrivenPropertyValue CircleLayer::getDefaultCircleStrokeWidth() { return { 0 }; } @@ -205,6 +233,10 @@ void CircleLayer::setCircleStrokeWidth(DataDrivenPropertyValue value, con } } +void CircleLayer::setCircleStrokeWidthTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + DataDrivenPropertyValue CircleLayer::getDefaultCircleStrokeColor() { return { Color::black() }; } @@ -224,6 +256,10 @@ void CircleLayer::setCircleStrokeColor(DataDrivenPropertyValue value, con } } +void CircleLayer::setCircleStrokeColorTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + DataDrivenPropertyValue CircleLayer::getDefaultCircleStrokeOpacity() { return { 1 }; } @@ -243,5 +279,9 @@ void CircleLayer::setCircleStrokeOpacity(DataDrivenPropertyValue value, c } } +void CircleLayer::setCircleStrokeOpacityTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + } // namespace style } // namespace mbgl diff --git a/src/mbgl/style/layers/fill_extrusion_layer.cpp b/src/mbgl/style/layers/fill_extrusion_layer.cpp index 0ef5c9bcbc5..4672ede9b8b 100644 --- a/src/mbgl/style/layers/fill_extrusion_layer.cpp +++ b/src/mbgl/style/layers/fill_extrusion_layer.cpp @@ -80,6 +80,10 @@ void FillExtrusionLayer::setFillExtrusionOpacity(PropertyValue value, con impl->observer->onLayerPaintPropertyChanged(*this); } +void FillExtrusionLayer::setFillExtrusionOpacityTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + DataDrivenPropertyValue FillExtrusionLayer::getDefaultFillExtrusionColor() { return { Color::black() }; } @@ -99,6 +103,10 @@ void FillExtrusionLayer::setFillExtrusionColor(DataDrivenPropertyValue va } } +void FillExtrusionLayer::setFillExtrusionColorTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + PropertyValue> FillExtrusionLayer::getDefaultFillExtrusionTranslate() { return { {{ 0, 0 }} }; } @@ -114,6 +122,10 @@ void FillExtrusionLayer::setFillExtrusionTranslate(PropertyValueobserver->onLayerPaintPropertyChanged(*this); } +void FillExtrusionLayer::setFillExtrusionTranslateTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + PropertyValue FillExtrusionLayer::getDefaultFillExtrusionTranslateAnchor() { return { TranslateAnchorType::Map }; } @@ -129,6 +141,10 @@ void FillExtrusionLayer::setFillExtrusionTranslateAnchor(PropertyValueobserver->onLayerPaintPropertyChanged(*this); } +void FillExtrusionLayer::setFillExtrusionTranslateAnchorTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + PropertyValue FillExtrusionLayer::getDefaultFillExtrusionPattern() { return { "" }; } @@ -144,6 +160,10 @@ void FillExtrusionLayer::setFillExtrusionPattern(PropertyValue valu impl->observer->onLayerPaintPropertyChanged(*this); } +void FillExtrusionLayer::setFillExtrusionPatternTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + DataDrivenPropertyValue FillExtrusionLayer::getDefaultFillExtrusionHeight() { return { 0 }; } @@ -163,6 +183,10 @@ void FillExtrusionLayer::setFillExtrusionHeight(DataDrivenPropertyValue v } } +void FillExtrusionLayer::setFillExtrusionHeightTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + DataDrivenPropertyValue FillExtrusionLayer::getDefaultFillExtrusionBase() { return { 0 }; } @@ -182,5 +206,9 @@ void FillExtrusionLayer::setFillExtrusionBase(DataDrivenPropertyValue val } } +void FillExtrusionLayer::setFillExtrusionBaseTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + } // namespace style } // namespace mbgl diff --git a/src/mbgl/style/layers/fill_layer.cpp b/src/mbgl/style/layers/fill_layer.cpp index e1c0d4d243a..dfa88b5b0f0 100644 --- a/src/mbgl/style/layers/fill_layer.cpp +++ b/src/mbgl/style/layers/fill_layer.cpp @@ -80,6 +80,10 @@ void FillLayer::setFillAntialias(PropertyValue value, const optionalobserver->onLayerPaintPropertyChanged(*this); } +void FillLayer::setFillAntialiasTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + DataDrivenPropertyValue FillLayer::getDefaultFillOpacity() { return { 1 }; } @@ -99,6 +103,10 @@ void FillLayer::setFillOpacity(DataDrivenPropertyValue value, const optio } } +void FillLayer::setFillOpacityTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + DataDrivenPropertyValue FillLayer::getDefaultFillColor() { return { Color::black() }; } @@ -118,6 +126,10 @@ void FillLayer::setFillColor(DataDrivenPropertyValue value, const optiona } } +void FillLayer::setFillColorTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + DataDrivenPropertyValue FillLayer::getDefaultFillOutlineColor() { return { {} }; } @@ -137,6 +149,10 @@ void FillLayer::setFillOutlineColor(DataDrivenPropertyValue value, const } } +void FillLayer::setFillOutlineColorTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + PropertyValue> FillLayer::getDefaultFillTranslate() { return { {{ 0, 0 }} }; } @@ -152,6 +168,10 @@ void FillLayer::setFillTranslate(PropertyValue> value, cons impl->observer->onLayerPaintPropertyChanged(*this); } +void FillLayer::setFillTranslateTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + PropertyValue FillLayer::getDefaultFillTranslateAnchor() { return { TranslateAnchorType::Map }; } @@ -167,6 +187,10 @@ void FillLayer::setFillTranslateAnchor(PropertyValue value, impl->observer->onLayerPaintPropertyChanged(*this); } +void FillLayer::setFillTranslateAnchorTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + PropertyValue FillLayer::getDefaultFillPattern() { return { "" }; } @@ -182,5 +206,9 @@ void FillLayer::setFillPattern(PropertyValue value, const optional< impl->observer->onLayerPaintPropertyChanged(*this); } +void FillLayer::setFillPatternTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + } // namespace style } // namespace mbgl diff --git a/src/mbgl/style/layers/layer.cpp.ejs b/src/mbgl/style/layers/layer.cpp.ejs index 4a91a5c7e3c..335573abf3e 100644 --- a/src/mbgl/style/layers/layer.cpp.ejs +++ b/src/mbgl/style/layers/layer.cpp.ejs @@ -126,6 +126,10 @@ void <%- camelize(type) %>Layer::set<%- camelize(property.name) %>(<%- propertyV impl->observer->onLayerPaintPropertyChanged(*this); <% } -%> } + +void <%- camelize(type) %>Layer::set<%- camelize(property.name) %>Transition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition<<%- camelize(property.name) %>>(value, klass); +} <% } -%> } // namespace style diff --git a/src/mbgl/style/layers/line_layer.cpp b/src/mbgl/style/layers/line_layer.cpp index fcad1eacb6b..eaaa0fcd45e 100644 --- a/src/mbgl/style/layers/line_layer.cpp +++ b/src/mbgl/style/layers/line_layer.cpp @@ -141,6 +141,10 @@ void LineLayer::setLineOpacity(DataDrivenPropertyValue value, const optio } } +void LineLayer::setLineOpacityTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + DataDrivenPropertyValue LineLayer::getDefaultLineColor() { return { Color::black() }; } @@ -160,6 +164,10 @@ void LineLayer::setLineColor(DataDrivenPropertyValue value, const optiona } } +void LineLayer::setLineColorTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + PropertyValue> LineLayer::getDefaultLineTranslate() { return { {{ 0, 0 }} }; } @@ -175,6 +183,10 @@ void LineLayer::setLineTranslate(PropertyValue> value, cons impl->observer->onLayerPaintPropertyChanged(*this); } +void LineLayer::setLineTranslateTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + PropertyValue LineLayer::getDefaultLineTranslateAnchor() { return { TranslateAnchorType::Map }; } @@ -190,6 +202,10 @@ void LineLayer::setLineTranslateAnchor(PropertyValue value, impl->observer->onLayerPaintPropertyChanged(*this); } +void LineLayer::setLineTranslateAnchorTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + PropertyValue LineLayer::getDefaultLineWidth() { return { 1 }; } @@ -205,6 +221,10 @@ void LineLayer::setLineWidth(PropertyValue value, const optionalobserver->onLayerPaintPropertyChanged(*this); } +void LineLayer::setLineWidthTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + DataDrivenPropertyValue LineLayer::getDefaultLineGapWidth() { return { 0 }; } @@ -224,6 +244,10 @@ void LineLayer::setLineGapWidth(DataDrivenPropertyValue value, const opti } } +void LineLayer::setLineGapWidthTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + DataDrivenPropertyValue LineLayer::getDefaultLineOffset() { return { 0 }; } @@ -243,6 +267,10 @@ void LineLayer::setLineOffset(DataDrivenPropertyValue value, const option } } +void LineLayer::setLineOffsetTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + DataDrivenPropertyValue LineLayer::getDefaultLineBlur() { return { 0 }; } @@ -262,6 +290,10 @@ void LineLayer::setLineBlur(DataDrivenPropertyValue value, const optional } } +void LineLayer::setLineBlurTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + PropertyValue> LineLayer::getDefaultLineDasharray() { return { { } }; } @@ -277,6 +309,10 @@ void LineLayer::setLineDasharray(PropertyValue> value, const impl->observer->onLayerPaintPropertyChanged(*this); } +void LineLayer::setLineDasharrayTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + PropertyValue LineLayer::getDefaultLinePattern() { return { "" }; } @@ -292,5 +328,9 @@ void LineLayer::setLinePattern(PropertyValue value, const optional< impl->observer->onLayerPaintPropertyChanged(*this); } +void LineLayer::setLinePatternTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + } // namespace style } // namespace mbgl diff --git a/src/mbgl/style/layers/raster_layer.cpp b/src/mbgl/style/layers/raster_layer.cpp index 0fda27f0dc3..2108a5c49f3 100644 --- a/src/mbgl/style/layers/raster_layer.cpp +++ b/src/mbgl/style/layers/raster_layer.cpp @@ -62,6 +62,10 @@ void RasterLayer::setRasterOpacity(PropertyValue value, const optionalobserver->onLayerPaintPropertyChanged(*this); } +void RasterLayer::setRasterOpacityTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + PropertyValue RasterLayer::getDefaultRasterHueRotate() { return { 0 }; } @@ -77,6 +81,10 @@ void RasterLayer::setRasterHueRotate(PropertyValue value, const optional< impl->observer->onLayerPaintPropertyChanged(*this); } +void RasterLayer::setRasterHueRotateTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + PropertyValue RasterLayer::getDefaultRasterBrightnessMin() { return { 0 }; } @@ -92,6 +100,10 @@ void RasterLayer::setRasterBrightnessMin(PropertyValue value, const optio impl->observer->onLayerPaintPropertyChanged(*this); } +void RasterLayer::setRasterBrightnessMinTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + PropertyValue RasterLayer::getDefaultRasterBrightnessMax() { return { 1 }; } @@ -107,6 +119,10 @@ void RasterLayer::setRasterBrightnessMax(PropertyValue value, const optio impl->observer->onLayerPaintPropertyChanged(*this); } +void RasterLayer::setRasterBrightnessMaxTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + PropertyValue RasterLayer::getDefaultRasterSaturation() { return { 0 }; } @@ -122,6 +138,10 @@ void RasterLayer::setRasterSaturation(PropertyValue value, const optional impl->observer->onLayerPaintPropertyChanged(*this); } +void RasterLayer::setRasterSaturationTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + PropertyValue RasterLayer::getDefaultRasterContrast() { return { 0 }; } @@ -137,6 +157,10 @@ void RasterLayer::setRasterContrast(PropertyValue value, const optionalobserver->onLayerPaintPropertyChanged(*this); } +void RasterLayer::setRasterContrastTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + PropertyValue RasterLayer::getDefaultRasterFadeDuration() { return { 300 }; } @@ -152,5 +176,9 @@ void RasterLayer::setRasterFadeDuration(PropertyValue value, const option impl->observer->onLayerPaintPropertyChanged(*this); } +void RasterLayer::setRasterFadeDurationTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + } // namespace style } // namespace mbgl diff --git a/src/mbgl/style/layers/symbol_layer.cpp b/src/mbgl/style/layers/symbol_layer.cpp index 94c47f48b76..94167f57053 100644 --- a/src/mbgl/style/layers/symbol_layer.cpp +++ b/src/mbgl/style/layers/symbol_layer.cpp @@ -557,6 +557,10 @@ void SymbolLayer::setIconOpacity(PropertyValue value, const optionalobserver->onLayerPaintPropertyChanged(*this); } +void SymbolLayer::setIconOpacityTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + PropertyValue SymbolLayer::getDefaultIconColor() { return { Color::black() }; } @@ -572,6 +576,10 @@ void SymbolLayer::setIconColor(PropertyValue value, const optionalobserver->onLayerPaintPropertyChanged(*this); } +void SymbolLayer::setIconColorTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + PropertyValue SymbolLayer::getDefaultIconHaloColor() { return { {} }; } @@ -587,6 +595,10 @@ void SymbolLayer::setIconHaloColor(PropertyValue value, const optionalobserver->onLayerPaintPropertyChanged(*this); } +void SymbolLayer::setIconHaloColorTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + PropertyValue SymbolLayer::getDefaultIconHaloWidth() { return { 0 }; } @@ -602,6 +614,10 @@ void SymbolLayer::setIconHaloWidth(PropertyValue value, const optionalobserver->onLayerPaintPropertyChanged(*this); } +void SymbolLayer::setIconHaloWidthTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + PropertyValue SymbolLayer::getDefaultIconHaloBlur() { return { 0 }; } @@ -617,6 +633,10 @@ void SymbolLayer::setIconHaloBlur(PropertyValue value, const optionalobserver->onLayerPaintPropertyChanged(*this); } +void SymbolLayer::setIconHaloBlurTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + PropertyValue> SymbolLayer::getDefaultIconTranslate() { return { {{ 0, 0 }} }; } @@ -632,6 +652,10 @@ void SymbolLayer::setIconTranslate(PropertyValue> value, co impl->observer->onLayerPaintPropertyChanged(*this); } +void SymbolLayer::setIconTranslateTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + PropertyValue SymbolLayer::getDefaultIconTranslateAnchor() { return { TranslateAnchorType::Map }; } @@ -651,6 +675,10 @@ PropertyValue SymbolLayer::getDefaultTextOpacity() { return { 1 }; } +void SymbolLayer::setIconTranslateAnchorTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + PropertyValue SymbolLayer::getTextOpacity(const optional& klass) const { return impl->paint.get(klass); } @@ -666,6 +694,10 @@ PropertyValue SymbolLayer::getDefaultTextColor() { return { Color::black() }; } +void SymbolLayer::setTextOpacityTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + PropertyValue SymbolLayer::getTextColor(const optional& klass) const { return impl->paint.get(klass); } @@ -677,6 +709,10 @@ void SymbolLayer::setTextColor(PropertyValue value, const optionalobserver->onLayerPaintPropertyChanged(*this); } +void SymbolLayer::setTextColorTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + PropertyValue SymbolLayer::getDefaultTextHaloColor() { return { {} }; } @@ -692,6 +728,10 @@ void SymbolLayer::setTextHaloColor(PropertyValue value, const optionalobserver->onLayerPaintPropertyChanged(*this); } +void SymbolLayer::setTextHaloColorTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + PropertyValue SymbolLayer::getDefaultTextHaloWidth() { return { 0 }; } @@ -707,6 +747,10 @@ void SymbolLayer::setTextHaloWidth(PropertyValue value, const optionalobserver->onLayerPaintPropertyChanged(*this); } +void SymbolLayer::setTextHaloWidthTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + PropertyValue SymbolLayer::getDefaultTextHaloBlur() { return { 0 }; } @@ -722,6 +766,10 @@ void SymbolLayer::setTextHaloBlur(PropertyValue value, const optionalobserver->onLayerPaintPropertyChanged(*this); } +void SymbolLayer::setTextHaloBlurTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + PropertyValue> SymbolLayer::getDefaultTextTranslate() { return { {{ 0, 0 }} }; } @@ -737,6 +785,10 @@ void SymbolLayer::setTextTranslate(PropertyValue> value, co impl->observer->onLayerPaintPropertyChanged(*this); } +void SymbolLayer::setTextTranslateTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + PropertyValue SymbolLayer::getDefaultTextTranslateAnchor() { return { TranslateAnchorType::Map }; } @@ -752,5 +804,9 @@ void SymbolLayer::setTextTranslateAnchor(PropertyValue valu impl->observer->onLayerPaintPropertyChanged(*this); } +void SymbolLayer::setTextTranslateAnchorTransition(const TransitionOptions& value, const optional& klass) { + impl->paint.setTransition(value, klass); +} + } // namespace style } // namespace mbgl diff --git a/src/mbgl/style/paint_property.hpp b/src/mbgl/style/paint_property.hpp index 9031d590fe7..1fa2390f339 100644 --- a/src/mbgl/style/paint_property.hpp +++ b/src/mbgl/style/paint_property.hpp @@ -97,6 +97,12 @@ class CascadingPaintProperty { values[klass ? ClassDictionary::Get().lookup(*klass) : ClassID::Default] = value_; } + const TransitionOptions& getTransition(const optional& klass) const { + static const TransitionOptions staticValue{}; + const auto it = transitions.find(klass ? ClassDictionary::Get().lookup(*klass) : ClassID::Default); + return it == transitions.end() ? staticValue : it->second; + } + void setTransition(const TransitionOptions& transition, const optional& klass) { transitions[klass ? ClassDictionary::Get().lookup(*klass) : ClassID::Default] = transition; } @@ -209,6 +215,11 @@ class PaintProperties { cascading.template get

().set(value, klass); } + template + void setTransition(const TransitionOptions& value, const optional& klass) { + cascading.template get

().setTransition(value, klass); + } + void cascade(const CascadeParameters& parameters) { unevaluated = Unevaluated { cascading.template get().cascade(parameters, diff --git a/test/style/conversion/layer.test.cpp b/test/style/conversion/layer.test.cpp new file mode 100644 index 00000000000..b27c1841ee6 --- /dev/null +++ b/test/style/conversion/layer.test.cpp @@ -0,0 +1,46 @@ +#include + +#include +#include +#include +#include +#include + +using namespace mbgl; +using namespace mbgl::style; +using namespace mbgl::style::conversion; +using namespace std::literals::chrono_literals; + +auto parseLayer(const std::string& src) { + JSDocument doc; + doc.Parse<0>(src); + return convert, JSValue>(doc); +} + +TEST(StyleConversion, LayerTransition) { + auto layer = parseLayer(R"JSON({ + "type": "background", + "id": "background", + "paint": { + "background-color-transition": { + "duration": 400, + "delay": 500 + } + }, + "paint.class": { + "background-color-transition": { + "duration": 100 + } + } + })JSON"); + + ASSERT_EQ(400ms, *(*layer)->as()->impl->paint.cascading + .get().getTransition({}).duration); + ASSERT_EQ(500ms, *(*layer)->as()->impl->paint.cascading + .get().getTransition({}).delay); + + ASSERT_EQ(100ms, *(*layer)->as()->impl->paint.cascading + .get().getTransition({"class"}).duration); + ASSERT_FALSE(bool((*layer)->as()->impl->paint.cascading + .get().getTransition({"class"}).delay)); +}