diff options
author | Fabian Guerra Soto <fabian.guerra@mapbox.com> | 2018-12-13 10:19:56 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-13 10:19:56 -0800 |
commit | bbeec8dacb1a007ffadad391b63620b6d2575eb7 (patch) | |
tree | 81e6d72141e2986bbd00c7354da4fe45b6b8bec8 /platform | |
parent | b1ae6c90518671896fef8e7895610e75e4be5284 (diff) | |
download | qtlocation-mapboxgl-bbeec8dacb1a007ffadad391b63620b6d2575eb7.tar.gz |
[ios, macos] Add enablePlacementTransitions to MGLStyle. (#13565)
* [ios, macos] Add enablePlacementTransitions to MGLStyle.
* [ios, macos] Update changelogs.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/darwin/src/MGLStyle.h | 7 | ||||
-rw-r--r-- | platform/darwin/src/MGLStyle.mm | 13 | ||||
-rw-r--r-- | platform/darwin/test/MGLStyleTests.mm | 20 | ||||
-rw-r--r-- | platform/ios/CHANGELOG.md | 1 | ||||
-rw-r--r-- | platform/macos/CHANGELOG.md | 1 |
5 files changed, 42 insertions, 0 deletions
diff --git a/platform/darwin/src/MGLStyle.h b/platform/darwin/src/MGLStyle.h index 7621db0ad5..2b2f0998d4 100644 --- a/platform/darwin/src/MGLStyle.h +++ b/platform/darwin/src/MGLStyle.h @@ -271,6 +271,13 @@ MGL_EXPORT @property (nonatomic) MGLTransition transition; /** + A boolean value indicating whether label placement transitions are enabled. + + The default value of this property is `YES`. + */ +@property (nonatomic, assign) BOOL enablePlacementTransitions; + +/** Returns a source with the given identifier in the current style. @note Source identifiers are not guaranteed to exist across styles or different diff --git a/platform/darwin/src/MGLStyle.mm b/platform/darwin/src/MGLStyle.mm index df5f51102a..82fed5e922 100644 --- a/platform/darwin/src/MGLStyle.mm +++ b/platform/darwin/src/MGLStyle.mm @@ -534,6 +534,19 @@ static_assert(6 == mbgl::util::default_styles::numOrderedStyles, return MGLTransitionFromOptions(transitionOptions); } +- (void)setEnablePlacementTransitions:(BOOL)enablePlacementTransitions +{ + mbgl::style::TransitionOptions transitionOptions = self.rawStyle->getTransitionOptions(); + transitionOptions.enablePlacementTransitions = static_cast<bool>(enablePlacementTransitions); + self.rawStyle->setTransitionOptions(transitionOptions); +} + +- (BOOL)enablePlacementTransitions +{ + mbgl::style::TransitionOptions transitionOptions = self.rawStyle->getTransitionOptions(); + return transitionOptions.enablePlacementTransitions; +} + #pragma mark Style light - (void)setLight:(MGLLight *)light diff --git a/platform/darwin/test/MGLStyleTests.mm b/platform/darwin/test/MGLStyleTests.mm index 7330477126..ff075f63a6 100644 --- a/platform/darwin/test/MGLStyleTests.mm +++ b/platform/darwin/test/MGLStyleTests.mm @@ -470,4 +470,24 @@ } } +#pragma mark Transition tests + +- (void)testTransition +{ + MGLTransition transitionTest = MGLTransitionMake(5, 4); + + self.style.transition = transitionTest; + + XCTAssert(self.style.transition.delay == transitionTest.delay); + XCTAssert(self.style.transition.duration == transitionTest.duration); +} + +- (void)testEnablePlacementTransition +{ + XCTAssertTrue(self.style.enablePlacementTransitions, @"The default value for enabling placement transitions should be YES."); + + self.style.enablePlacementTransitions = NO; + XCTAssertFalse(self.style.enablePlacementTransitions, @"Enabling placement transitions should be NO."); +} + @end diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index e1449b663e..ffb4a53cf0 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -17,6 +17,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT * Added support for setting `MGLCollisionBehaviorPre4_0` in `NSUserDefaults`. ([#13426](https://github.com/mapbox/mapbox-gl-native/pull/13426)) * `-[MGLStyle localizeLabelsIntoLocale:]` and `-[NSExpression(MGLAdditions) mgl_expressionLocalizedIntoLocale:]` can automatically localize styles that use version 8 of the Mapbox Streets source. ([#13481](https://github.com/mapbox/mapbox-gl-native/pull/13481)) * Fixed symbol flickering during instantaneous transitions. ([#13535](https://github.com/mapbox/mapbox-gl-native/pull/13535)) +* Added an `MGLStyle.enablePlacementTransitions` property to control how long it takes for collided labels to fade out. ([#13565](https://github.com/mapbox/mapbox-gl-native/pull/13565)) ### Map snapshots diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md index cc873a6bac..3c1ffdd188 100644 --- a/platform/macos/CHANGELOG.md +++ b/platform/macos/CHANGELOG.md @@ -10,6 +10,7 @@ * Added support for setting `MGLCollisionBehaviorPre4_0` in `NSUserDefaults`. ([#13426](https://github.com/mapbox/mapbox-gl-native/pull/13426)) * Added support for automatic localization of version 8 of the Mapbox Streets source. ([#13481](https://github.com/mapbox/mapbox-gl-native/pull/13481)) * Fixed symbol flickering during instantaneous transitions. ([#13535](https://github.com/mapbox/mapbox-gl-native/pull/13535)) +* Added an `MGLStyle.enablePlacementTransitions` property to control how long it takes for collided labels to fade out. ([#13565](https://github.com/mapbox/mapbox-gl-native/pull/13565)) ### Other changes |