[core] Make Paint/LayoutProperties constructor explicit
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user