* [ios, macos] new struct MGLTransition * [ios] MGLTransition struct moved to MGLTypes.h * [ios] MGLTransition implemented for style layer properties * [ios, macos] added support for getting property transitions * [ios, macos] updated to MGLDurationFromTimeInterval and MGLTimeIntervalFromDuration * [ios, macos] added transition properties test * [ios, macos] modified key strings imp * [ios, macos] The impl for transition properties were changed to public methods * [ios, macos] Changelog update * [ios] Fixed layer space formatting * [core] The name space was fixed for getters that returned TransitionOptions * [ios, macos] Added rawLayer transition property tests * [ios] Added a factory method for MGLTransition and transition-related methods to NSValue(MGLAdditions) * [ios, macos] Copyedited changelog blurbs about transition properties
194 lines
6.8 KiB
Plaintext
194 lines
6.8 KiB
Plaintext
// 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 "NSDate+MGLAdditions.h"
|
|
#import "MGLStyleLayer_Private.h"
|
|
#import "MGLStyleValue_Private.h"
|
|
#import "MGLBackgroundStyleLayer.h"
|
|
|
|
#include <mbgl/map/map.hpp>
|
|
#include <mbgl/style/layers/background_layer.hpp>
|
|
|
|
@interface MGLBackgroundStyleLayer ()
|
|
|
|
@property (nonatomic) mbgl::style::BackgroundLayer *rawLayer;
|
|
|
|
@end
|
|
|
|
@implementation MGLBackgroundStyleLayer
|
|
{
|
|
std::unique_ptr<mbgl::style::BackgroundLayer> _pendingLayer;
|
|
}
|
|
|
|
- (instancetype)initWithIdentifier:(NSString *)identifier
|
|
{
|
|
if (self = [super initWithIdentifier:identifier]) {
|
|
auto layer = std::make_unique<mbgl::style::BackgroundLayer>(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<std::string> 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<mbgl::style::BackgroundLayer *>(removedLayer.get());
|
|
if (!layer) {
|
|
return;
|
|
}
|
|
|
|
removedLayer.release();
|
|
|
|
_pendingLayer = std::unique_ptr<mbgl::style::BackgroundLayer>(layer);
|
|
self.rawLayer = _pendingLayer.get();
|
|
}
|
|
|
|
#pragma mark - Accessing the Paint Attributes
|
|
|
|
- (void)setBackgroundColor:(MGLStyleValue<MGLColor *> *)backgroundColor {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toInterpolatablePropertyValue(backgroundColor);
|
|
self.rawLayer->setBackgroundColor(mbglValue);
|
|
}
|
|
|
|
- (MGLStyleValue<MGLColor *> *)backgroundColor {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
auto propertyValue = self.rawLayer->getBackgroundColor();
|
|
if (propertyValue.isUndefined()) {
|
|
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toStyleValue(self.rawLayer->getDefaultBackgroundColor());
|
|
}
|
|
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toStyleValue(propertyValue);
|
|
}
|
|
|
|
- (void)setBackgroundColorTransition:(MGLTransition )transition {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } };
|
|
self.rawLayer->setBackgroundColorTransition(options);
|
|
}
|
|
|
|
- (MGLTransition)backgroundColorTransition {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getBackgroundColorTransition();
|
|
MGLTransition transition;
|
|
transition.duration = MGLTimeIntervalFromDuration(transitionOptions.duration.value_or(mbgl::Duration::zero()));
|
|
transition.delay = MGLTimeIntervalFromDuration(transitionOptions.delay.value_or(mbgl::Duration::zero()));
|
|
|
|
return transition;
|
|
}
|
|
|
|
- (void)setBackgroundOpacity:(MGLStyleValue<NSNumber *> *)backgroundOpacity {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toInterpolatablePropertyValue(backgroundOpacity);
|
|
self.rawLayer->setBackgroundOpacity(mbglValue);
|
|
}
|
|
|
|
- (MGLStyleValue<NSNumber *> *)backgroundOpacity {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
auto propertyValue = self.rawLayer->getBackgroundOpacity();
|
|
if (propertyValue.isUndefined()) {
|
|
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(self.rawLayer->getDefaultBackgroundOpacity());
|
|
}
|
|
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
|
}
|
|
|
|
- (void)setBackgroundOpacityTransition:(MGLTransition )transition {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } };
|
|
self.rawLayer->setBackgroundOpacityTransition(options);
|
|
}
|
|
|
|
- (MGLTransition)backgroundOpacityTransition {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getBackgroundOpacityTransition();
|
|
MGLTransition transition;
|
|
transition.duration = MGLTimeIntervalFromDuration(transitionOptions.duration.value_or(mbgl::Duration::zero()));
|
|
transition.delay = MGLTimeIntervalFromDuration(transitionOptions.delay.value_or(mbgl::Duration::zero()));
|
|
|
|
return transition;
|
|
}
|
|
|
|
- (void)setBackgroundPattern:(MGLStyleValue<NSString *> *)backgroundPattern {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
auto mbglValue = MGLStyleValueTransformer<std::string, NSString *>().toPropertyValue(backgroundPattern);
|
|
self.rawLayer->setBackgroundPattern(mbglValue);
|
|
}
|
|
|
|
- (MGLStyleValue<NSString *> *)backgroundPattern {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
auto propertyValue = self.rawLayer->getBackgroundPattern();
|
|
if (propertyValue.isUndefined()) {
|
|
return MGLStyleValueTransformer<std::string, NSString *>().toStyleValue(self.rawLayer->getDefaultBackgroundPattern());
|
|
}
|
|
return MGLStyleValueTransformer<std::string, NSString *>().toStyleValue(propertyValue);
|
|
}
|
|
|
|
- (void)setBackgroundPatternTransition:(MGLTransition )transition {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } };
|
|
self.rawLayer->setBackgroundPatternTransition(options);
|
|
}
|
|
|
|
- (MGLTransition)backgroundPatternTransition {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getBackgroundPatternTransition();
|
|
MGLTransition transition;
|
|
transition.duration = MGLTimeIntervalFromDuration(transitionOptions.duration.value_or(mbgl::Duration::zero()));
|
|
transition.delay = MGLTimeIntervalFromDuration(transitionOptions.delay.value_or(mbgl::Duration::zero()));
|
|
|
|
return transition;
|
|
}
|
|
|
|
@end
|