From d7dede2f1b7e5731e41d5975f9bfe2c186122f2c Mon Sep 17 00:00:00 2001 From: Fabian Guerra Date: Fri, 31 May 2019 18:54:42 -0700 Subject: [PATCH 1/5] [ios] Fix content insets with custom edge padding. --- platform/ios/src/MGLMapView.mm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index a304bfddfc6..d11d0a07c6d 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -3554,7 +3554,7 @@ - (void)setCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration a - (void)setCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function completionHandler:(nullable void (^)(void))completion { MGLLogDebug(@"Setting camera: %@ duration: %f animationTimingFunction: %@ completionHandler: %@", camera, duration, function, completion); - [self setCamera:camera withDuration:duration animationTimingFunction:function edgePadding:self.contentInset completionHandler:completion]; + [self setCamera:camera withDuration:duration animationTimingFunction:function edgePadding:UIEdgeInsetsZero completionHandler:completion]; } - (void)setCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function edgePadding:(UIEdgeInsets)edgePadding completionHandler:(nullable void (^)(void))completion { @@ -3568,6 +3568,11 @@ - (void)setCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration a } MGLLogDebug(@"Setting camera: %@ duration: %f animationTimingFunction: %@ edgePadding: %@ completionHandler: %@", camera, duration, function, NSStringFromUIEdgeInsets(edgePadding), completion); + + edgePadding = UIEdgeInsetsMake(edgePadding.top + self.contentInset.top, + edgePadding.left + self.contentInset.left, + edgePadding.bottom + self.contentInset.bottom, + edgePadding.right + self.contentInset.right); mbgl::AnimationOptions animationOptions; if (duration > 0) From 0fa69a86e78a4a47168c33d9cd3df9b5863d5517 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Fri, 31 May 2019 19:31:04 -0700 Subject: [PATCH 2/5] [ios, macos] Consolidated edge insets math --- platform/darwin/src/MGLGeometry_Private.h | 20 ++++++++++++++----- .../darwin/src/NSExpression+MGLAdditions.mm | 3 +-- .../src/NSValue+MGLStyleAttributeAdditions.mm | 4 +--- platform/ios/src/MGLMapView.mm | 5 +---- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/platform/darwin/src/MGLGeometry_Private.h b/platform/darwin/src/MGLGeometry_Private.h index b91d4e0f810..a89a382c5e5 100644 --- a/platform/darwin/src/MGLGeometry_Private.h +++ b/platform/darwin/src/MGLGeometry_Private.h @@ -97,14 +97,24 @@ NS_INLINE BOOL MGLLocationCoordinate2DIsValid(CLLocationCoordinate2D coordinate) } #if TARGET_OS_IPHONE -NS_INLINE mbgl::EdgeInsets MGLEdgeInsetsFromNSEdgeInsets(UIEdgeInsets insets) { - return { insets.top, insets.left, insets.bottom, insets.right }; -} + #define MGLEdgeInsets UIEdgeInsets + #define MGLEdgeInsetsMake UIEdgeInsetsMake #else -NS_INLINE mbgl::EdgeInsets MGLEdgeInsetsFromNSEdgeInsets(NSEdgeInsets insets) { + #define MGLEdgeInsets NSEdgeInsets + #define MGLEdgeInsetsMake NSEdgeInsetsMake +#endif + +NS_INLINE mbgl::EdgeInsets MGLEdgeInsetsFromNSEdgeInsets(MGLEdgeInsets insets) { return { insets.top, insets.left, insets.bottom, insets.right }; } -#endif + +/// Returns the combination of two edge insets. +NS_INLINE MGLEdgeInsets MGLEdgeInsetsInsetEdgeInset(MGLEdgeInsets base, MGLEdgeInsets inset) { + return MGLEdgeInsetsMake(base.top + inset.top, + base.left + inset.left, + base.bottom + inset.bottom, + base.right + inset.right); +} /** Returns MGLRadianCoordinate2D, converted from CLLocationCoordinate2D. */ NS_INLINE MGLRadianCoordinate2D MGLRadianCoordinateFromLocationCoordinate(CLLocationCoordinate2D locationCoordinate) { diff --git a/platform/darwin/src/NSExpression+MGLAdditions.mm b/platform/darwin/src/NSExpression+MGLAdditions.mm index b3060b5787c..2ca4e0ed880 100644 --- a/platform/darwin/src/NSExpression+MGLAdditions.mm +++ b/platform/darwin/src/NSExpression+MGLAdditions.mm @@ -1,13 +1,12 @@ #import "MGLFoundation_Private.h" +#import "MGLGeometry_Private.h" #import "NSExpression+MGLPrivateAdditions.h" #import "MGLTypes.h" #if TARGET_OS_IPHONE #import "UIColor+MGLAdditions.h" - #define MGLEdgeInsets UIEdgeInsets #else #import "NSColor+MGLAdditions.h" - #define MGLEdgeInsets NSEdgeInsets #endif #import "NSPredicate+MGLAdditions.h" #import "NSValue+MGLStyleAttributeAdditions.h" diff --git a/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm b/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm index e2cde278f49..aa3e003d042 100644 --- a/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm +++ b/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm @@ -1,11 +1,9 @@ #import "NSValue+MGLStyleAttributeAdditions.h" #import "MGLLight.h" #import "MGLLoggingConfiguration_Private.h" +#import "MGLGeometry_Private.h" #if TARGET_OS_IPHONE #import - #define MGLEdgeInsets UIEdgeInsets -#else - #define MGLEdgeInsets NSEdgeInsets #endif @implementation NSValue (MGLStyleAttributeAdditions) diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index d11d0a07c6d..e65c3704ab7 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -3569,10 +3569,7 @@ - (void)setCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration a MGLLogDebug(@"Setting camera: %@ duration: %f animationTimingFunction: %@ edgePadding: %@ completionHandler: %@", camera, duration, function, NSStringFromUIEdgeInsets(edgePadding), completion); - edgePadding = UIEdgeInsetsMake(edgePadding.top + self.contentInset.top, - edgePadding.left + self.contentInset.left, - edgePadding.bottom + self.contentInset.bottom, - edgePadding.right + self.contentInset.right); + edgePadding = MGLEdgeInsetsInsetEdgeInset(edgePadding, self.contentInset); mbgl::AnimationOptions animationOptions; if (duration > 0) From 4f34cbbce4f49a85cbd4d79969f1d2af25ea63ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Fri, 31 May 2019 19:35:19 -0700 Subject: [PATCH 3/5] [macos] Add content insets to edge padding when setting camera --- platform/macos/src/MGLMapView.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm index 589a39f0b33..04b895bb507 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -1168,10 +1168,11 @@ - (void)setCamera:(MGLMapCamera *)camera animated:(BOOL)animated { - (void)setCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function completionHandler:(nullable void (^)(void))completion { MGLLogDebug(@"Setting camera: %@ duration: %f animationTimingFunction: %@", camera, duration, function); - [self setCamera:camera withDuration:duration animationTimingFunction:function edgePadding:self.contentInsets completionHandler:completion]; + [self setCamera:camera withDuration:duration animationTimingFunction:function edgePadding:NSEdgeInsetsZero completionHandler:completion]; } - (void)setCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function edgePadding:(NSEdgeInsets)edgePadding completionHandler:(nullable void (^)(void))completion { + edgePadding = MGLEdgeInsetsInsetEdgeInset(edgePadding, self.contentInsets); mbgl::AnimationOptions animationOptions; if (duration > 0) { animationOptions.duration.emplace(MGLDurationFromTimeInterval(duration)); From 711211a0a142dfe7aa0e2761f3f6dfe2f8a75975 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Fri, 31 May 2019 19:37:16 -0700 Subject: [PATCH 4/5] [ios, macos] Updated changelogs --- platform/ios/CHANGELOG.md | 4 ++++ platform/macos/CHANGELOG.md | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index 3ddeb6b3149..045daf4cada 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -8,6 +8,10 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT * Setting `MGLMapView.contentInset` now moves the map’s focal point to the center of the content frame after insetting. ([#14664](https://github.com/mapbox/mapbox-gl-native/pull/14664)) +### Other changes + +* The `-[MGLMapView setCamera:withDuration:animationTimingFunction:edgePadding:completionHandler:]` method now adds the current value of the `MGLMapView.contentInset` property to the `edgePadding` parameter. ([#14813](https://github.com/mapbox/mapbox-gl-native/pull/14813)) + ## 5.0.0 - May 22, 2019 This release improves how monthly active users are counted. By upgrading to this release, you are opting into the changes outlined in [this blog post](https://www.mapbox.com/52219) and [#14421](https://github.com/mapbox/mapbox-gl-native/pull/14421). diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md index e3f1c84547b..520f8c204b3 100644 --- a/platform/macos/CHANGELOG.md +++ b/platform/macos/CHANGELOG.md @@ -6,6 +6,10 @@ * Setting `MGLMapView.contentInset` now moves the map’s focal point to the center of the content frame after insetting. ([#14664](https://github.com/mapbox/mapbox-gl-native/pull/14664)) +### Other changes + +* The `-[MGLMapView setCamera:withDuration:animationTimingFunction:edgePadding:completionHandler:]` method now adds the current value of the `MGLMapView.contentInsets` property to the `edgePadding` parameter. ([#14813](https://github.com/mapbox/mapbox-gl-native/pull/14813)) + ## 0.14.0 - May 22, 2018 ### Styles and rendering From a784164b77351adee3877c027eb635dc39ce7a51 Mon Sep 17 00:00:00 2001 From: Fabian Guerra Date: Sat, 1 Jun 2019 07:48:30 -0700 Subject: [PATCH 5/5] [ios, macos] Clarify setCamera:withDuration:animationTimingFunction:edgePadding method documentation. --- platform/ios/src/MGLMapView.h | 3 ++- platform/macos/src/MGLMapView.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/platform/ios/src/MGLMapView.h b/platform/ios/src/MGLMapView.h index 63bd28fc0c1..3baae2ee3c5 100644 --- a/platform/ios/src/MGLMapView.h +++ b/platform/ios/src/MGLMapView.h @@ -1036,7 +1036,8 @@ MGL_EXPORT /** Moves the viewpoint to a different location with respect to the map with an - optional transition duration and timing function. + optional transition duration and timing function, and optionally some additional + padding on each side. @param camera The new viewpoint. @param duration The amount of time, measured in seconds, that the transition diff --git a/platform/macos/src/MGLMapView.h b/platform/macos/src/MGLMapView.h index ddb57471091..21ae8c29744 100644 --- a/platform/macos/src/MGLMapView.h +++ b/platform/macos/src/MGLMapView.h @@ -325,7 +325,8 @@ MGL_EXPORT IB_DESIGNABLE /** Moves the viewpoint to a different location with respect to the map with an - optional transition duration and timing function. + optional transition duration and timing function, and optionally some additional + padding on each side. @param camera The new viewpoint. @param duration The amount of time, measured in seconds, that the transition