diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2017-01-08 17:10:44 -0800 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2017-01-09 01:38:20 -0800 |
commit | e0f98704061f6e1b3b078da468baea37851391b5 (patch) | |
tree | 421404274580ebf71e186780068b62f40953fec6 /platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm | |
parent | a5e43f027297f8f5b83304a02354c2d3f75d0bc7 (diff) | |
download | qtlocation-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/src/NSValue+MGLStyleAttributeAdditions.mm')
-rw-r--r-- | platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm b/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm index 59afe559d7..e66145aec1 100644 --- a/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm +++ b/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm @@ -12,6 +12,11 @@ + (instancetype)mgl_valueWithOffsetArray:(std::array<float, 2>)offsetArray { CGVector vector = CGVectorMake(offsetArray[0], offsetArray[1]); +#if !TARGET_OS_IPHONE + // Style specification assumes an origin at the upper-left corner. + // macOS defines an origin at the lower-left corner. + vector.dy *= -1; +#endif return [NSValue value:&vector withObjCType:@encode(CGVector)]; } @@ -33,6 +38,9 @@ NSAssert(strcmp(self.objCType, @encode(CGVector)) == 0, @"Value does not represent a CGVector"); CGVector vector; [self getValue:&vector]; +#if !TARGET_OS_IPHONE + vector.dy *= -1; +#endif return { static_cast<float>(vector.dx), static_cast<float>(vector.dy), |