diff options
author | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2019-06-18 14:41:46 +0300 |
---|---|---|
committer | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2019-08-13 13:32:56 +0300 |
commit | f94460041353be26eb7516d7006a2c83a4aa19f2 (patch) | |
tree | 2ae50d7ec0b8da5a230f7a833acaea222ae9596c /platform/darwin/src/MGLSymbolStyleLayer.mm | |
parent | dad43ba8fcd04698230fefa9c6af93931f6c10f3 (diff) | |
download | qtlocation-mapboxgl-f94460041353be26eb7516d7006a2c83a4aa19f2.tar.gz |
[darwin] Bindings for new 'text-writing-mode' layout property
Diffstat (limited to 'platform/darwin/src/MGLSymbolStyleLayer.mm')
-rw-r--r-- | platform/darwin/src/MGLSymbolStyleLayer.mm | 33 |
1 files changed, 33 insertions, 0 deletions
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)]; } |