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 /platform/macos | |
parent | 0a8858f2da4f637fbf8ae7d3f5ffe4640d3e0c80 (diff) | |
download | qtlocation-mapboxgl-4a0173bbd79f90a543dc51ebf15c20a3d30a8827.tar.gz |
[ios, macos] Deprecate -[MGLMapViewDelegate mapView:alphaForShapeAnnotation:] (#6706)
Diffstat (limited to 'platform/macos')
-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 |
4 files changed, 21 insertions, 13 deletions
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. |