[ios, macos] Revert deprecation of alphaForShapeAnnotation: delegate method

This commit is contained in:
Jason Wray
2017-01-12 21:37:21 -05:00
parent 4d5036616f
commit 8f6009ea20
8 changed files with 41 additions and 32 deletions

View File

@@ -58,7 +58,6 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT
* Fixed an issue causing the callout view to be dismissed when panning around. ([#6676](https://github.com/mapbox/mapbox-gl-native/pull/6676))
* Per documentation, the first and last coordinates in an MGLPolygon must be identical in order for the polygon to draw correctly. The same is true for an MGLPolygon’s interior polygon. ([#5514](https://github.com/mapbox/mapbox-gl-native/pull/5514))
* To make an MGLPolyline or MGLPolygon span the antimeridian, specify coordinates with longitudes greater than 180° or less than −180°. ([#6088](https://github.com/mapbox/mapbox-gl-native/pull/6088))
* 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))
* Various method arguments that are represented as C arrays of `CLLocationCoordinate2D` instances have been marked `const` to streamline bridging to Swift. ([#7215](https://github.com/mapbox/mapbox-gl-native/pull/7215))
* 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))
* Fixed an issue that could reset user-added transformations on annotation views. ([#6166](https://github.com/mapbox/mapbox-gl-native/pull/6166))

View File

@@ -1554,9 +1554,15 @@ 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]);
UIColor *color = [annotation isKindOfClass:[MGLPolyline class]] ? [UIColor greenColor] : [UIColor blackColor];
return [color colorWithAlphaComponent:0.9];
}
- (UIColor *)mapView:(__unused MGLMapView *)mapView fillColorForPolygonAnnotation:(__unused MGLPolygon *)annotation

View File

@@ -3132,23 +3132,9 @@ 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;
}

View File

@@ -228,7 +228,22 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (nullable MGLAnnotationImage *)mapView:(MGLMapView *)mapView imageForAnnotation:(id <MGLAnnotation>)annotation;
- (CGFloat)mapView:(MGLMapView *)mapView alphaForShapeAnnotation:(MGLShape *)annotation __attribute__((deprecated("Use -mapView:strokeColorForShapeAnnotation: or -mapView:fillColorForPolygonAnnotation:.")));
/**
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.
This method sets the opacity of an entire shape, inclusive of its stroke and
fill. To independently set the values for stroke or fill, specify an alpha
component in the color returned by `-mapView:strokeColorForShapeAnnotation:` or
`-mapView:fillColorForPolygonAnnotation:`.
@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;
/**
Returns the color to use when rendering the outline of a shape annotation.

View File

@@ -38,7 +38,6 @@ This version of the Mapbox macOS SDK corresponds to version 3.4.0 of the Mapbox
* Added `showAnnotations:animated:` and `showAnnotations:edgePadding:animated:`, which moves the map viewport to show the specified annotations. ([#5749](https://github.com/mapbox/mapbox-gl-native/pull/5749))
* Added new methods to MGLMultiPoint for changing the vertices along a polyline annotation or the exterior of a polygon annotation. ([#6565](https://github.com/mapbox/mapbox-gl-native/pull/6565))
* Added new APIs to MGLMapView to query for visible annotations. ([6061](https://github.com/mapbox/mapbox-gl-native/pull/6061))
* 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))
* Shape, feature, and annotation classes now conform to NSSecureCoding. ([#6559](https://github.com/mapbox/mapbox-gl-native/pull/6559))
* Various method arguments that are represented as C arrays of `CLLocationCoordinate2D` instances have been marked `const` to streamline bridging to Swift. ([#7215](https://github.com/mapbox/mapbox-gl-native/pull/7215))
* To make an MGLPolyline or MGLPolygon span the antimeridian, specify coordinates with longitudes greater than 180° or less than −180°. ([#6088](https://github.com/mapbox/mapbox-gl-native/pull/6088))

View File

@@ -1088,9 +1088,8 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio
}
}
- (NSColor *)mapView:(MGLMapView *)mapView fillColorForPolygonAnnotation:(MGLPolygon *)annotation {
NSColor *color = [[NSColor selectedMenuItemColor] colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
return [color colorWithAlphaComponent:0.8];
- (CGFloat)mapView:(MGLMapView *)mapView alphaForShapeAnnotation:(MGLShape *)annotation {
return 0.8;
}
@end

View File

@@ -2273,18 +2273,8 @@ 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;
}

View File

@@ -156,7 +156,22 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (nullable MGLAnnotationImage *)mapView:(MGLMapView *)mapView imageForAnnotation:(id <MGLAnnotation>)annotation;
- (CGFloat)mapView:(MGLMapView *)mapView alphaForShapeAnnotation:(MGLShape *)annotation __attribute__((deprecated("Use -mapView:strokeColorForShapeAnnotation: or -mapView:fillColorForPolygonAnnotation:.")));
/**
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.
This method sets the opacity of an entire shape, inclusive of its stroke and
fill. To independently set the values for stroke or fill, specify an alpha
component in the color returned by `-mapView:strokeColorForShapeAnnotation:` or
`-mapView:fillColorForPolygonAnnotation:`.
@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;
/**
Returns the color to use when rendering the outline of a shape annotation.