diff --git a/src/mbgl/layer/background_layer.hpp b/src/mbgl/layer/background_layer.hpp index ee8d3fc88..4a3428919 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 opacity = 1.0f; - PaintProperty color = { {{ 0, 0, 0, 1 }} }; - PaintProperty> pattern = { "" }; + PaintProperty opacity { 1.0f }; + PaintProperty color { {{ 0, 0, 0, 1 }} }; + PaintProperty> pattern { "" }; }; class BackgroundLayer : public StyleLayer { diff --git a/src/mbgl/layer/circle_layer.hpp b/src/mbgl/layer/circle_layer.hpp index 3e4581ef6..80a94c740 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 radius = 5.0f; - PaintProperty color = { {{ 0, 0, 0, 1 }} }; - PaintProperty opacity = 1.0f; - PaintProperty> translate = { {{ 0, 0 }} }; - PaintProperty translateAnchor = TranslateAnchorType::Map; - PaintProperty blur = 0; + PaintProperty radius { 5.0f }; + PaintProperty color { {{ 0, 0, 0, 1 }} }; + PaintProperty opacity { 1.0f }; + PaintProperty> translate { {{ 0, 0 }} }; + PaintProperty translateAnchor { TranslateAnchorType::Map }; + PaintProperty 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 1132fbf4e..93514ee42 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 antialias = true; - PaintProperty opacity = 1.0f; - PaintProperty color = { {{ 0, 0, 0, 1 }} }; - PaintProperty outlineColor = { {{ 0, 0, 0, -1 }} }; - PaintProperty> translate = { {{ 0, 0 }} }; - PaintProperty translateAnchor = TranslateAnchorType::Map; - PaintProperty> pattern = { "" }; + PaintProperty antialias { true }; + PaintProperty opacity { 1.0f }; + PaintProperty color { {{ 0, 0, 0, 1 }} }; + PaintProperty outlineColor { {{ 0, 0, 0, -1 }} }; + PaintProperty> translate { {{ 0, 0 }} }; + PaintProperty translateAnchor { TranslateAnchorType::Map }; + PaintProperty> pattern { "" }; }; class FillLayer : public StyleLayer { diff --git a/src/mbgl/layer/line_layer.hpp b/src/mbgl/layer/line_layer.hpp index d1c654619..b1917b4ca 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 cap = CapType::Butt; - LayoutProperty join = JoinType::Miter; - LayoutProperty miterLimit = 2.0f; - LayoutProperty roundLimit = 1.0f; + LayoutProperty cap { CapType::Butt }; + LayoutProperty join { JoinType::Miter }; + LayoutProperty miterLimit { 2.0f }; + LayoutProperty roundLimit { 1.0f }; }; class LinePaintProperties { public: - PaintProperty opacity = 1.0f; - PaintProperty color = { {{ 0, 0, 0, 1 }} }; - PaintProperty> translate = { {{ 0, 0 }} }; - PaintProperty translateAnchor = TranslateAnchorType::Map; - PaintProperty width = 1; - PaintProperty gapWidth = 0; - PaintProperty blur = 0; - PaintProperty offset = 0; - PaintProperty, Faded>> dasharray = { {} }; - PaintProperty> pattern = { "" }; + PaintProperty opacity { 1.0f }; + PaintProperty color { {{ 0, 0, 0, 1 }} }; + PaintProperty> translate { {{ 0, 0 }} }; + PaintProperty translateAnchor { TranslateAnchorType::Map }; + PaintProperty width { 1 }; + PaintProperty gapWidth { 0 }; + PaintProperty blur { 0 }; + PaintProperty offset { 0 }; + PaintProperty, Faded>> dasharray { {} }; + PaintProperty> pattern { "" }; // Special case float dashLineWidth = 1; diff --git a/src/mbgl/layer/raster_layer.hpp b/src/mbgl/layer/raster_layer.hpp index 43ffa4886..fc571617a 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 opacity = 1.0f; - PaintProperty hueRotate = 0.0f; - PaintProperty brightnessMin = 0.0f; - PaintProperty brightnessMax = 1.0f; - PaintProperty saturation = 0.0f; - PaintProperty contrast = 0.0f; - PaintProperty fadeDuration = 0.0f; + PaintProperty opacity { 1.0f }; + PaintProperty hueRotate { 0.0f }; + PaintProperty brightnessMin { 0.0f }; + PaintProperty brightnessMax { 1.0f }; + PaintProperty saturation { 0.0f }; + PaintProperty contrast { 0.0f }; + PaintProperty fadeDuration { 0.0f }; }; class RasterLayer : public StyleLayer { diff --git a/src/mbgl/layer/symbol_layer.hpp b/src/mbgl/layer/symbol_layer.hpp index 4b37d1205..42d0bb9c7 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 placement = PlacementType::Point; - LayoutProperty spacing = 250.0f; - LayoutProperty avoidEdges = false; + LayoutProperty placement { PlacementType::Point }; + LayoutProperty spacing { 250.0f }; + LayoutProperty avoidEdges { false }; class IconProperties { public: - LayoutProperty allowOverlap = false; - LayoutProperty ignorePlacement = false; - LayoutProperty optional = false; - LayoutProperty rotationAlignment = RotationAlignmentType::Viewport; - LayoutProperty size = 1.0f; - LayoutProperty image = { "" }; - LayoutProperty rotate = 0.0f; - LayoutProperty padding = 2.0f; - LayoutProperty keepUpright = false; - LayoutProperty> offset = { {{ 0, 0 }} }; + LayoutProperty allowOverlap { false }; + LayoutProperty ignorePlacement { false }; + LayoutProperty optional { false }; + LayoutProperty rotationAlignment { RotationAlignmentType::Viewport }; + LayoutProperty size { 1.0f }; + LayoutProperty image { "" }; + LayoutProperty rotate { 0.0f }; + LayoutProperty padding { 2.0f }; + LayoutProperty keepUpright { false }; + LayoutProperty> offset { {{ 0, 0 }} }; } icon; class TextProperties { public: - LayoutProperty rotationAlignment = RotationAlignmentType::Viewport; - LayoutProperty field = { "" }; - LayoutProperty font = { "Open Sans Regular, Arial Unicode MS Regular" }; - LayoutProperty size = 16.0f; - LayoutProperty maxWidth = 15.0f /* em */; - LayoutProperty lineHeight = 1.2f /* em */; - LayoutProperty letterSpacing = 0.0f /* em */; - LayoutProperty justify = TextJustifyType::Center; - LayoutProperty anchor = TextAnchorType::Center; - LayoutProperty maxAngle = 45.0f /* degrees */; - LayoutProperty rotate = 0.0f; - LayoutProperty padding = 2.0f; - LayoutProperty keepUpright = true; - LayoutProperty transform = TextTransformType::None; - LayoutProperty> offset = { {{ 0, 0 }} }; - LayoutProperty allowOverlap = false; - LayoutProperty ignorePlacement = false; - LayoutProperty optional = false; + LayoutProperty rotationAlignment { RotationAlignmentType::Viewport }; + LayoutProperty field { "" }; + LayoutProperty font { "Open Sans Regular, Arial Unicode MS Regular" }; + LayoutProperty size { 16.0f }; + LayoutProperty maxWidth { 15.0f /* em */ }; + LayoutProperty lineHeight { 1.2f /* em */ }; + LayoutProperty letterSpacing { 0.0f /* em */ }; + LayoutProperty justify { TextJustifyType::Center }; + LayoutProperty anchor { TextAnchorType::Center }; + LayoutProperty maxAngle { 45.0f /* degrees */ }; + LayoutProperty rotate { 0.0f }; + LayoutProperty padding { 2.0f }; + LayoutProperty keepUpright { true }; + LayoutProperty transform { TextTransformType::None }; + LayoutProperty> offset { {{ 0, 0 }} }; + LayoutProperty allowOverlap { false }; + LayoutProperty ignorePlacement { false }; + LayoutProperty optional { false }; } text; // Special case. @@ -62,13 +62,13 @@ public: public: PaintProperties(float size_) : size(size_) {} - PaintProperty opacity = 1.0f; - PaintProperty color = { {{ 0, 0, 0, 1 }} }; - PaintProperty haloColor = { {{ 0, 0, 0, 0 }} }; - PaintProperty haloWidth = 0.0f; - PaintProperty haloBlur = 0.0f; - PaintProperty> translate = { {{ 0, 0 }} }; - PaintProperty translateAnchor = TranslateAnchorType::Map; + PaintProperty opacity { 1.0f }; + PaintProperty color { {{ 0, 0, 0, 1 }} }; + PaintProperty haloColor { {{ 0, 0, 0, 0 }} }; + PaintProperty haloWidth { 0.0f }; + PaintProperty haloBlur { 0.0f }; + PaintProperty> translate { {{ 0, 0 }} }; + PaintProperty translateAnchor { TranslateAnchorType::Map }; // Special case float size; diff --git a/src/mbgl/style/layout_property.hpp b/src/mbgl/style/layout_property.hpp index db2b2d3ab..65ce06a15 100644 --- a/src/mbgl/style/layout_property.hpp +++ b/src/mbgl/style/layout_property.hpp @@ -14,7 +14,7 @@ using JSVal = rapidjson::Value; template 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> parsedValue; diff --git a/src/mbgl/style/paint_property.hpp b/src/mbgl/style/paint_property.hpp index f6ab430ed..3fb0a194f 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; - PaintProperty(T fallbackValue) + explicit PaintProperty(T fallbackValue) : value(fallbackValue) { values.emplace(ClassID::Fallback, Fn(fallbackValue)); }