summaryrefslogtreecommitdiff
path: root/src/mbgl/style
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2018-11-28 11:29:50 +0200
committerBruno de Oliveira Abinader <bruno@mapbox.com>2018-11-29 14:23:55 +0200
commite64c28613a3e2f0ee9591ab412a466d52ca17551 (patch)
tree914cc344412361849746808ae150a6a2718ec718 /src/mbgl/style
parent217acb894893f64c35a876f573cc616321cfeafd (diff)
downloadqtlocation-mapboxgl-e64c28613a3e2f0ee9591ab412a466d52ca17551.tar.gz
[core] Support fill-extrusion-vertical-gradient
Diffstat (limited to 'src/mbgl/style')
-rw-r--r--src/mbgl/style/layers/fill_extrusion_layer.cpp56
-rw-r--r--src/mbgl/style/layers/fill_extrusion_layer_properties.hpp7
2 files changed, 62 insertions, 1 deletions
diff --git a/src/mbgl/style/layers/fill_extrusion_layer.cpp b/src/mbgl/style/layers/fill_extrusion_layer.cpp
index 7ca9d6ed6f..12f566e00b 100644
--- a/src/mbgl/style/layers/fill_extrusion_layer.cpp
+++ b/src/mbgl/style/layers/fill_extrusion_layer.cpp
@@ -252,6 +252,33 @@ TransitionOptions FillExtrusionLayer::getFillExtrusionBaseTransition() const {
return impl().paint.template get<FillExtrusionBase>().options;
}
+PropertyValue<bool> FillExtrusionLayer::getDefaultFillExtrusionVerticalGradient() {
+ return { true };
+}
+
+PropertyValue<bool> FillExtrusionLayer::getFillExtrusionVerticalGradient() const {
+ return impl().paint.template get<FillExtrusionVerticalGradient>().value;
+}
+
+void FillExtrusionLayer::setFillExtrusionVerticalGradient(PropertyValue<bool> value) {
+ if (value == getFillExtrusionVerticalGradient())
+ return;
+ auto impl_ = mutableImpl();
+ impl_->paint.template get<FillExtrusionVerticalGradient>().value = value;
+ baseImpl = std::move(impl_);
+ observer->onLayerChanged(*this);
+}
+
+void FillExtrusionLayer::setFillExtrusionVerticalGradientTransition(const TransitionOptions& options) {
+ auto impl_ = mutableImpl();
+ impl_->paint.template get<FillExtrusionVerticalGradient>().options = options;
+ baseImpl = std::move(impl_);
+}
+
+TransitionOptions FillExtrusionLayer::getFillExtrusionVerticalGradientTransition() const {
+ return impl().paint.template get<FillExtrusionVerticalGradient>().options;
+}
+
using namespace conversion;
optional<Error> FillExtrusionLayer::setPaintProperty(const std::string& name, const Convertible& value) {
@@ -264,6 +291,7 @@ optional<Error> FillExtrusionLayer::setPaintProperty(const std::string& name, co
FillExtrusionPattern,
FillExtrusionHeight,
FillExtrusionBase,
+ FillExtrusionVerticalGradient,
FillExtrusionOpacityTransition,
FillExtrusionColorTransition,
FillExtrusionTranslateTransition,
@@ -271,6 +299,7 @@ optional<Error> FillExtrusionLayer::setPaintProperty(const std::string& name, co
FillExtrusionPatternTransition,
FillExtrusionHeightTransition,
FillExtrusionBaseTransition,
+ FillExtrusionVerticalGradientTransition,
};
Property property = Property::Unknown;
@@ -345,6 +374,16 @@ optional<Error> FillExtrusionLayer::setPaintProperty(const std::string& name, co
property = Property::FillExtrusionBaseTransition;
}
break;
+ case util::hashFNV1a("fill-extrusion-vertical-gradient"):
+ if (name == "fill-extrusion-vertical-gradient") {
+ property = Property::FillExtrusionVerticalGradient;
+ }
+ break;
+ case util::hashFNV1a("fill-extrusion-vertical-gradient-transition"):
+ if (name == "fill-extrusion-vertical-gradient-transition") {
+ property = Property::FillExtrusionVerticalGradientTransition;
+ }
+ break;
}
@@ -432,6 +471,18 @@ optional<Error> FillExtrusionLayer::setPaintProperty(const std::string& name, co
}
+ if (property == Property::FillExtrusionVerticalGradient) {
+ Error error;
+ optional<PropertyValue<bool>> typedValue = convert<PropertyValue<bool>>(value, error, false, false);
+ if (!typedValue) {
+ return error;
+ }
+
+ setFillExtrusionVerticalGradient(*typedValue);
+ return nullopt;
+
+ }
+
Error error;
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
@@ -474,6 +525,11 @@ optional<Error> FillExtrusionLayer::setPaintProperty(const std::string& name, co
return nullopt;
}
+ if (property == Property::FillExtrusionVerticalGradientTransition) {
+ setFillExtrusionVerticalGradientTransition(*transition);
+ return nullopt;
+ }
+
return Error { "layer doesn't support this property" };
}
diff --git a/src/mbgl/style/layers/fill_extrusion_layer_properties.hpp b/src/mbgl/style/layers/fill_extrusion_layer_properties.hpp
index 47d8cd3a1c..20cba699fe 100644
--- a/src/mbgl/style/layers/fill_extrusion_layer_properties.hpp
+++ b/src/mbgl/style/layers/fill_extrusion_layer_properties.hpp
@@ -40,6 +40,10 @@ struct FillExtrusionBase : DataDrivenPaintProperty<float, attributes::a_base, un
static float defaultValue() { return 0; }
};
+struct FillExtrusionVerticalGradient : PaintProperty<bool> {
+ static bool defaultValue() { return true; }
+};
+
class FillExtrusionPaintProperties : public Properties<
FillExtrusionOpacity,
FillExtrusionColor,
@@ -47,7 +51,8 @@ class FillExtrusionPaintProperties : public Properties<
FillExtrusionTranslateAnchor,
FillExtrusionPattern,
FillExtrusionHeight,
- FillExtrusionBase
+ FillExtrusionBase,
+ FillExtrusionVerticalGradient
> {};
} // namespace style