From 8f5e7d2126c47b106e89462d93677aa8a9182e21 Mon Sep 17 00:00:00 2001 From: Fabian Guerra Date: Wed, 12 Dec 2018 14:52:18 -0800 Subject: [ios, macos] Add enablePlacementTransitions to MGLStyle. --- platform/darwin/src/MGLStyle.h | 7 +++++++ platform/darwin/src/MGLStyle.mm | 13 +++++++++++++ platform/darwin/test/MGLStyleTests.mm | 20 ++++++++++++++++++++ 3 files changed, 40 insertions(+) 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 @@ -270,6 +270,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. 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(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 -- cgit v1.2.1