diff options
Diffstat (limited to 'platform/darwin/src')
-rw-r--r-- | platform/darwin/src/MGLStyleLayer.h.ejs | 4 | ||||
-rw-r--r-- | platform/darwin/src/MGLStyleLayer.mm.ejs | 4 | ||||
-rw-r--r-- | platform/darwin/src/MGLSymbolStyleLayer.h | 69 | ||||
-rw-r--r-- | platform/darwin/src/MGLSymbolStyleLayer.mm | 33 |
4 files changed, 106 insertions, 4 deletions
diff --git a/platform/darwin/src/MGLStyleLayer.h.ejs b/platform/darwin/src/MGLStyleLayer.h.ejs index 9435e0d2ff..4bbb9e9f0d 100644 --- a/platform/darwin/src/MGLStyleLayer.h.ejs +++ b/platform/darwin/src/MGLStyleLayer.h.ejs @@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN <% for (const property of layoutProperties) { -%> -<% if (property.type == "enum") { -%> +<% if (definesEnum(property, layoutProperties)) { -%> /** <%- propertyDoc(property.name, property, type, 'enum').wrap(80, 1) %> @@ -38,7 +38,7 @@ typedef NS_ENUM(NSUInteger, MGL<%- camelize(property.name) %>) { <% } -%> <% } -%> <% for (const property of paintProperties) { -%> -<% if (property.type == "enum") { -%> +<% if (definesEnum(property, paintProperties)) { -%> /** <%- propertyDoc(property.name, property, type, 'enum').wrap(80, 1) %> diff --git a/platform/darwin/src/MGLStyleLayer.mm.ejs b/platform/darwin/src/MGLStyleLayer.mm.ejs index 26cb3e26f6..e8c8d8cfd9 100644 --- a/platform/darwin/src/MGLStyleLayer.mm.ejs +++ b/platform/darwin/src/MGLStyleLayer.mm.ejs @@ -25,7 +25,7 @@ namespace mbgl { <% if (layoutProperties.length) { -%> <% for (const property of layoutProperties) { -%> -<% if (property.type == "enum") { -%> +<% if (definesEnum(property, layoutProperties)) { -%> MBGL_DEFINE_ENUM(MGL<%- camelize(property.name) %>, { <% for (const value in property.values) { -%> { MGL<%- camelize(property.name) %><%- camelize(value) %>, "<%-value%>" }, @@ -37,7 +37,7 @@ namespace mbgl { <% } -%> <% if (paintProperties.length) { -%> <% for (const property of paintProperties) { -%> -<% if (property.type == "enum") { -%> +<% if (definesEnum(property, paintProperties)) { -%> MBGL_DEFINE_ENUM(MGL<%- camelize(property.name) %>, { <% for (const value in property.values) { -%> { MGL<%- camelize(property.name) %><%- camelize(value) %>, "<%-value%>" }, diff --git a/platform/darwin/src/MGLSymbolStyleLayer.h b/platform/darwin/src/MGLSymbolStyleLayer.h index 658a31679e..bbb5dae905 100644 --- a/platform/darwin/src/MGLSymbolStyleLayer.h +++ b/platform/darwin/src/MGLSymbolStyleLayer.h @@ -317,6 +317,30 @@ typedef NS_ENUM(NSUInteger, MGLTextTransform) { }; /** + The property allows to control an orientation of a symbol. Note, that the + property values act as a hint, so that Symbols whose language doesn't support + provided orientation, will be laid out in their natural orientation. Example: + English point symbol will be rendered horizontally even if `"textWritingMode": + ["vertical"]` is set. The order of elements in an array define priority order + for the placement of an orientation variant. + + Values of this type are used in the `MGLSymbolStyleLayer.textWritingMode` + property. + */ +typedef NS_ENUM(NSUInteger, MGLTextWritingMode) { + /** + If a text's language supports horizontal writing mode, symbols with point + placement would be laid out horizontally. + */ + MGLTextWritingModeHorizontal, + /** + If a text's language supports vertical writing mode, symbols with point + placement would be laid out vertically. + */ + MGLTextWritingModeVertical, +}; + +/** Controls the frame of reference for `MGLSymbolStyleLayer.iconTranslation`. Values of this type are used in the `MGLSymbolStyleLayer.iconTranslationAnchor` @@ -1646,6 +1670,38 @@ MGL_EXPORT */ @property (nonatomic, null_resettable) NSExpression *textVariableAnchor; +/** + The property allows to control an orientation of a symbol. Note, that the + property values act as a hint, so that Symbols whose language doesn't support + provided orientation, will be laid out in their natural orientation. Example: + English point symbol will be rendered horizontally even if `"textWritingMode": + ["vertical"]` is set. The order of elements in an array define priority order + for the placement of an orientation variant. + + This property is only applied to the style if `text` is non-`nil`, and + `symbolPlacement` is set to an expression that evaluates to or + `MGLSymbolPlacementPoint`. Otherwise, it is ignored. + + You can set this property to an expression containing any of the following: + + * Constant `MGLTextWritingMode` array values + * Constant array, whose each element is any of the following constant string + values: + * `horizontal`: If a text's language supports horizontal writing mode, + symbols with point placement would be laid out horizontally. + * `vertical`: If a text's language supports vertical writing mode, symbols + with point placement would be laid out vertically. + * Predefined functions, including mathematical and string operators + * Conditional expressions + * Variable assignments and references to assigned variables + * Step functions applied to the `$zoomLevel` variable + + This property does not support applying interpolation functions to the + `$zoomLevel` variable or applying interpolation or step functions to feature + attributes. + */ +@property (nonatomic, null_resettable) NSExpression *textWritingMode; + #pragma mark - Accessing the Paint Attributes #if TARGET_OS_IPHONE @@ -2383,6 +2439,19 @@ MGL_EXPORT @property (readonly) MGLTextTransform MGLTextTransformValue; /** + Creates a new value object containing the given `MGLTextWritingMode` enumeration. + + @param textWritingMode The value for the new object. + @return A new value object that contains the enumeration value. + */ ++ (instancetype)valueWithMGLTextWritingMode:(MGLTextWritingMode)textWritingMode; + +/** + The `MGLTextWritingMode` enumeration representation of the value. + */ +@property (readonly) MGLTextWritingMode MGLTextWritingModeValue; + +/** Creates a new value object containing the given `MGLIconTranslationAnchor` enumeration. @param iconTranslationAnchor The value for the new object. diff --git a/platform/darwin/src/MGLSymbolStyleLayer.mm b/platform/darwin/src/MGLSymbolStyleLayer.mm index e54a0b9a15..99cfe5db10 100644 --- a/platform/darwin/src/MGLSymbolStyleLayer.mm +++ b/platform/darwin/src/MGLSymbolStyleLayer.mm @@ -96,6 +96,11 @@ namespace mbgl { { MGLTextTransformLowercase, "lowercase" }, }); + MBGL_DEFINE_ENUM(MGLTextWritingMode, { + { MGLTextWritingModeHorizontal, "horizontal" }, + { MGLTextWritingModeVertical, "vertical" }, + }); + MBGL_DEFINE_ENUM(MGLIconTranslationAnchor, { { MGLIconTranslationAnchorMap, "map" }, { MGLIconTranslationAnchorViewport, "viewport" }, @@ -1023,6 +1028,24 @@ namespace mbgl { return MGLStyleValueTransformer<std::vector<mbgl::style::SymbolAnchorType>, NSArray<NSValue *> *, mbgl::style::SymbolAnchorType, MGLTextAnchor>().toExpression(propertyValue); } +- (void)setTextWritingMode:(NSExpression *)textWritingMode { + MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting textWritingMode: %@", textWritingMode); + + auto mbglValue = MGLStyleValueTransformer<std::vector<mbgl::style::TextWritingModeType>, NSArray<NSValue *> *, mbgl::style::TextWritingModeType, MGLTextWritingMode>().toPropertyValue<mbgl::style::PropertyValue<std::vector<mbgl::style::TextWritingModeType>>>(textWritingMode, false); + self.rawLayer->setTextWritingMode(mbglValue); +} + +- (NSExpression *)textWritingMode { + MGLAssertStyleLayerIsValid(); + + auto propertyValue = self.rawLayer->getTextWritingMode(); + if (propertyValue.isUndefined()) { + propertyValue = self.rawLayer->getDefaultTextWritingMode(); + } + return MGLStyleValueTransformer<std::vector<mbgl::style::TextWritingModeType>, NSArray<NSValue *> *, mbgl::style::TextWritingModeType, MGLTextWritingMode>().toExpression(propertyValue); +} + #pragma mark - Accessing the Paint Attributes - (void)setIconColor:(NSExpression *)iconColor { @@ -1599,6 +1622,16 @@ namespace mbgl { return textTransform; } ++ (NSValue *)valueWithMGLTextWritingMode:(MGLTextWritingMode)textWritingMode { + return [NSValue value:&textWritingMode withObjCType:@encode(MGLTextWritingMode)]; +} + +- (MGLTextWritingMode)MGLTextWritingModeValue { + MGLTextWritingMode textWritingMode; + [self getValue:&textWritingMode]; + return textWritingMode; +} + + (NSValue *)valueWithMGLIconTranslationAnchor:(MGLIconTranslationAnchor)iconTranslationAnchor { return [NSValue value:&iconTranslationAnchor withObjCType:@encode(MGLIconTranslationAnchor)]; } |