diff options
author | Jason Wray <friedbunny@users.noreply.github.com> | 2016-10-14 19:50:21 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-14 19:50:21 -0400 |
commit | 4a0173bbd79f90a543dc51ebf15c20a3d30a8827 (patch) | |
tree | e18746ee592dae0caf1c1c18f9e0742fd6eff500 | |
parent | 0a8858f2da4f637fbf8ae7d3f5ffe4640d3e0c80 (diff) | |
download | qtlocation-mapboxgl-4a0173bbd79f90a543dc51ebf15c20a3d30a8827.tar.gz |
[ios, macos] Deprecate -[MGLMapViewDelegate mapView:alphaForShapeAnnotation:] (#6706)
-rw-r--r-- | platform/ios/CHANGELOG.md | 1 | ||||
-rw-r--r-- | platform/ios/app/MBXViewController.m | 8 | ||||
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 14 | ||||
-rw-r--r-- | platform/ios/src/MGLMapViewDelegate.h | 18 | ||||
-rw-r--r-- | platform/macos/CHANGELOG.md | 1 | ||||
-rw-r--r-- | platform/macos/app/MapDocument.m | 5 | ||||
-rw-r--r-- | platform/macos/src/MGLMapView.mm | 10 | ||||
-rw-r--r-- | platform/macos/src/MGLMapViewDelegate.h | 18 |
8 files changed, 45 insertions, 30 deletions
diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index 98d12b723d..a2273a5787 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -51,6 +51,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT * Improved the precision of annotations at zoom levels greater than 18. ([#5517](https://github.com/mapbox/mapbox-gl-native/pull/5517)) * Fixed an issue that could reset user-added transformations on annotation views. ([#6166](https://github.com/mapbox/mapbox-gl-native/pull/6166)) * Fixed an issue that caused an annotation view to disappear if it isn’t created using the annotation view reuse queue. ([#6485](https://github.com/mapbox/mapbox-gl-native/pull/6485)) +* Deprecated `-[MGLMapViewDelegate mapView:alphaForShapeAnnotation:]` in favor of specifying an alpha component via `-[MGLMapViewDelegate mapView:strokeColorForShapeAnnotation:]` or `-[MGLMapViewDelegate mapView:fillColorForPolygonAnnotation:]`. ([#6706](https://github.com/mapbox/mapbox-gl-native/pull/6706)) ### Networking and offline maps diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m index 0f62e65ce1..5a0854f6bf 100644 --- a/platform/ios/app/MBXViewController.m +++ b/platform/ios/app/MBXViewController.m @@ -1123,11 +1123,6 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { return YES; } -- (CGFloat)mapView:(__unused MGLMapView *)mapView alphaForShapeAnnotation:(MGLShape *)annotation -{ - return ([annotation isKindOfClass:[MGLPolygon class]] ? 0.5 : 1.0); -} - - (UIColor *)mapView:(__unused MGLMapView *)mapView strokeColorForShapeAnnotation:(MGLShape *)annotation { return ([annotation isKindOfClass:[MGLPolyline class]] ? [UIColor purpleColor] : [UIColor blackColor]); @@ -1135,7 +1130,8 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { - (UIColor *)mapView:(__unused MGLMapView *)mapView fillColorForPolygonAnnotation:(__unused MGLPolygon *)annotation { - return (annotation.pointCount > 3 ? [UIColor greenColor] : [UIColor redColor]); + UIColor *color = annotation.pointCount > 3 ? [UIColor greenColor] : [UIColor redColor]; + return [color colorWithAlphaComponent:0.5]; } - (void)mapView:(__unused MGLMapView *)mapView didChangeUserTrackingMode:(MGLUserTrackingMode)mode animated:(__unused BOOL)animated diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index d0c95d9c0c..06a7684f38 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -3054,9 +3054,23 @@ public: - (double)alphaForShapeAnnotation:(MGLShape *)annotation { + // The explicit -mapView:alphaForShapeAnnotation: delegate method is deprecated + // but still used, if implemented. When not implemented, call the stroke or + // fill color delegate methods and pull the alpha from the returned color. if (_delegateHasAlphasForShapeAnnotations) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" return [self.delegate mapView:self alphaForShapeAnnotation:annotation]; +#pragma clang diagnostic pop + } + else if ([annotation isKindOfClass:[MGLPolygon class]]) + { + return [self fillColorForPolygonAnnotation:(MGLPolygon *)annotation].a ?: 1.0; + } + else if ([annotation isKindOfClass:[MGLShape class]]) + { + return [self strokeColorForShapeAnnotation:annotation].a ?: 1.0; } return 1.0; } diff --git a/platform/ios/src/MGLMapViewDelegate.h b/platform/ios/src/MGLMapViewDelegate.h index c07c43d3e4..777af4ba63 100644 --- a/platform/ios/src/MGLMapViewDelegate.h +++ b/platform/ios/src/MGLMapViewDelegate.h @@ -228,17 +228,7 @@ NS_ASSUME_NONNULL_BEGIN */ - (nullable MGLAnnotationImage *)mapView:(MGLMapView *)mapView imageForAnnotation:(id <MGLAnnotation>)annotation; -/** - Returns the alpha value to use when rendering a shape annotation. - - A value of `0.0` results in a completely transparent shape. A value of `1.0`, - the default, results in a completely opaque shape. - - @param mapView The map view rendering the shape annotation. - @param annotation The annotation being rendered. - @return An alpha value between `0` and `1.0`. - */ -- (CGFloat)mapView:(MGLMapView *)mapView alphaForShapeAnnotation:(MGLShape *)annotation; +- (CGFloat)mapView:(MGLMapView *)mapView alphaForShapeAnnotation:(MGLShape *)annotation __attribute__((deprecated("Use -mapView:strokeColorForShapeAnnotation: or -mapView:fillColorForPolygonAnnotation:."))); /** Returns the color to use when rendering the outline of a shape annotation. @@ -246,6 +236,9 @@ NS_ASSUME_NONNULL_BEGIN The default stroke color is the map view’s tint color. If a pattern color is specified, the result is undefined. + Opacity may be set by specifying an alpha component. The default alpha value is + `1.0` and results in a completely opaque stroke. + @param mapView The map view rendering the shape annotation. @param annotation The annotation being rendered. @return A color to use for the shape outline. @@ -258,6 +251,9 @@ NS_ASSUME_NONNULL_BEGIN The default fill color is the map view’s tint color. If a pattern color is specified, the result is undefined. + Opacity may be set by specifying an alpha component. The default alpha value is + `1.0` and results in a completely opaque shape. + @param mapView The map view rendering the polygon annotation. @param annotation The annotation being rendered. @return The polygon’s interior fill color. diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md index 9e5b861e82..5049a3aae8 100644 --- a/platform/macos/CHANGELOG.md +++ b/platform/macos/CHANGELOG.md @@ -30,6 +30,7 @@ * Database errors are now logged to the console. ([#6291](https://github.com/mapbox/mapbox-gl-native/pull/6291)) * Improved style parsing performance. ([#6170](https://github.com/mapbox/mapbox-gl-native/pull/6170)) * Fixed a typo in the documentation for the MGLCompassDirectionFormatter class. ([#5879](https://github.com/mapbox/mapbox-gl-native/pull/5879)) +* Deprecated `-[MGLMapViewDelegate mapView:alphaForShapeAnnotation:]` in favor of specifying an alpha component via `-[MGLMapViewDelegate mapView:strokeColorForShapeAnnotation:]` or `-[MGLMapViewDelegate mapView:fillColorForPolygonAnnotation:]`. ([#6706](https://github.com/mapbox/mapbox-gl-native/pull/6706)) ## 0.2.1 - July 19, 2016 diff --git a/platform/macos/app/MapDocument.m b/platform/macos/app/MapDocument.m index 9c3abc1a1e..505678fcc2 100644 --- a/platform/macos/app/MapDocument.m +++ b/platform/macos/app/MapDocument.m @@ -826,8 +826,9 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio } } -- (CGFloat)mapView:(MGLMapView *)mapView alphaForShapeAnnotation:(MGLShape *)annotation { - return 0.8; +- (NSColor *)mapView:(MGLMapView *)mapView fillColorForPolygonAnnotation:(MGLPolygon *)annotation { + NSColor *color = [[NSColor selectedMenuItemColor] colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; + return [color colorWithAlphaComponent:0.8]; } @end diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm index 2031173509..bd03af509d 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -2163,8 +2163,18 @@ public: #pragma mark MGLMultiPointDelegate methods - (double)alphaForShapeAnnotation:(MGLShape *)annotation { + // The explicit -mapView:alphaForShapeAnnotation: delegate method is deprecated + // but still used, if implemented. When not implemented, call the stroke or + // fill color delegate methods and pull the alpha from the returned color. if (_delegateHasAlphasForShapeAnnotations) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" return [self.delegate mapView:self alphaForShapeAnnotation:annotation]; +#pragma clang diagnostic pop + } else if ([annotation isKindOfClass:[MGLPolygon class]]) { + return [self fillColorForPolygonAnnotation:(MGLPolygon *)annotation].a ?: 1.0; + } else if ([annotation isKindOfClass:[MGLShape class]]) { + return [self strokeColorForShapeAnnotation:annotation].a ?: 1.0; } return 1.0; } diff --git a/platform/macos/src/MGLMapViewDelegate.h b/platform/macos/src/MGLMapViewDelegate.h index c946624f11..c5af93f8ad 100644 --- a/platform/macos/src/MGLMapViewDelegate.h +++ b/platform/macos/src/MGLMapViewDelegate.h @@ -156,17 +156,7 @@ NS_ASSUME_NONNULL_BEGIN */ - (nullable MGLAnnotationImage *)mapView:(MGLMapView *)mapView imageForAnnotation:(id <MGLAnnotation>)annotation; -/** - Returns the alpha value to use when rendering a shape annotation. - - A value of 0.0 results in a completely transparent shape. A value of 1.0, the - default, results in a completely opaque shape. - - @param mapView The map view rendering the shape annotation. - @param annotation The annotation being rendered. - @return An alpha value between 0 and 1.0. - */ -- (CGFloat)mapView:(MGLMapView *)mapView alphaForShapeAnnotation:(MGLShape *)annotation; +- (CGFloat)mapView:(MGLMapView *)mapView alphaForShapeAnnotation:(MGLShape *)annotation __attribute__((deprecated("Use -mapView:strokeColorForShapeAnnotation: or -mapView:fillColorForPolygonAnnotation:."))); /** Returns the color to use when rendering the outline of a shape annotation. @@ -174,6 +164,9 @@ NS_ASSUME_NONNULL_BEGIN The default stroke color is the selected menu item color. If a pattern color is specified, the result is undefined. + Opacity may be set by specifying an alpha component. The default alpha value is + `1.0` and results in a completely opaque stroke. + @param mapView The map view rendering the shape annotation. @param annotation The annotation being rendered. @return A color to use for the shape outline. @@ -186,6 +179,9 @@ NS_ASSUME_NONNULL_BEGIN The default fill color is the selected menu item color. If a pattern color is specified, the result is undefined. + Opacity may be set by specifying an alpha component. The default alpha value is + `1.0` and results in a completely opaque shape. + @param mapView The map view rendering the polygon annotation. @param annotation The annotation being rendered. @return The polygon’s interior fill color. |