From 17b3ec1edd217b8b14d64b74cbf58b0e4ae4f241 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Thu, 5 Jan 2017 03:22:04 -0800 Subject: [ios, macos] Renamed text-field, text-font, text-font-size, circle-pitch-scale Reduced the likelihood that the developer might attempt to set textField to an NSTextField or UITextField, or textFont to an NSFont or UIFont, or textSize to a CGSize or NSSize, or circlePitchScale to a number (given iconScale). --- platform/darwin/src/MGLCircleStyleLayer.h | 42 ++++--- platform/darwin/src/MGLCircleStyleLayer.mm | 47 ++++---- platform/darwin/src/MGLSymbolStyleLayer.h | 181 +++++++++++++++++------------ platform/darwin/src/MGLSymbolStyleLayer.mm | 77 ++++++++---- 4 files changed, 208 insertions(+), 139 deletions(-) (limited to 'platform/darwin/src') diff --git a/platform/darwin/src/MGLCircleStyleLayer.h b/platform/darwin/src/MGLCircleStyleLayer.h index f0fc95db06..76f8cbd4c6 100644 --- a/platform/darwin/src/MGLCircleStyleLayer.h +++ b/platform/darwin/src/MGLCircleStyleLayer.h @@ -9,18 +9,18 @@ NS_ASSUME_NONNULL_BEGIN /** Controls the scaling behavior of the circle when the map is pitched. - Values of this type are used in the `MGLCircleStyleLayer.circlePitchScale` + Values of this type are used in the `MGLCircleStyleLayer.circleScaleAlignment` property. */ -typedef NS_ENUM(NSUInteger, MGLCirclePitchScale) { +typedef NS_ENUM(NSUInteger, MGLCircleScaleAlignment) { /** Circles are scaled according to their apparent distance to the camera. */ - MGLCirclePitchScaleMap, + MGLCircleScaleAlignmentMap, /** Circles are not scaled. */ - MGLCirclePitchScaleViewport, + MGLCircleScaleAlignmentViewport, }; /** @@ -118,15 +118,6 @@ typedef NS_ENUM(NSUInteger, MGLCircleTranslateAnchor) { */ @property (nonatomic, null_resettable) MGLStyleValue *circleOpacity; -/** - Controls the scaling behavior of the circle when the map is pitched. - - The default value of this property is an `MGLStyleValue` object containing an - `NSValue` object containing `MGLCirclePitchScaleMap`. Set this property to - `nil` to reset it to the default value. - */ -@property (nonatomic, null_resettable) MGLStyleValue *circlePitchScale; - /** Circle radius. @@ -138,6 +129,21 @@ typedef NS_ENUM(NSUInteger, MGLCircleTranslateAnchor) { */ @property (nonatomic, null_resettable) MGLStyleValue *circleRadius; +/** + Controls the scaling behavior of the circle when the map is pitched. + + The default value of this property is an `MGLStyleValue` object containing an + `NSValue` object containing `MGLCircleScaleAlignmentMap`. Set this property to + `nil` to reset it to the default value. + + This attribute corresponds to the circle-pitch-scale + layout property in the Mapbox Style Specification. + */ +@property (nonatomic, null_resettable) MGLStyleValue *circleScaleAlignment; + +@property (nonatomic, null_resettable) MGLStyleValue *circlePitchScale __attribute__((unavailable("Use circleScaleAlignment instead."))); + /** The geometry's offset. @@ -173,17 +179,17 @@ typedef NS_ENUM(NSUInteger, MGLCircleTranslateAnchor) { #pragma mark Working with Circle Style Layer Attribute Values /** - Creates a new value object containing the given `MGLCirclePitchScale` enumeration. + Creates a new value object containing the given `MGLCircleScaleAlignment` enumeration. - @param circlePitchScale The value for the new object. + @param circleScaleAlignment The value for the new object. @return A new value object that contains the enumeration value. */ -+ (instancetype)valueWithMGLCirclePitchScale:(MGLCirclePitchScale)circlePitchScale; ++ (instancetype)valueWithMGLCircleScaleAlignment:(MGLCircleScaleAlignment)circleScaleAlignment; /** - The `MGLCirclePitchScale` enumeration representation of the value. + The `MGLCircleScaleAlignment` enumeration representation of the value. */ -@property (readonly) MGLCirclePitchScale MGLCirclePitchScaleValue; +@property (readonly) MGLCircleScaleAlignment MGLCircleScaleAlignmentValue; /** Creates a new value object containing the given `MGLCircleTranslateAnchor` enumeration. diff --git a/platform/darwin/src/MGLCircleStyleLayer.mm b/platform/darwin/src/MGLCircleStyleLayer.mm index ecba9b01d3..c23658b518 100644 --- a/platform/darwin/src/MGLCircleStyleLayer.mm +++ b/platform/darwin/src/MGLCircleStyleLayer.mm @@ -11,9 +11,9 @@ #include namespace mbgl { - MBGL_DEFINE_ENUM(MGLCirclePitchScale, { - { MGLCirclePitchScaleMap, "map" }, - { MGLCirclePitchScaleViewport, "viewport" }, + MBGL_DEFINE_ENUM(MGLCircleScaleAlignment, { + { MGLCircleScaleAlignmentMap, "map" }, + { MGLCircleScaleAlignmentViewport, "viewport" }, }); MBGL_DEFINE_ENUM(MGLCircleTranslateAnchor, { @@ -173,32 +173,37 @@ namespace mbgl { return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setCirclePitchScale:(MGLStyleValue *)circlePitchScale { +- (void)setCircleRadius:(MGLStyleValue *)circleRadius { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toEnumPropertyValue(circlePitchScale); - self.rawLayer->setCirclePitchScale(mbglValue); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(circleRadius); + self.rawLayer->setCircleRadius(mbglValue); } -- (MGLStyleValue *)circlePitchScale { +- (MGLStyleValue *)circleRadius { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getCirclePitchScale() ?: self.rawLayer->getDefaultCirclePitchScale(); - return MGLStyleValueTransformer().toEnumStyleValue(propertyValue); + auto propertyValue = self.rawLayer->getCircleRadius() ?: self.rawLayer->getDefaultCircleRadius(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setCircleRadius:(MGLStyleValue *)circleRadius { +- (void)setCircleScaleAlignment:(MGLStyleValue *)circleScaleAlignment { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue(circleRadius); - self.rawLayer->setCircleRadius(mbglValue); + auto mbglValue = MGLStyleValueTransformer().toEnumPropertyValue(circleScaleAlignment); + self.rawLayer->setCirclePitchScale(mbglValue); } -- (MGLStyleValue *)circleRadius { +- (MGLStyleValue *)circleScaleAlignment { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getCircleRadius() ?: self.rawLayer->getDefaultCircleRadius(); - return MGLStyleValueTransformer().toStyleValue(propertyValue); + auto propertyValue = self.rawLayer->getCirclePitchScale() ?: self.rawLayer->getDefaultCirclePitchScale(); + return MGLStyleValueTransformer().toEnumStyleValue(propertyValue); +} + + +- (void)setCirclePitchScale:(MGLStyleValue *)circlePitchScale { + NSAssert(NO, @"Use -setCircleScaleAlignment: instead."); } - (void)setCircleTranslate:(MGLStyleValue *)circleTranslate { @@ -234,14 +239,14 @@ namespace mbgl { @implementation NSValue (MGLCircleStyleLayerAdditions) -+ (NSValue *)valueWithMGLCirclePitchScale:(MGLCirclePitchScale)circlePitchScale { - return [NSValue value:&circlePitchScale withObjCType:@encode(MGLCirclePitchScale)]; ++ (NSValue *)valueWithMGLCircleScaleAlignment:(MGLCircleScaleAlignment)circleScaleAlignment { + return [NSValue value:&circleScaleAlignment withObjCType:@encode(MGLCircleScaleAlignment)]; } -- (MGLCirclePitchScale)MGLCirclePitchScaleValue { - MGLCirclePitchScale circlePitchScale; - [self getValue:&circlePitchScale]; - return circlePitchScale; +- (MGLCircleScaleAlignment)MGLCircleScaleAlignmentValue { + MGLCircleScaleAlignment circleScaleAlignment; + [self getValue:&circleScaleAlignment]; + return circleScaleAlignment; } + (NSValue *)valueWithMGLCircleTranslateAnchor:(MGLCircleTranslateAnchor)circleTranslateAnchor { diff --git a/platform/darwin/src/MGLSymbolStyleLayer.h b/platform/darwin/src/MGLSymbolStyleLayer.h index e12faa46ea..8edc88dfa1 100644 --- a/platform/darwin/src/MGLSymbolStyleLayer.h +++ b/platform/darwin/src/MGLSymbolStyleLayer.h @@ -268,7 +268,7 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { layer.sourceLayerIdentifier = "pois" layer.iconImageName = MGLStyleValue(rawValue: "coffee") layer.iconScale = MGLStyleValue(rawValue: 0.5) - layer.textField = MGLStyleValue(rawValue: "{name}") + layer.text = MGLStyleValue(rawValue: "{name}") layer.textTranslate = MGLStyleValue(rawValue: NSValue(cgVector: CGVector(dx: 10, dy: 0))) layer.textJustification = MGLStyleValue(rawValue: NSValue(mglTextJustification: .left)) layer.textAnchor = MGLStyleValue(rawValue: NSValue(mglTextAnchor: .left)) @@ -352,7 +352,7 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { the default value. This property is only applied to the style if `iconImageName` is non-`nil`, and - `textField` is non-`nil`. Otherwise, it is ignored. + `text` is non-`nil`. Otherwise, it is ignored. */ @property (nonatomic, null_resettable, getter=isIconOptional) MGLStyleValue *iconOptional; @@ -432,7 +432,7 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { reset it to the default value. This property is only applied to the style if `iconImageName` is non-`nil`, and - `textField` is non-`nil`. Otherwise, it is ignored. + `text` is non-`nil`. Otherwise, it is ignored. */ @property (nonatomic, null_resettable) MGLStyleValue *iconTextFit; @@ -446,7 +446,7 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { property to `nil` to reset it to the default value. This property is only applied to the style if `iconImageName` is non-`nil`, and - `textField` is non-`nil`, and `iconTextFit` is set to an `MGLStyleValue` object + `text` is non-`nil`, and `iconTextFit` is set to an `MGLStyleValue` object containing an `NSValue` object containing `MGLIconTextFitBoth`, `MGLIconTextFitWidth`, or `MGLIconTextFitHeight`. Otherwise, it is ignored. */ @@ -482,7 +482,7 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { `NSNumber` object containing `YES`. Set this property to `nil` to reset it to the default value. - This property is only applied to the style if `textField` is non-`nil`, and + This property is only applied to the style if `text` is non-`nil`, and `textRotationAlignment` is set to an `MGLStyleValue` object containing an `NSValue` object containing `MGLTextRotationAlignmentMap`, and `symbolPlacement` is set to an `MGLStyleValue` object containing an `NSValue` @@ -506,7 +506,7 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { `NSNumber` object containing the float `45`. Set this property to `nil` to reset it to the default value. - This property is only applied to the style if `textField` is non-`nil`, and + This property is only applied to the style if `text` is non-`nil`, and `symbolPlacement` is set to an `MGLStyleValue` object containing an `NSValue` object containing `MGLSymbolPlacementLine`. Otherwise, it is ignored. @@ -528,8 +528,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { `NSNumber` object containing the float `10`. Set this property to `nil` to reset it to the default value. - This property is only applied to the style if `textField` is non-`nil`. - Otherwise, it is ignored. + This property is only applied to the style if `text` is non-`nil`. Otherwise, + it is ignored. This attribute corresponds to the text-max-width @@ -583,6 +583,22 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { */ @property (nonatomic, null_resettable) MGLStyleValue *symbolSpacing; +/** + Value to use for a text label. Feature properties are specified using tokens + like {field_name}. + + The default value of this property is an `MGLStyleValue` object containing the + empty string. Set this property to `nil` to reset it to the default value. + + This attribute corresponds to the text-field + layout property in the Mapbox Style Specification. + */ +@property (nonatomic, null_resettable) MGLStyleValue *text; + + +@property (nonatomic, null_resettable) MGLStyleValue *textField __attribute__((unavailable("Use text instead."))); + /** If true, the text will be visible even if it collides with other previously drawn symbols. @@ -591,8 +607,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { `NSNumber` object containing `NO`. Set this property to `nil` to reset it to the default value. - This property is only applied to the style if `textField` is non-`nil`. - Otherwise, it is ignored. + This property is only applied to the style if `text` is non-`nil`. Otherwise, + it is ignored. This attribute corresponds to the text-allow-overlap @@ -610,31 +626,60 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { `NSValue` object containing `MGLTextAnchorCenter`. Set this property to `nil` to reset it to the default value. - This property is only applied to the style if `textField` is non-`nil`. - Otherwise, it is ignored. + This property is only applied to the style if `text` is non-`nil`. Otherwise, + it is ignored. */ @property (nonatomic, null_resettable) MGLStyleValue *textAnchor; /** - Value to use for a text label. Feature properties are specified using tokens - like {field_name}. + An array of font face names used to display the text. + + Each font name must be included in the `{fontstack}` portion of the JSON + stylesheet’s glyphs + property. You can register a custom font when designing the style in Mapbox + Studio. Fonts installed on the system are not used. + + The first font named in the array is applied to the text. For each character in + the text, if the first font lacks a glyph for the character, the next font is + applied as a fallback, and so on. The default value of this property is an `MGLStyleValue` object containing the - empty string. Set this property to `nil` to reset it to the default value. + array `Open Sans Regular`, `Arial Unicode MS Regular`. Set this property to + `nil` to reset it to the default value. + + This property is only applied to the style if `text` is non-`nil`. Otherwise, + it is ignored. + + This attribute corresponds to the text-font + layout property in the Mapbox Style Specification. */ -@property (nonatomic, null_resettable) MGLStyleValue *textField; +@property (nonatomic, null_resettable) MGLStyleValue *> *textFontNames; + + +@property (nonatomic, null_resettable) MGLStyleValue *> *textFont __attribute__((unavailable("Use textFontNames instead."))); /** - Font stack to use for displaying text. + Font size. - The default value of this property is an `MGLStyleValue` object containing the - array `Open Sans Regular`, `Arial Unicode MS Regular`. Set this property to - `nil` to reset it to the default value. + This property is measured in points. - This property is only applied to the style if `textField` is non-`nil`. - Otherwise, it is ignored. + The default value of this property is an `MGLStyleValue` object containing an + `NSNumber` object containing the float `16`. Set this property to `nil` to + reset it to the default value. + + This property is only applied to the style if `text` is non-`nil`. Otherwise, + it is ignored. + + This attribute corresponds to the text-size + layout property in the Mapbox Style Specification. */ -@property (nonatomic, null_resettable) MGLStyleValue *> *textFont; +@property (nonatomic, null_resettable) MGLStyleValue *textFontSize; + + +@property (nonatomic, null_resettable) MGLStyleValue *textSize __attribute__((unavailable("Use textFontSize instead."))); /** If true, other symbols can be visible even if they collide with the text. @@ -643,8 +688,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { `NSNumber` object containing `NO`. Set this property to `nil` to reset it to the default value. - This property is only applied to the style if `textField` is non-`nil`. - Otherwise, it is ignored. + This property is only applied to the style if `text` is non-`nil`. Otherwise, + it is ignored. This attribute corresponds to the text-ignore-placement @@ -662,8 +707,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { `NSValue` object containing `MGLTextJustificationCenter`. Set this property to `nil` to reset it to the default value. - This property is only applied to the style if `textField` is non-`nil`. - Otherwise, it is ignored. + This property is only applied to the style if `text` is non-`nil`. Otherwise, + it is ignored. This attribute corresponds to the text-justify @@ -683,8 +728,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. - This property is only applied to the style if `textField` is non-`nil`. - Otherwise, it is ignored. + This property is only applied to the style if `text` is non-`nil`. Otherwise, + it is ignored. */ @property (nonatomic, null_resettable) MGLStyleValue *textLetterSpacing; @@ -697,8 +742,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { `NSNumber` object containing the float `1.2`. Set this property to `nil` to reset it to the default value. - This property is only applied to the style if `textField` is non-`nil`. - Otherwise, it is ignored. + This property is only applied to the style if `text` is non-`nil`. Otherwise, + it is ignored. */ @property (nonatomic, null_resettable) MGLStyleValue *textLineHeight; @@ -712,8 +757,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { 0 ems from the top. Set this property to `nil` to reset it to the default value. - This property is only applied to the style if `textField` is non-`nil`. - Otherwise, it is ignored. + This property is only applied to the style if `text` is non-`nil`. Otherwise, + it is ignored. */ @property (nonatomic, null_resettable) MGLStyleValue *textOffset; @@ -725,7 +770,7 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { `NSNumber` object containing `NO`. Set this property to `nil` to reset it to the default value. - This property is only applied to the style if `textField` is non-`nil`, and + This property is only applied to the style if `text` is non-`nil`, and `iconImageName` is non-`nil`. Otherwise, it is ignored. */ @property (nonatomic, null_resettable, getter=isTextOptional) MGLStyleValue *textOptional; @@ -740,8 +785,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { `NSNumber` object containing the float `2`. Set this property to `nil` to reset it to the default value. - This property is only applied to the style if `textField` is non-`nil`. - Otherwise, it is ignored. + This property is only applied to the style if `text` is non-`nil`. Otherwise, + it is ignored. */ @property (nonatomic, null_resettable) MGLStyleValue *textPadding; @@ -752,8 +797,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { `NSValue` object containing `MGLTextPitchAlignmentAuto`. Set this property to `nil` to reset it to the default value. - This property is only applied to the style if `textField` is non-`nil`. - Otherwise, it is ignored. + This property is only applied to the style if `text` is non-`nil`. Otherwise, + it is ignored. */ @property (nonatomic, null_resettable) MGLStyleValue *textPitchAlignment; @@ -766,8 +811,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. - This property is only applied to the style if `textField` is non-`nil`. - Otherwise, it is ignored. + This property is only applied to the style if `text` is non-`nil`. Otherwise, + it is ignored. This attribute corresponds to the text-rotate @@ -786,25 +831,11 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { `NSValue` object containing `MGLTextRotationAlignmentAuto`. Set this property to `nil` to reset it to the default value. - This property is only applied to the style if `textField` is non-`nil`. - Otherwise, it is ignored. + This property is only applied to the style if `text` is non-`nil`. Otherwise, + it is ignored. */ @property (nonatomic, null_resettable) MGLStyleValue *textRotationAlignment; -/** - Font size. - - This property is measured in points. - - The default value of this property is an `MGLStyleValue` object containing an - `NSNumber` object containing the float `16`. Set this property to `nil` to - reset it to the default value. - - This property is only applied to the style if `textField` is non-`nil`. - Otherwise, it is ignored. - */ -@property (nonatomic, null_resettable) MGLStyleValue *textSize; - /** Specifies how to capitalize text. @@ -812,8 +843,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { `NSValue` object containing `MGLTextTransformNone`. Set this property to `nil` to reset it to the default value. - This property is only applied to the style if `textField` is non-`nil`. - Otherwise, it is ignored. + This property is only applied to the style if `text` is non-`nil`. Otherwise, + it is ignored. */ @property (nonatomic, null_resettable) MGLStyleValue *textTransform; @@ -950,8 +981,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { `UIColor.blackColor`. Set this property to `nil` to reset it to the default value. - This property is only applied to the style if `textField` is non-`nil`. - Otherwise, it is ignored. + This property is only applied to the style if `text` is non-`nil`. Otherwise, + it is ignored. */ @property (nonatomic, null_resettable) MGLStyleValue *textColor; #else @@ -962,8 +993,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { `NSColor.blackColor`. Set this property to `nil` to reset it to the default value. - This property is only applied to the style if `textField` is non-`nil`. - Otherwise, it is ignored. + This property is only applied to the style if `text` is non-`nil`. Otherwise, + it is ignored. */ @property (nonatomic, null_resettable) MGLStyleValue *textColor; #endif @@ -977,8 +1008,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. - This property is only applied to the style if `textField` is non-`nil`. - Otherwise, it is ignored. + This property is only applied to the style if `text` is non-`nil`. Otherwise, + it is ignored. */ @property (nonatomic, null_resettable) MGLStyleValue *textHaloBlur; @@ -990,8 +1021,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { `UIColor.clearColor`. Set this property to `nil` to reset it to the default value. - This property is only applied to the style if `textField` is non-`nil`. - Otherwise, it is ignored. + This property is only applied to the style if `text` is non-`nil`. Otherwise, + it is ignored. */ @property (nonatomic, null_resettable) MGLStyleValue *textHaloColor; #else @@ -1002,8 +1033,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { `NSColor.clearColor`. Set this property to `nil` to reset it to the default value. - This property is only applied to the style if `textField` is non-`nil`. - Otherwise, it is ignored. + This property is only applied to the style if `text` is non-`nil`. Otherwise, + it is ignored. */ @property (nonatomic, null_resettable) MGLStyleValue *textHaloColor; #endif @@ -1018,8 +1049,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. - This property is only applied to the style if `textField` is non-`nil`. - Otherwise, it is ignored. + This property is only applied to the style if `text` is non-`nil`. Otherwise, + it is ignored. */ @property (nonatomic, null_resettable) MGLStyleValue *textHaloWidth; @@ -1030,8 +1061,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { `NSNumber` object containing the float `1`. Set this property to `nil` to reset it to the default value. - This property is only applied to the style if `textField` is non-`nil`. - Otherwise, it is ignored. + This property is only applied to the style if `text` is non-`nil`. Otherwise, + it is ignored. */ @property (nonatomic, null_resettable) MGLStyleValue *textOpacity; @@ -1045,8 +1076,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { and 0 points from the top. Set this property to `nil` to reset it to the default value. - This property is only applied to the style if `textField` is non-`nil`. - Otherwise, it is ignored. + This property is only applied to the style if `text` is non-`nil`. Otherwise, + it is ignored. */ @property (nonatomic, null_resettable) MGLStyleValue *textTranslate; @@ -1057,7 +1088,7 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { `NSValue` object containing `MGLTextTranslateAnchorMap`. Set this property to `nil` to reset it to the default value. - This property is only applied to the style if `textField` is non-`nil`, and + This property is only applied to the style if `text` is non-`nil`, and `textTranslate` is non-`nil`. Otherwise, it is ignored. */ @property (nonatomic, null_resettable) MGLStyleValue *textTranslateAnchor; diff --git a/platform/darwin/src/MGLSymbolStyleLayer.mm b/platform/darwin/src/MGLSymbolStyleLayer.mm index 3cfaee986b..cf79d67967 100644 --- a/platform/darwin/src/MGLSymbolStyleLayer.mm +++ b/platform/darwin/src/MGLSymbolStyleLayer.mm @@ -527,6 +527,29 @@ namespace mbgl { return MGLStyleValueTransformer().toStyleValue(propertyValue); } +- (void)setText:(MGLStyleValue *)text { + MGLAssertStyleLayerIsValid(); + + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(text); + self.rawLayer->setTextField(mbglValue); +} + +- (MGLStyleValue *)text { + MGLAssertStyleLayerIsValid(); + + auto propertyValue = self.rawLayer->getTextField() ?: self.rawLayer->getDefaultTextField(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); +} + + +- (void)setTextField:(MGLStyleValue *)textField { + self.text = textField; +} + +- (MGLStyleValue *)textField { + return self.text; +} + - (void)setTextAllowsOverlap:(MGLStyleValue *)textAllowsOverlap { MGLAssertStyleLayerIsValid(); @@ -564,32 +587,50 @@ namespace mbgl { return MGLStyleValueTransformer().toEnumStyleValue(propertyValue); } -- (void)setTextField:(MGLStyleValue *)textField { +- (void)setTextFontNames:(MGLStyleValue *> *)textFontNames { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textField); - self.rawLayer->setTextField(mbglValue); + auto mbglValue = MGLStyleValueTransformer, NSArray *, std::string>().toPropertyValue(textFontNames); + self.rawLayer->setTextFont(mbglValue); } -- (MGLStyleValue *)textField { +- (MGLStyleValue *> *)textFontNames { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getTextField() ?: self.rawLayer->getDefaultTextField(); - return MGLStyleValueTransformer().toStyleValue(propertyValue); + auto propertyValue = self.rawLayer->getTextFont() ?: self.rawLayer->getDefaultTextFont(); + return MGLStyleValueTransformer, NSArray *, std::string>().toStyleValue(propertyValue); } + - (void)setTextFont:(MGLStyleValue *> *)textFont { + self.textFontNames = textFont; +} + +- (MGLStyleValue *> *)textFont { + return self.textFontNames; +} + +- (void)setTextFontSize:(MGLStyleValue *)textFontSize { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer, NSArray *, std::string>().toPropertyValue(textFont); - self.rawLayer->setTextFont(mbglValue); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textFontSize); + self.rawLayer->setTextSize(mbglValue); } -- (MGLStyleValue *> *)textFont { +- (MGLStyleValue *)textFontSize { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getTextFont() ?: self.rawLayer->getDefaultTextFont(); - return MGLStyleValueTransformer, NSArray *, std::string>().toStyleValue(propertyValue); + auto propertyValue = self.rawLayer->getTextSize() ?: self.rawLayer->getDefaultTextSize(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); +} + + +- (void)setTextSize:(MGLStyleValue *)textSize { + self.textFontSize = textSize; +} + +- (MGLStyleValue *)textSize { + return self.textFontSize; } - (void)setTextIgnoresPlacement:(MGLStyleValue *)textIgnoresPlacement { @@ -759,20 +800,6 @@ namespace mbgl { return MGLStyleValueTransformer().toEnumStyleValue(propertyValue); } -- (void)setTextSize:(MGLStyleValue *)textSize { - MGLAssertStyleLayerIsValid(); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textSize); - self.rawLayer->setTextSize(mbglValue); -} - -- (MGLStyleValue *)textSize { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getTextSize() ?: self.rawLayer->getDefaultTextSize(); - return MGLStyleValueTransformer().toStyleValue(propertyValue); -} - - (void)setTextTransform:(MGLStyleValue *)textTransform { MGLAssertStyleLayerIsValid(); -- cgit v1.2.1