summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2015-12-04 12:04:22 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2015-12-07 11:19:08 -0800
commitcdd129335cc7a58ef57b2258b4cde5b56ce414a6 (patch)
treee2abffd54e932c6bb988c8f0f57c3c7018e50e69 /src
parent0a0007e0acdce85576857bec76e1333d771472f1 (diff)
downloadqtlocation-mapboxgl-cdd129335cc7a58ef57b2258b4cde5b56ce414a6.tar.gz
[core] Make Paint/LayoutProperties constructor explicit
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/layer/background_layer.hpp6
-rw-r--r--src/mbgl/layer/circle_layer.hpp12
-rw-r--r--src/mbgl/layer/fill_layer.hpp14
-rw-r--r--src/mbgl/layer/line_layer.hpp28
-rw-r--r--src/mbgl/layer/raster_layer.hpp14
-rw-r--r--src/mbgl/layer/symbol_layer.hpp76
-rw-r--r--src/mbgl/style/layout_property.hpp3
-rw-r--r--src/mbgl/style/paint_property.hpp2
8 files changed, 78 insertions, 77 deletions
diff --git a/src/mbgl/layer/background_layer.hpp b/src/mbgl/layer/background_layer.hpp
index ee8d3fc88a..4a34289193 100644
--- a/src/mbgl/layer/background_layer.hpp
+++ b/src/mbgl/layer/background_layer.hpp
@@ -8,9 +8,9 @@ namespace mbgl {
class BackgroundPaintProperties {
public:
- PaintProperty<float> opacity = 1.0f;
- PaintProperty<Color> color = { {{ 0, 0, 0, 1 }} };
- PaintProperty<std::string, Faded<std::string>> pattern = { "" };
+ PaintProperty<float> opacity { 1.0f };
+ PaintProperty<Color> color { {{ 0, 0, 0, 1 }} };
+ PaintProperty<std::string, Faded<std::string>> pattern { "" };
};
class BackgroundLayer : public StyleLayer {
diff --git a/src/mbgl/layer/circle_layer.hpp b/src/mbgl/layer/circle_layer.hpp
index 3e4581ef62..80a94c7401 100644
--- a/src/mbgl/layer/circle_layer.hpp
+++ b/src/mbgl/layer/circle_layer.hpp
@@ -8,12 +8,12 @@ namespace mbgl {
class CirclePaintProperties {
public:
- PaintProperty<float> radius = 5.0f;
- PaintProperty<Color> color = { {{ 0, 0, 0, 1 }} };
- PaintProperty<float> opacity = 1.0f;
- PaintProperty<std::array<float, 2>> translate = { {{ 0, 0 }} };
- PaintProperty<TranslateAnchorType> translateAnchor = TranslateAnchorType::Map;
- PaintProperty<float> blur = 0;
+ PaintProperty<float> radius { 5.0f };
+ PaintProperty<Color> color { {{ 0, 0, 0, 1 }} };
+ PaintProperty<float> opacity { 1.0f };
+ PaintProperty<std::array<float, 2>> translate { {{ 0, 0 }} };
+ PaintProperty<TranslateAnchorType> translateAnchor { TranslateAnchorType::Map };
+ PaintProperty<float> blur { 0 };
bool isVisible() const {
return radius > 0 && color.value[3] > 0 && opacity > 0;
diff --git a/src/mbgl/layer/fill_layer.hpp b/src/mbgl/layer/fill_layer.hpp
index 1132fbf4e8..93514ee425 100644
--- a/src/mbgl/layer/fill_layer.hpp
+++ b/src/mbgl/layer/fill_layer.hpp
@@ -8,13 +8,13 @@ namespace mbgl {
class FillPaintProperties {
public:
- PaintProperty<bool> antialias = true;
- PaintProperty<float> opacity = 1.0f;
- PaintProperty<Color> color = { {{ 0, 0, 0, 1 }} };
- PaintProperty<Color> outlineColor = { {{ 0, 0, 0, -1 }} };
- PaintProperty<std::array<float, 2>> translate = { {{ 0, 0 }} };
- PaintProperty<TranslateAnchorType> translateAnchor = TranslateAnchorType::Map;
- PaintProperty<std::string, Faded<std::string>> pattern = { "" };
+ PaintProperty<bool> antialias { true };
+ PaintProperty<float> opacity { 1.0f };
+ PaintProperty<Color> color { {{ 0, 0, 0, 1 }} };
+ PaintProperty<Color> outlineColor { {{ 0, 0, 0, -1 }} };
+ PaintProperty<std::array<float, 2>> translate { {{ 0, 0 }} };
+ PaintProperty<TranslateAnchorType> translateAnchor { TranslateAnchorType::Map };
+ PaintProperty<std::string, Faded<std::string>> pattern { "" };
};
class FillLayer : public StyleLayer {
diff --git a/src/mbgl/layer/line_layer.hpp b/src/mbgl/layer/line_layer.hpp
index d1c654619a..b1917b4ca3 100644
--- a/src/mbgl/layer/line_layer.hpp
+++ b/src/mbgl/layer/line_layer.hpp
@@ -9,24 +9,24 @@ namespace mbgl {
class LineLayoutProperties {
public:
- LayoutProperty<CapType> cap = CapType::Butt;
- LayoutProperty<JoinType> join = JoinType::Miter;
- LayoutProperty<float> miterLimit = 2.0f;
- LayoutProperty<float> roundLimit = 1.0f;
+ LayoutProperty<CapType> cap { CapType::Butt };
+ LayoutProperty<JoinType> join { JoinType::Miter };
+ LayoutProperty<float> miterLimit { 2.0f };
+ LayoutProperty<float> roundLimit { 1.0f };
};
class LinePaintProperties {
public:
- PaintProperty<float> opacity = 1.0f;
- PaintProperty<Color> color = { {{ 0, 0, 0, 1 }} };
- PaintProperty<std::array<float, 2>> translate = { {{ 0, 0 }} };
- PaintProperty<TranslateAnchorType> translateAnchor = TranslateAnchorType::Map;
- PaintProperty<float> width = 1;
- PaintProperty<float> gapWidth = 0;
- PaintProperty<float> blur = 0;
- PaintProperty<float> offset = 0;
- PaintProperty<std::vector<float>, Faded<std::vector<float>>> dasharray = { {} };
- PaintProperty<std::string, Faded<std::string>> pattern = { "" };
+ PaintProperty<float> opacity { 1.0f };
+ PaintProperty<Color> color { {{ 0, 0, 0, 1 }} };
+ PaintProperty<std::array<float, 2>> translate { {{ 0, 0 }} };
+ PaintProperty<TranslateAnchorType> translateAnchor { TranslateAnchorType::Map };
+ PaintProperty<float> width { 1 };
+ PaintProperty<float> gapWidth { 0 };
+ PaintProperty<float> blur { 0 };
+ PaintProperty<float> offset { 0 };
+ PaintProperty<std::vector<float>, Faded<std::vector<float>>> dasharray { {} };
+ PaintProperty<std::string, Faded<std::string>> pattern { "" };
// Special case
float dashLineWidth = 1;
diff --git a/src/mbgl/layer/raster_layer.hpp b/src/mbgl/layer/raster_layer.hpp
index 43ffa48869..fc571617ab 100644
--- a/src/mbgl/layer/raster_layer.hpp
+++ b/src/mbgl/layer/raster_layer.hpp
@@ -8,13 +8,13 @@ namespace mbgl {
class RasterPaintProperties {
public:
- PaintProperty<float> opacity = 1.0f;
- PaintProperty<float> hueRotate = 0.0f;
- PaintProperty<float> brightnessMin = 0.0f;
- PaintProperty<float> brightnessMax = 1.0f;
- PaintProperty<float> saturation = 0.0f;
- PaintProperty<float> contrast = 0.0f;
- PaintProperty<float> fadeDuration = 0.0f;
+ PaintProperty<float> opacity { 1.0f };
+ PaintProperty<float> hueRotate { 0.0f };
+ PaintProperty<float> brightnessMin { 0.0f };
+ PaintProperty<float> brightnessMax { 1.0f };
+ PaintProperty<float> saturation { 0.0f };
+ PaintProperty<float> contrast { 0.0f };
+ PaintProperty<float> fadeDuration { 0.0f };
};
class RasterLayer : public StyleLayer {
diff --git a/src/mbgl/layer/symbol_layer.hpp b/src/mbgl/layer/symbol_layer.hpp
index 4b37d12055..42d0bb9c74 100644
--- a/src/mbgl/layer/symbol_layer.hpp
+++ b/src/mbgl/layer/symbol_layer.hpp
@@ -11,44 +11,44 @@ class SpriteAtlas;
class SymbolLayoutProperties {
public:
- LayoutProperty<PlacementType> placement = PlacementType::Point;
- LayoutProperty<float> spacing = 250.0f;
- LayoutProperty<bool> avoidEdges = false;
+ LayoutProperty<PlacementType> placement { PlacementType::Point };
+ LayoutProperty<float> spacing { 250.0f };
+ LayoutProperty<bool> avoidEdges { false };
class IconProperties {
public:
- LayoutProperty<bool> allowOverlap = false;
- LayoutProperty<bool> ignorePlacement = false;
- LayoutProperty<bool> optional = false;
- LayoutProperty<RotationAlignmentType> rotationAlignment = RotationAlignmentType::Viewport;
- LayoutProperty<float> size = 1.0f;
- LayoutProperty<std::string> image = { "" };
- LayoutProperty<float> rotate = 0.0f;
- LayoutProperty<float> padding = 2.0f;
- LayoutProperty<bool> keepUpright = false;
- LayoutProperty<std::array<float, 2>> offset = { {{ 0, 0 }} };
+ LayoutProperty<bool> allowOverlap { false };
+ LayoutProperty<bool> ignorePlacement { false };
+ LayoutProperty<bool> optional { false };
+ LayoutProperty<RotationAlignmentType> rotationAlignment { RotationAlignmentType::Viewport };
+ LayoutProperty<float> size { 1.0f };
+ LayoutProperty<std::string> image { "" };
+ LayoutProperty<float> rotate { 0.0f };
+ LayoutProperty<float> padding { 2.0f };
+ LayoutProperty<bool> keepUpright { false };
+ LayoutProperty<std::array<float, 2>> offset { {{ 0, 0 }} };
} icon;
class TextProperties {
public:
- LayoutProperty<RotationAlignmentType> rotationAlignment = RotationAlignmentType::Viewport;
- LayoutProperty<std::string> field = { "" };
- LayoutProperty<std::string> font = { "Open Sans Regular, Arial Unicode MS Regular" };
- LayoutProperty<float> size = 16.0f;
- LayoutProperty<float> maxWidth = 15.0f /* em */;
- LayoutProperty<float> lineHeight = 1.2f /* em */;
- LayoutProperty<float> letterSpacing = 0.0f /* em */;
- LayoutProperty<TextJustifyType> justify = TextJustifyType::Center;
- LayoutProperty<TextAnchorType> anchor = TextAnchorType::Center;
- LayoutProperty<float> maxAngle = 45.0f /* degrees */;
- LayoutProperty<float> rotate = 0.0f;
- LayoutProperty<float> padding = 2.0f;
- LayoutProperty<bool> keepUpright = true;
- LayoutProperty<TextTransformType> transform = TextTransformType::None;
- LayoutProperty<std::array<float, 2>> offset = { {{ 0, 0 }} };
- LayoutProperty<bool> allowOverlap = false;
- LayoutProperty<bool> ignorePlacement = false;
- LayoutProperty<bool> optional = false;
+ LayoutProperty<RotationAlignmentType> rotationAlignment { RotationAlignmentType::Viewport };
+ LayoutProperty<std::string> field { "" };
+ LayoutProperty<std::string> font { "Open Sans Regular, Arial Unicode MS Regular" };
+ LayoutProperty<float> size { 16.0f };
+ LayoutProperty<float> maxWidth { 15.0f /* em */ };
+ LayoutProperty<float> lineHeight { 1.2f /* em */ };
+ LayoutProperty<float> letterSpacing { 0.0f /* em */ };
+ LayoutProperty<TextJustifyType> justify { TextJustifyType::Center };
+ LayoutProperty<TextAnchorType> anchor { TextAnchorType::Center };
+ LayoutProperty<float> maxAngle { 45.0f /* degrees */ };
+ LayoutProperty<float> rotate { 0.0f };
+ LayoutProperty<float> padding { 2.0f };
+ LayoutProperty<bool> keepUpright { true };
+ LayoutProperty<TextTransformType> transform { TextTransformType::None };
+ LayoutProperty<std::array<float, 2>> offset { {{ 0, 0 }} };
+ LayoutProperty<bool> allowOverlap { false };
+ LayoutProperty<bool> ignorePlacement { false };
+ LayoutProperty<bool> optional { false };
} text;
// Special case.
@@ -62,13 +62,13 @@ public:
public:
PaintProperties(float size_) : size(size_) {}
- PaintProperty<float> opacity = 1.0f;
- PaintProperty<Color> color = { {{ 0, 0, 0, 1 }} };
- PaintProperty<Color> haloColor = { {{ 0, 0, 0, 0 }} };
- PaintProperty<float> haloWidth = 0.0f;
- PaintProperty<float> haloBlur = 0.0f;
- PaintProperty<std::array<float, 2>> translate = { {{ 0, 0 }} };
- PaintProperty<TranslateAnchorType> translateAnchor = TranslateAnchorType::Map;
+ PaintProperty<float> opacity { 1.0f };
+ PaintProperty<Color> color { {{ 0, 0, 0, 1 }} };
+ PaintProperty<Color> haloColor { {{ 0, 0, 0, 0 }} };
+ PaintProperty<float> haloWidth { 0.0f };
+ PaintProperty<float> haloBlur { 0.0f };
+ PaintProperty<std::array<float, 2>> translate { {{ 0, 0 }} };
+ PaintProperty<TranslateAnchorType> translateAnchor { TranslateAnchorType::Map };
// Special case
float size;
diff --git a/src/mbgl/style/layout_property.hpp b/src/mbgl/style/layout_property.hpp
index db2b2d3aba..65ce06a153 100644
--- a/src/mbgl/style/layout_property.hpp
+++ b/src/mbgl/style/layout_property.hpp
@@ -14,7 +14,7 @@ using JSVal = rapidjson::Value;
template <typename T>
class LayoutProperty {
public:
- LayoutProperty(T v) : value(std::move(v)) {}
+ explicit LayoutProperty(T v) : value(std::move(v)) {}
void parse(const char * name, const JSVal& layout) {
if (layout.HasMember(name)) {
@@ -28,6 +28,7 @@ public:
}
}
+ void operator=(const T& v) { value = v; }
operator T() const { return value; }
mapbox::util::optional<Function<T>> parsedValue;
diff --git a/src/mbgl/style/paint_property.hpp b/src/mbgl/style/paint_property.hpp
index f6ab430ed9..3fb0a194f0 100644
--- a/src/mbgl/style/paint_property.hpp
+++ b/src/mbgl/style/paint_property.hpp
@@ -24,7 +24,7 @@ class PaintProperty {
public:
using Fn = Function<Result>;
- PaintProperty(T fallbackValue)
+ explicit PaintProperty(T fallbackValue)
: value(fallbackValue) {
values.emplace(ClassID::Fallback, Fn(fallbackValue));
}