[core] Move enum type classes to implementation (#4831)
This commit is contained in:
@@ -46,27 +46,12 @@ enum class VisibilityType : bool {
|
||||
None,
|
||||
};
|
||||
|
||||
MBGL_DEFINE_ENUM_CLASS(VisibilityTypeClass, VisibilityType, {
|
||||
{ VisibilityType::Visible, "visible" },
|
||||
{ VisibilityType::None, "none" },
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
|
||||
enum class LineCapType : uint8_t {
|
||||
Round,
|
||||
Butt,
|
||||
Square,
|
||||
};
|
||||
|
||||
MBGL_DEFINE_ENUM_CLASS(LineCapTypeClass, LineCapType, {
|
||||
{ LineCapType::Round, "round" },
|
||||
{ LineCapType::Butt, "butt" },
|
||||
{ LineCapType::Square, "square" },
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
|
||||
enum class LineJoinType : uint8_t {
|
||||
Miter,
|
||||
Bevel,
|
||||
@@ -76,78 +61,32 @@ enum class LineJoinType : uint8_t {
|
||||
FlipBevel
|
||||
};
|
||||
|
||||
MBGL_DEFINE_ENUM_CLASS(LineJoinTypeClass, LineJoinType, {
|
||||
{ LineJoinType::Miter, "miter" },
|
||||
{ LineJoinType::Bevel, "bevel" },
|
||||
{ LineJoinType::Round, "round" },
|
||||
{ LineJoinType::FakeRound, "fakeround" },
|
||||
{ LineJoinType::FlipBevel, "flipbevel" },
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
|
||||
enum class TranslateAnchorType : bool {
|
||||
Map,
|
||||
Viewport
|
||||
};
|
||||
|
||||
MBGL_DEFINE_ENUM_CLASS(TranslateAnchorTypeClass, TranslateAnchorType, {
|
||||
{ TranslateAnchorType::Map, "map" },
|
||||
{ TranslateAnchorType::Viewport, "viewport" },
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
|
||||
enum class RotateAnchorType : bool {
|
||||
Map,
|
||||
Viewport,
|
||||
};
|
||||
|
||||
MBGL_DEFINE_ENUM_CLASS(RotateAnchorTypeClass, RotateAnchorType, {
|
||||
{ RotateAnchorType::Map, "map" },
|
||||
{ RotateAnchorType::Viewport, "viewport" },
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
|
||||
enum class SymbolPlacementType : bool {
|
||||
Point,
|
||||
Line,
|
||||
};
|
||||
|
||||
MBGL_DEFINE_ENUM_CLASS(SymbolPlacementTypeClass, SymbolPlacementType, {
|
||||
{ SymbolPlacementType::Point, "point" },
|
||||
{ SymbolPlacementType::Line, "line" },
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
|
||||
enum class RotationAlignmentType : bool {
|
||||
Map,
|
||||
Viewport,
|
||||
};
|
||||
|
||||
MBGL_DEFINE_ENUM_CLASS(RotationAlignmentTypeClass, RotationAlignmentType, {
|
||||
{ RotationAlignmentType::Map, "map" },
|
||||
{ RotationAlignmentType::Viewport, "viewport" },
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
|
||||
enum class TextJustifyType : uint8_t {
|
||||
Center,
|
||||
Left,
|
||||
Right
|
||||
};
|
||||
|
||||
MBGL_DEFINE_ENUM_CLASS(TextJustifyTypeClass, TextJustifyType, {
|
||||
{ TextJustifyType::Center, "center" },
|
||||
{ TextJustifyType::Left, "left" },
|
||||
{ TextJustifyType::Right, "right" },
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
|
||||
enum class TextAnchorType : uint8_t {
|
||||
Center,
|
||||
Left,
|
||||
@@ -160,32 +99,12 @@ enum class TextAnchorType : uint8_t {
|
||||
BottomRight
|
||||
};
|
||||
|
||||
MBGL_DEFINE_ENUM_CLASS(TextAnchorTypeClass, TextAnchorType, {
|
||||
{ TextAnchorType::Center, "center" },
|
||||
{ TextAnchorType::Left, "left" },
|
||||
{ TextAnchorType::Right, "right" },
|
||||
{ TextAnchorType::Top, "top" },
|
||||
{ TextAnchorType::Bottom, "bottom" },
|
||||
{ TextAnchorType::TopLeft, "top-left" },
|
||||
{ TextAnchorType::TopRight, "top-right" },
|
||||
{ TextAnchorType::BottomLeft, "bottom-left" },
|
||||
{ TextAnchorType::BottomRight, "bottom-right" }
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
|
||||
enum class TextTransformType : uint8_t {
|
||||
None,
|
||||
Uppercase,
|
||||
Lowercase,
|
||||
};
|
||||
|
||||
MBGL_DEFINE_ENUM_CLASS(TextTransformTypeClass, TextTransformType, {
|
||||
{ TextTransformType::None, "none" },
|
||||
{ TextTransformType::Uppercase, "uppercase" },
|
||||
{ TextTransformType::Lowercase, "lowercase" },
|
||||
});
|
||||
|
||||
/**
|
||||
* Initialize any GL state needed by the custom layer. This method is called once, from the
|
||||
* rendering thread, at a point when the GL context is active but before rendering for the
|
||||
|
||||
@@ -58,6 +58,11 @@ optional<Color> parseProperty(const char* name, const JSValue& value) {
|
||||
css_color.a}};
|
||||
}
|
||||
|
||||
MBGL_DEFINE_ENUM_CLASS(TranslateAnchorTypeClass, TranslateAnchorType, {
|
||||
{ TranslateAnchorType::Map, "map" },
|
||||
{ TranslateAnchorType::Viewport, "viewport" },
|
||||
});
|
||||
|
||||
template <>
|
||||
optional<TranslateAnchorType> parseProperty(const char* name, const JSValue& value) {
|
||||
if (!value.IsString()) {
|
||||
@@ -68,6 +73,11 @@ optional<TranslateAnchorType> parseProperty(const char* name, const JSValue& val
|
||||
return { TranslateAnchorTypeClass({ value.GetString(), value.GetStringLength() }) };
|
||||
}
|
||||
|
||||
MBGL_DEFINE_ENUM_CLASS(RotateAnchorTypeClass, RotateAnchorType, {
|
||||
{ RotateAnchorType::Map, "map" },
|
||||
{ RotateAnchorType::Viewport, "viewport" },
|
||||
});
|
||||
|
||||
template <>
|
||||
optional<RotateAnchorType> parseProperty<RotateAnchorType>(const char* name, const JSValue& value) {
|
||||
if (!value.IsString()) {
|
||||
@@ -78,6 +88,12 @@ optional<RotateAnchorType> parseProperty<RotateAnchorType>(const char* name, con
|
||||
return { RotateAnchorTypeClass({ value.GetString(), value.GetStringLength() }) };
|
||||
}
|
||||
|
||||
MBGL_DEFINE_ENUM_CLASS(LineCapTypeClass, LineCapType, {
|
||||
{ LineCapType::Round, "round" },
|
||||
{ LineCapType::Butt, "butt" },
|
||||
{ LineCapType::Square, "square" },
|
||||
});
|
||||
|
||||
template <>
|
||||
optional<LineCapType> parseProperty<LineCapType>(const char* name, const JSValue& value) {
|
||||
if (!value.IsString()) {
|
||||
@@ -88,6 +104,14 @@ optional<LineCapType> parseProperty<LineCapType>(const char* name, const JSValue
|
||||
return { LineCapTypeClass({ value.GetString(), value.GetStringLength() }) };
|
||||
}
|
||||
|
||||
MBGL_DEFINE_ENUM_CLASS(LineJoinTypeClass, LineJoinType, {
|
||||
{ LineJoinType::Miter, "miter" },
|
||||
{ LineJoinType::Bevel, "bevel" },
|
||||
{ LineJoinType::Round, "round" },
|
||||
{ LineJoinType::FakeRound, "fakeround" },
|
||||
{ LineJoinType::FlipBevel, "flipbevel" },
|
||||
});
|
||||
|
||||
template <>
|
||||
optional<LineJoinType> parseProperty<LineJoinType>(const char* name, const JSValue& value) {
|
||||
if (!value.IsString()) {
|
||||
@@ -98,6 +122,11 @@ optional<LineJoinType> parseProperty<LineJoinType>(const char* name, const JSVal
|
||||
return { LineJoinTypeClass({ value.GetString(), value.GetStringLength() }) };
|
||||
}
|
||||
|
||||
MBGL_DEFINE_ENUM_CLASS(SymbolPlacementTypeClass, SymbolPlacementType, {
|
||||
{ SymbolPlacementType::Point, "point" },
|
||||
{ SymbolPlacementType::Line, "line" },
|
||||
});
|
||||
|
||||
template <>
|
||||
optional<SymbolPlacementType> parseProperty<SymbolPlacementType>(const char* name, const JSValue& value) {
|
||||
if (!value.IsString()) {
|
||||
@@ -108,6 +137,18 @@ optional<SymbolPlacementType> parseProperty<SymbolPlacementType>(const char* nam
|
||||
return { SymbolPlacementTypeClass({ value.GetString(), value.GetStringLength() }) };
|
||||
}
|
||||
|
||||
MBGL_DEFINE_ENUM_CLASS(TextAnchorTypeClass, TextAnchorType, {
|
||||
{ TextAnchorType::Center, "center" },
|
||||
{ TextAnchorType::Left, "left" },
|
||||
{ TextAnchorType::Right, "right" },
|
||||
{ TextAnchorType::Top, "top" },
|
||||
{ TextAnchorType::Bottom, "bottom" },
|
||||
{ TextAnchorType::TopLeft, "top-left" },
|
||||
{ TextAnchorType::TopRight, "top-right" },
|
||||
{ TextAnchorType::BottomLeft, "bottom-left" },
|
||||
{ TextAnchorType::BottomRight, "bottom-right" }
|
||||
});
|
||||
|
||||
template <>
|
||||
optional<TextAnchorType> parseProperty<TextAnchorType>(const char* name, const JSValue& value) {
|
||||
if (!value.IsString()) {
|
||||
@@ -118,6 +159,12 @@ optional<TextAnchorType> parseProperty<TextAnchorType>(const char* name, const J
|
||||
return { TextAnchorTypeClass({ value.GetString(), value.GetStringLength() }) };
|
||||
}
|
||||
|
||||
MBGL_DEFINE_ENUM_CLASS(TextJustifyTypeClass, TextJustifyType, {
|
||||
{ TextJustifyType::Center, "center" },
|
||||
{ TextJustifyType::Left, "left" },
|
||||
{ TextJustifyType::Right, "right" },
|
||||
});
|
||||
|
||||
template <>
|
||||
optional<TextJustifyType> parseProperty<TextJustifyType>(const char* name, const JSValue& value) {
|
||||
if (!value.IsString()) {
|
||||
@@ -128,6 +175,12 @@ optional<TextJustifyType> parseProperty<TextJustifyType>(const char* name, const
|
||||
return { TextJustifyTypeClass({ value.GetString(), value.GetStringLength() }) };
|
||||
}
|
||||
|
||||
MBGL_DEFINE_ENUM_CLASS(TextTransformTypeClass, TextTransformType, {
|
||||
{ TextTransformType::None, "none" },
|
||||
{ TextTransformType::Uppercase, "uppercase" },
|
||||
{ TextTransformType::Lowercase, "lowercase" },
|
||||
});
|
||||
|
||||
template <>
|
||||
optional<TextTransformType> parseProperty<TextTransformType>(const char* name, const JSValue& value) {
|
||||
if (!value.IsString()) {
|
||||
@@ -138,6 +191,11 @@ optional<TextTransformType> parseProperty<TextTransformType>(const char* name, c
|
||||
return { TextTransformTypeClass({ value.GetString(), value.GetStringLength() }) };
|
||||
}
|
||||
|
||||
MBGL_DEFINE_ENUM_CLASS(RotationAlignmentTypeClass, RotationAlignmentType, {
|
||||
{ RotationAlignmentType::Map, "map" },
|
||||
{ RotationAlignmentType::Viewport, "viewport" },
|
||||
});
|
||||
|
||||
template <>
|
||||
optional<RotationAlignmentType> parseProperty<RotationAlignmentType>(const char* name, const JSValue& value) {
|
||||
if (!value.IsString()) {
|
||||
|
||||
@@ -481,6 +481,11 @@ void StyleParser::parseLayer(const std::string& id, const JSValue& value, std::u
|
||||
layer->parsePaints(value);
|
||||
}
|
||||
|
||||
MBGL_DEFINE_ENUM_CLASS(VisibilityTypeClass, VisibilityType, {
|
||||
{ VisibilityType::Visible, "visible" },
|
||||
{ VisibilityType::None, "none" },
|
||||
});
|
||||
|
||||
void StyleParser::parseVisibility(StyleLayer& layer, const JSValue& value) {
|
||||
if (!value.HasMember("visibility")) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user