diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2015-12-24 19:58:13 -0800 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2016-01-04 15:20:25 -0800 |
commit | af4b9599cb61baf3ae800b05d5649f6a4564cc2a (patch) | |
tree | 5553c4009fe322ca55751b35f196d525bc1ed196 /platform | |
parent | 8aad739ec2bfa420318973c1f68a311f57949fb9 (diff) | |
download | qtlocation-mapboxgl-af4b9599cb61baf3ae800b05d5649f6a4564cc2a.tar.gz |
Double-tap to zoom out on Magic Mice
Fixes #3426.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/osx/src/MGLMapView.mm | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/platform/osx/src/MGLMapView.mm b/platform/osx/src/MGLMapView.mm index a6afa0bf28..7646e524a3 100644 --- a/platform/osx/src/MGLMapView.mm +++ b/platform/osx/src/MGLMapView.mm @@ -872,10 +872,12 @@ public: } - (void)scaleBy:(double)scaleFactor atPoint:(NSPoint)point animated:(BOOL)animated { + [self willChangeValueForKey:@"centerCoordinate"]; [self willChangeValueForKey:@"zoomLevel"]; mbgl::PrecisionPoint center(point.x, point.y); _mbglMap->scaleBy(scaleFactor, center, MGLDurationInSeconds(animated ? MGLAnimationDuration : 0)); [self didChangeValueForKey:@"zoomLevel"]; + [self didChangeValueForKey:@"centerCoordinate"]; } - (double)maximumZoomLevel { @@ -1214,6 +1216,17 @@ public: [self scaleBy:2 atPoint:NSMakePoint(gesturePoint.x, self.bounds.size.height - gesturePoint.y) animated:YES]; } +- (void)smartMagnifyWithEvent:(NSEvent *)event { + if (!self.zoomEnabled) { + return; + } + + _mbglMap->cancelTransitions(); + + NSPoint gesturePoint = [self convertPoint:event.locationInWindow fromView:nil]; + [self scaleBy:0.5 atPoint:NSMakePoint(gesturePoint.x, self.bounds.size.height - gesturePoint.y) animated:YES]; +} + /// Rotate fingers to rotate. - (void)handleRotationGesture:(NSRotationGestureRecognizer *)gestureRecognizer { if (!self.rotateEnabled) { @@ -1242,18 +1255,15 @@ public: - (void)scrollWheel:(NSEvent *)event { // https://developer.apple.com/library/mac/releasenotes/AppKit/RN-AppKitOlderNotes/#10_7Dragging - if (event.phase == NSEventPhaseNone && event.momentumPhase == NSEventPhaseNone) { + if (event.phase == NSEventPhaseNone && event.momentumPhase == NSEventPhaseNone && !event.hasPreciseScrollingDeltas) { // A traditional, vertical scroll wheel zooms instead of panning. if (self.zoomEnabled && std::abs(event.scrollingDeltaX) < std::abs(event.scrollingDeltaY)) { _mbglMap->cancelTransitions(); - [self willChangeValueForKey:@"zoomLevel"]; - [self willChangeValueForKey:@"centerCoordinate"]; NSPoint gesturePoint = [self convertPoint:event.locationInWindow fromView:nil]; - mbgl::PrecisionPoint center(gesturePoint.x, self.bounds.size.height - gesturePoint.y); - _mbglMap->scaleBy(exp2(event.scrollingDeltaY / 20), center); - [self didChangeValueForKey:@"centerCoordinate"]; - [self didChangeValueForKey:@"zoomLevel"]; + gesturePoint.y = self.bounds.size.height - gesturePoint.y; + double zoomDelta = event.scrollingDeltaY / 4; + [self scaleBy:exp2(zoomDelta) atPoint:gesturePoint animated:YES]; } } else if (self.scrollEnabled && _magnificationGestureRecognizer.state == NSGestureRecognizerStatePossible |