diff options
-rw-r--r-- | include/mbgl/style/style_bucket.hpp | 3 | ||||
-rw-r--r-- | include/mbgl/style/types.hpp | 28 | ||||
-rw-r--r-- | src/renderer/symbol_bucket.cpp | 26 | ||||
-rw-r--r-- | src/style/style_parser.cpp | 3 | ||||
m--------- | styles | 0 |
5 files changed, 28 insertions, 32 deletions
diff --git a/include/mbgl/style/style_bucket.hpp b/include/mbgl/style/style_bucket.hpp index c4a8f6037e..d84d35d5b2 100644 --- a/include/mbgl/style/style_bucket.hpp +++ b/include/mbgl/style/style_bucket.hpp @@ -64,8 +64,7 @@ public: 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; + TextAnchorType anchor = TextAnchorType::Center; float max_angle = 45.0f /* degrees */; float rotate = 0.0f; float slant = 0.0f; diff --git a/include/mbgl/style/types.hpp b/include/mbgl/style/types.hpp index fa21f819a5..36cb39181e 100644 --- a/include/mbgl/style/types.hpp +++ b/include/mbgl/style/types.hpp @@ -152,30 +152,20 @@ MBGL_DEFINE_ENUM_CLASS(TextJustifyTypeClass, TextJustifyType, { // ------------------------------------------------------------------------------------------------- -enum class TextHorizontalAlignType : uint8_t { - Left, +enum class TextAnchorType : uint8_t { Center, + Left, Right, -}; - -MBGL_DEFINE_ENUM_CLASS(TextHorizontalAlignTypeClass, TextHorizontalAlignType, { - { TextHorizontalAlignType::Left, "left" }, - { TextHorizontalAlignType::Center, "center" }, - { TextHorizontalAlignType::Right, "right" }, -}); - -// ------------------------------------------------------------------------------------------------- - -enum class TextVerticalAlignType : uint8_t { Top, - Center, - Bottom, + Bottom }; -MBGL_DEFINE_ENUM_CLASS(TextVerticalAlignTypeClass, TextVerticalAlignType, { - { TextVerticalAlignType::Top, "top" }, - { TextVerticalAlignType::Center, "center" }, - { TextVerticalAlignType::Bottom, "bottom" }, +MBGL_DEFINE_ENUM_CLASS(TextAnchorTypeClass, TextAnchorType, { + { TextAnchorType::Center, "center" }, + { TextAnchorType::Left, "left" }, + { TextAnchorType::Right, "right" }, + { TextAnchorType::Top, "top" }, + { TextAnchorType::Bottom, "bottom" }, }); // ------------------------------------------------------------------------------------------------- diff --git a/src/renderer/symbol_bucket.cpp b/src/renderer/symbol_bucket.cpp index 37ff4a0a6b..e80f1505bf 100644 --- a/src/renderer/symbol_bucket.cpp +++ b/src/renderer/symbol_bucket.cpp @@ -103,16 +103,24 @@ void SymbolBucket::addFeatures(const VectorTileLayer &layer, const FilterExpress const std::vector<SymbolFeature> features = processFeatures(layer, filter, glyphStore, sprite); float horizontalAlign = 0.5; - if (properties.text.horizontal_align == TextHorizontalAlignType::Right) - horizontalAlign = 1; - else if (properties.text.horizontal_align == TextHorizontalAlignType::Left) - horizontalAlign = 0; - float verticalAlign = 0.5; - if (properties.text.vertical_align == TextVerticalAlignType::Bottom) - verticalAlign = 1; - else if (properties.text.vertical_align == TextVerticalAlignType::Top) - verticalAlign = 0; + + switch (properties.text.anchor) { + case TextAnchorType::Center: + break; + case TextAnchorType::Right: + horizontalAlign = 1; + break; + case TextAnchorType::Left: + horizontalAlign = 0; + break; + case TextAnchorType::Bottom: + verticalAlign = 1; + break; + case TextAnchorType::Top: + verticalAlign = 0; + break; + } float justify = 0.5; if (properties.text.justify == TextJustifyType::Right) justify = 1; diff --git a/src/style/style_parser.cpp b/src/style/style_parser.cpp index b32c36f17a..fa51e48cee 100644 --- a/src/style/style_parser.cpp +++ b/src/style/style_parser.cpp @@ -801,8 +801,7 @@ void StyleParser::parseLayout(JSVal value, util::ptr<StyleLayer> &layer) { render.text.letter_spacing *= 24; // em } parseRenderProperty<TextJustifyTypeClass>(value, render.text.justify, "text-justify"); - parseRenderProperty<TextHorizontalAlignTypeClass>(value, render.text.horizontal_align, "text-horizontal-align"); - parseRenderProperty<TextVerticalAlignTypeClass>(value, render.text.vertical_align, "text-vertical-align"); + parseRenderProperty<TextAnchorTypeClass>(value, render.text.anchor, "text-anchor"); parseRenderProperty(value, render.text.max_angle, "text-max-angle"); parseRenderProperty(value, render.text.rotate, "text-rotate"); parseRenderProperty(value, render.text.slant, "text-slant"); diff --git a/styles b/styles -Subproject 65dc5c9b7e926a7f43c2834979bd4c7395e8dca +Subproject 225f78f4281dbb315c030b1ba288e51193282cf |