1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
#pragma once
#include <mbgl/style/style_layer.hpp>
#include <mbgl/style/layout_property.hpp>
#include <mbgl/style/paint_property.hpp>
namespace mbgl {
class SpriteAtlas;
class SymbolLayoutProperties {
public:
LayoutProperty<SymbolPlacementType> symbolPlacement { SymbolPlacementType::Point };
LayoutProperty<float> symbolSpacing { 250.0f };
LayoutProperty<bool> symbolAvoidEdges { false };
LayoutProperty<bool> iconAllowOverlap { false };
LayoutProperty<bool> iconIgnorePlacement { false };
LayoutProperty<bool> iconOptional { false };
LayoutProperty<RotationAlignmentType> iconRotationAlignment { RotationAlignmentType::Viewport };
LayoutProperty<float> iconSize { 1.0f };
LayoutProperty<std::string> iconImage { "" };
LayoutProperty<float> iconRotate { 0.0f };
LayoutProperty<float> iconPadding { 2.0f };
LayoutProperty<bool> iconKeepUpright { false };
LayoutProperty<std::array<float, 2>> iconOffset { {{ 0, 0 }} };
LayoutProperty<RotationAlignmentType> textRotationAlignment { RotationAlignmentType::Viewport };
LayoutProperty<std::string> textField { "" };
LayoutProperty<std::vector<std::string>> textFont { { "Open Sans Regular", "Arial Unicode MS Regular" } };
LayoutProperty<float> textSize { 16.0f };
LayoutProperty<float> textMaxWidth { 10.0f /* em */ };
LayoutProperty<float> textLineHeight { 1.2f /* em */ };
LayoutProperty<float> textLetterSpacing { 0.0f /* em */ };
LayoutProperty<TextJustifyType> textJustify { TextJustifyType::Center };
LayoutProperty<TextAnchorType> textAnchor { TextAnchorType::Center };
LayoutProperty<float> textMaxAngle { 45.0f /* degrees */ };
LayoutProperty<float> textRotate { 0.0f };
LayoutProperty<float> textPadding { 2.0f };
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:
PaintProperty<float> iconOpacity { 1.0f };
PaintProperty<Color> iconColor { {{ 0, 0, 0, 1 }} };
PaintProperty<Color> iconHaloColor { {{ 0, 0, 0, 0 }} };
PaintProperty<float> iconHaloWidth { 0.0f };
PaintProperty<float> iconHaloBlur { 0.0f };
PaintProperty<std::array<float, 2>> iconTranslate { {{ 0, 0 }} };
PaintProperty<TranslateAnchorType> iconTranslateAnchor { TranslateAnchorType::Map };
PaintProperty<float> textOpacity { 1.0f };
PaintProperty<Color> textColor { {{ 0, 0, 0, 1 }} };
PaintProperty<Color> textHaloColor { {{ 0, 0, 0, 0 }} };
PaintProperty<float> textHaloWidth { 0.0f };
PaintProperty<float> textHaloBlur { 0.0f };
PaintProperty<std::array<float, 2>> textTranslate { {{ 0, 0 }} };
PaintProperty<TranslateAnchorType> textTranslateAnchor { TranslateAnchorType::Map };
};
class SymbolLayer : public StyleLayer {
public:
SymbolLayer() : StyleLayer(Type::Symbol) {}
std::unique_ptr<StyleLayer> clone() const override;
void parseLayout(const JSValue&) override;
void parsePaints(const JSValue&) override;
void cascade(const StyleCascadeParameters&) override;
bool recalculate(const StyleCalculationParameters&) override;
std::unique_ptr<Bucket> createBucket(StyleBucketParameters&) const override;
SymbolLayoutProperties layout;
SymbolPaintProperties paint;
float iconSize = 1.0f;
float textSize = 16.0f;
SpriteAtlas* spriteAtlas = nullptr;
};
template <>
inline bool StyleLayer::is<SymbolLayer>() const {
return type == Type::Symbol;
}
} // namespace mbgl
|