Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[ios] Fix content insets with custom edge padding. #14813

Merged
merged 5 commits into from Jun 3, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 15 additions & 5 deletions platform/darwin/src/MGLGeometry_Private.h
Expand Up @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions 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"
Expand Down
4 changes: 1 addition & 3 deletions 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 <UIKit/UIKit.h>
#define MGLEdgeInsets UIEdgeInsets
#else
#define MGLEdgeInsets NSEdgeInsets
#endif

@implementation NSValue (MGLStyleAttributeAdditions)
Expand Down
4 changes: 4 additions & 0 deletions platform/ios/CHANGELOG.md
Expand Up @@ -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).
Expand Down
4 changes: 3 additions & 1 deletion platform/ios/src/MGLMapView.mm
Expand Up @@ -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 {
Expand All @@ -3568,6 +3568,8 @@ - (void)setCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration a
}

MGLLogDebug(@"Setting camera: %@ duration: %f animationTimingFunction: %@ edgePadding: %@ completionHandler: %@", camera, duration, function, NSStringFromUIEdgeInsets(edgePadding), completion);

edgePadding = MGLEdgeInsetsInsetEdgeInset(edgePadding, self.contentInset);

mbgl::AnimationOptions animationOptions;
if (duration > 0)
Expand Down
4 changes: 4 additions & 0 deletions platform/macos/CHANGELOG.md
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion platform/macos/src/MGLMapView.mm
Expand Up @@ -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));
Expand Down