summaryrefslogtreecommitdiff
path: root/src/mbgl/style/layers
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-10-30 11:06:59 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-11-17 15:13:38 -0800
commit38fcbe21d48186c4630a3b8a76d1b20e156faadd (patch)
tree098f73bfea98deb5202fe1c13b1277e43e322755 /src/mbgl/style/layers
parentd4fc66af3924805d40576989c1e139ddafcc4670 (diff)
downloadqtlocation-mapboxgl-38fcbe21d48186c4630a3b8a76d1b20e156faadd.tar.gz
[core] Convert style properties to a tuple-based approach
This converts the style property classes (CirclePaintProperties and so on) to the same tuple-based approach as gl::Attribute and gl::Uniform. The approach is outlined in https://github.com/mapbox/cpp/blob/master/C%2B%2B%20Structural%20Metaprogramming.md. The main advantage of this approach is it allows writing algorithms that work on sets of style properties, without resorting to code generation or manually repetitive code. This lets us iterate on approaches to data-driven properties more easily. Another advantage is that the cascading, unevaluated, and evaluated states of a set of properties exist as independent structures, instead of individual properties holding their own state. This is a more functional approach that makes data flow clearer and reduces state.
Diffstat (limited to 'src/mbgl/style/layers')
-rw-r--r--src/mbgl/style/layers/background_layer.cpp12
-rw-r--r--src/mbgl/style/layers/background_layer_impl.cpp8
-rw-r--r--src/mbgl/style/layers/background_layer_impl.hpp2
-rw-r--r--src/mbgl/style/layers/background_layer_properties.cpp16
-rw-r--r--src/mbgl/style/layers/background_layer_properties.hpp23
-rw-r--r--src/mbgl/style/layers/circle_layer.cpp28
-rw-r--r--src/mbgl/style/layers/circle_layer_impl.cpp16
-rw-r--r--src/mbgl/style/layers/circle_layer_impl.hpp2
-rw-r--r--src/mbgl/style/layers/circle_layer_properties.cpp24
-rw-r--r--src/mbgl/style/layers/circle_layer_properties.hpp51
-rw-r--r--src/mbgl/style/layers/custom_layer_impl.cpp2
-rw-r--r--src/mbgl/style/layers/custom_layer_impl.hpp2
-rw-r--r--src/mbgl/style/layers/fill_layer.cpp28
-rw-r--r--src/mbgl/style/layers/fill_layer_impl.cpp14
-rw-r--r--src/mbgl/style/layers/fill_layer_impl.hpp2
-rw-r--r--src/mbgl/style/layers/fill_layer_properties.cpp24
-rw-r--r--src/mbgl/style/layers/fill_layer_properties.hpp51
-rw-r--r--src/mbgl/style/layers/layer.cpp.ejs10
-rw-r--r--src/mbgl/style/layers/layer_properties.cpp.ejs24
-rw-r--r--src/mbgl/style/layers/layer_properties.hpp.ejs40
-rw-r--r--src/mbgl/style/layers/line_layer.cpp64
-rw-r--r--src/mbgl/style/layers/line_layer_impl.cpp30
-rw-r--r--src/mbgl/style/layers/line_layer_impl.hpp2
-rw-r--r--src/mbgl/style/layers/line_layer_properties.cpp37
-rw-r--r--src/mbgl/style/layers/line_layer_properties.hpp102
-rw-r--r--src/mbgl/style/layers/raster_layer.cpp28
-rw-r--r--src/mbgl/style/layers/raster_layer_impl.cpp8
-rw-r--r--src/mbgl/style/layers/raster_layer_impl.hpp2
-rw-r--r--src/mbgl/style/layers/raster_layer_properties.cpp24
-rw-r--r--src/mbgl/style/layers/raster_layer_properties.hpp51
-rw-r--r--src/mbgl/style/layers/symbol_layer.cpp260
-rw-r--r--src/mbgl/style/layers/symbol_layer_impl.cpp95
-rw-r--r--src/mbgl/style/layers/symbol_layer_impl.hpp6
-rw-r--r--src/mbgl/style/layers/symbol_layer_properties.cpp75
-rw-r--r--src/mbgl/style/layers/symbol_layer_properties.hpp306
35 files changed, 768 insertions, 701 deletions
diff --git a/src/mbgl/style/layers/background_layer.cpp b/src/mbgl/style/layers/background_layer.cpp
index 5e5faf37e6..a54115d1a7 100644
--- a/src/mbgl/style/layers/background_layer.cpp
+++ b/src/mbgl/style/layers/background_layer.cpp
@@ -42,13 +42,13 @@ PropertyValue<Color> BackgroundLayer::getDefaultBackgroundColor() {
}
PropertyValue<Color> BackgroundLayer::getBackgroundColor(const optional<std::string>& klass) const {
- return impl->paint.backgroundColor.get(klass);
+ return impl->paint.get<BackgroundColor>(klass);
}
void BackgroundLayer::setBackgroundColor(PropertyValue<Color> value, const optional<std::string>& klass) {
if (value == getBackgroundColor(klass))
return;
- impl->paint.backgroundColor.set(value, klass);
+ impl->paint.set<BackgroundColor>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -57,13 +57,13 @@ PropertyValue<std::string> BackgroundLayer::getDefaultBackgroundPattern() {
}
PropertyValue<std::string> BackgroundLayer::getBackgroundPattern(const optional<std::string>& klass) const {
- return impl->paint.backgroundPattern.get(klass);
+ return impl->paint.get<BackgroundPattern>(klass);
}
void BackgroundLayer::setBackgroundPattern(PropertyValue<std::string> value, const optional<std::string>& klass) {
if (value == getBackgroundPattern(klass))
return;
- impl->paint.backgroundPattern.set(value, klass);
+ impl->paint.set<BackgroundPattern>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -72,13 +72,13 @@ PropertyValue<float> BackgroundLayer::getDefaultBackgroundOpacity() {
}
PropertyValue<float> BackgroundLayer::getBackgroundOpacity(const optional<std::string>& klass) const {
- return impl->paint.backgroundOpacity.get(klass);
+ return impl->paint.get<BackgroundOpacity>(klass);
}
void BackgroundLayer::setBackgroundOpacity(PropertyValue<float> value, const optional<std::string>& klass) {
if (value == getBackgroundOpacity(klass))
return;
- impl->paint.backgroundOpacity.set(value, klass);
+ impl->paint.set<BackgroundOpacity>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
diff --git a/src/mbgl/style/layers/background_layer_impl.cpp b/src/mbgl/style/layers/background_layer_impl.cpp
index ea389b828e..9a7db9416e 100644
--- a/src/mbgl/style/layers/background_layer_impl.cpp
+++ b/src/mbgl/style/layers/background_layer_impl.cpp
@@ -8,12 +8,12 @@ void BackgroundLayer::Impl::cascade(const CascadeParameters& parameters) {
paint.cascade(parameters);
}
-bool BackgroundLayer::Impl::recalculate(const CalculationParameters& parameters) {
- bool hasTransitions = paint.recalculate(parameters);
+bool BackgroundLayer::Impl::evaluate(const PropertyEvaluationParameters& parameters) {
+ paint.evaluate(parameters);
- passes = paint.backgroundOpacity > 0 ? RenderPass::Translucent : RenderPass::None;
+ passes = paint.evaluated.get<BackgroundOpacity>() > 0 ? RenderPass::Translucent : RenderPass::None;
- return hasTransitions;
+ return paint.hasTransition();
}
std::unique_ptr<Bucket> BackgroundLayer::Impl::createBucket(BucketParameters&) const {
diff --git a/src/mbgl/style/layers/background_layer_impl.hpp b/src/mbgl/style/layers/background_layer_impl.hpp
index abbb740f42..6ede1b7d97 100644
--- a/src/mbgl/style/layers/background_layer_impl.hpp
+++ b/src/mbgl/style/layers/background_layer_impl.hpp
@@ -13,7 +13,7 @@ public:
std::unique_ptr<Layer> cloneRef(const std::string& id) const override;
void cascade(const CascadeParameters&) override;
- bool recalculate(const CalculationParameters&) override;
+ bool evaluate(const PropertyEvaluationParameters&) override;
std::unique_ptr<Bucket> createBucket(BucketParameters&) const override;
diff --git a/src/mbgl/style/layers/background_layer_properties.cpp b/src/mbgl/style/layers/background_layer_properties.cpp
index 558093a255..ba3e638977 100644
--- a/src/mbgl/style/layers/background_layer_properties.cpp
+++ b/src/mbgl/style/layers/background_layer_properties.cpp
@@ -5,21 +5,5 @@
namespace mbgl {
namespace style {
-void BackgroundPaintProperties::cascade(const CascadeParameters& parameters) {
- backgroundColor.cascade(parameters);
- backgroundPattern.cascade(parameters);
- backgroundOpacity.cascade(parameters);
-}
-
-bool BackgroundPaintProperties::recalculate(const CalculationParameters& parameters) {
- bool hasTransitions = false;
-
- hasTransitions |= backgroundColor.calculate(parameters);
- hasTransitions |= backgroundPattern.calculate(parameters);
- hasTransitions |= backgroundOpacity.calculate(parameters);
-
- return hasTransitions;
-}
-
} // namespace style
} // namespace mbgl
diff --git a/src/mbgl/style/layers/background_layer_properties.hpp b/src/mbgl/style/layers/background_layer_properties.hpp
index 78a35a4f0c..792bf3de94 100644
--- a/src/mbgl/style/layers/background_layer_properties.hpp
+++ b/src/mbgl/style/layers/background_layer_properties.hpp
@@ -9,18 +9,23 @@
namespace mbgl {
namespace style {
-class CascadeParameters;
-class CalculationParameters;
+struct BackgroundColor : PaintProperty<Color> {
+ static Color defaultValue() { return Color::black(); }
+};
-class BackgroundPaintProperties {
-public:
- void cascade(const CascadeParameters&);
- bool recalculate(const CalculationParameters&);
+struct BackgroundPattern : CrossFadedPaintProperty<std::string> {
+ static std::string defaultValue() { return ""; }
+};
- PaintProperty<Color> backgroundColor { Color::black() };
- PaintProperty<std::string, CrossFadedPropertyEvaluator> backgroundPattern { "" };
- PaintProperty<float> backgroundOpacity { 1 };
+struct BackgroundOpacity : PaintProperty<float> {
+ static float defaultValue() { return 1; }
};
+class BackgroundPaintProperties : public PaintProperties<
+ BackgroundColor,
+ BackgroundPattern,
+ BackgroundOpacity
+> {};
+
} // namespace style
} // namespace mbgl
diff --git a/src/mbgl/style/layers/circle_layer.cpp b/src/mbgl/style/layers/circle_layer.cpp
index a2b8d316d6..ce01a12ff2 100644
--- a/src/mbgl/style/layers/circle_layer.cpp
+++ b/src/mbgl/style/layers/circle_layer.cpp
@@ -67,13 +67,13 @@ PropertyValue<float> CircleLayer::getDefaultCircleRadius() {
}
PropertyValue<float> CircleLayer::getCircleRadius(const optional<std::string>& klass) const {
- return impl->paint.circleRadius.get(klass);
+ return impl->paint.get<CircleRadius>(klass);
}
void CircleLayer::setCircleRadius(PropertyValue<float> value, const optional<std::string>& klass) {
if (value == getCircleRadius(klass))
return;
- impl->paint.circleRadius.set(value, klass);
+ impl->paint.set<CircleRadius>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -82,13 +82,13 @@ PropertyValue<Color> CircleLayer::getDefaultCircleColor() {
}
PropertyValue<Color> CircleLayer::getCircleColor(const optional<std::string>& klass) const {
- return impl->paint.circleColor.get(klass);
+ return impl->paint.get<CircleColor>(klass);
}
void CircleLayer::setCircleColor(PropertyValue<Color> value, const optional<std::string>& klass) {
if (value == getCircleColor(klass))
return;
- impl->paint.circleColor.set(value, klass);
+ impl->paint.set<CircleColor>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -97,13 +97,13 @@ PropertyValue<float> CircleLayer::getDefaultCircleBlur() {
}
PropertyValue<float> CircleLayer::getCircleBlur(const optional<std::string>& klass) const {
- return impl->paint.circleBlur.get(klass);
+ return impl->paint.get<CircleBlur>(klass);
}
void CircleLayer::setCircleBlur(PropertyValue<float> value, const optional<std::string>& klass) {
if (value == getCircleBlur(klass))
return;
- impl->paint.circleBlur.set(value, klass);
+ impl->paint.set<CircleBlur>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -112,13 +112,13 @@ PropertyValue<float> CircleLayer::getDefaultCircleOpacity() {
}
PropertyValue<float> CircleLayer::getCircleOpacity(const optional<std::string>& klass) const {
- return impl->paint.circleOpacity.get(klass);
+ return impl->paint.get<CircleOpacity>(klass);
}
void CircleLayer::setCircleOpacity(PropertyValue<float> value, const optional<std::string>& klass) {
if (value == getCircleOpacity(klass))
return;
- impl->paint.circleOpacity.set(value, klass);
+ impl->paint.set<CircleOpacity>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -127,13 +127,13 @@ PropertyValue<std::array<float, 2>> CircleLayer::getDefaultCircleTranslate() {
}
PropertyValue<std::array<float, 2>> CircleLayer::getCircleTranslate(const optional<std::string>& klass) const {
- return impl->paint.circleTranslate.get(klass);
+ return impl->paint.get<CircleTranslate>(klass);
}
void CircleLayer::setCircleTranslate(PropertyValue<std::array<float, 2>> value, const optional<std::string>& klass) {
if (value == getCircleTranslate(klass))
return;
- impl->paint.circleTranslate.set(value, klass);
+ impl->paint.set<CircleTranslate>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -142,13 +142,13 @@ PropertyValue<TranslateAnchorType> CircleLayer::getDefaultCircleTranslateAnchor(
}
PropertyValue<TranslateAnchorType> CircleLayer::getCircleTranslateAnchor(const optional<std::string>& klass) const {
- return impl->paint.circleTranslateAnchor.get(klass);
+ return impl->paint.get<CircleTranslateAnchor>(klass);
}
void CircleLayer::setCircleTranslateAnchor(PropertyValue<TranslateAnchorType> value, const optional<std::string>& klass) {
if (value == getCircleTranslateAnchor(klass))
return;
- impl->paint.circleTranslateAnchor.set(value, klass);
+ impl->paint.set<CircleTranslateAnchor>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -157,13 +157,13 @@ PropertyValue<CirclePitchScaleType> CircleLayer::getDefaultCirclePitchScale() {
}
PropertyValue<CirclePitchScaleType> CircleLayer::getCirclePitchScale(const optional<std::string>& klass) const {
- return impl->paint.circlePitchScale.get(klass);
+ return impl->paint.get<CirclePitchScale>(klass);
}
void CircleLayer::setCirclePitchScale(PropertyValue<CirclePitchScaleType> value, const optional<std::string>& klass) {
if (value == getCirclePitchScale(klass))
return;
- impl->paint.circlePitchScale.set(value, klass);
+ impl->paint.set<CirclePitchScale>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
diff --git a/src/mbgl/style/layers/circle_layer_impl.cpp b/src/mbgl/style/layers/circle_layer_impl.cpp
index 33699b6665..6599126702 100644
--- a/src/mbgl/style/layers/circle_layer_impl.cpp
+++ b/src/mbgl/style/layers/circle_layer_impl.cpp
@@ -12,13 +12,13 @@ void CircleLayer::Impl::cascade(const CascadeParameters& parameters) {
paint.cascade(parameters);
}
-bool CircleLayer::Impl::recalculate(const CalculationParameters& parameters) {
- bool hasTransitions = paint.recalculate(parameters);
+bool CircleLayer::Impl::evaluate(const PropertyEvaluationParameters& parameters) {
+ paint.evaluate(parameters);
- passes = (paint.circleRadius > 0 && paint.circleColor.value.a > 0 && paint.circleOpacity > 0)
+ passes = (paint.evaluated.get<CircleRadius>() > 0 && paint.evaluated.get<CircleColor>().a > 0 && paint.evaluated.get<CircleOpacity>() > 0)
? RenderPass::Translucent : RenderPass::None;
- return hasTransitions;
+ return paint.hasTransition();
}
std::unique_ptr<Bucket> CircleLayer::Impl::createBucket(BucketParameters& parameters) const {
@@ -35,8 +35,8 @@ std::unique_ptr<Bucket> CircleLayer::Impl::createBucket(BucketParameters& parame
}
float CircleLayer::Impl::getQueryRadius() const {
- const std::array<float, 2>& translate = paint.circleTranslate;
- return paint.circleRadius + util::length(translate[0], translate[1]);
+ const std::array<float, 2>& translate = paint.evaluated.get<CircleTranslate>();
+ return paint.evaluated.get<CircleRadius>() + util::length(translate[0], translate[1]);
}
bool CircleLayer::Impl::queryIntersectsGeometry(
@@ -46,9 +46,9 @@ bool CircleLayer::Impl::queryIntersectsGeometry(
const float pixelsToTileUnits) const {
auto translatedQueryGeometry = FeatureIndex::translateQueryGeometry(
- queryGeometry, paint.circleTranslate, paint.circleTranslateAnchor, bearing, pixelsToTileUnits);
+ queryGeometry, paint.evaluated.get<CircleTranslate>(), paint.evaluated.get<CircleTranslateAnchor>(), bearing, pixelsToTileUnits);
- auto circleRadius = paint.circleRadius * pixelsToTileUnits;
+ auto circleRadius = paint.evaluated.get<CircleRadius>() * pixelsToTileUnits;
return util::polygonIntersectsBufferedMultiPoint(
translatedQueryGeometry.value_or(queryGeometry), geometry, circleRadius);
diff --git a/src/mbgl/style/layers/circle_layer_impl.hpp b/src/mbgl/style/layers/circle_layer_impl.hpp
index 14baaf84e4..df3b34cc1a 100644
--- a/src/mbgl/style/layers/circle_layer_impl.hpp
+++ b/src/mbgl/style/layers/circle_layer_impl.hpp
@@ -13,7 +13,7 @@ public:
std::unique_ptr<Layer> cloneRef(const std::string& id) const override;
void cascade(const CascadeParameters&) override;
- bool recalculate(const CalculationParameters&) override;
+ bool evaluate(const PropertyEvaluationParameters&) override;
std::unique_ptr<Bucket> createBucket(BucketParameters&) const override;
diff --git a/src/mbgl/style/layers/circle_layer_properties.cpp b/src/mbgl/style/layers/circle_layer_properties.cpp
index 7243cf87f4..af727fa36f 100644
--- a/src/mbgl/style/layers/circle_layer_properties.cpp
+++ b/src/mbgl/style/layers/circle_layer_properties.cpp
@@ -5,29 +5,5 @@
namespace mbgl {
namespace style {
-void CirclePaintProperties::cascade(const CascadeParameters& parameters) {
- circleRadius.cascade(parameters);
- circleColor.cascade(parameters);
- circleBlur.cascade(parameters);
- circleOpacity.cascade(parameters);
- circleTranslate.cascade(parameters);
- circleTranslateAnchor.cascade(parameters);
- circlePitchScale.cascade(parameters);
-}
-
-bool CirclePaintProperties::recalculate(const CalculationParameters& parameters) {
- bool hasTransitions = false;
-
- hasTransitions |= circleRadius.calculate(parameters);
- hasTransitions |= circleColor.calculate(parameters);
- hasTransitions |= circleBlur.calculate(parameters);
- hasTransitions |= circleOpacity.calculate(parameters);
- hasTransitions |= circleTranslate.calculate(parameters);
- hasTransitions |= circleTranslateAnchor.calculate(parameters);
- hasTransitions |= circlePitchScale.calculate(parameters);
-
- return hasTransitions;
-}
-
} // namespace style
} // namespace mbgl
diff --git a/src/mbgl/style/layers/circle_layer_properties.hpp b/src/mbgl/style/layers/circle_layer_properties.hpp
index 0166bc8be4..b7f279de4b 100644
--- a/src/mbgl/style/layers/circle_layer_properties.hpp
+++ b/src/mbgl/style/layers/circle_layer_properties.hpp
@@ -9,22 +9,43 @@
namespace mbgl {
namespace style {
-class CascadeParameters;
-class CalculationParameters;
-
-class CirclePaintProperties {
-public:
- void cascade(const CascadeParameters&);
- bool recalculate(const CalculationParameters&);
-
- PaintProperty<float> circleRadius { 5 };
- PaintProperty<Color> circleColor { Color::black() };
- PaintProperty<float> circleBlur { 0 };
- PaintProperty<float> circleOpacity { 1 };
- PaintProperty<std::array<float, 2>> circleTranslate { {{ 0, 0 }} };
- PaintProperty<TranslateAnchorType> circleTranslateAnchor { TranslateAnchorType::Map };
- PaintProperty<CirclePitchScaleType> circlePitchScale { CirclePitchScaleType::Map };
+struct CircleRadius : PaintProperty<float> {
+ static float defaultValue() { return 5; }
};
+struct CircleColor : PaintProperty<Color> {
+ static Color defaultValue() { return Color::black(); }
+};
+
+struct CircleBlur : PaintProperty<float> {
+ static float defaultValue() { return 0; }
+};
+
+struct CircleOpacity : PaintProperty<float> {
+ static float defaultValue() { return 1; }
+};
+
+struct CircleTranslate : PaintProperty<std::array<float, 2>> {
+ static std::array<float, 2> defaultValue() { return {{ 0, 0 }}; }
+};
+
+struct CircleTranslateAnchor : PaintProperty<TranslateAnchorType> {
+ static TranslateAnchorType defaultValue() { return TranslateAnchorType::Map; }
+};
+
+struct CirclePitchScale : PaintProperty<CirclePitchScaleType> {
+ static CirclePitchScaleType defaultValue() { return CirclePitchScaleType::Map; }
+};
+
+class CirclePaintProperties : public PaintProperties<
+ CircleRadius,
+ CircleColor,
+ CircleBlur,
+ CircleOpacity,
+ CircleTranslate,
+ CircleTranslateAnchor,
+ CirclePitchScale
+> {};
+
} // namespace style
} // namespace mbgl
diff --git a/src/mbgl/style/layers/custom_layer_impl.cpp b/src/mbgl/style/layers/custom_layer_impl.cpp
index 1126d57552..50dcc0dda9 100644
--- a/src/mbgl/style/layers/custom_layer_impl.cpp
+++ b/src/mbgl/style/layers/custom_layer_impl.cpp
@@ -62,7 +62,7 @@ void CustomLayer::Impl::render(const TransformState& state) const {
renderFn(context, parameters);
}
-bool CustomLayer::Impl::recalculate(const CalculationParameters&) {
+bool CustomLayer::Impl::evaluate(const PropertyEvaluationParameters&) {
passes = RenderPass::Translucent;
return false;
}
diff --git a/src/mbgl/style/layers/custom_layer_impl.hpp b/src/mbgl/style/layers/custom_layer_impl.hpp
index b5b626ca5e..56e3f3146c 100644
--- a/src/mbgl/style/layers/custom_layer_impl.hpp
+++ b/src/mbgl/style/layers/custom_layer_impl.hpp
@@ -29,7 +29,7 @@ private:
std::unique_ptr<Layer> cloneRef(const std::string& id) const override;
void cascade(const CascadeParameters&) final {}
- bool recalculate(const CalculationParameters&) final;
+ bool evaluate(const PropertyEvaluationParameters&) final;
std::unique_ptr<Bucket> createBucket(BucketParameters&) const final;
diff --git a/src/mbgl/style/layers/fill_layer.cpp b/src/mbgl/style/layers/fill_layer.cpp
index c61de81d1a..3bea9b56b0 100644
--- a/src/mbgl/style/layers/fill_layer.cpp
+++ b/src/mbgl/style/layers/fill_layer.cpp
@@ -67,13 +67,13 @@ PropertyValue<bool> FillLayer::getDefaultFillAntialias() {
}
PropertyValue<bool> FillLayer::getFillAntialias(const optional<std::string>& klass) const {
- return impl->paint.fillAntialias.get(klass);
+ return impl->paint.get<FillAntialias>(klass);
}
void FillLayer::setFillAntialias(PropertyValue<bool> value, const optional<std::string>& klass) {
if (value == getFillAntialias(klass))
return;
- impl->paint.fillAntialias.set(value, klass);
+ impl->paint.set<FillAntialias>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -82,13 +82,13 @@ PropertyValue<float> FillLayer::getDefaultFillOpacity() {
}
PropertyValue<float> FillLayer::getFillOpacity(const optional<std::string>& klass) const {
- return impl->paint.fillOpacity.get(klass);
+ return impl->paint.get<FillOpacity>(klass);
}
void FillLayer::setFillOpacity(PropertyValue<float> value, const optional<std::string>& klass) {
if (value == getFillOpacity(klass))
return;
- impl->paint.fillOpacity.set(value, klass);
+ impl->paint.set<FillOpacity>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -97,13 +97,13 @@ PropertyValue<Color> FillLayer::getDefaultFillColor() {
}
PropertyValue<Color> FillLayer::getFillColor(const optional<std::string>& klass) const {
- return impl->paint.fillColor.get(klass);
+ return impl->paint.get<FillColor>(klass);
}
void FillLayer::setFillColor(PropertyValue<Color> value, const optional<std::string>& klass) {
if (value == getFillColor(klass))
return;
- impl->paint.fillColor.set(value, klass);
+ impl->paint.set<FillColor>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -112,13 +112,13 @@ PropertyValue<Color> FillLayer::getDefaultFillOutlineColor() {
}
PropertyValue<Color> FillLayer::getFillOutlineColor(const optional<std::string>& klass) const {
- return impl->paint.fillOutlineColor.get(klass);
+ return impl->paint.get<FillOutlineColor>(klass);
}
void FillLayer::setFillOutlineColor(PropertyValue<Color> value, const optional<std::string>& klass) {
if (value == getFillOutlineColor(klass))
return;
- impl->paint.fillOutlineColor.set(value, klass);
+ impl->paint.set<FillOutlineColor>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -127,13 +127,13 @@ PropertyValue<std::array<float, 2>> FillLayer::getDefaultFillTranslate() {
}
PropertyValue<std::array<float, 2>> FillLayer::getFillTranslate(const optional<std::string>& klass) const {
- return impl->paint.fillTranslate.get(klass);
+ return impl->paint.get<FillTranslate>(klass);
}
void FillLayer::setFillTranslate(PropertyValue<std::array<float, 2>> value, const optional<std::string>& klass) {
if (value == getFillTranslate(klass))
return;
- impl->paint.fillTranslate.set(value, klass);
+ impl->paint.set<FillTranslate>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -142,13 +142,13 @@ PropertyValue<TranslateAnchorType> FillLayer::getDefaultFillTranslateAnchor() {
}
PropertyValue<TranslateAnchorType> FillLayer::getFillTranslateAnchor(const optional<std::string>& klass) const {
- return impl->paint.fillTranslateAnchor.get(klass);
+ return impl->paint.get<FillTranslateAnchor>(klass);
}
void FillLayer::setFillTranslateAnchor(PropertyValue<TranslateAnchorType> value, const optional<std::string>& klass) {
if (value == getFillTranslateAnchor(klass))
return;
- impl->paint.fillTranslateAnchor.set(value, klass);
+ impl->paint.set<FillTranslateAnchor>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -157,13 +157,13 @@ PropertyValue<std::string> FillLayer::getDefaultFillPattern() {
}
PropertyValue<std::string> FillLayer::getFillPattern(const optional<std::string>& klass) const {
- return impl->paint.fillPattern.get(klass);
+ return impl->paint.get<FillPattern>(klass);
}
void FillLayer::setFillPattern(PropertyValue<std::string> value, const optional<std::string>& klass) {
if (value == getFillPattern(klass))
return;
- impl->paint.fillPattern.set(value, klass);
+ impl->paint.set<FillPattern>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
diff --git a/src/mbgl/style/layers/fill_layer_impl.cpp b/src/mbgl/style/layers/fill_layer_impl.cpp
index fc439f1cd1..6a690ba447 100644
--- a/src/mbgl/style/layers/fill_layer_impl.cpp
+++ b/src/mbgl/style/layers/fill_layer_impl.cpp
@@ -12,22 +12,22 @@ void FillLayer::Impl::cascade(const CascadeParameters& parameters) {
paint.cascade(parameters);
}
-bool FillLayer::Impl::recalculate(const CalculationParameters& parameters) {
- bool hasTransitions = paint.recalculate(parameters);
+bool FillLayer::Impl::evaluate(const PropertyEvaluationParameters& parameters) {
+ paint.evaluate(parameters);
passes = RenderPass::None;
- if (paint.fillAntialias) {
+ if (paint.evaluated.get<FillAntialias>()) {
passes |= RenderPass::Translucent;
}
- if (!paint.fillPattern.value.from.empty() || (paint.fillColor.value.a * paint.fillOpacity) < 1.0f) {
+ if (!paint.evaluated.get<FillPattern>().from.empty() || (paint.evaluated.get<FillColor>().a * paint.evaluated.get<FillOpacity>()) < 1.0f) {
passes |= RenderPass::Translucent;
} else {
passes |= RenderPass::Opaque;
}
- return hasTransitions;
+ return paint.hasTransition();
}
std::unique_ptr<Bucket> FillLayer::Impl::createBucket(BucketParameters& parameters) const {
@@ -44,7 +44,7 @@ std::unique_ptr<Bucket> FillLayer::Impl::createBucket(BucketParameters& paramete
}
float FillLayer::Impl::getQueryRadius() const {
- const std::array<float, 2>& translate = paint.fillTranslate;
+ const std::array<float, 2>& translate = paint.evaluated.get<FillTranslate>();
return util::length(translate[0], translate[1]);
}
@@ -55,7 +55,7 @@ bool FillLayer::Impl::queryIntersectsGeometry(
const float pixelsToTileUnits) const {
auto translatedQueryGeometry = FeatureIndex::translateQueryGeometry(
- queryGeometry, paint.fillTranslate, paint.fillTranslateAnchor, bearing, pixelsToTileUnits);
+ queryGeometry, paint.evaluated.get<FillTranslate>(), paint.evaluated.get<FillTranslateAnchor>(), bearing, pixelsToTileUnits);
return util::polygonIntersectsMultiPolygon(translatedQueryGeometry.value_or(queryGeometry), geometry);
}
diff --git a/src/mbgl/style/layers/fill_layer_impl.hpp b/src/mbgl/style/layers/fill_layer_impl.hpp
index 54cfb80c86..53276d744a 100644
--- a/src/mbgl/style/layers/fill_layer_impl.hpp
+++ b/src/mbgl/style/layers/fill_layer_impl.hpp
@@ -13,7 +13,7 @@ public:
std::unique_ptr<Layer> cloneRef(const std::string& id) const override;
void cascade(const CascadeParameters&) override;
- bool recalculate(const CalculationParameters&) override;
+ bool evaluate(const PropertyEvaluationParameters&) override;
std::unique_ptr<Bucket> createBucket(BucketParameters&) const override;
diff --git a/src/mbgl/style/layers/fill_layer_properties.cpp b/src/mbgl/style/layers/fill_layer_properties.cpp
index 9a55cbc145..b07a083950 100644
--- a/src/mbgl/style/layers/fill_layer_properties.cpp
+++ b/src/mbgl/style/layers/fill_layer_properties.cpp
@@ -5,29 +5,5 @@
namespace mbgl {
namespace style {
-void FillPaintProperties::cascade(const CascadeParameters& parameters) {
- fillAntialias.cascade(parameters);
- fillOpacity.cascade(parameters);
- fillColor.cascade(parameters);
- fillOutlineColor.cascade(parameters);
- fillTranslate.cascade(parameters);
- fillTranslateAnchor.cascade(parameters);
- fillPattern.cascade(parameters);
-}
-
-bool FillPaintProperties::recalculate(const CalculationParameters& parameters) {
- bool hasTransitions = false;
-
- hasTransitions |= fillAntialias.calculate(parameters);
- hasTransitions |= fillOpacity.calculate(parameters);
- hasTransitions |= fillColor.calculate(parameters);
- hasTransitions |= fillOutlineColor.calculate(parameters);
- hasTransitions |= fillTranslate.calculate(parameters);
- hasTransitions |= fillTranslateAnchor.calculate(parameters);
- hasTransitions |= fillPattern.calculate(parameters);
-
- return hasTransitions;
-}
-
} // namespace style
} // namespace mbgl
diff --git a/src/mbgl/style/layers/fill_layer_properties.hpp b/src/mbgl/style/layers/fill_layer_properties.hpp
index d12eb8d6f4..b2d926c31e 100644
--- a/src/mbgl/style/layers/fill_layer_properties.hpp
+++ b/src/mbgl/style/layers/fill_layer_properties.hpp
@@ -9,22 +9,43 @@
namespace mbgl {
namespace style {
-class CascadeParameters;
-class CalculationParameters;
-
-class FillPaintProperties {
-public:
- void cascade(const CascadeParameters&);
- bool recalculate(const CalculationParameters&);
-
- PaintProperty<bool> fillAntialias { true };
- PaintProperty<float> fillOpacity { 1 };
- PaintProperty<Color> fillColor { Color::black() };
- PaintProperty<Color> fillOutlineColor { {} };
- PaintProperty<std::array<float, 2>> fillTranslate { {{ 0, 0 }} };
- PaintProperty<TranslateAnchorType> fillTranslateAnchor { TranslateAnchorType::Map };
- PaintProperty<std::string, CrossFadedPropertyEvaluator> fillPattern { "" };
+struct FillAntialias : PaintProperty<bool> {
+ static bool defaultValue() { return true; }
};
+struct FillOpacity : PaintProperty<float> {
+ static float defaultValue() { return 1; }
+};
+
+struct FillColor : PaintProperty<Color> {
+ static Color defaultValue() { return Color::black(); }
+};
+
+struct FillOutlineColor : PaintProperty<Color> {
+ static Color defaultValue() { return {}; }
+};
+
+struct FillTranslate : PaintProperty<std::array<float, 2>> {
+ static std::array<float, 2> defaultValue() { return {{ 0, 0 }}; }
+};
+
+struct FillTranslateAnchor : PaintProperty<TranslateAnchorType> {
+ static TranslateAnchorType defaultValue() { return TranslateAnchorType::Map; }
+};
+
+struct FillPattern : CrossFadedPaintProperty<std::string> {
+ static std::string defaultValue() { return ""; }
+};
+
+class FillPaintProperties : public PaintProperties<
+ FillAntialias,
+ FillOpacity,
+ FillColor,
+ FillOutlineColor,
+ FillTranslate,
+ FillTranslateAnchor,
+ FillPattern
+> {};
+
} // namespace style
} // namespace mbgl
diff --git a/src/mbgl/style/layers/layer.cpp.ejs b/src/mbgl/style/layers/layer.cpp.ejs
index c2cbc56a09..dcc78bafe5 100644
--- a/src/mbgl/style/layers/layer.cpp.ejs
+++ b/src/mbgl/style/layers/layer.cpp.ejs
@@ -78,17 +78,17 @@ const Filter& <%- camelize(type) %>Layer::getFilter() const {
<% for (const property of layoutProperties) { -%>
PropertyValue<<%- propertyType(property) %>> <%- camelize(type) %>Layer::getDefault<%- camelize(property.name) %>() {
- return { <%- defaultValue(property) %> };
+ return <%- camelize(property.name) %>::defaultValue();
}
PropertyValue<<%- propertyType(property) %>> <%- camelize(type) %>Layer::get<%- camelize(property.name) %>() const {
- return impl->layout.<%- camelizeWithLeadingLowercase(property.name) %>.get();
+ return impl->layout.unevaluated.get<<%- camelize(property.name) %>>();
}
void <%- camelize(type) %>Layer::set<%- camelize(property.name) %>(PropertyValue<<%- propertyType(property) %>> value) {
if (value == get<%- camelize(property.name) %>())
return;
- impl->layout.<%- camelizeWithLeadingLowercase(property.name) %>.set(value);
+ impl->layout.unevaluated.get<<%- camelize(property.name) %>>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "<%- property.name %>");
}
<% } -%>
@@ -100,13 +100,13 @@ PropertyValue<<%- propertyType(property) %>> <%- camelize(type) %>Layer::getDefa
}
PropertyValue<<%- propertyType(property) %>> <%- camelize(type) %>Layer::get<%- camelize(property.name) %>(const optional<std::string>& klass) const {
- return impl->paint.<%- camelizeWithLeadingLowercase(property.name) %>.get(klass);
+ return impl->paint.get<<%- camelize(property.name) %>>(klass);
}
void <%- camelize(type) %>Layer::set<%- camelize(property.name) %>(PropertyValue<<%- propertyType(property) %>> value, const optional<std::string>& klass) {
if (value == get<%- camelize(property.name) %>(klass))
return;
- impl->paint.<%- camelizeWithLeadingLowercase(property.name) %>.set(value, klass);
+ impl->paint.set<<%- camelize(property.name) %>>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
<% } -%>
diff --git a/src/mbgl/style/layers/layer_properties.cpp.ejs b/src/mbgl/style/layers/layer_properties.cpp.ejs
index b781a4a9d9..3b287decc0 100644
--- a/src/mbgl/style/layers/layer_properties.cpp.ejs
+++ b/src/mbgl/style/layers/layer_properties.cpp.ejs
@@ -10,29 +10,5 @@
namespace mbgl {
namespace style {
-<% if (layoutProperties.length) { -%>
-void <%- camelize(type) %>LayoutProperties::recalculate(const CalculationParameters& parameters) {
-<% for (const property of layoutProperties) { -%>
- <%- camelizeWithLeadingLowercase(property.name) %>.calculate(parameters);
-<% } -%>
-}
-
-<% } -%>
-void <%- camelize(type) %>PaintProperties::cascade(const CascadeParameters& parameters) {
-<% for (const property of paintProperties) { -%>
- <%- camelizeWithLeadingLowercase(property.name) %>.cascade(parameters);
-<% } -%>
-}
-
-bool <%- camelize(type) %>PaintProperties::recalculate(const CalculationParameters& parameters) {
- bool hasTransitions = false;
-
-<% for (const property of paintProperties) { -%>
- hasTransitions |= <%- camelizeWithLeadingLowercase(property.name) %>.calculate(parameters);
-<% } -%>
-
- return hasTransitions;
-}
-
} // namespace style
} // namespace mbgl
diff --git a/src/mbgl/style/layers/layer_properties.hpp.ejs b/src/mbgl/style/layers/layer_properties.hpp.ejs
index 0c91ecba8c..f490a636f9 100644
--- a/src/mbgl/style/layers/layer_properties.hpp.ejs
+++ b/src/mbgl/style/layers/layer_properties.hpp.ejs
@@ -14,33 +14,35 @@
namespace mbgl {
namespace style {
-class CascadeParameters;
-class CalculationParameters;
-
-<% if (layoutProperties.length) { -%>
-class <%- camelize(type) %>LayoutProperties {
-public:
- void recalculate(const CalculationParameters&);
-
<% for (const property of layoutProperties) { -%>
- LayoutProperty<<%- propertyType(property) %>> <%- camelizeWithLeadingLowercase(property.name) %> { <%- defaultValue(property) %> };
+struct <%- camelize(property.name) %> : LayoutProperty<<%- propertyType(property) %>> {
+ static <%- propertyType(property) %> defaultValue() { return <%- defaultValue(property) %>; }
+};
+
<% } -%>
+<% for (const property of paintProperties) { -%>
+struct <%- camelize(property.name) %> : <%
+if (/-pattern$/.test(property.name) || property.name === 'line-dasharray') {
+%>CrossFaded<% } -%>PaintProperty<<%- propertyType(property) %>> {
+ static <%- propertyType(property) %> defaultValue() { return <%- defaultValue(property) %>; }
};
<% } -%>
-class <%- camelize(type) %>PaintProperties {
-public:
- void cascade(const CascadeParameters&);
- bool recalculate(const CalculationParameters&);
+<% if (layoutProperties.length) { -%>
+class <%- camelize(type) %>LayoutProperties : public LayoutProperties<
+<% for (const property of layoutProperties.slice(0, -1)) { -%>
+ <%- camelize(property.name) %>,
+<% } -%>
+ <%- camelize(layoutProperties.slice(-1)[0].name) %>
+> {};
-<% for (const property of paintProperties) { -%>
-<% if (/-pattern$/.test(property.name) || property.name === 'line-dasharray') { -%>
- PaintProperty<<%- propertyType(property) %>, CrossFadedPropertyEvaluator> <%- camelizeWithLeadingLowercase(property.name) %> { <%- defaultValue(property) %> };
-<% } else { -%>
- PaintProperty<<%- propertyType(property) %>> <%- camelizeWithLeadingLowercase(property.name) %> { <%- defaultValue(property) %> };
<% } -%>
+class <%- camelize(type) %>PaintProperties : public PaintProperties<
+<% for (const property of paintProperties.slice(0, -1)) { -%>
+ <%- camelize(property.name) %>,
<% } -%>
-};
+ <%- camelize(paintProperties.slice(-1)[0].name) %>
+> {};
} // namespace style
} // namespace mbgl
diff --git a/src/mbgl/style/layers/line_layer.cpp b/src/mbgl/style/layers/line_layer.cpp
index 49ecf63c18..8c38ef5694 100644
--- a/src/mbgl/style/layers/line_layer.cpp
+++ b/src/mbgl/style/layers/line_layer.cpp
@@ -60,59 +60,59 @@ const Filter& LineLayer::getFilter() const {
// Layout properties
PropertyValue<LineCapType> LineLayer::getDefaultLineCap() {
- return { LineCapType::Butt };
+ return LineCap::defaultValue();
}
PropertyValue<LineCapType> LineLayer::getLineCap() const {
- return impl->layout.lineCap.get();
+ return impl->layout.unevaluated.get<LineCap>();
}
void LineLayer::setLineCap(PropertyValue<LineCapType> value) {
if (value == getLineCap())
return;
- impl->layout.lineCap.set(value);
+ impl->layout.unevaluated.get<LineCap>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "line-cap");
}
PropertyValue<LineJoinType> LineLayer::getDefaultLineJoin() {
- return { LineJoinType::Miter };
+ return LineJoin::defaultValue();
}
PropertyValue<LineJoinType> LineLayer::getLineJoin() const {
- return impl->layout.lineJoin.get();
+ return impl->layout.unevaluated.get<LineJoin>();
}
void LineLayer::setLineJoin(PropertyValue<LineJoinType> value) {
if (value == getLineJoin())
return;
- impl->layout.lineJoin.set(value);
+ impl->layout.unevaluated.get<LineJoin>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "line-join");
}
PropertyValue<float> LineLayer::getDefaultLineMiterLimit() {
- return { 2 };
+ return LineMiterLimit::defaultValue();
}
PropertyValue<float> LineLayer::getLineMiterLimit() const {
- return impl->layout.lineMiterLimit.get();
+ return impl->layout.unevaluated.get<LineMiterLimit>();
}
void LineLayer::setLineMiterLimit(PropertyValue<float> value) {
if (value == getLineMiterLimit())
return;
- impl->layout.lineMiterLimit.set(value);
+ impl->layout.unevaluated.get<LineMiterLimit>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "line-miter-limit");
}
PropertyValue<float> LineLayer::getDefaultLineRoundLimit() {
- return { 1 };
+ return LineRoundLimit::defaultValue();
}
PropertyValue<float> LineLayer::getLineRoundLimit() const {
- return impl->layout.lineRoundLimit.get();
+ return impl->layout.unevaluated.get<LineRoundLimit>();
}
void LineLayer::setLineRoundLimit(PropertyValue<float> value) {
if (value == getLineRoundLimit())
return;
- impl->layout.lineRoundLimit.set(value);
+ impl->layout.unevaluated.get<LineRoundLimit>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "line-round-limit");
}
@@ -123,13 +123,13 @@ PropertyValue<float> LineLayer::getDefaultLineOpacity() {
}
PropertyValue<float> LineLayer::getLineOpacity(const optional<std::string>& klass) const {
- return impl->paint.lineOpacity.get(klass);
+ return impl->paint.get<LineOpacity>(klass);
}
void LineLayer::setLineOpacity(PropertyValue<float> value, const optional<std::string>& klass) {
if (value == getLineOpacity(klass))
return;
- impl->paint.lineOpacity.set(value, klass);
+ impl->paint.set<LineOpacity>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -138,13 +138,13 @@ PropertyValue<Color> LineLayer::getDefaultLineColor() {
}
PropertyValue<Color> LineLayer::getLineColor(const optional<std::string>& klass) const {
- return impl->paint.lineColor.get(klass);
+ return impl->paint.get<LineColor>(klass);
}
void LineLayer::setLineColor(PropertyValue<Color> value, const optional<std::string>& klass) {
if (value == getLineColor(klass))
return;
- impl->paint.lineColor.set(value, klass);
+ impl->paint.set<LineColor>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -153,13 +153,13 @@ PropertyValue<std::array<float, 2>> LineLayer::getDefaultLineTranslate() {
}
PropertyValue<std::array<float, 2>> LineLayer::getLineTranslate(const optional<std::string>& klass) const {
- return impl->paint.lineTranslate.get(klass);
+ return impl->paint.get<LineTranslate>(klass);
}
void LineLayer::setLineTranslate(PropertyValue<std::array<float, 2>> value, const optional<std::string>& klass) {
if (value == getLineTranslate(klass))
return;
- impl->paint.lineTranslate.set(value, klass);
+ impl->paint.set<LineTranslate>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -168,13 +168,13 @@ PropertyValue<TranslateAnchorType> LineLayer::getDefaultLineTranslateAnchor() {
}
PropertyValue<TranslateAnchorType> LineLayer::getLineTranslateAnchor(const optional<std::string>& klass) const {
- return impl->paint.lineTranslateAnchor.get(klass);
+ return impl->paint.get<LineTranslateAnchor>(klass);
}
void LineLayer::setLineTranslateAnchor(PropertyValue<TranslateAnchorType> value, const optional<std::string>& klass) {
if (value == getLineTranslateAnchor(klass))
return;
- impl->paint.lineTranslateAnchor.set(value, klass);
+ impl->paint.set<LineTranslateAnchor>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -183,13 +183,13 @@ PropertyValue<float> LineLayer::getDefaultLineWidth() {
}
PropertyValue<float> LineLayer::getLineWidth(const optional<std::string>& klass) const {
- return impl->paint.lineWidth.get(klass);
+ return impl->paint.get<LineWidth>(klass);
}
void LineLayer::setLineWidth(PropertyValue<float> value, const optional<std::string>& klass) {
if (value == getLineWidth(klass))
return;
- impl->paint.lineWidth.set(value, klass);
+ impl->paint.set<LineWidth>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -198,13 +198,13 @@ PropertyValue<float> LineLayer::getDefaultLineGapWidth() {
}
PropertyValue<float> LineLayer::getLineGapWidth(const optional<std::string>& klass) const {
- return impl->paint.lineGapWidth.get(klass);
+ return impl->paint.get<LineGapWidth>(klass);
}
void LineLayer::setLineGapWidth(PropertyValue<float> value, const optional<std::string>& klass) {
if (value == getLineGapWidth(klass))
return;
- impl->paint.lineGapWidth.set(value, klass);
+ impl->paint.set<LineGapWidth>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -213,13 +213,13 @@ PropertyValue<float> LineLayer::getDefaultLineOffset() {
}
PropertyValue<float> LineLayer::getLineOffset(const optional<std::string>& klass) const {
- return impl->paint.lineOffset.get(klass);
+ return impl->paint.get<LineOffset>(klass);
}
void LineLayer::setLineOffset(PropertyValue<float> value, const optional<std::string>& klass) {
if (value == getLineOffset(klass))
return;
- impl->paint.lineOffset.set(value, klass);
+ impl->paint.set<LineOffset>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -228,13 +228,13 @@ PropertyValue<float> LineLayer::getDefaultLineBlur() {
}
PropertyValue<float> LineLayer::getLineBlur(const optional<std::string>& klass) const {
- return impl->paint.lineBlur.get(klass);
+ return impl->paint.get<LineBlur>(klass);
}
void LineLayer::setLineBlur(PropertyValue<float> value, const optional<std::string>& klass) {
if (value == getLineBlur(klass))
return;
- impl->paint.lineBlur.set(value, klass);
+ impl->paint.set<LineBlur>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -243,13 +243,13 @@ PropertyValue<std::vector<float>> LineLayer::getDefaultLineDasharray() {
}
PropertyValue<std::vector<float>> LineLayer::getLineDasharray(const optional<std::string>& klass) const {
- return impl->paint.lineDasharray.get(klass);
+ return impl->paint.get<LineDasharray>(klass);
}
void LineLayer::setLineDasharray(PropertyValue<std::vector<float>> value, const optional<std::string>& klass) {
if (value == getLineDasharray(klass))
return;
- impl->paint.lineDasharray.set(value, klass);
+ impl->paint.set<LineDasharray>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -258,13 +258,13 @@ PropertyValue<std::string> LineLayer::getDefaultLinePattern() {
}
PropertyValue<std::string> LineLayer::getLinePattern(const optional<std::string>& klass) const {
- return impl->paint.linePattern.get(klass);
+ return impl->paint.get<LinePattern>(klass);
}
void LineLayer::setLinePattern(PropertyValue<std::string> value, const optional<std::string>& klass) {
if (value == getLinePattern(klass))
return;
- impl->paint.linePattern.set(value, klass);
+ impl->paint.set<LinePattern>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
diff --git a/src/mbgl/style/layers/line_layer_impl.cpp b/src/mbgl/style/layers/line_layer_impl.cpp
index c116af5fc2..e6ec21a659 100644
--- a/src/mbgl/style/layers/line_layer_impl.cpp
+++ b/src/mbgl/style/layers/line_layer_impl.cpp
@@ -12,26 +12,24 @@ void LineLayer::Impl::cascade(const CascadeParameters& parameters) {
paint.cascade(parameters);
}
-bool LineLayer::Impl::recalculate(const CalculationParameters& parameters) {
+bool LineLayer::Impl::evaluate(const PropertyEvaluationParameters& parameters) {
// for scaling dasharrays
- CalculationParameters dashArrayParams = parameters;
+ PropertyEvaluationParameters dashArrayParams = parameters;
dashArrayParams.z = std::floor(dashArrayParams.z);
- paint.lineWidth.calculate(dashArrayParams);
- dashLineWidth = paint.lineWidth;
+ dashLineWidth = paint.evaluate<LineWidth>(dashArrayParams);
- bool hasTransitions = paint.recalculate(parameters);
+ paint.evaluate(parameters);
- passes = (paint.lineOpacity > 0 && paint.lineColor.value.a > 0 && paint.lineWidth > 0)
+ passes = (paint.evaluated.get<LineOpacity>() > 0 && paint.evaluated.get<LineColor>().a > 0 && paint.evaluated.get<LineWidth>() > 0)
? RenderPass::Translucent : RenderPass::None;
- return hasTransitions;
+ return paint.hasTransition();
}
std::unique_ptr<Bucket> LineLayer::Impl::createBucket(BucketParameters& parameters) const {
auto bucket = std::make_unique<LineBucket>(parameters.tileID.overscaleFactor());
- bucket->layout = layout;
- bucket->layout.recalculate(CalculationParameters(parameters.tileID.overscaledZ));
+ bucket->layout = layout.evaluate(PropertyEvaluationParameters(parameters.tileID.overscaledZ));
auto& name = bucketName();
parameters.eachFilteredFeature(filter, [&] (const auto& feature, std::size_t index, const std::string& layerName) {
@@ -44,10 +42,10 @@ std::unique_ptr<Bucket> LineLayer::Impl::createBucket(BucketParameters& paramete
}
float LineLayer::Impl::getLineWidth() const {
- if (paint.lineGapWidth > 0) {
- return paint.lineGapWidth + 2 * paint.lineWidth;
+ if (paint.evaluated.get<LineGapWidth>() > 0) {
+ return paint.evaluated.get<LineGapWidth>() + 2 * paint.evaluated.get<LineWidth>();
} else {
- return paint.lineWidth;
+ return paint.evaluated.get<LineWidth>();
}
}
@@ -82,8 +80,8 @@ optional<GeometryCollection> offsetLine(const GeometryCollection& rings, const d
}
float LineLayer::Impl::getQueryRadius() const {
- const std::array<float, 2>& translate = paint.lineTranslate;
- return getLineWidth() / 2.0 + std::abs(paint.lineOffset) + util::length(translate[0], translate[1]);
+ const std::array<float, 2>& translate = paint.evaluated.get<LineTranslate>();
+ return getLineWidth() / 2.0 + std::abs(paint.evaluated.get<LineOffset>()) + util::length(translate[0], translate[1]);
}
bool LineLayer::Impl::queryIntersectsGeometry(
@@ -95,8 +93,8 @@ bool LineLayer::Impl::queryIntersectsGeometry(
const float halfWidth = getLineWidth() / 2.0 * pixelsToTileUnits;
auto translatedQueryGeometry = FeatureIndex::translateQueryGeometry(
- queryGeometry, paint.lineTranslate, paint.lineTranslateAnchor, bearing, pixelsToTileUnits);
- auto offsetGeometry = offsetLine(geometry, paint.lineOffset * pixelsToTileUnits);
+ queryGeometry, paint.evaluated.get<LineTranslate>(), paint.evaluated.get<LineTranslateAnchor>(), bearing, pixelsToTileUnits);
+ auto offsetGeometry = offsetLine(geometry, paint.evaluated.get<LineOffset>() * pixelsToTileUnits);
return util::polygonIntersectsBufferedMultiLine(
translatedQueryGeometry.value_or(queryGeometry),
diff --git a/src/mbgl/style/layers/line_layer_impl.hpp b/src/mbgl/style/layers/line_layer_impl.hpp
index c6b4be3bec..3387db07f0 100644
--- a/src/mbgl/style/layers/line_layer_impl.hpp
+++ b/src/mbgl/style/layers/line_layer_impl.hpp
@@ -13,7 +13,7 @@ public:
std::unique_ptr<Layer> cloneRef(const std::string& id) const override;
void cascade(const CascadeParameters&) override;
- bool recalculate(const CalculationParameters&) override;
+ bool evaluate(const PropertyEvaluationParameters&) override;
std::unique_ptr<Bucket> createBucket(BucketParameters&) const override;
diff --git a/src/mbgl/style/layers/line_layer_properties.cpp b/src/mbgl/style/layers/line_layer_properties.cpp
index 2d6092745e..174239bcc8 100644
--- a/src/mbgl/style/layers/line_layer_properties.cpp
+++ b/src/mbgl/style/layers/line_layer_properties.cpp
@@ -5,42 +5,5 @@
namespace mbgl {
namespace style {
-void LineLayoutProperties::recalculate(const CalculationParameters& parameters) {
- lineCap.calculate(parameters);
- lineJoin.calculate(parameters);
- lineMiterLimit.calculate(parameters);
- lineRoundLimit.calculate(parameters);
-}
-
-void LinePaintProperties::cascade(const CascadeParameters& parameters) {
- lineOpacity.cascade(parameters);
- lineColor.cascade(parameters);
- lineTranslate.cascade(parameters);
- lineTranslateAnchor.cascade(parameters);
- lineWidth.cascade(parameters);
- lineGapWidth.cascade(parameters);
- lineOffset.cascade(parameters);
- lineBlur.cascade(parameters);
- lineDasharray.cascade(parameters);
- linePattern.cascade(parameters);
-}
-
-bool LinePaintProperties::recalculate(const CalculationParameters& parameters) {
- bool hasTransitions = false;
-
- hasTransitions |= lineOpacity.calculate(parameters);
- hasTransitions |= lineColor.calculate(parameters);
- hasTransitions |= lineTranslate.calculate(parameters);
- hasTransitions |= lineTranslateAnchor.calculate(parameters);
- hasTransitions |= lineWidth.calculate(parameters);
- hasTransitions |= lineGapWidth.calculate(parameters);
- hasTransitions |= lineOffset.calculate(parameters);
- hasTransitions |= lineBlur.calculate(parameters);
- hasTransitions |= lineDasharray.calculate(parameters);
- hasTransitions |= linePattern.calculate(parameters);
-
- return hasTransitions;
-}
-
} // namespace style
} // namespace mbgl
diff --git a/src/mbgl/style/layers/line_layer_properties.hpp b/src/mbgl/style/layers/line_layer_properties.hpp
index b73e3f2ef2..07458cd634 100644
--- a/src/mbgl/style/layers/line_layer_properties.hpp
+++ b/src/mbgl/style/layers/line_layer_properties.hpp
@@ -9,35 +9,81 @@
namespace mbgl {
namespace style {
-class CascadeParameters;
-class CalculationParameters;
-
-class LineLayoutProperties {
-public:
- void recalculate(const CalculationParameters&);
-
- LayoutProperty<LineCapType> lineCap { LineCapType::Butt };
- LayoutProperty<LineJoinType> lineJoin { LineJoinType::Miter };
- LayoutProperty<float> lineMiterLimit { 2 };
- LayoutProperty<float> lineRoundLimit { 1 };
-};
-
-class LinePaintProperties {
-public:
- void cascade(const CascadeParameters&);
- bool recalculate(const CalculationParameters&);
-
- PaintProperty<float> lineOpacity { 1 };
- PaintProperty<Color> lineColor { Color::black() };
- PaintProperty<std::array<float, 2>> lineTranslate { {{ 0, 0 }} };
- PaintProperty<TranslateAnchorType> lineTranslateAnchor { TranslateAnchorType::Map };
- PaintProperty<float> lineWidth { 1 };
- PaintProperty<float> lineGapWidth { 0 };
- PaintProperty<float> lineOffset { 0 };
- PaintProperty<float> lineBlur { 0 };
- PaintProperty<std::vector<float>, CrossFadedPropertyEvaluator> lineDasharray { { } };
- PaintProperty<std::string, CrossFadedPropertyEvaluator> linePattern { "" };
+struct LineCap : LayoutProperty<LineCapType> {
+ static LineCapType defaultValue() { return LineCapType::Butt; }
};
+struct LineJoin : LayoutProperty<LineJoinType> {
+ static LineJoinType defaultValue() { return LineJoinType::Miter; }
+};
+
+struct LineMiterLimit : LayoutProperty<float> {
+ static float defaultValue() { return 2; }
+};
+
+struct LineRoundLimit : LayoutProperty<float> {
+ static float defaultValue() { return 1; }
+};
+
+struct LineOpacity : PaintProperty<float> {
+ static float defaultValue() { return 1; }
+};
+
+struct LineColor : PaintProperty<Color> {
+ static Color defaultValue() { return Color::black(); }
+};
+
+struct LineTranslate : PaintProperty<std::array<float, 2>> {
+ static std::array<float, 2> defaultValue() { return {{ 0, 0 }}; }
+};
+
+struct LineTranslateAnchor : PaintProperty<TranslateAnchorType> {
+ static TranslateAnchorType defaultValue() { return TranslateAnchorType::Map; }
+};
+
+struct LineWidth : PaintProperty<float> {
+ static float defaultValue() { return 1; }
+};
+
+struct LineGapWidth : PaintProperty<float> {
+ static float defaultValue() { return 0; }
+};
+
+struct LineOffset : PaintProperty<float> {
+ static float defaultValue() { return 0; }
+};
+
+struct LineBlur : PaintProperty<float> {
+ static float defaultValue() { return 0; }
+};
+
+struct LineDasharray : CrossFadedPaintProperty<std::vector<float>> {
+ static std::vector<float> defaultValue() { return { }; }
+};
+
+struct LinePattern : CrossFadedPaintProperty<std::string> {
+ static std::string defaultValue() { return ""; }
+};
+
+class LineLayoutProperties : public LayoutProperties<
+ LineCap,
+ LineJoin,
+ LineMiterLimit,
+ LineRoundLimit
+> {};
+
+class LinePaintProperties : public PaintProperties<
+ LineOpacity,
+ LineColor,
+ LineTranslate,
+ LineTranslateAnchor,
+ LineWidth,
+ LineGapWidth,
+ LineOffset,
+ LineBlur,
+ LineDasharray,
+ LinePattern
+> {};
+
} // namespace style
} // namespace mbgl
diff --git a/src/mbgl/style/layers/raster_layer.cpp b/src/mbgl/style/layers/raster_layer.cpp
index 238bfef6e4..21d72a0fdc 100644
--- a/src/mbgl/style/layers/raster_layer.cpp
+++ b/src/mbgl/style/layers/raster_layer.cpp
@@ -49,13 +49,13 @@ PropertyValue<float> RasterLayer::getDefaultRasterOpacity() {
}
PropertyValue<float> RasterLayer::getRasterOpacity(const optional<std::string>& klass) const {
- return impl->paint.rasterOpacity.get(klass);
+ return impl->paint.get<RasterOpacity>(klass);
}
void RasterLayer::setRasterOpacity(PropertyValue<float> value, const optional<std::string>& klass) {
if (value == getRasterOpacity(klass))
return;
- impl->paint.rasterOpacity.set(value, klass);
+ impl->paint.set<RasterOpacity>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -64,13 +64,13 @@ PropertyValue<float> RasterLayer::getDefaultRasterHueRotate() {
}
PropertyValue<float> RasterLayer::getRasterHueRotate(const optional<std::string>& klass) const {
- return impl->paint.rasterHueRotate.get(klass);
+ return impl->paint.get<RasterHueRotate>(klass);
}
void RasterLayer::setRasterHueRotate(PropertyValue<float> value, const optional<std::string>& klass) {
if (value == getRasterHueRotate(klass))
return;
- impl->paint.rasterHueRotate.set(value, klass);
+ impl->paint.set<RasterHueRotate>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -79,13 +79,13 @@ PropertyValue<float> RasterLayer::getDefaultRasterBrightnessMin() {
}
PropertyValue<float> RasterLayer::getRasterBrightnessMin(const optional<std::string>& klass) const {
- return impl->paint.rasterBrightnessMin.get(klass);
+ return impl->paint.get<RasterBrightnessMin>(klass);
}
void RasterLayer::setRasterBrightnessMin(PropertyValue<float> value, const optional<std::string>& klass) {
if (value == getRasterBrightnessMin(klass))
return;
- impl->paint.rasterBrightnessMin.set(value, klass);
+ impl->paint.set<RasterBrightnessMin>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -94,13 +94,13 @@ PropertyValue<float> RasterLayer::getDefaultRasterBrightnessMax() {
}
PropertyValue<float> RasterLayer::getRasterBrightnessMax(const optional<std::string>& klass) const {
- return impl->paint.rasterBrightnessMax.get(klass);
+ return impl->paint.get<RasterBrightnessMax>(klass);
}
void RasterLayer::setRasterBrightnessMax(PropertyValue<float> value, const optional<std::string>& klass) {
if (value == getRasterBrightnessMax(klass))
return;
- impl->paint.rasterBrightnessMax.set(value, klass);
+ impl->paint.set<RasterBrightnessMax>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -109,13 +109,13 @@ PropertyValue<float> RasterLayer::getDefaultRasterSaturation() {
}
PropertyValue<float> RasterLayer::getRasterSaturation(const optional<std::string>& klass) const {
- return impl->paint.rasterSaturation.get(klass);
+ return impl->paint.get<RasterSaturation>(klass);
}
void RasterLayer::setRasterSaturation(PropertyValue<float> value, const optional<std::string>& klass) {
if (value == getRasterSaturation(klass))
return;
- impl->paint.rasterSaturation.set(value, klass);
+ impl->paint.set<RasterSaturation>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -124,13 +124,13 @@ PropertyValue<float> RasterLayer::getDefaultRasterContrast() {
}
PropertyValue<float> RasterLayer::getRasterContrast(const optional<std::string>& klass) const {
- return impl->paint.rasterContrast.get(klass);
+ return impl->paint.get<RasterContrast>(klass);
}
void RasterLayer::setRasterContrast(PropertyValue<float> value, const optional<std::string>& klass) {
if (value == getRasterContrast(klass))
return;
- impl->paint.rasterContrast.set(value, klass);
+ impl->paint.set<RasterContrast>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -139,13 +139,13 @@ PropertyValue<float> RasterLayer::getDefaultRasterFadeDuration() {
}
PropertyValue<float> RasterLayer::getRasterFadeDuration(const optional<std::string>& klass) const {
- return impl->paint.rasterFadeDuration.get(klass);
+ return impl->paint.get<RasterFadeDuration>(klass);
}
void RasterLayer::setRasterFadeDuration(PropertyValue<float> value, const optional<std::string>& klass) {
if (value == getRasterFadeDuration(klass))
return;
- impl->paint.rasterFadeDuration.set(value, klass);
+ impl->paint.set<RasterFadeDuration>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
diff --git a/src/mbgl/style/layers/raster_layer_impl.cpp b/src/mbgl/style/layers/raster_layer_impl.cpp
index 879bfa4559..3be4bb4fbd 100644
--- a/src/mbgl/style/layers/raster_layer_impl.cpp
+++ b/src/mbgl/style/layers/raster_layer_impl.cpp
@@ -8,12 +8,12 @@ void RasterLayer::Impl::cascade(const CascadeParameters& parameters) {
paint.cascade(parameters);
}
-bool RasterLayer::Impl::recalculate(const CalculationParameters& parameters) {
- bool hasTransitions = paint.recalculate(parameters);
+bool RasterLayer::Impl::evaluate(const PropertyEvaluationParameters& parameters) {
+ paint.evaluate(parameters);
- passes = paint.rasterOpacity > 0 ? RenderPass::Translucent : RenderPass::None;
+ passes = paint.evaluated.get<RasterOpacity>() > 0 ? RenderPass::Translucent : RenderPass::None;
- return hasTransitions;
+ return paint.hasTransition();
}
std::unique_ptr<Bucket> RasterLayer::Impl::createBucket(BucketParameters&) const {
diff --git a/src/mbgl/style/layers/raster_layer_impl.hpp b/src/mbgl/style/layers/raster_layer_impl.hpp
index a5b396e2ed..df5d388bdf 100644
--- a/src/mbgl/style/layers/raster_layer_impl.hpp
+++ b/src/mbgl/style/layers/raster_layer_impl.hpp
@@ -13,7 +13,7 @@ public:
std::unique_ptr<Layer> cloneRef(const std::string& id) const override;
void cascade(const CascadeParameters&) override;
- bool recalculate(const CalculationParameters&) override;
+ bool evaluate(const PropertyEvaluationParameters&) override;
std::unique_ptr<Bucket> createBucket(BucketParameters&) const override;
diff --git a/src/mbgl/style/layers/raster_layer_properties.cpp b/src/mbgl/style/layers/raster_layer_properties.cpp
index 68d9d1d35d..303719af40 100644
--- a/src/mbgl/style/layers/raster_layer_properties.cpp
+++ b/src/mbgl/style/layers/raster_layer_properties.cpp
@@ -5,29 +5,5 @@
namespace mbgl {
namespace style {
-void RasterPaintProperties::cascade(const CascadeParameters& parameters) {
- rasterOpacity.cascade(parameters);
- rasterHueRotate.cascade(parameters);
- rasterBrightnessMin.cascade(parameters);
- rasterBrightnessMax.cascade(parameters);
- rasterSaturation.cascade(parameters);
- rasterContrast.cascade(parameters);
- rasterFadeDuration.cascade(parameters);
-}
-
-bool RasterPaintProperties::recalculate(const CalculationParameters& parameters) {
- bool hasTransitions = false;
-
- hasTransitions |= rasterOpacity.calculate(parameters);
- hasTransitions |= rasterHueRotate.calculate(parameters);
- hasTransitions |= rasterBrightnessMin.calculate(parameters);
- hasTransitions |= rasterBrightnessMax.calculate(parameters);
- hasTransitions |= rasterSaturation.calculate(parameters);
- hasTransitions |= rasterContrast.calculate(parameters);
- hasTransitions |= rasterFadeDuration.calculate(parameters);
-
- return hasTransitions;
-}
-
} // namespace style
} // namespace mbgl
diff --git a/src/mbgl/style/layers/raster_layer_properties.hpp b/src/mbgl/style/layers/raster_layer_properties.hpp
index ddfb833e12..caa6d0c58d 100644
--- a/src/mbgl/style/layers/raster_layer_properties.hpp
+++ b/src/mbgl/style/layers/raster_layer_properties.hpp
@@ -9,22 +9,43 @@
namespace mbgl {
namespace style {
-class CascadeParameters;
-class CalculationParameters;
-
-class RasterPaintProperties {
-public:
- void cascade(const CascadeParameters&);
- bool recalculate(const CalculationParameters&);
-
- PaintProperty<float> rasterOpacity { 1 };
- PaintProperty<float> rasterHueRotate { 0 };
- PaintProperty<float> rasterBrightnessMin { 0 };
- PaintProperty<float> rasterBrightnessMax { 1 };
- PaintProperty<float> rasterSaturation { 0 };
- PaintProperty<float> rasterContrast { 0 };
- PaintProperty<float> rasterFadeDuration { 300 };
+struct RasterOpacity : PaintProperty<float> {
+ static float defaultValue() { return 1; }
};
+struct RasterHueRotate : PaintProperty<float> {
+ static float defaultValue() { return 0; }
+};
+
+struct RasterBrightnessMin : PaintProperty<float> {
+ static float defaultValue() { return 0; }
+};
+
+struct RasterBrightnessMax : PaintProperty<float> {
+ static float defaultValue() { return 1; }
+};
+
+struct RasterSaturation : PaintProperty<float> {
+ static float defaultValue() { return 0; }
+};
+
+struct RasterContrast : PaintProperty<float> {
+ static float defaultValue() { return 0; }
+};
+
+struct RasterFadeDuration : PaintProperty<float> {
+ static float defaultValue() { return 300; }
+};
+
+class RasterPaintProperties : public PaintProperties<
+ RasterOpacity,
+ RasterHueRotate,
+ RasterBrightnessMin,
+ RasterBrightnessMax,
+ RasterSaturation,
+ RasterContrast,
+ RasterFadeDuration
+> {};
+
} // namespace style
} // namespace mbgl
diff --git a/src/mbgl/style/layers/symbol_layer.cpp b/src/mbgl/style/layers/symbol_layer.cpp
index d49e8d7fe3..61f360ff64 100644
--- a/src/mbgl/style/layers/symbol_layer.cpp
+++ b/src/mbgl/style/layers/symbol_layer.cpp
@@ -60,479 +60,479 @@ const Filter& SymbolLayer::getFilter() const {
// Layout properties
PropertyValue<SymbolPlacementType> SymbolLayer::getDefaultSymbolPlacement() {
- return { SymbolPlacementType::Point };
+ return SymbolPlacement::defaultValue();
}
PropertyValue<SymbolPlacementType> SymbolLayer::getSymbolPlacement() const {
- return impl->layout.symbolPlacement.get();
+ return impl->layout.unevaluated.get<SymbolPlacement>();
}
void SymbolLayer::setSymbolPlacement(PropertyValue<SymbolPlacementType> value) {
if (value == getSymbolPlacement())
return;
- impl->layout.symbolPlacement.set(value);
+ impl->layout.unevaluated.get<SymbolPlacement>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "symbol-placement");
}
PropertyValue<float> SymbolLayer::getDefaultSymbolSpacing() {
- return { 250 };
+ return SymbolSpacing::defaultValue();
}
PropertyValue<float> SymbolLayer::getSymbolSpacing() const {
- return impl->layout.symbolSpacing.get();
+ return impl->layout.unevaluated.get<SymbolSpacing>();
}
void SymbolLayer::setSymbolSpacing(PropertyValue<float> value) {
if (value == getSymbolSpacing())
return;
- impl->layout.symbolSpacing.set(value);
+ impl->layout.unevaluated.get<SymbolSpacing>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "symbol-spacing");
}
PropertyValue<bool> SymbolLayer::getDefaultSymbolAvoidEdges() {
- return { false };
+ return SymbolAvoidEdges::defaultValue();
}
PropertyValue<bool> SymbolLayer::getSymbolAvoidEdges() const {
- return impl->layout.symbolAvoidEdges.get();
+ return impl->layout.unevaluated.get<SymbolAvoidEdges>();
}
void SymbolLayer::setSymbolAvoidEdges(PropertyValue<bool> value) {
if (value == getSymbolAvoidEdges())
return;
- impl->layout.symbolAvoidEdges.set(value);
+ impl->layout.unevaluated.get<SymbolAvoidEdges>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "symbol-avoid-edges");
}
PropertyValue<bool> SymbolLayer::getDefaultIconAllowOverlap() {
- return { false };
+ return IconAllowOverlap::defaultValue();
}
PropertyValue<bool> SymbolLayer::getIconAllowOverlap() const {
- return impl->layout.iconAllowOverlap.get();
+ return impl->layout.unevaluated.get<IconAllowOverlap>();
}
void SymbolLayer::setIconAllowOverlap(PropertyValue<bool> value) {
if (value == getIconAllowOverlap())
return;
- impl->layout.iconAllowOverlap.set(value);
+ impl->layout.unevaluated.get<IconAllowOverlap>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "icon-allow-overlap");
}
PropertyValue<bool> SymbolLayer::getDefaultIconIgnorePlacement() {
- return { false };
+ return IconIgnorePlacement::defaultValue();
}
PropertyValue<bool> SymbolLayer::getIconIgnorePlacement() const {
- return impl->layout.iconIgnorePlacement.get();
+ return impl->layout.unevaluated.get<IconIgnorePlacement>();
}
void SymbolLayer::setIconIgnorePlacement(PropertyValue<bool> value) {
if (value == getIconIgnorePlacement())
return;
- impl->layout.iconIgnorePlacement.set(value);
+ impl->layout.unevaluated.get<IconIgnorePlacement>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "icon-ignore-placement");
}
PropertyValue<bool> SymbolLayer::getDefaultIconOptional() {
- return { false };
+ return IconOptional::defaultValue();
}
PropertyValue<bool> SymbolLayer::getIconOptional() const {
- return impl->layout.iconOptional.get();
+ return impl->layout.unevaluated.get<IconOptional>();
}
void SymbolLayer::setIconOptional(PropertyValue<bool> value) {
if (value == getIconOptional())
return;
- impl->layout.iconOptional.set(value);
+ impl->layout.unevaluated.get<IconOptional>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "icon-optional");
}
PropertyValue<AlignmentType> SymbolLayer::getDefaultIconRotationAlignment() {
- return { AlignmentType::Auto };
+ return IconRotationAlignment::defaultValue();
}
PropertyValue<AlignmentType> SymbolLayer::getIconRotationAlignment() const {
- return impl->layout.iconRotationAlignment.get();
+ return impl->layout.unevaluated.get<IconRotationAlignment>();
}
void SymbolLayer::setIconRotationAlignment(PropertyValue<AlignmentType> value) {
if (value == getIconRotationAlignment())
return;
- impl->layout.iconRotationAlignment.set(value);
+ impl->layout.unevaluated.get<IconRotationAlignment>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "icon-rotation-alignment");
}
PropertyValue<float> SymbolLayer::getDefaultIconSize() {
- return { 1 };
+ return IconSize::defaultValue();
}
PropertyValue<float> SymbolLayer::getIconSize() const {
- return impl->layout.iconSize.get();
+ return impl->layout.unevaluated.get<IconSize>();
}
void SymbolLayer::setIconSize(PropertyValue<float> value) {
if (value == getIconSize())
return;
- impl->layout.iconSize.set(value);
+ impl->layout.unevaluated.get<IconSize>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "icon-size");
}
PropertyValue<IconTextFitType> SymbolLayer::getDefaultIconTextFit() {
- return { IconTextFitType::None };
+ return IconTextFit::defaultValue();
}
PropertyValue<IconTextFitType> SymbolLayer::getIconTextFit() const {
- return impl->layout.iconTextFit.get();
+ return impl->layout.unevaluated.get<IconTextFit>();
}
void SymbolLayer::setIconTextFit(PropertyValue<IconTextFitType> value) {
if (value == getIconTextFit())
return;
- impl->layout.iconTextFit.set(value);
+ impl->layout.unevaluated.get<IconTextFit>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "icon-text-fit");
}
PropertyValue<std::array<float, 4>> SymbolLayer::getDefaultIconTextFitPadding() {
- return { {{ 0, 0, 0, 0 }} };
+ return IconTextFitPadding::defaultValue();
}
PropertyValue<std::array<float, 4>> SymbolLayer::getIconTextFitPadding() const {
- return impl->layout.iconTextFitPadding.get();
+ return impl->layout.unevaluated.get<IconTextFitPadding>();
}
void SymbolLayer::setIconTextFitPadding(PropertyValue<std::array<float, 4>> value) {
if (value == getIconTextFitPadding())
return;
- impl->layout.iconTextFitPadding.set(value);
+ impl->layout.unevaluated.get<IconTextFitPadding>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "icon-text-fit-padding");
}
PropertyValue<std::string> SymbolLayer::getDefaultIconImage() {
- return { "" };
+ return IconImage::defaultValue();
}
PropertyValue<std::string> SymbolLayer::getIconImage() const {
- return impl->layout.iconImage.get();
+ return impl->layout.unevaluated.get<IconImage>();
}
void SymbolLayer::setIconImage(PropertyValue<std::string> value) {
if (value == getIconImage())
return;
- impl->layout.iconImage.set(value);
+ impl->layout.unevaluated.get<IconImage>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "icon-image");
}
PropertyValue<float> SymbolLayer::getDefaultIconRotate() {
- return { 0 };
+ return IconRotate::defaultValue();
}
PropertyValue<float> SymbolLayer::getIconRotate() const {
- return impl->layout.iconRotate.get();
+ return impl->layout.unevaluated.get<IconRotate>();
}
void SymbolLayer::setIconRotate(PropertyValue<float> value) {
if (value == getIconRotate())
return;
- impl->layout.iconRotate.set(value);
+ impl->layout.unevaluated.get<IconRotate>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "icon-rotate");
}
PropertyValue<float> SymbolLayer::getDefaultIconPadding() {
- return { 2 };
+ return IconPadding::defaultValue();
}
PropertyValue<float> SymbolLayer::getIconPadding() const {
- return impl->layout.iconPadding.get();
+ return impl->layout.unevaluated.get<IconPadding>();
}
void SymbolLayer::setIconPadding(PropertyValue<float> value) {
if (value == getIconPadding())
return;
- impl->layout.iconPadding.set(value);
+ impl->layout.unevaluated.get<IconPadding>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "icon-padding");
}
PropertyValue<bool> SymbolLayer::getDefaultIconKeepUpright() {
- return { false };
+ return IconKeepUpright::defaultValue();
}
PropertyValue<bool> SymbolLayer::getIconKeepUpright() const {
- return impl->layout.iconKeepUpright.get();
+ return impl->layout.unevaluated.get<IconKeepUpright>();
}
void SymbolLayer::setIconKeepUpright(PropertyValue<bool> value) {
if (value == getIconKeepUpright())
return;
- impl->layout.iconKeepUpright.set(value);
+ impl->layout.unevaluated.get<IconKeepUpright>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "icon-keep-upright");
}
PropertyValue<std::array<float, 2>> SymbolLayer::getDefaultIconOffset() {
- return { {{ 0, 0 }} };
+ return IconOffset::defaultValue();
}
PropertyValue<std::array<float, 2>> SymbolLayer::getIconOffset() const {
- return impl->layout.iconOffset.get();
+ return impl->layout.unevaluated.get<IconOffset>();
}
void SymbolLayer::setIconOffset(PropertyValue<std::array<float, 2>> value) {
if (value == getIconOffset())
return;
- impl->layout.iconOffset.set(value);
+ impl->layout.unevaluated.get<IconOffset>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "icon-offset");
}
PropertyValue<AlignmentType> SymbolLayer::getDefaultTextPitchAlignment() {
- return { AlignmentType::Auto };
+ return TextPitchAlignment::defaultValue();
}
PropertyValue<AlignmentType> SymbolLayer::getTextPitchAlignment() const {
- return impl->layout.textPitchAlignment.get();
+ return impl->layout.unevaluated.get<TextPitchAlignment>();
}
void SymbolLayer::setTextPitchAlignment(PropertyValue<AlignmentType> value) {
if (value == getTextPitchAlignment())
return;
- impl->layout.textPitchAlignment.set(value);
+ impl->layout.unevaluated.get<TextPitchAlignment>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "text-pitch-alignment");
}
PropertyValue<AlignmentType> SymbolLayer::getDefaultTextRotationAlignment() {
- return { AlignmentType::Auto };
+ return TextRotationAlignment::defaultValue();
}
PropertyValue<AlignmentType> SymbolLayer::getTextRotationAlignment() const {
- return impl->layout.textRotationAlignment.get();
+ return impl->layout.unevaluated.get<TextRotationAlignment>();
}
void SymbolLayer::setTextRotationAlignment(PropertyValue<AlignmentType> value) {
if (value == getTextRotationAlignment())
return;
- impl->layout.textRotationAlignment.set(value);
+ impl->layout.unevaluated.get<TextRotationAlignment>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "text-rotation-alignment");
}
PropertyValue<std::string> SymbolLayer::getDefaultTextField() {
- return { "" };
+ return TextField::defaultValue();
}
PropertyValue<std::string> SymbolLayer::getTextField() const {
- return impl->layout.textField.get();
+ return impl->layout.unevaluated.get<TextField>();
}
void SymbolLayer::setTextField(PropertyValue<std::string> value) {
if (value == getTextField())
return;
- impl->layout.textField.set(value);
+ impl->layout.unevaluated.get<TextField>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "text-field");
}
PropertyValue<std::vector<std::string>> SymbolLayer::getDefaultTextFont() {
- return { { "Open Sans Regular", "Arial Unicode MS Regular" } };
+ return TextFont::defaultValue();
}
PropertyValue<std::vector<std::string>> SymbolLayer::getTextFont() const {
- return impl->layout.textFont.get();
+ return impl->layout.unevaluated.get<TextFont>();
}
void SymbolLayer::setTextFont(PropertyValue<std::vector<std::string>> value) {
if (value == getTextFont())
return;
- impl->layout.textFont.set(value);
+ impl->layout.unevaluated.get<TextFont>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "text-font");
}
PropertyValue<float> SymbolLayer::getDefaultTextSize() {
- return { 16 };
+ return TextSize::defaultValue();
}
PropertyValue<float> SymbolLayer::getTextSize() const {
- return impl->layout.textSize.get();
+ return impl->layout.unevaluated.get<TextSize>();
}
void SymbolLayer::setTextSize(PropertyValue<float> value) {
if (value == getTextSize())
return;
- impl->layout.textSize.set(value);
+ impl->layout.unevaluated.get<TextSize>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "text-size");
}
PropertyValue<float> SymbolLayer::getDefaultTextMaxWidth() {
- return { 10 };
+ return TextMaxWidth::defaultValue();
}
PropertyValue<float> SymbolLayer::getTextMaxWidth() const {
- return impl->layout.textMaxWidth.get();
+ return impl->layout.unevaluated.get<TextMaxWidth>();
}
void SymbolLayer::setTextMaxWidth(PropertyValue<float> value) {
if (value == getTextMaxWidth())
return;
- impl->layout.textMaxWidth.set(value);
+ impl->layout.unevaluated.get<TextMaxWidth>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "text-max-width");
}
PropertyValue<float> SymbolLayer::getDefaultTextLineHeight() {
- return { 1.2 };
+ return TextLineHeight::defaultValue();
}
PropertyValue<float> SymbolLayer::getTextLineHeight() const {
- return impl->layout.textLineHeight.get();
+ return impl->layout.unevaluated.get<TextLineHeight>();
}
void SymbolLayer::setTextLineHeight(PropertyValue<float> value) {
if (value == getTextLineHeight())
return;
- impl->layout.textLineHeight.set(value);
+ impl->layout.unevaluated.get<TextLineHeight>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "text-line-height");
}
PropertyValue<float> SymbolLayer::getDefaultTextLetterSpacing() {
- return { 0 };
+ return TextLetterSpacing::defaultValue();
}
PropertyValue<float> SymbolLayer::getTextLetterSpacing() const {
- return impl->layout.textLetterSpacing.get();
+ return impl->layout.unevaluated.get<TextLetterSpacing>();
}
void SymbolLayer::setTextLetterSpacing(PropertyValue<float> value) {
if (value == getTextLetterSpacing())
return;
- impl->layout.textLetterSpacing.set(value);
+ impl->layout.unevaluated.get<TextLetterSpacing>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "text-letter-spacing");
}
PropertyValue<TextJustifyType> SymbolLayer::getDefaultTextJustify() {
- return { TextJustifyType::Center };
+ return TextJustify::defaultValue();
}
PropertyValue<TextJustifyType> SymbolLayer::getTextJustify() const {
- return impl->layout.textJustify.get();
+ return impl->layout.unevaluated.get<TextJustify>();
}
void SymbolLayer::setTextJustify(PropertyValue<TextJustifyType> value) {
if (value == getTextJustify())
return;
- impl->layout.textJustify.set(value);
+ impl->layout.unevaluated.get<TextJustify>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "text-justify");
}
PropertyValue<TextAnchorType> SymbolLayer::getDefaultTextAnchor() {
- return { TextAnchorType::Center };
+ return TextAnchor::defaultValue();
}
PropertyValue<TextAnchorType> SymbolLayer::getTextAnchor() const {
- return impl->layout.textAnchor.get();
+ return impl->layout.unevaluated.get<TextAnchor>();
}
void SymbolLayer::setTextAnchor(PropertyValue<TextAnchorType> value) {
if (value == getTextAnchor())
return;
- impl->layout.textAnchor.set(value);
+ impl->layout.unevaluated.get<TextAnchor>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "text-anchor");
}
PropertyValue<float> SymbolLayer::getDefaultTextMaxAngle() {
- return { 45 };
+ return TextMaxAngle::defaultValue();
}
PropertyValue<float> SymbolLayer::getTextMaxAngle() const {
- return impl->layout.textMaxAngle.get();
+ return impl->layout.unevaluated.get<TextMaxAngle>();
}
void SymbolLayer::setTextMaxAngle(PropertyValue<float> value) {
if (value == getTextMaxAngle())
return;
- impl->layout.textMaxAngle.set(value);
+ impl->layout.unevaluated.get<TextMaxAngle>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "text-max-angle");
}
PropertyValue<float> SymbolLayer::getDefaultTextRotate() {
- return { 0 };
+ return TextRotate::defaultValue();
}
PropertyValue<float> SymbolLayer::getTextRotate() const {
- return impl->layout.textRotate.get();
+ return impl->layout.unevaluated.get<TextRotate>();
}
void SymbolLayer::setTextRotate(PropertyValue<float> value) {
if (value == getTextRotate())
return;
- impl->layout.textRotate.set(value);
+ impl->layout.unevaluated.get<TextRotate>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "text-rotate");
}
PropertyValue<float> SymbolLayer::getDefaultTextPadding() {
- return { 2 };
+ return TextPadding::defaultValue();
}
PropertyValue<float> SymbolLayer::getTextPadding() const {
- return impl->layout.textPadding.get();
+ return impl->layout.unevaluated.get<TextPadding>();
}
void SymbolLayer::setTextPadding(PropertyValue<float> value) {
if (value == getTextPadding())
return;
- impl->layout.textPadding.set(value);
+ impl->layout.unevaluated.get<TextPadding>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "text-padding");
}
PropertyValue<bool> SymbolLayer::getDefaultTextKeepUpright() {
- return { true };
+ return TextKeepUpright::defaultValue();
}
PropertyValue<bool> SymbolLayer::getTextKeepUpright() const {
- return impl->layout.textKeepUpright.get();
+ return impl->layout.unevaluated.get<TextKeepUpright>();
}
void SymbolLayer::setTextKeepUpright(PropertyValue<bool> value) {
if (value == getTextKeepUpright())
return;
- impl->layout.textKeepUpright.set(value);
+ impl->layout.unevaluated.get<TextKeepUpright>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "text-keep-upright");
}
PropertyValue<TextTransformType> SymbolLayer::getDefaultTextTransform() {
- return { TextTransformType::None };
+ return TextTransform::defaultValue();
}
PropertyValue<TextTransformType> SymbolLayer::getTextTransform() const {
- return impl->layout.textTransform.get();
+ return impl->layout.unevaluated.get<TextTransform>();
}
void SymbolLayer::setTextTransform(PropertyValue<TextTransformType> value) {
if (value == getTextTransform())
return;
- impl->layout.textTransform.set(value);
+ impl->layout.unevaluated.get<TextTransform>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "text-transform");
}
PropertyValue<std::array<float, 2>> SymbolLayer::getDefaultTextOffset() {
- return { {{ 0, 0 }} };
+ return TextOffset::defaultValue();
}
PropertyValue<std::array<float, 2>> SymbolLayer::getTextOffset() const {
- return impl->layout.textOffset.get();
+ return impl->layout.unevaluated.get<TextOffset>();
}
void SymbolLayer::setTextOffset(PropertyValue<std::array<float, 2>> value) {
if (value == getTextOffset())
return;
- impl->layout.textOffset.set(value);
+ impl->layout.unevaluated.get<TextOffset>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "text-offset");
}
PropertyValue<bool> SymbolLayer::getDefaultTextAllowOverlap() {
- return { false };
+ return TextAllowOverlap::defaultValue();
}
PropertyValue<bool> SymbolLayer::getTextAllowOverlap() const {
- return impl->layout.textAllowOverlap.get();
+ return impl->layout.unevaluated.get<TextAllowOverlap>();
}
void SymbolLayer::setTextAllowOverlap(PropertyValue<bool> value) {
if (value == getTextAllowOverlap())
return;
- impl->layout.textAllowOverlap.set(value);
+ impl->layout.unevaluated.get<TextAllowOverlap>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "text-allow-overlap");
}
PropertyValue<bool> SymbolLayer::getDefaultTextIgnorePlacement() {
- return { false };
+ return TextIgnorePlacement::defaultValue();
}
PropertyValue<bool> SymbolLayer::getTextIgnorePlacement() const {
- return impl->layout.textIgnorePlacement.get();
+ return impl->layout.unevaluated.get<TextIgnorePlacement>();
}
void SymbolLayer::setTextIgnorePlacement(PropertyValue<bool> value) {
if (value == getTextIgnorePlacement())
return;
- impl->layout.textIgnorePlacement.set(value);
+ impl->layout.unevaluated.get<TextIgnorePlacement>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "text-ignore-placement");
}
PropertyValue<bool> SymbolLayer::getDefaultTextOptional() {
- return { false };
+ return TextOptional::defaultValue();
}
PropertyValue<bool> SymbolLayer::getTextOptional() const {
- return impl->layout.textOptional.get();
+ return impl->layout.unevaluated.get<TextOptional>();
}
void SymbolLayer::setTextOptional(PropertyValue<bool> value) {
if (value == getTextOptional())
return;
- impl->layout.textOptional.set(value);
+ impl->layout.unevaluated.get<TextOptional>() = value;
impl->observer->onLayerLayoutPropertyChanged(*this, "text-optional");
}
@@ -543,13 +543,13 @@ PropertyValue<float> SymbolLayer::getDefaultIconOpacity() {
}
PropertyValue<float> SymbolLayer::getIconOpacity(const optional<std::string>& klass) const {
- return impl->paint.iconOpacity.get(klass);
+ return impl->paint.get<IconOpacity>(klass);
}
void SymbolLayer::setIconOpacity(PropertyValue<float> value, const optional<std::string>& klass) {
if (value == getIconOpacity(klass))
return;
- impl->paint.iconOpacity.set(value, klass);
+ impl->paint.set<IconOpacity>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -558,13 +558,13 @@ PropertyValue<Color> SymbolLayer::getDefaultIconColor() {
}
PropertyValue<Color> SymbolLayer::getIconColor(const optional<std::string>& klass) const {
- return impl->paint.iconColor.get(klass);
+ return impl->paint.get<IconColor>(klass);
}
void SymbolLayer::setIconColor(PropertyValue<Color> value, const optional<std::string>& klass) {
if (value == getIconColor(klass))
return;
- impl->paint.iconColor.set(value, klass);
+ impl->paint.set<IconColor>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -573,13 +573,13 @@ PropertyValue<Color> SymbolLayer::getDefaultIconHaloColor() {
}
PropertyValue<Color> SymbolLayer::getIconHaloColor(const optional<std::string>& klass) const {
- return impl->paint.iconHaloColor.get(klass);
+ return impl->paint.get<IconHaloColor>(klass);
}
void SymbolLayer::setIconHaloColor(PropertyValue<Color> value, const optional<std::string>& klass) {
if (value == getIconHaloColor(klass))
return;
- impl->paint.iconHaloColor.set(value, klass);
+ impl->paint.set<IconHaloColor>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -588,13 +588,13 @@ PropertyValue<float> SymbolLayer::getDefaultIconHaloWidth() {
}
PropertyValue<float> SymbolLayer::getIconHaloWidth(const optional<std::string>& klass) const {
- return impl->paint.iconHaloWidth.get(klass);
+ return impl->paint.get<IconHaloWidth>(klass);
}
void SymbolLayer::setIconHaloWidth(PropertyValue<float> value, const optional<std::string>& klass) {
if (value == getIconHaloWidth(klass))
return;
- impl->paint.iconHaloWidth.set(value, klass);
+ impl->paint.set<IconHaloWidth>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -603,13 +603,13 @@ PropertyValue<float> SymbolLayer::getDefaultIconHaloBlur() {
}
PropertyValue<float> SymbolLayer::getIconHaloBlur(const optional<std::string>& klass) const {
- return impl->paint.iconHaloBlur.get(klass);
+ return impl->paint.get<IconHaloBlur>(klass);
}
void SymbolLayer::setIconHaloBlur(PropertyValue<float> value, const optional<std::string>& klass) {
if (value == getIconHaloBlur(klass))
return;
- impl->paint.iconHaloBlur.set(value, klass);
+ impl->paint.set<IconHaloBlur>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -618,13 +618,13 @@ PropertyValue<std::array<float, 2>> SymbolLayer::getDefaultIconTranslate() {
}
PropertyValue<std::array<float, 2>> SymbolLayer::getIconTranslate(const optional<std::string>& klass) const {
- return impl->paint.iconTranslate.get(klass);
+ return impl->paint.get<IconTranslate>(klass);
}
void SymbolLayer::setIconTranslate(PropertyValue<std::array<float, 2>> value, const optional<std::string>& klass) {
if (value == getIconTranslate(klass))
return;
- impl->paint.iconTranslate.set(value, klass);
+ impl->paint.set<IconTranslate>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -633,13 +633,13 @@ PropertyValue<TranslateAnchorType> SymbolLayer::getDefaultIconTranslateAnchor()
}
PropertyValue<TranslateAnchorType> SymbolLayer::getIconTranslateAnchor(const optional<std::string>& klass) const {
- return impl->paint.iconTranslateAnchor.get(klass);
+ return impl->paint.get<IconTranslateAnchor>(klass);
}
void SymbolLayer::setIconTranslateAnchor(PropertyValue<TranslateAnchorType> value, const optional<std::string>& klass) {
if (value == getIconTranslateAnchor(klass))
return;
- impl->paint.iconTranslateAnchor.set(value, klass);
+ impl->paint.set<IconTranslateAnchor>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -648,13 +648,13 @@ PropertyValue<float> SymbolLayer::getDefaultTextOpacity() {
}
PropertyValue<float> SymbolLayer::getTextOpacity(const optional<std::string>& klass) const {
- return impl->paint.textOpacity.get(klass);
+ return impl->paint.get<TextOpacity>(klass);
}
void SymbolLayer::setTextOpacity(PropertyValue<float> value, const optional<std::string>& klass) {
if (value == getTextOpacity(klass))
return;
- impl->paint.textOpacity.set(value, klass);
+ impl->paint.set<TextOpacity>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -663,13 +663,13 @@ PropertyValue<Color> SymbolLayer::getDefaultTextColor() {
}
PropertyValue<Color> SymbolLayer::getTextColor(const optional<std::string>& klass) const {
- return impl->paint.textColor.get(klass);
+ return impl->paint.get<TextColor>(klass);
}
void SymbolLayer::setTextColor(PropertyValue<Color> value, const optional<std::string>& klass) {
if (value == getTextColor(klass))
return;
- impl->paint.textColor.set(value, klass);
+ impl->paint.set<TextColor>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -678,13 +678,13 @@ PropertyValue<Color> SymbolLayer::getDefaultTextHaloColor() {
}
PropertyValue<Color> SymbolLayer::getTextHaloColor(const optional<std::string>& klass) const {
- return impl->paint.textHaloColor.get(klass);
+ return impl->paint.get<TextHaloColor>(klass);
}
void SymbolLayer::setTextHaloColor(PropertyValue<Color> value, const optional<std::string>& klass) {
if (value == getTextHaloColor(klass))
return;
- impl->paint.textHaloColor.set(value, klass);
+ impl->paint.set<TextHaloColor>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -693,13 +693,13 @@ PropertyValue<float> SymbolLayer::getDefaultTextHaloWidth() {
}
PropertyValue<float> SymbolLayer::getTextHaloWidth(const optional<std::string>& klass) const {
- return impl->paint.textHaloWidth.get(klass);
+ return impl->paint.get<TextHaloWidth>(klass);
}
void SymbolLayer::setTextHaloWidth(PropertyValue<float> value, const optional<std::string>& klass) {
if (value == getTextHaloWidth(klass))
return;
- impl->paint.textHaloWidth.set(value, klass);
+ impl->paint.set<TextHaloWidth>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -708,13 +708,13 @@ PropertyValue<float> SymbolLayer::getDefaultTextHaloBlur() {
}
PropertyValue<float> SymbolLayer::getTextHaloBlur(const optional<std::string>& klass) const {
- return impl->paint.textHaloBlur.get(klass);
+ return impl->paint.get<TextHaloBlur>(klass);
}
void SymbolLayer::setTextHaloBlur(PropertyValue<float> value, const optional<std::string>& klass) {
if (value == getTextHaloBlur(klass))
return;
- impl->paint.textHaloBlur.set(value, klass);
+ impl->paint.set<TextHaloBlur>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -723,13 +723,13 @@ PropertyValue<std::array<float, 2>> SymbolLayer::getDefaultTextTranslate() {
}
PropertyValue<std::array<float, 2>> SymbolLayer::getTextTranslate(const optional<std::string>& klass) const {
- return impl->paint.textTranslate.get(klass);
+ return impl->paint.get<TextTranslate>(klass);
}
void SymbolLayer::setTextTranslate(PropertyValue<std::array<float, 2>> value, const optional<std::string>& klass) {
if (value == getTextTranslate(klass))
return;
- impl->paint.textTranslate.set(value, klass);
+ impl->paint.set<TextTranslate>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
@@ -738,13 +738,13 @@ PropertyValue<TranslateAnchorType> SymbolLayer::getDefaultTextTranslateAnchor()
}
PropertyValue<TranslateAnchorType> SymbolLayer::getTextTranslateAnchor(const optional<std::string>& klass) const {
- return impl->paint.textTranslateAnchor.get(klass);
+ return impl->paint.get<TextTranslateAnchor>(klass);
}
void SymbolLayer::setTextTranslateAnchor(PropertyValue<TranslateAnchorType> value, const optional<std::string>& klass) {
if (value == getTextTranslateAnchor(klass))
return;
- impl->paint.textTranslateAnchor.set(value, klass);
+ impl->paint.set<TextTranslateAnchor>(value, klass);
impl->observer->onLayerPaintPropertyChanged(*this);
}
diff --git a/src/mbgl/style/layers/symbol_layer_impl.cpp b/src/mbgl/style/layers/symbol_layer_impl.cpp
index 0ac9ff832d..957bc1993e 100644
--- a/src/mbgl/style/layers/symbol_layer_impl.cpp
+++ b/src/mbgl/style/layers/symbol_layer_impl.cpp
@@ -10,20 +10,18 @@ void SymbolLayer::Impl::cascade(const CascadeParameters& parameters) {
paint.cascade(parameters);
}
-bool SymbolLayer::Impl::recalculate(const CalculationParameters& parameters) {
- bool hasTransitions = paint.recalculate(parameters);
+bool SymbolLayer::Impl::evaluate(const PropertyEvaluationParameters& parameters) {
+ paint.evaluate(parameters);
// text-size and icon-size are layout properties but they also need to be evaluated as paint properties:
- layout.iconSize.calculate(parameters);
- layout.textSize.calculate(parameters);
- iconSize = layout.iconSize;
- textSize = layout.textSize;
+ iconSize = layout.evaluate<IconSize>(parameters);
+ textSize = layout.evaluate<TextSize>(parameters);
- passes = ((paint.iconOpacity > 0 && (paint.iconColor.value.a > 0 || paint.iconHaloColor.value.a > 0) && iconSize > 0)
- || (paint.textOpacity > 0 && (paint.textColor.value.a > 0 || paint.textHaloColor.value.a > 0) && textSize > 0))
+ passes = ((paint.evaluated.get<IconOpacity>() > 0 && (paint.evaluated.get<IconColor>().a > 0 || paint.evaluated.get<IconHaloColor>().a > 0) && iconSize > 0)
+ || (paint.evaluated.get<TextOpacity>() > 0 && (paint.evaluated.get<TextColor>().a > 0 || paint.evaluated.get<TextHaloColor>().a > 0) && textSize > 0))
? RenderPass::Translucent : RenderPass::None;
- return hasTransitions;
+ return paint.hasTransition();
}
std::unique_ptr<Bucket> SymbolLayer::Impl::createBucket(BucketParameters&) const {
@@ -32,37 +30,34 @@ std::unique_ptr<Bucket> SymbolLayer::Impl::createBucket(BucketParameters&) const
}
std::unique_ptr<SymbolLayout> SymbolLayer::Impl::createLayout(BucketParameters& parameters) const {
- SymbolLayoutProperties layoutProperties = layout;
+ PropertyEvaluationParameters p(parameters.tileID.overscaledZ);
+ SymbolLayoutProperties::Evaluated evaluated = layout.evaluate(p);
- CalculationParameters p(parameters.tileID.overscaledZ);
- layoutProperties.recalculate(p);
-
- if (layoutProperties.iconRotationAlignment.value == AlignmentType::Auto) {
- if (layoutProperties.symbolPlacement.value == SymbolPlacementType::Line) {
- layoutProperties.iconRotationAlignment.value = AlignmentType::Map;
+ if (evaluated.get<IconRotationAlignment>() == AlignmentType::Auto) {
+ if (evaluated.get<SymbolPlacement>() == SymbolPlacementType::Line) {
+ evaluated.get<IconRotationAlignment>() = AlignmentType::Map;
} else {
- layoutProperties.iconRotationAlignment.value = AlignmentType::Viewport;
+ evaluated.get<IconRotationAlignment>() = AlignmentType::Viewport;
}
}
- if (layoutProperties.textRotationAlignment.value == AlignmentType::Auto) {
- if (layoutProperties.symbolPlacement.value == SymbolPlacementType::Line) {
- layoutProperties.textRotationAlignment.value = AlignmentType::Map;
+ if (evaluated.get<TextRotationAlignment>() == AlignmentType::Auto) {
+ if (evaluated.get<SymbolPlacement>() == SymbolPlacementType::Line) {
+ evaluated.get<TextRotationAlignment>() = AlignmentType::Map;
} else {
- layoutProperties.textRotationAlignment.value = AlignmentType::Viewport;
+ evaluated.get<TextRotationAlignment>() = AlignmentType::Viewport;
}
}
// If unspecified `text-pitch-alignment` inherits `text-rotation-alignment`
- if (layoutProperties.textPitchAlignment.value == AlignmentType::Auto) {
- layoutProperties.textPitchAlignment.value = layoutProperties.textRotationAlignment.value;
+ if (evaluated.get<TextPitchAlignment>() == AlignmentType::Auto) {
+ evaluated.get<TextPitchAlignment>() = evaluated.get<TextRotationAlignment>();
}
- layoutProperties.textSize.calculate(CalculationParameters(18));
- float textMaxSize = layoutProperties.textSize;
+ float textMaxSize = layout.evaluate<TextSize>(PropertyEvaluationParameters(18));
- layoutProperties.iconSize.calculate(CalculationParameters(p.z + 1));
- layoutProperties.textSize.calculate(CalculationParameters(p.z + 1));
+ evaluated.get<IconSize>() = layout.evaluate<IconSize>(PropertyEvaluationParameters(p.z + 1));
+ evaluated.get<TextSize>() = layout.evaluate<TextSize>(PropertyEvaluationParameters(p.z + 1));
return std::make_unique<SymbolLayout>(id,
parameters.layer.getName(),
@@ -71,40 +66,40 @@ std::unique_ptr<SymbolLayout> SymbolLayer::Impl::createLayout(BucketParameters&
parameters.mode,
parameters.layer,
filter,
- layoutProperties,
+ evaluated,
textMaxSize,
*spriteAtlas);
}
-SymbolPropertyValues SymbolLayer::Impl::iconPropertyValues(const SymbolLayoutProperties& layout_) const {
+SymbolPropertyValues SymbolLayer::Impl::iconPropertyValues(const SymbolLayoutProperties::Evaluated& layout_) const {
return SymbolPropertyValues {
- layout_.iconRotationAlignment.value, // icon-pitch-alignment is not yet implemented; inherit the rotation alignment
- layout_.iconRotationAlignment.value,
- layout_.iconSize.value,
- paint.iconOpacity.value,
- paint.iconColor.value,
- paint.iconHaloColor.value,
- paint.iconHaloWidth.value,
- paint.iconHaloBlur.value,
- paint.iconTranslate.value,
- paint.iconTranslateAnchor.value,
+ layout_.get<IconRotationAlignment>(), // icon-pitch-alignment is not yet implemented; inherit the rotation alignment
+ layout_.get<IconRotationAlignment>(),
+ layout_.get<IconSize>(),
+ paint.evaluated.get<IconOpacity>(),
+ paint.evaluated.get<IconColor>(),
+ paint.evaluated.get<IconHaloColor>(),
+ paint.evaluated.get<IconHaloWidth>(),
+ paint.evaluated.get<IconHaloBlur>(),
+ paint.evaluated.get<IconTranslate>(),
+ paint.evaluated.get<IconTranslateAnchor>(),
iconSize,
1.0f
};
}
-SymbolPropertyValues SymbolLayer::Impl::textPropertyValues(const SymbolLayoutProperties& layout_) const {
+SymbolPropertyValues SymbolLayer::Impl::textPropertyValues(const SymbolLayoutProperties::Evaluated& layout_) const {
return SymbolPropertyValues {
- layout_.textPitchAlignment.value,
- layout_.textRotationAlignment.value,
- layout_.textSize.value,
- paint.textOpacity.value,
- paint.textColor.value,
- paint.textHaloColor.value,
- paint.textHaloWidth.value,
- paint.textHaloBlur.value,
- paint.textTranslate.value,
- paint.textTranslateAnchor.value,
+ layout_.get<TextPitchAlignment>(),
+ layout_.get<TextRotationAlignment>(),
+ layout_.get<TextSize>(),
+ paint.evaluated.get<TextOpacity>(),
+ paint.evaluated.get<TextColor>(),
+ paint.evaluated.get<TextHaloColor>(),
+ paint.evaluated.get<TextHaloWidth>(),
+ paint.evaluated.get<TextHaloBlur>(),
+ paint.evaluated.get<TextTranslate>(),
+ paint.evaluated.get<TextTranslateAnchor>(),
textSize,
24.0f
};
diff --git a/src/mbgl/style/layers/symbol_layer_impl.hpp b/src/mbgl/style/layers/symbol_layer_impl.hpp
index b760538f86..46ed75b231 100644
--- a/src/mbgl/style/layers/symbol_layer_impl.hpp
+++ b/src/mbgl/style/layers/symbol_layer_impl.hpp
@@ -47,13 +47,13 @@ public:
std::unique_ptr<Layer> cloneRef(const std::string& id) const override;
void cascade(const CascadeParameters&) override;
- bool recalculate(const CalculationParameters&) override;
+ bool evaluate(const PropertyEvaluationParameters&) override;
std::unique_ptr<Bucket> createBucket(BucketParameters&) const override;
std::unique_ptr<SymbolLayout> createLayout(BucketParameters&) const;
- SymbolPropertyValues iconPropertyValues(const SymbolLayoutProperties&) const;
- SymbolPropertyValues textPropertyValues(const SymbolLayoutProperties&) const;
+ SymbolPropertyValues iconPropertyValues(const SymbolLayoutProperties::Evaluated&) const;
+ SymbolPropertyValues textPropertyValues(const SymbolLayoutProperties::Evaluated&) const;
SymbolLayoutProperties layout;
SymbolPaintProperties paint;
diff --git a/src/mbgl/style/layers/symbol_layer_properties.cpp b/src/mbgl/style/layers/symbol_layer_properties.cpp
index 59a73d3d59..5a1ce713ba 100644
--- a/src/mbgl/style/layers/symbol_layer_properties.cpp
+++ b/src/mbgl/style/layers/symbol_layer_properties.cpp
@@ -5,80 +5,5 @@
namespace mbgl {
namespace style {
-void SymbolLayoutProperties::recalculate(const CalculationParameters& parameters) {
- symbolPlacement.calculate(parameters);
- symbolSpacing.calculate(parameters);
- symbolAvoidEdges.calculate(parameters);
- iconAllowOverlap.calculate(parameters);
- iconIgnorePlacement.calculate(parameters);
- iconOptional.calculate(parameters);
- iconRotationAlignment.calculate(parameters);
- iconSize.calculate(parameters);
- iconTextFit.calculate(parameters);
- iconTextFitPadding.calculate(parameters);
- iconImage.calculate(parameters);
- iconRotate.calculate(parameters);
- iconPadding.calculate(parameters);
- iconKeepUpright.calculate(parameters);
- iconOffset.calculate(parameters);
- textPitchAlignment.calculate(parameters);
- textRotationAlignment.calculate(parameters);
- textField.calculate(parameters);
- textFont.calculate(parameters);
- textSize.calculate(parameters);
- textMaxWidth.calculate(parameters);
- textLineHeight.calculate(parameters);
- textLetterSpacing.calculate(parameters);
- textJustify.calculate(parameters);
- textAnchor.calculate(parameters);
- textMaxAngle.calculate(parameters);
- textRotate.calculate(parameters);
- textPadding.calculate(parameters);
- textKeepUpright.calculate(parameters);
- textTransform.calculate(parameters);
- textOffset.calculate(parameters);
- textAllowOverlap.calculate(parameters);
- textIgnorePlacement.calculate(parameters);
- textOptional.calculate(parameters);
-}
-
-void SymbolPaintProperties::cascade(const CascadeParameters& parameters) {
- iconOpacity.cascade(parameters);
- iconColor.cascade(parameters);
- iconHaloColor.cascade(parameters);
- iconHaloWidth.cascade(parameters);
- iconHaloBlur.cascade(parameters);
- iconTranslate.cascade(parameters);
- iconTranslateAnchor.cascade(parameters);
- textOpacity.cascade(parameters);
- textColor.cascade(parameters);
- textHaloColor.cascade(parameters);
- textHaloWidth.cascade(parameters);
- textHaloBlur.cascade(parameters);
- textTranslate.cascade(parameters);
- textTranslateAnchor.cascade(parameters);
-}
-
-bool SymbolPaintProperties::recalculate(const CalculationParameters& parameters) {
- bool hasTransitions = false;
-
- hasTransitions |= iconOpacity.calculate(parameters);
- hasTransitions |= iconColor.calculate(parameters);
- hasTransitions |= iconHaloColor.calculate(parameters);
- hasTransitions |= iconHaloWidth.calculate(parameters);
- hasTransitions |= iconHaloBlur.calculate(parameters);
- hasTransitions |= iconTranslate.calculate(parameters);
- hasTransitions |= iconTranslateAnchor.calculate(parameters);
- hasTransitions |= textOpacity.calculate(parameters);
- hasTransitions |= textColor.calculate(parameters);
- hasTransitions |= textHaloColor.calculate(parameters);
- hasTransitions |= textHaloWidth.calculate(parameters);
- hasTransitions |= textHaloBlur.calculate(parameters);
- hasTransitions |= textTranslate.calculate(parameters);
- hasTransitions |= textTranslateAnchor.calculate(parameters);
-
- return hasTransitions;
-}
-
} // namespace style
} // namespace mbgl
diff --git a/src/mbgl/style/layers/symbol_layer_properties.hpp b/src/mbgl/style/layers/symbol_layer_properties.hpp
index fefa0ae05e..8b72c4347a 100644
--- a/src/mbgl/style/layers/symbol_layer_properties.hpp
+++ b/src/mbgl/style/layers/symbol_layer_properties.hpp
@@ -9,69 +9,251 @@
namespace mbgl {
namespace style {
-class CascadeParameters;
-class CalculationParameters;
-
-class SymbolLayoutProperties {
-public:
- void recalculate(const CalculationParameters&);
-
- LayoutProperty<SymbolPlacementType> symbolPlacement { SymbolPlacementType::Point };
- LayoutProperty<float> symbolSpacing { 250 };
- LayoutProperty<bool> symbolAvoidEdges { false };
- LayoutProperty<bool> iconAllowOverlap { false };
- LayoutProperty<bool> iconIgnorePlacement { false };
- LayoutProperty<bool> iconOptional { false };
- LayoutProperty<AlignmentType> iconRotationAlignment { AlignmentType::Auto };
- LayoutProperty<float> iconSize { 1 };
- LayoutProperty<IconTextFitType> iconTextFit { IconTextFitType::None };
- LayoutProperty<std::array<float, 4>> iconTextFitPadding { {{ 0, 0, 0, 0 }} };
- LayoutProperty<std::string> iconImage { "" };
- LayoutProperty<float> iconRotate { 0 };
- LayoutProperty<float> iconPadding { 2 };
- LayoutProperty<bool> iconKeepUpright { false };
- LayoutProperty<std::array<float, 2>> iconOffset { {{ 0, 0 }} };
- LayoutProperty<AlignmentType> textPitchAlignment { AlignmentType::Auto };
- LayoutProperty<AlignmentType> textRotationAlignment { AlignmentType::Auto };
- LayoutProperty<std::string> textField { "" };
- LayoutProperty<std::vector<std::string>> textFont { { "Open Sans Regular", "Arial Unicode MS Regular" } };
- LayoutProperty<float> textSize { 16 };
- LayoutProperty<float> textMaxWidth { 10 };
- LayoutProperty<float> textLineHeight { 1.2 };
- LayoutProperty<float> textLetterSpacing { 0 };
- LayoutProperty<TextJustifyType> textJustify { TextJustifyType::Center };
- LayoutProperty<TextAnchorType> textAnchor { TextAnchorType::Center };
- LayoutProperty<float> textMaxAngle { 45 };
- LayoutProperty<float> textRotate { 0 };
- LayoutProperty<float> textPadding { 2 };
- LayoutProperty<bool> textKeepUpright { true };
- LayoutProperty<TextTransformType> textTransform { TextTransformType::None };
- LayoutProperty<std::array<float, 2>> textOffset { {{ 0, 0 }} };
- LayoutProperty<bool> textAllowOverlap { false };
- LayoutProperty<bool> textIgnorePlacement { false };
- LayoutProperty<bool> textOptional { false };
-};
-
-class SymbolPaintProperties {
-public:
- void cascade(const CascadeParameters&);
- bool recalculate(const CalculationParameters&);
-
- PaintProperty<float> iconOpacity { 1 };
- PaintProperty<Color> iconColor { Color::black() };
- PaintProperty<Color> iconHaloColor { {} };
- PaintProperty<float> iconHaloWidth { 0 };
- PaintProperty<float> iconHaloBlur { 0 };
- PaintProperty<std::array<float, 2>> iconTranslate { {{ 0, 0 }} };
- PaintProperty<TranslateAnchorType> iconTranslateAnchor { TranslateAnchorType::Map };
- PaintProperty<float> textOpacity { 1 };
- PaintProperty<Color> textColor { Color::black() };
- PaintProperty<Color> textHaloColor { {} };
- PaintProperty<float> textHaloWidth { 0 };
- PaintProperty<float> textHaloBlur { 0 };
- PaintProperty<std::array<float, 2>> textTranslate { {{ 0, 0 }} };
- PaintProperty<TranslateAnchorType> textTranslateAnchor { TranslateAnchorType::Map };
+struct SymbolPlacement : LayoutProperty<SymbolPlacementType> {
+ static SymbolPlacementType defaultValue() { return SymbolPlacementType::Point; }
};
+struct SymbolSpacing : LayoutProperty<float> {
+ static float defaultValue() { return 250; }
+};
+
+struct SymbolAvoidEdges : LayoutProperty<bool> {
+ static bool defaultValue() { return false; }
+};
+
+struct IconAllowOverlap : LayoutProperty<bool> {
+ static bool defaultValue() { return false; }
+};
+
+struct IconIgnorePlacement : LayoutProperty<bool> {
+ static bool defaultValue() { return false; }
+};
+
+struct IconOptional : LayoutProperty<bool> {
+ static bool defaultValue() { return false; }
+};
+
+struct IconRotationAlignment : LayoutProperty<AlignmentType> {
+ static AlignmentType defaultValue() { return AlignmentType::Auto; }
+};
+
+struct IconSize : LayoutProperty<float> {
+ static float defaultValue() { return 1; }
+};
+
+struct IconTextFit : LayoutProperty<IconTextFitType> {
+ static IconTextFitType defaultValue() { return IconTextFitType::None; }
+};
+
+struct IconTextFitPadding : LayoutProperty<std::array<float, 4>> {
+ static std::array<float, 4> defaultValue() { return {{ 0, 0, 0, 0 }}; }
+};
+
+struct IconImage : LayoutProperty<std::string> {
+ static std::string defaultValue() { return ""; }
+};
+
+struct IconRotate : LayoutProperty<float> {
+ static float defaultValue() { return 0; }
+};
+
+struct IconPadding : LayoutProperty<float> {
+ static float defaultValue() { return 2; }
+};
+
+struct IconKeepUpright : LayoutProperty<bool> {
+ static bool defaultValue() { return false; }
+};
+
+struct IconOffset : LayoutProperty<std::array<float, 2>> {
+ static std::array<float, 2> defaultValue() { return {{ 0, 0 }}; }
+};
+
+struct TextPitchAlignment : LayoutProperty<AlignmentType> {
+ static AlignmentType defaultValue() { return AlignmentType::Auto; }
+};
+
+struct TextRotationAlignment : LayoutProperty<AlignmentType> {
+ static AlignmentType defaultValue() { return AlignmentType::Auto; }
+};
+
+struct TextField : LayoutProperty<std::string> {
+ static std::string defaultValue() { return ""; }
+};
+
+struct TextFont : LayoutProperty<std::vector<std::string>> {
+ static std::vector<std::string> defaultValue() { return { "Open Sans Regular", "Arial Unicode MS Regular" }; }
+};
+
+struct TextSize : LayoutProperty<float> {
+ static float defaultValue() { return 16; }
+};
+
+struct TextMaxWidth : LayoutProperty<float> {
+ static float defaultValue() { return 10; }
+};
+
+struct TextLineHeight : LayoutProperty<float> {
+ static float defaultValue() { return 1.2; }
+};
+
+struct TextLetterSpacing : LayoutProperty<float> {
+ static float defaultValue() { return 0; }
+};
+
+struct TextJustify : LayoutProperty<TextJustifyType> {
+ static TextJustifyType defaultValue() { return TextJustifyType::Center; }
+};
+
+struct TextAnchor : LayoutProperty<TextAnchorType> {
+ static TextAnchorType defaultValue() { return TextAnchorType::Center; }
+};
+
+struct TextMaxAngle : LayoutProperty<float> {
+ static float defaultValue() { return 45; }
+};
+
+struct TextRotate : LayoutProperty<float> {
+ static float defaultValue() { return 0; }
+};
+
+struct TextPadding : LayoutProperty<float> {
+ static float defaultValue() { return 2; }
+};
+
+struct TextKeepUpright : LayoutProperty<bool> {
+ static bool defaultValue() { return true; }
+};
+
+struct TextTransform : LayoutProperty<TextTransformType> {
+ static TextTransformType defaultValue() { return TextTransformType::None; }
+};
+
+struct TextOffset : LayoutProperty<std::array<float, 2>> {
+ static std::array<float, 2> defaultValue() { return {{ 0, 0 }}; }
+};
+
+struct TextAllowOverlap : LayoutProperty<bool> {
+ static bool defaultValue() { return false; }
+};
+
+struct TextIgnorePlacement : LayoutProperty<bool> {
+ static bool defaultValue() { return false; }
+};
+
+struct TextOptional : LayoutProperty<bool> {
+ static bool defaultValue() { return false; }
+};
+
+struct IconOpacity : PaintProperty<float> {
+ static float defaultValue() { return 1; }
+};
+
+struct IconColor : PaintProperty<Color> {
+ static Color defaultValue() { return Color::black(); }
+};
+
+struct IconHaloColor : PaintProperty<Color> {
+ static Color defaultValue() { return {}; }
+};
+
+struct IconHaloWidth : PaintProperty<float> {
+ static float defaultValue() { return 0; }
+};
+
+struct IconHaloBlur : PaintProperty<float> {
+ static float defaultValue() { return 0; }
+};
+
+struct IconTranslate : PaintProperty<std::array<float, 2>> {
+ static std::array<float, 2> defaultValue() { return {{ 0, 0 }}; }
+};
+
+struct IconTranslateAnchor : PaintProperty<TranslateAnchorType> {
+ static TranslateAnchorType defaultValue() { return TranslateAnchorType::Map; }
+};
+
+struct TextOpacity : PaintProperty<float> {
+ static float defaultValue() { return 1; }
+};
+
+struct TextColor : PaintProperty<Color> {
+ static Color defaultValue() { return Color::black(); }
+};
+
+struct TextHaloColor : PaintProperty<Color> {
+ static Color defaultValue() { return {}; }
+};
+
+struct TextHaloWidth : PaintProperty<float> {
+ static float defaultValue() { return 0; }
+};
+
+struct TextHaloBlur : PaintProperty<float> {
+ static float defaultValue() { return 0; }
+};
+
+struct TextTranslate : PaintProperty<std::array<float, 2>> {
+ static std::array<float, 2> defaultValue() { return {{ 0, 0 }}; }
+};
+
+struct TextTranslateAnchor : PaintProperty<TranslateAnchorType> {
+ static TranslateAnchorType defaultValue() { return TranslateAnchorType::Map; }
+};
+
+class SymbolLayoutProperties : public LayoutProperties<
+ SymbolPlacement,
+ SymbolSpacing,
+ SymbolAvoidEdges,
+ IconAllowOverlap,
+ IconIgnorePlacement,
+ IconOptional,
+ IconRotationAlignment,
+ IconSize,
+ IconTextFit,
+ IconTextFitPadding,
+ IconImage,
+ IconRotate,
+ IconPadding,
+ IconKeepUpright,
+ IconOffset,
+ TextPitchAlignment,
+ TextRotationAlignment,
+ TextField,
+ TextFont,
+ TextSize,
+ TextMaxWidth,
+ TextLineHeight,
+ TextLetterSpacing,
+ TextJustify,
+ TextAnchor,
+ TextMaxAngle,
+ TextRotate,
+ TextPadding,
+ TextKeepUpright,
+ TextTransform,
+ TextOffset,
+ TextAllowOverlap,
+ TextIgnorePlacement,
+ TextOptional
+> {};
+
+class SymbolPaintProperties : public PaintProperties<
+ IconOpacity,
+ IconColor,
+ IconHaloColor,
+ IconHaloWidth,
+ IconHaloBlur,
+ IconTranslate,
+ IconTranslateAnchor,
+ TextOpacity,
+ TextColor,
+ TextHaloColor,
+ TextHaloWidth,
+ TextHaloBlur,
+ TextTranslate,
+ TextTranslateAnchor
+> {};
+
} // namespace style
} // namespace mbgl