summaryrefslogtreecommitdiff
path: root/platform/darwin/scripts/generate-style-code.js
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2017-01-08 17:10:44 -0800
committerMinh Nguyễn <mxn@1ec5.org>2017-01-09 01:38:20 -0800
commite0f98704061f6e1b3b078da468baea37851391b5 (patch)
tree421404274580ebf71e186780068b62f40953fec6 /platform/darwin/scripts/generate-style-code.js
parenta5e43f027297f8f5b83304a02354c2d3f75d0bc7 (diff)
downloadqtlocation-mapboxgl-e0f98704061f6e1b3b078da468baea37851391b5.tar.gz
[macos] Flip offsets and translations
The screen origin is at the lower-left, so offsets and translations increase rightwards and upwards, in contrast to iOS and Web contexts, where the coordinate system increases rightwards and downwards. Duplicated style layer property declarations to reflect this difference.
Diffstat (limited to 'platform/darwin/scripts/generate-style-code.js')
-rw-r--r--platform/darwin/scripts/generate-style-code.js13
1 files changed, 12 insertions, 1 deletions
diff --git a/platform/darwin/scripts/generate-style-code.js b/platform/darwin/scripts/generate-style-code.js
index a5fff0322d..418153591a 100644
--- a/platform/darwin/scripts/generate-style-code.js
+++ b/platform/darwin/scripts/generate-style-code.js
@@ -273,7 +273,7 @@ global.describeValue = function (value, property, layerType) {
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`;
case 'offset':
case 'translate':
- return 'an `NSValue` object containing a `CGVector` struct set to' + ` ${value[0]}${units} from the left and ${value[1]}${units} from the top`;
+ return 'an `NSValue` object containing a `CGVector` struct set to' + ` ${value[0]}${units} rightward and ${value[1]}${units} downward`;
default:
return 'the array `' + value.join('`, `') + '`';
}
@@ -420,6 +420,17 @@ ${iosComment}${decl}
#else
${macosComment}${decl}
#endif`;
+ })
+ // Do the same for CGVector-typed properties.
+ .replace(/(\/\*\*(?:\*[^\/]|[^*])*?\bCGVector\b[\s\S]*?\*\/)(\s*.+?;)/g,
+ (match, comment, decl) => {
+ let macosComment = comment.replace(/\bdownward\b/g, 'upward');
+ return `\
+#if TARGET_OS_IPHONE
+${comment}${decl}
+#else
+${macosComment}${decl}
+#endif`;
});
}