add symbol* properties/keys

This commit is contained in:
Konstantin Käfer
2014-07-23 15:37:01 +02:00
parent 6e44e03241
commit 270c24a9a8
8 changed files with 146 additions and 13 deletions

View File

@@ -30,7 +30,14 @@ enum class PropertyKey {
IconOpacity,
IconRotate,
IconRotateAnchor,
IconSize,
IconColor,
IconHaloColor,
IconHaloWidth,
IconHaloBlur,
IconTranslateX,
IconTranslateY,
IconTranslateAnchor,
TextOpacity,
TextSize,
@@ -38,6 +45,9 @@ enum class PropertyKey {
TextHaloColor,
TextHaloWidth,
TextHaloBlur,
TextTranslateX,
TextTranslateY,
TextTranslateAnchor,
CompositeOpacity,

View File

@@ -4,8 +4,10 @@
#include <mbgl/style/types.hpp>
#include <mbgl/style/filter_expression.hpp>
#include <mbgl/style/style_source.hpp>
#include <mbgl/util/vec.hpp>
#include <mbgl/util/variant.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <memory>
#include <forward_list>
@@ -59,6 +61,47 @@ public:
bool always_visible = false;
};
class StyleBucketSymbol : util::noncopyable {
public:
PlacementType placement = PlacementType::Default;
float min_distance = 250.0f;
struct {
bool allow_overlap = false;
bool ignore_placement = false;
bool optional = false;
RotationAlignmentType rotation_alignment = RotationAlignmentType::Viewport;
float max_size = 1.0f;
std::string image;
float padding = 2.0f;
bool keep_upright = false;
vec2<float> offset = {0, 0};
} icon;
struct {
RotationAlignmentType rotation_alignment = RotationAlignmentType::Viewport;
std::string field;
std::string font;
float max_size = 16.0f;
float max_width = 15.0f * 24 /* em */;
float line_height = 1.2f * 24 /* em */;
float letter_spacing = 0.0f * 24 /* em */;
TextJustifyType justify = TextJustifyType::Center;
TextHorizontalAlignType horizontal_align = TextHorizontalAlignType::Center;
TextVerticalAlignType vertical_align = TextVerticalAlignType::Center;
float max_angle_delta = 45.0f /* degrees */;
float rotate = 0.0f;
float slant = 0.0f;
float padding = 2.0f;
bool keep_upright = true;
TextTransformType transform = TextTransformType::None;
vec2<float> offset = {0, 0};
bool allow_overlap = false;
bool ignore_placement = false;
bool optional = false;
} text;
};
class StyleBucketRaster {
public:
};

View File

@@ -69,6 +69,39 @@ struct TextProperties {
}
};
struct SymbolProperties {
inline SymbolProperties() {}
struct {
float opacity = 1.0f;
float rotate = 0.0f;
float size = 1.0f;
Color color = {{ 0, 0, 0, 1 }};
Color halo_color = {{ 0, 0, 0, 0 }};
float halo_width = 0.0f;
float halo_blur = 0.0f;
std::array<float, 2> translate = {{ 0, 0 }};
TranslateAnchorType translate_anchor = TranslateAnchorType::Map;
} icon;
struct {
float opacity = 1.0f;
float size = 12.0f;
Color color = {{ 0, 0, 0, 1 }};
Color halo_color = {{ 0, 0, 0, 0 }};
float halo_width = 0.0f;
float halo_blur = 0.0f;
std::array<float, 2> translate = {{ 0, 0 }};
TranslateAnchorType translate_anchor = TranslateAnchorType::Map;
} text;
inline bool isVisible() const {
return (icon.opacity > 0 && (icon.color[3] > 0 || icon.halo_color[3] > 0) && icon.size > 0) ||
(text.opacity > 0 && (text.color[3] > 0 || text.halo_color[3] > 0) && text.size > 0);
}
};
struct CompositeProperties {
inline CompositeProperties() {}
float opacity = 1.0f;

View File

@@ -61,6 +61,12 @@ enum class TextPathType : uint8_t {
Default = Horizontal
};
enum class PlacementType : bool {
Point,
Line,
Default = Point
};
enum class TextTransformType : uint8_t {
None,
Uppercase,
@@ -80,6 +86,33 @@ enum class RotateAnchorType : uint8_t {
Default = Viewport
};
enum class RotationAlignmentType : bool {
Map,
Viewport,
Default = Viewport
};
enum class TextJustifyType : uint8_t {
Center,
Left,
Right,
Default = Center
};
enum class TextHorizontalAlignType : uint8_t {
Left,
Center,
Right,
Default = Center
};
enum class TextVerticalAlignType : uint8_t {
Top,
Center,
Bottom,
Default = Center
};
enum class SourceType : uint8_t {
Vector,
Raster,
@@ -114,6 +147,12 @@ inline TextPathType parseTextPathType(const std::string &path) {
return TextPathType::Default;
}
inline PlacementType parsePlacementType(const std::string &path) {
if (path == "point") return PlacementType::Point;
if (path == "line") return PlacementType::Line;
return PlacementType::Default;
}
inline TextTransformType parseTextTransformType(const std::string& transform) {
if (transform == "uppercase") return TextTransformType::Uppercase;
if (transform == "lowercase") return TextTransformType::Lowercase;