diff options
author | Fabian Guerra <fabian.guerra@mapbox.com> | 2017-02-23 15:34:37 -0500 |
---|---|---|
committer | Justin R. Miller <incanus@codesorcery.net> | 2017-03-06 17:09:25 -0800 |
commit | 32115a9a4eb339e688f54cb0c9206474c312a72a (patch) | |
tree | c11d2a8dfc286eaa41ba7563d138254c28ad5491 | |
parent | 7e9701283f96bfcce3a56a3af4c8fe9154f02b61 (diff) | |
download | qtlocation-mapboxgl-32115a9a4eb339e688f54cb0c9206474c312a72a.tar.gz |
[ios, macos] new struct MGLTransition
-rw-r--r-- | platform/darwin/src/MGLStyle.h | 37 | ||||
-rw-r--r-- | platform/darwin/src/MGLStyle.mm | 14 | ||||
-rw-r--r-- | platform/ios/app/MBXViewController.m | 4 | ||||
-rw-r--r-- | platform/macos/app/MapDocument.m | 4 |
4 files changed, 39 insertions, 20 deletions
diff --git a/platform/darwin/src/MGLStyle.h b/platform/darwin/src/MGLStyle.h index 689faf78cf..e0bc5b70e9 100644 --- a/platform/darwin/src/MGLStyle.h +++ b/platform/darwin/src/MGLStyle.h @@ -31,6 +31,22 @@ NS_ASSUME_NONNULL_BEGIN static MGL_EXPORT const NSInteger MGLStyleDefaultVersion = 9; /** + A structure containing information about a transition values. + */ +typedef struct MGLTransition { + /** + The duration in seconds to animate any changes to the style URL or to layout and paint attributes. + */ + NSTimeInterval duration; + + /** + The delay in seconds to before applying any changes to the style URL or to layout and paint attributes. + */ + NSTimeInterval delay; +} MGLTransition; + + +/** The proxy object for the current map style. MGLStyle provides a set of convenience methods for changing Mapbox @@ -194,6 +210,11 @@ MGL_EXPORT @property (nonatomic, strong) NS_SET_OF(__kindof MGLSource *) *sources; /** + Transition values. + */ +@property (nonatomic) MGLTransition transition; + +/** Returns a source with the given identifier in the current style. @note Source identifiers are not guaranteed to exist across styles or different @@ -442,22 +463,6 @@ MGL_EXPORT */ - (void)removeImageForName:(NSString *)name; -#pragma mark Managing a Style’s Transition Options - -/** - The duration in seconds to animate any changes to the style URL or to layout and paint attributes. - - By default, this property is set to zero seconds, so any changes take effect without animation. - */ -@property (nonatomic) NSTimeInterval transitionDuration; - -/** - The delay in seconds to before applying any changes to the style URL or to layout and paint attributes. - - By default, this property is set to zero seconds, so any changes begin to animate immediately. - */ -@property (nonatomic) NSTimeInterval transitionDelay; - @end NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MGLStyle.mm b/platform/darwin/src/MGLStyle.mm index be82e34cb4..ab0155a40c 100644 --- a/platform/darwin/src/MGLStyle.mm +++ b/platform/darwin/src/MGLStyle.mm @@ -572,6 +572,20 @@ static NSURL *MGLStyleURL_emerald; #pragma mark Style transitions +- (void)setTransition:(MGLTransition)transition +{ + [self setTransitionDuration:transition.duration]; + [self setTransitionDelay:transition.delay]; +} + +- (MGLTransition)transition +{ + MGLTransition transition; + transition.delay = [self transitionDelay]; + transition.duration = [self transitionDuration]; + + return transition; +} - (void)setTransitionDuration:(NSTimeInterval)duration { auto transitionOptions = self.mapView.mbglMap->getTransitionOptions(); diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m index e1ff440e9e..39458c4f31 100644 --- a/platform/ios/app/MBXViewController.m +++ b/platform/ios/app/MBXViewController.m @@ -915,8 +915,8 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { - (void)styleBuildingLayer { - self.mapView.style.transitionDuration = 5; - self.mapView.style.transitionDelay = 1; + MGLTransition transition = { 5, 1 }; + self.mapView.style.transition = transition; MGLFillStyleLayer *buildingLayer = (MGLFillStyleLayer *)[self.mapView.style layerWithIdentifier:@"building"]; buildingLayer.fillColor = [MGLStyleValue<UIColor *> valueWithRawValue:[UIColor purpleColor]]; } diff --git a/platform/macos/app/MapDocument.m b/platform/macos/app/MapDocument.m index b120f2da6d..ec90888084 100644 --- a/platform/macos/app/MapDocument.m +++ b/platform/macos/app/MapDocument.m @@ -683,8 +683,8 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio } - (IBAction)manipulateStyle:(id)sender { - self.mapView.style.transitionDuration = 5; - self.mapView.style.transitionDelay = 1; + MGLTransition transition = { .duration = 5, .delay = 1 }; + self.mapView.style.transition = transition; MGLFillStyleLayer *fillStyleLayer = (MGLFillStyleLayer *)[self.mapView.style layerWithIdentifier:@"water"]; |