[darwin] Add plural override for 'text-writing-mode' layout property
This commit is contained in:
@@ -468,7 +468,7 @@ global.describeType = function (property) {
|
||||
case 'anchor':
|
||||
return '`MGLTextAnchor` array';
|
||||
case 'mode':
|
||||
return '`MGLTextWritingMode` array';
|
||||
return '`MGLTextWritingModes` array';
|
||||
default:
|
||||
return 'array';
|
||||
}
|
||||
@@ -647,7 +647,7 @@ global.valueTransformerArguments = function (property) {
|
||||
case 'anchor':
|
||||
return ['std::vector<mbgl::style::SymbolAnchorType>', objCType, 'mbgl::style::SymbolAnchorType', 'MGLTextAnchor'];
|
||||
case 'mode':
|
||||
return ['std::vector<mbgl::style::TextWritingModeType>', objCType, 'mbgl::style::TextWritingModeType', 'MGLTextWritingMode'];
|
||||
return ['std::vector<mbgl::style::TextWritingModeType>', objCType, 'mbgl::style::TextWritingModeType', 'MGLTextWritingModes'];
|
||||
default:
|
||||
throw new Error(`unknown array type for ${property.name}`);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
"text-max-width": "maximum-text-width",
|
||||
"text-optional": "is-text-optional",
|
||||
"text-rotate": "text-rotation",
|
||||
"text-size": "text-font-size"
|
||||
"text-size": "text-font-size",
|
||||
"text-writing-mode": "text-writing-modes"
|
||||
},
|
||||
"paint_circle": {
|
||||
"circle-pitch-scale": "circle-scale-alignment",
|
||||
|
||||
@@ -324,20 +324,20 @@ typedef NS_ENUM(NSUInteger, MGLTextTransform) {
|
||||
["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`
|
||||
Values of this type are used in the `MGLSymbolStyleLayer.textWritingModes`
|
||||
property.
|
||||
*/
|
||||
typedef NS_ENUM(NSUInteger, MGLTextWritingMode) {
|
||||
typedef NS_ENUM(NSUInteger, MGLTextWritingModes) {
|
||||
/**
|
||||
If a text's language supports horizontal writing mode, symbols with point
|
||||
placement would be laid out horizontally.
|
||||
*/
|
||||
MGLTextWritingModeHorizontal,
|
||||
MGLTextWritingModesHorizontal,
|
||||
/**
|
||||
If a text's language supports vertical writing mode, symbols with point
|
||||
placement would be laid out vertically.
|
||||
*/
|
||||
MGLTextWritingModeVertical,
|
||||
MGLTextWritingModesVertical,
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1682,9 +1682,13 @@ MGL_EXPORT
|
||||
`symbolPlacement` is set to an expression that evaluates to or
|
||||
`MGLSymbolPlacementPoint`. Otherwise, it is ignored.
|
||||
|
||||
This attribute corresponds to the <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-text-writing-mode"><code>text-writing-mode</code></a>
|
||||
layout property in the Mapbox Style Specification.
|
||||
|
||||
You can set this property to an expression containing any of the following:
|
||||
|
||||
* Constant `MGLTextWritingMode` array values
|
||||
* Constant `MGLTextWritingModes` 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,
|
||||
@@ -1700,7 +1704,10 @@ MGL_EXPORT
|
||||
`$zoomLevel` variable or applying interpolation or step functions to feature
|
||||
attributes.
|
||||
*/
|
||||
@property (nonatomic, null_resettable) NSExpression *textWritingMode;
|
||||
@property (nonatomic, null_resettable) NSExpression *textWritingModes;
|
||||
|
||||
|
||||
@property (nonatomic, null_resettable) NSExpression *textWritingMode __attribute__((unavailable("Use textWritingModes instead.")));
|
||||
|
||||
#pragma mark - Accessing the Paint Attributes
|
||||
|
||||
@@ -2439,17 +2446,17 @@ MGL_EXPORT
|
||||
@property (readonly) MGLTextTransform MGLTextTransformValue;
|
||||
|
||||
/**
|
||||
Creates a new value object containing the given `MGLTextWritingMode` enumeration.
|
||||
Creates a new value object containing the given `MGLTextWritingModes` enumeration.
|
||||
|
||||
@param textWritingMode The value for the new object.
|
||||
@param textWritingModes The value for the new object.
|
||||
@return A new value object that contains the enumeration value.
|
||||
*/
|
||||
+ (instancetype)valueWithMGLTextWritingMode:(MGLTextWritingMode)textWritingMode;
|
||||
+ (instancetype)valueWithMGLTextWritingModes:(MGLTextWritingModes)textWritingModes;
|
||||
|
||||
/**
|
||||
The `MGLTextWritingMode` enumeration representation of the value.
|
||||
The `MGLTextWritingModes` enumeration representation of the value.
|
||||
*/
|
||||
@property (readonly) MGLTextWritingMode MGLTextWritingModeValue;
|
||||
@property (readonly) MGLTextWritingModes MGLTextWritingModesValue;
|
||||
|
||||
/**
|
||||
Creates a new value object containing the given `MGLIconTranslationAnchor` enumeration.
|
||||
|
||||
@@ -96,9 +96,9 @@ namespace mbgl {
|
||||
{ MGLTextTransformLowercase, "lowercase" },
|
||||
});
|
||||
|
||||
MBGL_DEFINE_ENUM(MGLTextWritingMode, {
|
||||
{ MGLTextWritingModeHorizontal, "horizontal" },
|
||||
{ MGLTextWritingModeVertical, "vertical" },
|
||||
MBGL_DEFINE_ENUM(MGLTextWritingModes, {
|
||||
{ MGLTextWritingModesHorizontal, "horizontal" },
|
||||
{ MGLTextWritingModesVertical, "vertical" },
|
||||
});
|
||||
|
||||
MBGL_DEFINE_ENUM(MGLIconTranslationAnchor, {
|
||||
@@ -1028,22 +1028,29 @@ namespace mbgl {
|
||||
return MGLStyleValueTransformer<std::vector<mbgl::style::SymbolAnchorType>, NSArray<NSValue *> *, mbgl::style::SymbolAnchorType, MGLTextAnchor>().toExpression(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setTextWritingMode:(NSExpression *)textWritingMode {
|
||||
- (void)setTextWritingModes:(NSExpression *)textWritingModes {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
MGLLogDebug(@"Setting textWritingMode: %@", textWritingMode);
|
||||
MGLLogDebug(@"Setting textWritingModes: %@", textWritingModes);
|
||||
|
||||
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);
|
||||
auto mbglValue = MGLStyleValueTransformer<std::vector<mbgl::style::TextWritingModeType>, NSArray<NSValue *> *, mbgl::style::TextWritingModeType, MGLTextWritingModes>().toPropertyValue<mbgl::style::PropertyValue<std::vector<mbgl::style::TextWritingModeType>>>(textWritingModes, false);
|
||||
self.rawLayer->setTextWritingMode(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)textWritingMode {
|
||||
- (NSExpression *)textWritingModes {
|
||||
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);
|
||||
return MGLStyleValueTransformer<std::vector<mbgl::style::TextWritingModeType>, NSArray<NSValue *> *, mbgl::style::TextWritingModeType, MGLTextWritingModes>().toExpression(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setTextWritingMode:(NSExpression *)textWritingMode {
|
||||
}
|
||||
|
||||
- (NSExpression *)textWritingMode {
|
||||
return self.textWritingModes;
|
||||
}
|
||||
|
||||
#pragma mark - Accessing the Paint Attributes
|
||||
@@ -1622,14 +1629,14 @@ namespace mbgl {
|
||||
return textTransform;
|
||||
}
|
||||
|
||||
+ (NSValue *)valueWithMGLTextWritingMode:(MGLTextWritingMode)textWritingMode {
|
||||
return [NSValue value:&textWritingMode withObjCType:@encode(MGLTextWritingMode)];
|
||||
+ (NSValue *)valueWithMGLTextWritingModes:(MGLTextWritingModes)textWritingModes {
|
||||
return [NSValue value:&textWritingModes withObjCType:@encode(MGLTextWritingModes)];
|
||||
}
|
||||
|
||||
- (MGLTextWritingMode)MGLTextWritingModeValue {
|
||||
MGLTextWritingMode textWritingMode;
|
||||
[self getValue:&textWritingMode];
|
||||
return textWritingMode;
|
||||
- (MGLTextWritingModes)MGLTextWritingModesValue {
|
||||
MGLTextWritingModes textWritingModes;
|
||||
[self getValue:&textWritingModes];
|
||||
return textWritingModes;
|
||||
}
|
||||
|
||||
+ (NSValue *)valueWithMGLIconTranslationAnchor:(MGLIconTranslationAnchor)iconTranslationAnchor {
|
||||
|
||||
@@ -2078,19 +2078,19 @@
|
||||
{
|
||||
XCTAssertTrue(rawLayer->getTextWritingMode().isUndefined(),
|
||||
@"text-writing-mode should be unset initially.");
|
||||
NSExpression *defaultExpression = layer.textWritingMode;
|
||||
NSExpression *defaultExpression = layer.textWritingModes;
|
||||
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"{'horizontal','vertical'}"];
|
||||
layer.textWritingMode = constantExpression;
|
||||
layer.textWritingModes = constantExpression;
|
||||
mbgl::style::PropertyValue<std::vector<mbgl::style::TextWritingModeType>> propertyValue = { { mbgl::style::TextWritingModeType::Horizontal, mbgl::style::TextWritingModeType::Vertical } };
|
||||
XCTAssertEqual(rawLayer->getTextWritingMode(), propertyValue,
|
||||
@"Setting textWritingMode to a constant value expression should update text-writing-mode.");
|
||||
XCTAssertEqualObjects(layer.textWritingMode, constantExpression,
|
||||
@"textWritingMode should round-trip constant value expressions.");
|
||||
@"Setting textWritingModes to a constant value expression should update text-writing-mode.");
|
||||
XCTAssertEqualObjects(layer.textWritingModes, constantExpression,
|
||||
@"textWritingModes should round-trip constant value expressions.");
|
||||
|
||||
constantExpression = [NSExpression expressionWithFormat:@"{'horizontal','vertical'}"];
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.textWritingMode = functionExpression;
|
||||
layer.textWritingModes = functionExpression;
|
||||
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
@@ -2100,22 +2100,22 @@
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getTextWritingMode(), propertyValue,
|
||||
@"Setting textWritingMode to a camera expression should update text-writing-mode.");
|
||||
XCTAssertEqualObjects(layer.textWritingMode, functionExpression,
|
||||
@"textWritingMode should round-trip camera expressions.");
|
||||
@"Setting textWritingModes to a camera expression should update text-writing-mode.");
|
||||
XCTAssertEqualObjects(layer.textWritingModes, functionExpression,
|
||||
@"textWritingModes should round-trip camera expressions.");
|
||||
|
||||
|
||||
layer.textWritingMode = nil;
|
||||
layer.textWritingModes = nil;
|
||||
XCTAssertTrue(rawLayer->getTextWritingMode().isUndefined(),
|
||||
@"Unsetting textWritingMode should return text-writing-mode to the default value.");
|
||||
XCTAssertEqualObjects(layer.textWritingMode, defaultExpression,
|
||||
@"textWritingMode should return the default value after being unset.");
|
||||
@"Unsetting textWritingModes should return text-writing-mode to the default value.");
|
||||
XCTAssertEqualObjects(layer.textWritingModes, defaultExpression,
|
||||
@"textWritingModes should return the default value after being unset.");
|
||||
|
||||
functionExpression = [NSExpression expressionForKeyPath:@"bogus"];
|
||||
XCTAssertThrowsSpecificNamed(layer.textWritingMode = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
|
||||
XCTAssertThrowsSpecificNamed(layer.textWritingModes = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
|
||||
XCTAssertThrowsSpecificNamed(layer.textWritingMode = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
|
||||
XCTAssertThrowsSpecificNamed(layer.textWritingModes = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes.");
|
||||
}
|
||||
|
||||
// icon-color
|
||||
@@ -3128,7 +3128,7 @@
|
||||
[self testPropertyName:@"text-rotation-alignment" isBoolean:NO];
|
||||
[self testPropertyName:@"text-transform" isBoolean:NO];
|
||||
[self testPropertyName:@"text-variable-anchor" isBoolean:NO];
|
||||
[self testPropertyName:@"text-writing-mode" isBoolean:NO];
|
||||
[self testPropertyName:@"text-writing-modes" isBoolean:NO];
|
||||
[self testPropertyName:@"icon-color" isBoolean:NO];
|
||||
[self testPropertyName:@"icon-halo-blur" isBoolean:NO];
|
||||
[self testPropertyName:@"icon-halo-color" isBoolean:NO];
|
||||
@@ -3193,8 +3193,8 @@
|
||||
XCTAssertEqual([NSValue valueWithMGLTextTransform:MGLTextTransformNone].MGLTextTransformValue, MGLTextTransformNone);
|
||||
XCTAssertEqual([NSValue valueWithMGLTextTransform:MGLTextTransformUppercase].MGLTextTransformValue, MGLTextTransformUppercase);
|
||||
XCTAssertEqual([NSValue valueWithMGLTextTransform:MGLTextTransformLowercase].MGLTextTransformValue, MGLTextTransformLowercase);
|
||||
XCTAssertEqual([NSValue valueWithMGLTextWritingMode:MGLTextWritingModeHorizontal].MGLTextWritingModeValue, MGLTextWritingModeHorizontal);
|
||||
XCTAssertEqual([NSValue valueWithMGLTextWritingMode:MGLTextWritingModeVertical].MGLTextWritingModeValue, MGLTextWritingModeVertical);
|
||||
XCTAssertEqual([NSValue valueWithMGLTextWritingModes:MGLTextWritingModesHorizontal].MGLTextWritingModesValue, MGLTextWritingModesHorizontal);
|
||||
XCTAssertEqual([NSValue valueWithMGLTextWritingModes:MGLTextWritingModesVertical].MGLTextWritingModesValue, MGLTextWritingModesVertical);
|
||||
XCTAssertEqual([NSValue valueWithMGLIconTranslationAnchor:MGLIconTranslationAnchorMap].MGLIconTranslationAnchorValue, MGLIconTranslationAnchorMap);
|
||||
XCTAssertEqual([NSValue valueWithMGLIconTranslationAnchor:MGLIconTranslationAnchorViewport].MGLIconTranslationAnchorValue, MGLIconTranslationAnchorViewport);
|
||||
XCTAssertEqual([NSValue valueWithMGLTextTranslationAnchor:MGLTextTranslationAnchorMap].MGLTextTranslationAnchorValue, MGLTextTranslationAnchorMap);
|
||||
|
||||
@@ -270,6 +270,7 @@ In style JSON | In Objective-C | In Swift
|
||||
`text-justify` | `MGLSymbolStyleLayer.textJustification` | `MGLSymbolStyleLayer.textJustification`
|
||||
`text-optional` | `MGLSymbolStyleLayer.textOptional` | `MGLSymbolStyleLayer.isTextOptional`
|
||||
`text-rotate` | `MGLSymbolStyleLayer.textRotation` | `MGLSymbolStyleLayer.textRotation`
|
||||
`text-writing-mode` | `MGLSymbolStyleLayer.textWritingModes` | `MGLSymbolStyleLayer.textWritingModes`
|
||||
`icon-translate` | `MGLSymbolStyleLayer.iconTranslation` | `MGLSymbolStyleLayer.iconTranslation`
|
||||
`icon-translate-anchor` | `MGLSymbolStyleLayer.iconTranslationAnchor` | `MGLSymbolStyleLayer.iconTranslationAnchor`
|
||||
`text-translate` | `MGLSymbolStyleLayer.textTranslation` | `MGLSymbolStyleLayer.textTranslation`
|
||||
|
||||
@@ -257,6 +257,7 @@ In style JSON | In Objective-C | In Swift
|
||||
`text-justify` | `MGLSymbolStyleLayer.textJustification` | `MGLSymbolStyleLayer.textJustification`
|
||||
`text-optional` | `MGLSymbolStyleLayer.textOptional` | `MGLSymbolStyleLayer.isTextOptional`
|
||||
`text-rotate` | `MGLSymbolStyleLayer.textRotation` | `MGLSymbolStyleLayer.textRotation`
|
||||
`text-writing-mode` | `MGLSymbolStyleLayer.textWritingModes` | `MGLSymbolStyleLayer.textWritingModes`
|
||||
`icon-translate` | `MGLSymbolStyleLayer.iconTranslation` | `MGLSymbolStyleLayer.iconTranslation`
|
||||
`icon-translate-anchor` | `MGLSymbolStyleLayer.iconTranslationAnchor` | `MGLSymbolStyleLayer.iconTranslationAnchor`
|
||||
`text-translate` | `MGLSymbolStyleLayer.textTranslation` | `MGLSymbolStyleLayer.textTranslation`
|
||||
|
||||
Reference in New Issue
Block a user