diff options
author | Jesse Bounds <jesse@rebounds.net> | 2016-11-14 16:59:30 -0800 |
---|---|---|
committer | Jesse Bounds <jesse@rebounds.net> | 2016-11-22 19:53:54 -0800 |
commit | 13e0f9e527366dce43f59055fde17818f443e356 (patch) | |
tree | 83b3ca4e2b0f103575c28335ac39fc76b7ec33a5 /platform/darwin/src/MGLBackgroundStyleLayer.mm | |
parent | 4e4e05ef50808a27d7a9a46c830d05165bd85e94 (diff) | |
download | qtlocation-mapboxgl-13e0f9e527366dce43f59055fde17818f443e356.tar.gz |
[ios, macos] Refactor runtime styling enumeration properties
Correctly map SDK runtime styling enumerations to mbgl
equivalents. Also, add category methods to NSValue so enums
can be wrapped up with less of the details of how they
are layed out in memory in Objective-C.
Diffstat (limited to 'platform/darwin/src/MGLBackgroundStyleLayer.mm')
-rw-r--r-- | platform/darwin/src/MGLBackgroundStyleLayer.mm | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/platform/darwin/src/MGLBackgroundStyleLayer.mm b/platform/darwin/src/MGLBackgroundStyleLayer.mm index a4914d3242..386c6322eb 100644 --- a/platform/darwin/src/MGLBackgroundStyleLayer.mm +++ b/platform/darwin/src/MGLBackgroundStyleLayer.mm @@ -10,6 +10,7 @@ #include <mbgl/style/layers/background_layer.hpp> + @interface MGLBackgroundStyleLayer () @property (nonatomic) mbgl::style::BackgroundLayer *rawLayer; @@ -26,13 +27,11 @@ if (self = [super initWithIdentifier:identifier]) { auto layer = std::make_unique<mbgl::style::BackgroundLayer>(identifier.UTF8String); _pendingLayer = std::move(layer); - self.rawLayer = _pendingLayer.get(); + _rawLayer = _pendingLayer.get(); } return self; } - - #pragma mark - Adding to and removing from a map view - (void)addToMapView:(MGLMapView *)mapView @@ -54,38 +53,38 @@ { auto removedLayer = mapView.mbglMap->removeLayer(self.identifier.UTF8String); _pendingLayer = std::move(reinterpret_cast<std::unique_ptr<mbgl::style::BackgroundLayer> &>(removedLayer)); - self.rawLayer = _pendingLayer.get(); + _rawLayer = _pendingLayer.get(); } #pragma mark - Accessing the Paint Attributes - (void)setBackgroundColor:(MGLStyleValue<MGLColor *> *)backgroundColor { auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue(backgroundColor); - self.rawLayer->setBackgroundColor(mbglValue); + _rawLayer->setBackgroundColor(mbglValue); } - (MGLStyleValue<MGLColor *> *)backgroundColor { - auto propertyValue = self.rawLayer->getBackgroundColor() ?: self.rawLayer->getDefaultBackgroundColor(); + auto propertyValue = _rawLayer->getBackgroundColor() ?: _rawLayer->getDefaultBackgroundColor(); return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toStyleValue(propertyValue); } - (void)setBackgroundPattern:(MGLStyleValue<NSString *> *)backgroundPattern { auto mbglValue = MGLStyleValueTransformer<std::string, NSString *>().toPropertyValue(backgroundPattern); - self.rawLayer->setBackgroundPattern(mbglValue); + _rawLayer->setBackgroundPattern(mbglValue); } - (MGLStyleValue<NSString *> *)backgroundPattern { - auto propertyValue = self.rawLayer->getBackgroundPattern() ?: self.rawLayer->getDefaultBackgroundPattern(); + auto propertyValue = _rawLayer->getBackgroundPattern() ?: _rawLayer->getDefaultBackgroundPattern(); return MGLStyleValueTransformer<std::string, NSString *>().toStyleValue(propertyValue); } - (void)setBackgroundOpacity:(MGLStyleValue<NSNumber *> *)backgroundOpacity { auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(backgroundOpacity); - self.rawLayer->setBackgroundOpacity(mbglValue); + _rawLayer->setBackgroundOpacity(mbglValue); } - (MGLStyleValue<NSNumber *> *)backgroundOpacity { - auto propertyValue = self.rawLayer->getBackgroundOpacity() ?: self.rawLayer->getDefaultBackgroundOpacity(); + auto propertyValue = _rawLayer->getBackgroundOpacity() ?: _rawLayer->getDefaultBackgroundOpacity(); return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue); } |