// This file is generated. // Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. #import "MGLSource.h" #import "MGLMapView_Private.h" #import "NSPredicate+MGLAdditions.h" #import "MGLStyleLayer_Private.h" #import "MGLStyleValue_Private.h" #import "MGLBackgroundStyleLayer.h" #include #include @interface MGLBackgroundStyleLayer () @property (nonatomic) mbgl::style::BackgroundLayer *rawLayer; @end @implementation MGLBackgroundStyleLayer { std::unique_ptr _pendingLayer; } - (instancetype)initWithIdentifier:(NSString *)identifier { if (self = [super initWithIdentifier:identifier]) { auto layer = std::make_unique(identifier.UTF8String); _pendingLayer = std::move(layer); self.rawLayer = _pendingLayer.get(); } return self; } - (mbgl::style::BackgroundLayer *)rawLayer { return (mbgl::style::BackgroundLayer *)super.rawLayer; } - (void)setRawLayer:(mbgl::style::BackgroundLayer *)rawLayer { super.rawLayer = rawLayer; } #pragma mark - Adding to and removing from a map view - (void)addToMapView:(MGLMapView *)mapView belowLayer:(MGLStyleLayer *)otherLayer { if (_pendingLayer == nullptr) { [NSException raise:@"MGLRedundantLayerException" format:@"This instance %@ was already added to %@. Adding the same layer instance " \ "to the style more than once is invalid.", self, mapView.style]; } if (otherLayer) { const mbgl::optional belowLayerId{otherLayer.identifier.UTF8String}; mapView.mbglMap->addLayer(std::move(_pendingLayer), belowLayerId); } else { mapView.mbglMap->addLayer(std::move(_pendingLayer)); } } - (void)removeFromMapView:(MGLMapView *)mapView { if (self.rawLayer != mapView.mbglMap->getLayer(self.identifier.UTF8String)) { return; } auto removedLayer = mapView.mbglMap->removeLayer(self.identifier.UTF8String); if (!removedLayer) { return; } mbgl::style::BackgroundLayer *layer = dynamic_cast(removedLayer.get()); if (!layer) { return; } removedLayer.release(); _pendingLayer = std::unique_ptr(layer); self.rawLayer = _pendingLayer.get(); } #pragma mark - Accessing the Paint Attributes - (void)setBackgroundColor:(MGLStyleValue *)backgroundColor { MGLAssertStyleLayerIsValid(); auto mbglValue = MGLStyleValueTransformer().toInterpolatablePropertyValue(backgroundColor); self.rawLayer->setBackgroundColor(mbglValue); } - (MGLStyleValue *)backgroundColor { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->getBackgroundColor(); if (propertyValue.isUndefined()) { return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultBackgroundColor()); } return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setBackgroundOpacity:(MGLStyleValue *)backgroundOpacity { MGLAssertStyleLayerIsValid(); auto mbglValue = MGLStyleValueTransformer().toInterpolatablePropertyValue(backgroundOpacity); self.rawLayer->setBackgroundOpacity(mbglValue); } - (MGLStyleValue *)backgroundOpacity { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->getBackgroundOpacity(); if (propertyValue.isUndefined()) { return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultBackgroundOpacity()); } return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setBackgroundPattern:(MGLStyleValue *)backgroundPattern { MGLAssertStyleLayerIsValid(); auto mbglValue = MGLStyleValueTransformer().toPropertyValue(backgroundPattern); self.rawLayer->setBackgroundPattern(mbglValue); } - (MGLStyleValue *)backgroundPattern { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->getBackgroundPattern(); if (propertyValue.isUndefined()) { return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultBackgroundPattern()); } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @end