From ea57be5598826a14991e2ac17a826186c2d9ce0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Wed, 2 Dec 2015 16:05:41 -0800 Subject: [osx] Documentation comments for public classes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added documentation comments for all the public headers that aren’t being shared with iOS. Removed an animated: parameter from -selectAnnotation: and -deselectAnnotation:: because callout popovers may extend beyond the entire window, there is no need to scroll the map to make the entire callout visible. Added missing geometric conversion methods. Renamed -mapView:regionWillChangeAnimated: et al. to say “camera” instead of “region”. “Region” leaves ambiguity about whether properties like rotation and pitch trigger this method. “Camera” associates these methods with the camera property, which seems apt. --- platform/darwin/MGLGeometry.m | 3 --- platform/darwin/MGLGeometry.mm | 21 +++++++++++++++++++++ platform/darwin/MGLGeometry_Private.h | 15 +++++++++++---- 3 files changed, 32 insertions(+), 7 deletions(-) delete mode 100644 platform/darwin/MGLGeometry.m create mode 100644 platform/darwin/MGLGeometry.mm (limited to 'platform/darwin') diff --git a/platform/darwin/MGLGeometry.m b/platform/darwin/MGLGeometry.m deleted file mode 100644 index 9eab5565fa..0000000000 --- a/platform/darwin/MGLGeometry.m +++ /dev/null @@ -1,3 +0,0 @@ -#import "MGLGeometry.h" - -const MGLCoordinateSpan MGLCoordinateSpanZero = {0, 0}; diff --git a/platform/darwin/MGLGeometry.mm b/platform/darwin/MGLGeometry.mm new file mode 100644 index 0000000000..b80203d142 --- /dev/null +++ b/platform/darwin/MGLGeometry.mm @@ -0,0 +1,21 @@ +#import "MGLGeometry_Private.h" + +const MGLCoordinateSpan MGLCoordinateSpanZero = {0, 0}; + +CGRect MGLExtendRect(CGRect rect, CGPoint point) { + if (point.x < rect.origin.x) { + rect.size.width += rect.origin.x - point.x; + rect.origin.x = point.x; + } + if (point.x > rect.origin.x + rect.size.width) { + rect.size.width += point.x - (rect.origin.x + rect.size.width); + } + if (point.y < rect.origin.y) { + rect.size.height += rect.origin.y - point.y; + rect.origin.y = point.y; + } + if (point.y > rect.origin.y + rect.size.height) { + rect.size.height += point.y - (rect.origin.y + rect.size.height); + } + return rect; +} diff --git a/platform/darwin/MGLGeometry_Private.h b/platform/darwin/MGLGeometry_Private.h index 08d1ad3695..49a306701d 100644 --- a/platform/darwin/MGLGeometry_Private.h +++ b/platform/darwin/MGLGeometry_Private.h @@ -1,10 +1,17 @@ #import "MGLGeometry.h" #import +#if TARGET_OS_IPHONE + #import +#endif #import #import +/// Returns the smallest rectangle that contains both the given rectangle and +/// the given point. +CGRect MGLExtendRect(CGRect rect, CGPoint point); + NS_INLINE mbgl::LatLng MGLLatLngFromLocationCoordinate2D(CLLocationCoordinate2D coordinate) { return mbgl::LatLng(coordinate.latitude, coordinate.longitude); } @@ -28,12 +35,12 @@ NS_INLINE BOOL MGLCoordinateInCoordinateBounds(CLLocationCoordinate2D coordinate return bounds.contains(MGLLatLngFromLocationCoordinate2D(coordinate)); } -#if TARGET_OS_MAC -NS_INLINE mbgl::EdgeInsets MGLEdgeInsetsFromNSEdgeInsets(NSEdgeInsets insets) { +#if TARGET_OS_IPHONE +NS_INLINE mbgl::EdgeInsets MGLEdgeInsetsFromNSEdgeInsets(UIEdgeInsets insets) { return { insets.top, insets.left, insets.bottom, insets.right }; } -#elif TARGET_OS_IOS -NS_INLINE mbgl::EdgeInsets MGLEdgeInsetsFromNSEdgeInsets(UIEdgeInsets insets) { +#else +NS_INLINE mbgl::EdgeInsets MGLEdgeInsetsFromNSEdgeInsets(NSEdgeInsets insets) { return { insets.top, insets.left, insets.bottom, insets.right }; } #endif -- cgit v1.2.1