summaryrefslogtreecommitdiff
path: root/platform/osx
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2016-01-08 22:18:55 -0800
committerMinh Nguyễn <mxn@1ec5.org>2016-01-14 00:39:12 -0800
commit27b308a23482660d705eb82457a21213bc12599e (patch)
treec59bee5ba7f56f2ce9532c07d14c8b3fe6323a0f /platform/osx
parent5119ce8155713e9f601b2a5dd6c6dc5aefcb93ed (diff)
downloadqtlocation-mapboxgl-27b308a23482660d705eb82457a21213bc12599e.tar.gz
[core] Separated AnimationOptions from CameraOptions
Diffstat (limited to 'platform/osx')
-rw-r--r--platform/osx/src/MGLMapView.mm37
1 files changed, 20 insertions, 17 deletions
diff --git a/platform/osx/src/MGLMapView.mm b/platform/osx/src/MGLMapView.mm
index 947dd41b17..829c3cade6 100644
--- a/platform/osx/src/MGLMapView.mm
+++ b/platform/osx/src/MGLMapView.mm
@@ -954,24 +954,25 @@ public:
return;
}
- mbgl::CameraOptions options = [self cameraOptionsObjectForAnimatingToCamera:camera];
+ mbgl::CameraOptions cameraOptions = [self cameraOptionsObjectForAnimatingToCamera:camera];
+ mbgl::AnimationOptions animationOptions;
if (duration > 0) {
- options.duration = MGLDurationInSeconds(duration);
- options.easing = MGLUnitBezierForMediaTimingFunction(function);
+ animationOptions.duration = MGLDurationInSeconds(duration);
+ animationOptions.easing = MGLUnitBezierForMediaTimingFunction(function);
}
if (completion) {
- options.transitionFinishFn = [completion]() {
+ animationOptions.transitionFinishFn = [completion]() {
// Must run asynchronously after the transition is completely over.
// Otherwise, a call to -setCamera: within the completion handler
// would reenter the completion handler’s caller.
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+ dispatch_async(dispatch_get_main_queue(), ^{
completion();
});
};
}
[self willChangeValueForKey:@"camera"];
- _mbglMap->easeTo(options);
+ _mbglMap->easeTo(cameraOptions, animationOptions);
[self didChangeValueForKey:@"camera"];
}
@@ -989,29 +990,30 @@ public:
return;
}
- mbgl::CameraOptions options = [self cameraOptionsObjectForAnimatingToCamera:camera];
+ mbgl::CameraOptions cameraOptions = [self cameraOptionsObjectForAnimatingToCamera:camera];
+ mbgl::AnimationOptions animationOptions;
if (duration >= 0) {
- options.duration = MGLDurationInSeconds(duration);
+ animationOptions.duration = MGLDurationInSeconds(duration);
}
if (peakAltitude >= 0) {
CLLocationDegrees peakLatitude = (self.centerCoordinate.latitude + camera.centerCoordinate.latitude) / 2;
CLLocationDegrees peakPitch = (self.camera.pitch + camera.pitch) / 2;
- options.minZoom = MGLZoomLevelForAltitude(peakAltitude, peakPitch,
- peakLatitude, self.frame.size);
+ animationOptions.minZoom = MGLZoomLevelForAltitude(peakAltitude, peakPitch,
+ peakLatitude, self.frame.size);
}
if (completion) {
- options.transitionFinishFn = [completion]() {
+ animationOptions.transitionFinishFn = [completion]() {
// Must run asynchronously after the transition is completely over.
// Otherwise, a call to -setCamera: within the completion handler
// would reenter the completion handler’s caller.
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+ dispatch_async(dispatch_get_main_queue(), ^{
completion();
});
};
}
[self willChangeValueForKey:@"camera"];
- _mbglMap->flyTo(options);
+ _mbglMap->flyTo(cameraOptions, animationOptions);
[self didChangeValueForKey:@"camera"];
}
@@ -1052,16 +1054,17 @@ public:
_mbglMap->cancelTransitions();
mbgl::EdgeInsets mbglInsets = MGLEdgeInsetsFromNSEdgeInsets(insets);
- mbgl::CameraOptions options = _mbglMap->cameraForLatLngBounds(MGLLatLngBoundsFromCoordinateBounds(bounds), mbglInsets);
+ mbgl::CameraOptions cameraOptions = _mbglMap->cameraForLatLngBounds(MGLLatLngBoundsFromCoordinateBounds(bounds), mbglInsets);
+ mbgl::AnimationOptions animationOptions;
if (animated) {
- options.duration = MGLDurationInSeconds(MGLAnimationDuration);
+ animationOptions.duration = MGLDurationInSeconds(MGLAnimationDuration);
}
[self willChangeValueForKey:@"visibleCoordinateBounds"];
- options.transitionFinishFn = ^() {
+ animationOptions.transitionFinishFn = ^() {
[self didChangeValueForKey:@"visibleCoordinateBounds"];
};
- _mbglMap->easeTo(options);
+ _mbglMap->easeTo(cameraOptions, animationOptions);
}
#pragma mark Mouse events and gestures