summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2017-01-08 17:30:09 -0800
committerMinh Nguyễn <mxn@1ec5.org>2017-01-09 01:38:20 -0800
commita4c44c51585fe1df8e8b38bf5b7b6a611b4ce986 (patch)
treebcf9d28429b7a8ae80a2b074fb7fdf7a80038a8e
parente0f98704061f6e1b3b078da468baea37851391b5 (diff)
downloadqtlocation-mapboxgl-a4c44c51585fe1df8e8b38bf5b7b6a611b4ce986.tar.gz
[ios, macos] Cleaned up color, edge insets declarations, comments
Eliminated references to MGLColor within style layer headers.
-rw-r--r--platform/darwin/scripts/generate-style-code.js36
-rw-r--r--platform/darwin/src/MGLBackgroundStyleLayer.h4
-rw-r--r--platform/darwin/src/MGLCircleStyleLayer.h4
-rw-r--r--platform/darwin/src/MGLFillStyleLayer.h17
-rw-r--r--platform/darwin/src/MGLLineStyleLayer.h4
-rw-r--r--platform/darwin/src/MGLSymbolStyleLayer.h38
6 files changed, 67 insertions, 36 deletions
diff --git a/platform/darwin/scripts/generate-style-code.js b/platform/darwin/scripts/generate-style-code.js
index 418153591a..ab3d8e1916 100644
--- a/platform/darwin/scripts/generate-style-code.js
+++ b/platform/darwin/scripts/generate-style-code.js
@@ -251,15 +251,15 @@ global.describeValue = function (value, property, layerType) {
throw new Error(`unrecognized color format in default value of ${property.name}`);
}
if (color.r === 0 && color.g === 0 && color.b === 0 && color.a === 0) {
- return '`MGLColor.clearColor`';
+ return '`UIColor.clearColor`';
}
if (color.r === 0 && color.g === 0 && color.b === 0 && color.a === 1) {
- return '`MGLColor.blackColor`';
+ return '`UIColor.blackColor`';
}
if (color.r === 1 && color.g === 1 && color.b === 1 && color.a === 1) {
- return '`MGLColor.whiteColor`';
+ return '`UIColor.whiteColor`';
}
- return 'an `MGLColor`' + ` object whose RGB value is ${color.r}, ${color.g}, ${color.b} and whose alpha value is ${color.a}`;
+ return 'a `UIColor`' + ` object whose RGB value is ${color.r}, ${color.g}, ${color.b} and whose alpha value is ${color.a}`;
case 'array':
let units = property.units || '';
if (units) {
@@ -268,9 +268,9 @@ global.describeValue = function (value, property, layerType) {
switch (arrayType(property)) {
case 'padding':
if (value[0] === 0 && value[1] === 0 && value[2] === 0 && value[3] === 0) {
- return 'an `NSValue` object containing `NSEdgeInsetsZero` or `UIEdgeInsetsZero`';
+ return 'an `NSValue` object containing `UIEdgeInsetsZero`';
}
- return 'an `NSValue` object containing an `NSEdgeInsets` or `UIEdgeInsets` struct set to' + ` ${value[0]}${units} on the top, ${value[3]}${units} on the left, ${value[2]}${units} on the bottom, and ${value[1]}${units} on the right`;
+ return 'an `NSValue` object containing a `UIEdgeInsets` struct set to' + ` ${value[0]}${units} on the top, ${value[3]}${units} on the left, ${value[2]}${units} on the bottom, and ${value[1]}${units} on the right`;
case 'offset':
case 'translate':
return 'an `NSValue` object containing a `CGVector` struct set to' + ` ${value[0]}${units} rightward and ${value[1]}${units} downward`;
@@ -405,26 +405,28 @@ const layers = _(spec.layer.type.values).map((value, layerType) => {
}).sortBy(['type']).value();
function duplicatePlatformDecls(src) {
- // Look for a documentation comment that contains “MGLColor” and the
- // subsequent function, method, or property declaration. Try not to match
- // greedily.
- return src.replace(/(\/\*\*(?:\*[^\/]|[^*])*?\bMGLColor\b[\s\S]*?\*\/)(\s*.+?;)/g,
+ // Look for a documentation comment that contains “MGLColor” or “UIColor”
+ // and the subsequent function, method, or property declaration. Try not to
+ // match greedily.
+ return src.replace(/(\/\*\*(?:\*[^\/]|[^*])*?\*\/)(\s*[^;]+?\b(?:MGL|NS|UI)(?:Color|EdgeInsets(?:Zero)?)\b[^;]+?;)/g,
(match, comment, decl) => {
- let iosComment = comment.replace(/\bMGLColor\b/g, 'UIColor')
+ let macosComment = comment.replace(/\b(?:MGL|UI)(Color|EdgeInsets(?:Zero)?)\b/g, 'NS$1')
// Use the correct indefinite article.
- .replace(/\b(a)n(\s+`?UIColor)\b/gi, '$1$2');
- let macosComment = comment.replace(/\bMGLColor\b/g, 'NSColor');
+ .replace(/\ba(\s+`?NS(?:Color|EdgeInsets))\b/gi, 'an$1');
+ let iosDecl = decl.replace(/\bMGL(Color|EdgeInsets)\b/g, 'UI$1');
+ let macosDecl = decl.replace(/\b(?:MGL|UI)(Color|EdgeInsets)\b/g, 'NS$1');
return `\
#if TARGET_OS_IPHONE
-${iosComment}${decl}
+${comment}${iosDecl}
#else
-${macosComment}${decl}
+${macosComment}${macosDecl}
#endif`;
})
// Do the same for CGVector-typed properties.
- .replace(/(\/\*\*(?:\*[^\/]|[^*])*?\bCGVector\b[\s\S]*?\*\/)(\s*.+?;)/g,
+ .replace(/(\/\*\*(?:\*[^\/]|[^*])*?\b(?:CGVector|UIEdgeInsets(?:Zero)?)\b[\s\S]*?\*\/)(\s*.+?;)/g,
(match, comment, decl) => {
- let macosComment = comment.replace(/\bdownward\b/g, 'upward');
+ let macosComment = comment.replace(/\bdownward\b/g, 'upward')
+ .replace(/\bUI(EdgeInsets(?:Zero)?)\b/g, 'NS$1');
return `\
#if TARGET_OS_IPHONE
${comment}${decl}
diff --git a/platform/darwin/src/MGLBackgroundStyleLayer.h b/platform/darwin/src/MGLBackgroundStyleLayer.h
index bcaf21a8d4..ed797c9f0a 100644
--- a/platform/darwin/src/MGLBackgroundStyleLayer.h
+++ b/platform/darwin/src/MGLBackgroundStyleLayer.h
@@ -37,7 +37,7 @@ NS_ASSUME_NONNULL_BEGIN
This property is only applied to the style if `backgroundPattern` is set to
`nil`. Otherwise, it is ignored.
*/
-@property (nonatomic, null_resettable) MGLStyleValue<MGLColor *> *backgroundColor;
+@property (nonatomic, null_resettable) MGLStyleValue<UIColor *> *backgroundColor;
#else
/**
The color with which the background will be drawn.
@@ -49,7 +49,7 @@ NS_ASSUME_NONNULL_BEGIN
This property is only applied to the style if `backgroundPattern` is set to
`nil`. Otherwise, it is ignored.
*/
-@property (nonatomic, null_resettable) MGLStyleValue<MGLColor *> *backgroundColor;
+@property (nonatomic, null_resettable) MGLStyleValue<NSColor *> *backgroundColor;
#endif
/**
diff --git a/platform/darwin/src/MGLCircleStyleLayer.h b/platform/darwin/src/MGLCircleStyleLayer.h
index 7d1da0ca68..186dfd23f6 100644
--- a/platform/darwin/src/MGLCircleStyleLayer.h
+++ b/platform/darwin/src/MGLCircleStyleLayer.h
@@ -97,7 +97,7 @@ typedef NS_ENUM(NSUInteger, MGLCircleTranslationAnchor) {
`UIColor.blackColor`. Set this property to `nil` to reset it to the default
value.
*/
-@property (nonatomic, null_resettable) MGLStyleValue<MGLColor *> *circleColor;
+@property (nonatomic, null_resettable) MGLStyleValue<UIColor *> *circleColor;
#else
/**
The fill color of the circle.
@@ -106,7 +106,7 @@ typedef NS_ENUM(NSUInteger, MGLCircleTranslationAnchor) {
`NSColor.blackColor`. Set this property to `nil` to reset it to the default
value.
*/
-@property (nonatomic, null_resettable) MGLStyleValue<MGLColor *> *circleColor;
+@property (nonatomic, null_resettable) MGLStyleValue<NSColor *> *circleColor;
#endif
/**
diff --git a/platform/darwin/src/MGLFillStyleLayer.h b/platform/darwin/src/MGLFillStyleLayer.h
index 16e1673a44..6fae42cefe 100644
--- a/platform/darwin/src/MGLFillStyleLayer.h
+++ b/platform/darwin/src/MGLFillStyleLayer.h
@@ -78,7 +78,7 @@ typedef NS_ENUM(NSUInteger, MGLFillTranslationAnchor) {
This property is only applied to the style if `fillPattern` is set to `nil`.
Otherwise, it is ignored.
*/
-@property (nonatomic, null_resettable) MGLStyleValue<MGLColor *> *fillColor;
+@property (nonatomic, null_resettable) MGLStyleValue<UIColor *> *fillColor;
#else
/**
The color of the filled part of this layer.
@@ -90,7 +90,7 @@ typedef NS_ENUM(NSUInteger, MGLFillTranslationAnchor) {
This property is only applied to the style if `fillPattern` is set to `nil`.
Otherwise, it is ignored.
*/
-@property (nonatomic, null_resettable) MGLStyleValue<MGLColor *> *fillColor;
+@property (nonatomic, null_resettable) MGLStyleValue<NSColor *> *fillColor;
#endif
/**
@@ -103,6 +103,16 @@ typedef NS_ENUM(NSUInteger, MGLFillTranslationAnchor) {
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *fillOpacity;
+#if TARGET_OS_IPHONE
+/**
+ The outline color of the fill. Matches the value of `fillColor` if unspecified.
+
+ This property is only applied to the style if `fillPattern` is set to `nil`,
+ and `fillAntialiased` is set to an `MGLStyleValue` object containing an
+ `NSNumber` object containing `YES`. Otherwise, it is ignored.
+ */
+@property (nonatomic, null_resettable) MGLStyleValue<UIColor *> *fillOutlineColor;
+#else
/**
The outline color of the fill. Matches the value of `fillColor` if unspecified.
@@ -110,7 +120,8 @@ typedef NS_ENUM(NSUInteger, MGLFillTranslationAnchor) {
and `fillAntialiased` is set to an `MGLStyleValue` object containing an
`NSNumber` object containing `YES`. Otherwise, it is ignored.
*/
-@property (nonatomic, null_resettable) MGLStyleValue<MGLColor *> *fillOutlineColor;
+@property (nonatomic, null_resettable) MGLStyleValue<NSColor *> *fillOutlineColor;
+#endif
/**
Name of image in sprite to use for drawing image fills. For seamless patterns,
diff --git a/platform/darwin/src/MGLLineStyleLayer.h b/platform/darwin/src/MGLLineStyleLayer.h
index 99bbaab52d..a9f1b4c866 100644
--- a/platform/darwin/src/MGLLineStyleLayer.h
+++ b/platform/darwin/src/MGLLineStyleLayer.h
@@ -175,7 +175,7 @@ typedef NS_ENUM(NSUInteger, MGLLineTranslationAnchor) {
This property is only applied to the style if `linePattern` is set to `nil`.
Otherwise, it is ignored.
*/
-@property (nonatomic, null_resettable) MGLStyleValue<MGLColor *> *lineColor;
+@property (nonatomic, null_resettable) MGLStyleValue<UIColor *> *lineColor;
#else
/**
The color with which the line will be drawn.
@@ -187,7 +187,7 @@ typedef NS_ENUM(NSUInteger, MGLLineTranslationAnchor) {
This property is only applied to the style if `linePattern` is set to `nil`.
Otherwise, it is ignored.
*/
-@property (nonatomic, null_resettable) MGLStyleValue<MGLColor *> *lineColor;
+@property (nonatomic, null_resettable) MGLStyleValue<NSColor *> *lineColor;
#endif
/**
diff --git a/platform/darwin/src/MGLSymbolStyleLayer.h b/platform/darwin/src/MGLSymbolStyleLayer.h
index 5943f2327e..690624c85a 100644
--- a/platform/darwin/src/MGLSymbolStyleLayer.h
+++ b/platform/darwin/src/MGLSymbolStyleLayer.h
@@ -450,14 +450,31 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslationAnchor) {
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *iconTextFit;
+#if TARGET_OS_IPHONE
+/**
+ Size of the additional area added to dimensions determined by `iconTextFit`.
+
+ This property is measured in points.
+
+ The default value of this property is an `MGLStyleValue` object containing an
+ `NSValue` object containing `UIEdgeInsetsZero`. Set this property to `nil` to
+ reset it to the default value.
+
+ This property is only applied to the style if `iconImageName` is non-`nil`, and
+ `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.
+ */
+@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *iconTextFitPadding;
+#else
/**
Size of the additional area added to dimensions determined by `iconTextFit`.
This property is measured in points.
The default value of this property is an `MGLStyleValue` object containing an
- `NSValue` object containing `NSEdgeInsetsZero` or `UIEdgeInsetsZero`. Set this
- property to `nil` to reset it to the default value.
+ `NSValue` object containing `NSEdgeInsetsZero`. Set this property to `nil` to
+ reset it to the default value.
This property is only applied to the style if `iconImageName` is non-`nil`, and
`text` is non-`nil`, and `iconTextFit` is set to an `MGLStyleValue` object
@@ -465,6 +482,7 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslationAnchor) {
`MGLIconTextFitWidth`, or `MGLIconTextFitHeight`. Otherwise, it is ignored.
*/
@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *iconTextFitPadding;
+#endif
/**
If true, the icon may be flipped to prevent it from being rendered upside-down.
@@ -891,7 +909,7 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslationAnchor) {
This property is only applied to the style if `iconImageName` is non-`nil`.
Otherwise, it is ignored.
*/
-@property (nonatomic, null_resettable) MGLStyleValue<MGLColor *> *iconColor;
+@property (nonatomic, null_resettable) MGLStyleValue<UIColor *> *iconColor;
#else
/**
The tint color to apply to the icon. The `iconImageName` property must be set
@@ -904,7 +922,7 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslationAnchor) {
This property is only applied to the style if `iconImageName` is non-`nil`.
Otherwise, it is ignored.
*/
-@property (nonatomic, null_resettable) MGLStyleValue<MGLColor *> *iconColor;
+@property (nonatomic, null_resettable) MGLStyleValue<NSColor *> *iconColor;
#endif
/**
@@ -933,7 +951,7 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslationAnchor) {
This property is only applied to the style if `iconImageName` is non-`nil`.
Otherwise, it is ignored.
*/
-@property (nonatomic, null_resettable) MGLStyleValue<MGLColor *> *iconHaloColor;
+@property (nonatomic, null_resettable) MGLStyleValue<UIColor *> *iconHaloColor;
#else
/**
The color of the icon’s halo. The `iconImageName` property must be set to a
@@ -946,7 +964,7 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslationAnchor) {
This property is only applied to the style if `iconImageName` is non-`nil`.
Otherwise, it is ignored.
*/
-@property (nonatomic, null_resettable) MGLStyleValue<MGLColor *> *iconHaloColor;
+@property (nonatomic, null_resettable) MGLStyleValue<NSColor *> *iconHaloColor;
#endif
/**
@@ -1044,7 +1062,7 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslationAnchor) {
This property is only applied to the style if `text` is non-`nil`. Otherwise,
it is ignored.
*/
-@property (nonatomic, null_resettable) MGLStyleValue<MGLColor *> *textColor;
+@property (nonatomic, null_resettable) MGLStyleValue<UIColor *> *textColor;
#else
/**
The color with which the text will be drawn.
@@ -1056,7 +1074,7 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslationAnchor) {
This property is only applied to the style if `text` is non-`nil`. Otherwise,
it is ignored.
*/
-@property (nonatomic, null_resettable) MGLStyleValue<MGLColor *> *textColor;
+@property (nonatomic, null_resettable) MGLStyleValue<NSColor *> *textColor;
#endif
/**
@@ -1084,7 +1102,7 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslationAnchor) {
This property is only applied to the style if `text` is non-`nil`. Otherwise,
it is ignored.
*/
-@property (nonatomic, null_resettable) MGLStyleValue<MGLColor *> *textHaloColor;
+@property (nonatomic, null_resettable) MGLStyleValue<UIColor *> *textHaloColor;
#else
/**
The color of the text's halo, which helps it stand out from backgrounds.
@@ -1096,7 +1114,7 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslationAnchor) {
This property is only applied to the style if `text` is non-`nil`. Otherwise,
it is ignored.
*/
-@property (nonatomic, null_resettable) MGLStyleValue<MGLColor *> *textHaloColor;
+@property (nonatomic, null_resettable) MGLStyleValue<NSColor *> *textHaloColor;
#endif
/**