summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2018-07-04 23:12:58 +0300
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2018-07-05 15:11:14 +0300
commit514485502db8ecacf2b11abad4599d7af09b0cf8 (patch)
tree21a76d2fda8b5ec5e19624f5eedf609a545b59b4 /src
parent32dce870d756063167e000302afb553714f1f0cb (diff)
downloadqtlocation-mapboxgl-514485502db8ecacf2b11abad4599d7af09b0cf8.tar.gz
Rename `HeatmapColorPropertyValue` to `ColorRampPropertyValue`
Based on patch from @lbud (Lauren Budorick). Give `HeatmapColorPropertyValue` a more generic name, since the same value type will be used for both `heatmap-color` and `line-gradient` properties.
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/style/conversion/make_property_setters.hpp2
-rw-r--r--src/mbgl/style/conversion/property_setter.hpp2
-rw-r--r--src/mbgl/style/layers/heatmap_layer.cpp10
-rw-r--r--src/mbgl/style/layers/heatmap_layer_properties.hpp2
-rw-r--r--src/mbgl/style/layers/layer.cpp.ejs2
-rw-r--r--src/mbgl/style/layers/layer_properties.hpp.ejs5
-rw-r--r--src/mbgl/style/paint_property.hpp14
7 files changed, 21 insertions, 16 deletions
diff --git a/src/mbgl/style/conversion/make_property_setters.hpp b/src/mbgl/style/conversion/make_property_setters.hpp
index 40461fc1e7..96aa1b6414 100644
--- a/src/mbgl/style/conversion/make_property_setters.hpp
+++ b/src/mbgl/style/conversion/make_property_setters.hpp
@@ -174,7 +174,7 @@ inline auto makePaintPropertySetters() {
result["heatmap-weight-transition"] = &setTransition<HeatmapLayer, &HeatmapLayer::setHeatmapWeightTransition>;
result["heatmap-intensity"] = &setProperty<HeatmapLayer, PropertyValue<float>, &HeatmapLayer::setHeatmapIntensity>;
result["heatmap-intensity-transition"] = &setTransition<HeatmapLayer, &HeatmapLayer::setHeatmapIntensityTransition>;
- result["heatmap-color"] = &setProperty<HeatmapLayer, HeatmapColorPropertyValue, &HeatmapLayer::setHeatmapColor>;
+ result["heatmap-color"] = &setProperty<HeatmapLayer, ColorRampPropertyValue, &HeatmapLayer::setHeatmapColor>;
result["heatmap-color-transition"] = &setTransition<HeatmapLayer, &HeatmapLayer::setHeatmapColorTransition>;
result["heatmap-opacity"] = &setProperty<HeatmapLayer, PropertyValue<float>, &HeatmapLayer::setHeatmapOpacity>;
result["heatmap-opacity-transition"] = &setTransition<HeatmapLayer, &HeatmapLayer::setHeatmapOpacityTransition>;
diff --git a/src/mbgl/style/conversion/property_setter.hpp b/src/mbgl/style/conversion/property_setter.hpp
index e3716a18dc..e13338f628 100644
--- a/src/mbgl/style/conversion/property_setter.hpp
+++ b/src/mbgl/style/conversion/property_setter.hpp
@@ -2,10 +2,10 @@
#include <mbgl/style/layer.hpp>
#include <mbgl/style/conversion.hpp>
+#include <mbgl/style/conversion/color_ramp_property_value.hpp>
#include <mbgl/style/conversion/constant.hpp>
#include <mbgl/style/conversion/property_value.hpp>
#include <mbgl/style/conversion/data_driven_property_value.hpp>
-#include <mbgl/style/conversion/heatmap_color_property_value.hpp>
#include <mbgl/style/conversion/transition_options.hpp>
#include <string>
diff --git a/src/mbgl/style/layers/heatmap_layer.cpp b/src/mbgl/style/layers/heatmap_layer.cpp
index 3f7881ddd3..c2a1545a00 100644
--- a/src/mbgl/style/layers/heatmap_layer.cpp
+++ b/src/mbgl/style/layers/heatmap_layer.cpp
@@ -5,8 +5,8 @@
#include <mbgl/style/layer_observer.hpp>
// for constructing default heatmap-color ramp expression from style JSON
#include <mbgl/style/conversion.hpp>
+#include <mbgl/style/conversion/color_ramp_property_value.hpp>
#include <mbgl/style/conversion/json.hpp>
-#include <mbgl/style/conversion/heatmap_color_property_value.hpp>
namespace mbgl {
namespace style {
@@ -181,17 +181,17 @@ TransitionOptions HeatmapLayer::getHeatmapIntensityTransition() const {
return impl().paint.template get<HeatmapIntensity>().options;
}
-HeatmapColorPropertyValue HeatmapLayer::getDefaultHeatmapColor() {
+ColorRampPropertyValue HeatmapLayer::getDefaultHeatmapColor() {
conversion::Error error;
std::string rawValue = R"JSON(["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"])JSON";
- return *conversion::convertJSON<HeatmapColorPropertyValue>(rawValue, error);
+ return *conversion::convertJSON<ColorRampPropertyValue>(rawValue, error);
}
-HeatmapColorPropertyValue HeatmapLayer::getHeatmapColor() const {
+ColorRampPropertyValue HeatmapLayer::getHeatmapColor() const {
return impl().paint.template get<HeatmapColor>().value;
}
-void HeatmapLayer::setHeatmapColor(HeatmapColorPropertyValue value) {
+void HeatmapLayer::setHeatmapColor(ColorRampPropertyValue value) {
if (value == getHeatmapColor())
return;
auto impl_ = mutableImpl();
diff --git a/src/mbgl/style/layers/heatmap_layer_properties.hpp b/src/mbgl/style/layers/heatmap_layer_properties.hpp
index f7afa5fbeb..fe7257a78a 100644
--- a/src/mbgl/style/layers/heatmap_layer_properties.hpp
+++ b/src/mbgl/style/layers/heatmap_layer_properties.hpp
@@ -24,6 +24,8 @@ struct HeatmapIntensity : PaintProperty<float> {
static float defaultValue() { return 1; }
};
+using HeatmapColor = ColorRampProperty;
+
struct HeatmapOpacity : PaintProperty<float> {
static float defaultValue() { return 1; }
};
diff --git a/src/mbgl/style/layers/layer.cpp.ejs b/src/mbgl/style/layers/layer.cpp.ejs
index 6d748311bf..a9b6d9d02d 100644
--- a/src/mbgl/style/layers/layer.cpp.ejs
+++ b/src/mbgl/style/layers/layer.cpp.ejs
@@ -11,8 +11,8 @@
<% if (type === 'heatmap') { -%>
// for constructing default heatmap-color ramp expression from style JSON
#include <mbgl/style/conversion.hpp>
+#include <mbgl/style/conversion/color_ramp_property_value.hpp>
#include <mbgl/style/conversion/json.hpp>
-#include <mbgl/style/conversion/heatmap_color_property_value.hpp>
<% } -%>
namespace mbgl {
diff --git a/src/mbgl/style/layers/layer_properties.hpp.ejs b/src/mbgl/style/layers/layer_properties.hpp.ejs
index 1bceb84960..5b774933a6 100644
--- a/src/mbgl/style/layers/layer_properties.hpp.ejs
+++ b/src/mbgl/style/layers/layer_properties.hpp.ejs
@@ -25,10 +25,13 @@ struct <%- camelize(property.name) %> : <%- layoutPropertyType(property, type) %
<% } -%>
<% for (const property of paintProperties) { -%>
-<% if (property.name === 'heatmap-color') continue; -%>
+<% if (property['property-type'] === 'color-ramp') { -%>
+using <%- camelize(property.name) %> = ColorRampProperty;
+<% } else { -%>
struct <%- camelize(property.name) %> : <%- paintPropertyType(property, type) %> {
static <%- evaluatedType(property) %> defaultValue() { return <%- defaultValue(property) %>; }
};
+<% } -%>
<% } -%>
<% if (layoutProperties.length) { -%>
diff --git a/src/mbgl/style/paint_property.hpp b/src/mbgl/style/paint_property.hpp
index 195eb645a9..d51a6760c5 100644
--- a/src/mbgl/style/paint_property.hpp
+++ b/src/mbgl/style/paint_property.hpp
@@ -1,8 +1,8 @@
#pragma once
+#include <mbgl/style/color_ramp_property_value.hpp>
#include <mbgl/style/properties.hpp>
#include <mbgl/style/property_value.hpp>
-#include <mbgl/style/heatmap_color_property_value.hpp>
#include <mbgl/style/data_driven_property_value.hpp>
#include <mbgl/renderer/property_evaluator.hpp>
#include <mbgl/renderer/cross_faded_property_evaluator.hpp>
@@ -50,19 +50,19 @@ public:
};
/*
- * Special-case paint property traits for heatmap-color, needed because
- * heatmap-color values do not fit into the
+ * Special-case paint property traits for heatmap-color and line-gradient,
+ * needed because these values do not fit into the
* Undefined | Value | {Camera,Source,Composite}Function taxonomy that applies
* to all other paint properties.
*
- * These traits are provided here--despite the fact that heatmap-color
+ * These traits are provided here--despite the fact that color ramps
* is not used like other paint properties--to allow the parameter-pack-based
* batch evaluation of paint properties to compile properly.
*/
-class HeatmapColor {
+class ColorRampProperty {
public:
- using TransitionableType = Transitionable<HeatmapColorPropertyValue>;
- using UnevaluatedType = Transitioning<HeatmapColorPropertyValue>;
+ using TransitionableType = Transitionable<ColorRampPropertyValue>;
+ using UnevaluatedType = Transitioning<ColorRampPropertyValue>;
using EvaluatorType = PropertyEvaluator<Color>;
using PossiblyEvaluatedType = Color;
using Type = Color;