| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #if !defined(__has_feature) || !__has_feature(objc_arc) | 5 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 6 #error "This file requires ARC support." | 6 #error "This file requires ARC support." |
| 7 #endif | 7 #endif |
| 8 | 8 |
| 9 #import "remoting/ios/client_gestures.h" | 9 #import "remoting/ios/client_gestures.h" |
| 10 | 10 |
| 11 #import "remoting/ios/session/remoting_client.h" | 11 #import "remoting/ios/session/remoting_client.h" |
| 12 | 12 |
| 13 #include "base/logging.h" | |
| 14 #include "remoting/client/gesture_interpreter.h" | 13 #include "remoting/client/gesture_interpreter.h" |
| 15 | 14 |
| 16 remoting::GestureInterpreter::GestureState toGestureState( | 15 remoting::GestureInterpreter::GestureState toGestureState( |
| 17 UIGestureRecognizerState state) { | 16 UIGestureRecognizerState state) { |
| 18 switch (state) { | 17 switch (state) { |
| 19 case UIGestureRecognizerStateBegan: | 18 case UIGestureRecognizerStateBegan: |
| 20 return remoting::GestureInterpreter::GESTURE_BEGAN; | 19 return remoting::GestureInterpreter::GESTURE_BEGAN; |
| 21 case UIGestureRecognizerStateChanged: | 20 case UIGestureRecognizerStateChanged: |
| 22 return remoting::GestureInterpreter::GESTURE_CHANGED; | 21 return remoting::GestureInterpreter::GESTURE_CHANGED; |
| 23 default: | 22 default: |
| 24 return remoting::GestureInterpreter::GESTURE_ENDED; | 23 return remoting::GestureInterpreter::GESTURE_ENDED; |
| 25 } | 24 } |
| 26 } | 25 } |
| 27 | 26 |
| 27 @interface ClientGestures ()<UIGestureRecognizerDelegate> { |
| 28 @private |
| 29 UILongPressGestureRecognizer* _longPressRecognizer; |
| 30 UIPanGestureRecognizer* _panRecognizer; |
| 31 UIPanGestureRecognizer* _flingRecognizer; |
| 32 UIPanGestureRecognizer* _scrollRecognizer; |
| 33 UIPanGestureRecognizer* _threeFingerPanRecognizer; |
| 34 UIPinchGestureRecognizer* _pinchRecognizer; |
| 35 UITapGestureRecognizer* _singleTapRecognizer; |
| 36 UITapGestureRecognizer* _twoFingerTapRecognizer; |
| 37 UITapGestureRecognizer* _threeFingerTapRecognizer; |
| 38 |
| 39 __weak UIView* _view; |
| 40 __weak RemotingClient* _client; |
| 41 } |
| 42 @end |
| 43 |
| 28 @implementation ClientGestures | 44 @implementation ClientGestures |
| 29 | 45 |
| 30 @synthesize delegate = _delegate; | 46 @synthesize delegate = _delegate; |
| 31 | 47 |
| 32 - (instancetype)initWithView:(UIView*)view client:(RemotingClient*)client { | 48 - (instancetype)initWithView:(UIView*)view client:(RemotingClient*)client { |
| 33 _view = view; | 49 _view = view; |
| 34 _client = client; | 50 _client = client; |
| 35 | 51 |
| 36 _inputScheme = HostInputSchemeTouch; | |
| 37 | |
| 38 _longPressRecognizer = [[UILongPressGestureRecognizer alloc] | 52 _longPressRecognizer = [[UILongPressGestureRecognizer alloc] |
| 39 initWithTarget:self | 53 initWithTarget:self |
| 40 action:@selector(longPressGestureTriggered:)]; | 54 action:@selector(longPressGestureTriggered:)]; |
| 41 _longPressRecognizer.delegate = self; | 55 _longPressRecognizer.delegate = self; |
| 42 [view addGestureRecognizer:_longPressRecognizer]; | 56 [view addGestureRecognizer:_longPressRecognizer]; |
| 43 | 57 |
| 44 _panRecognizer = [[UIPanGestureRecognizer alloc] | 58 _panRecognizer = [[UIPanGestureRecognizer alloc] |
| 45 initWithTarget:self | 59 initWithTarget:self |
| 46 action:@selector(panGestureTriggered:)]; | 60 action:@selector(panGestureTriggered:)]; |
| 47 _panRecognizer.minimumNumberOfTouches = 1; | 61 _panRecognizer.minimumNumberOfTouches = 1; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 _twoFingerTapRecognizer.delegate = self; | 106 _twoFingerTapRecognizer.delegate = self; |
| 93 [view addGestureRecognizer:_twoFingerTapRecognizer]; | 107 [view addGestureRecognizer:_twoFingerTapRecognizer]; |
| 94 | 108 |
| 95 _threeFingerTapRecognizer = [[UITapGestureRecognizer alloc] | 109 _threeFingerTapRecognizer = [[UITapGestureRecognizer alloc] |
| 96 initWithTarget:self | 110 initWithTarget:self |
| 97 action:@selector(threeFingerTapGestureTriggered:)]; | 111 action:@selector(threeFingerTapGestureTriggered:)]; |
| 98 _threeFingerTapRecognizer.numberOfTouchesRequired = 3; | 112 _threeFingerTapRecognizer.numberOfTouchesRequired = 3; |
| 99 _threeFingerTapRecognizer.delegate = self; | 113 _threeFingerTapRecognizer.delegate = self; |
| 100 [view addGestureRecognizer:_threeFingerTapRecognizer]; | 114 [view addGestureRecognizer:_threeFingerTapRecognizer]; |
| 101 | 115 |
| 102 _inputScheme = HostInputSchemeTouch; | |
| 103 | |
| 104 [_singleTapRecognizer requireGestureRecognizerToFail:_twoFingerTapRecognizer]; | 116 [_singleTapRecognizer requireGestureRecognizerToFail:_twoFingerTapRecognizer]; |
| 105 [_twoFingerTapRecognizer | 117 [_twoFingerTapRecognizer |
| 106 requireGestureRecognizerToFail:_threeFingerTapRecognizer]; | 118 requireGestureRecognizerToFail:_threeFingerTapRecognizer]; |
| 107 [_pinchRecognizer requireGestureRecognizerToFail:_singleTapRecognizer]; | 119 [_pinchRecognizer requireGestureRecognizerToFail:_singleTapRecognizer]; |
| 108 [_pinchRecognizer requireGestureRecognizerToFail:_threeFingerPanRecognizer]; | 120 [_pinchRecognizer requireGestureRecognizerToFail:_threeFingerPanRecognizer]; |
| 109 [_panRecognizer requireGestureRecognizerToFail:_singleTapRecognizer]; | 121 [_panRecognizer requireGestureRecognizerToFail:_singleTapRecognizer]; |
| 110 [_threeFingerPanRecognizer | 122 [_threeFingerPanRecognizer |
| 111 requireGestureRecognizerToFail:_threeFingerTapRecognizer]; | 123 requireGestureRecognizerToFail:_threeFingerTapRecognizer]; |
| 112 [_panRecognizer requireGestureRecognizerToFail:_scrollRecognizer]; | 124 [_panRecognizer requireGestureRecognizerToFail:_scrollRecognizer]; |
| 113 | 125 |
| 114 _edgeGesture = [[UIScreenEdgePanGestureRecognizer alloc] | |
| 115 initWithTarget:self | |
| 116 action:@selector(edgeGestureTriggered:)]; | |
| 117 //_edgeGesture.edges = UIRectEdgeLeft; | |
| 118 _edgeGesture.delegate = self; | |
| 119 [view addGestureRecognizer:_edgeGesture]; | |
| 120 | |
| 121 _swipeGesture = [[UISwipeGestureRecognizer alloc] | |
| 122 initWithTarget:self | |
| 123 action:@selector(swipeGestureTriggered:)]; | |
| 124 _swipeGesture.numberOfTouchesRequired = 2; | |
| 125 _swipeGesture.delegate = self; | |
| 126 [view addGestureRecognizer:_swipeGesture]; | |
| 127 | |
| 128 return self; | 126 return self; |
| 129 } | 127 } |
| 130 | 128 |
| 131 // TODO(nicholss): The following several methods have been commented out. | |
| 132 // Integreation with the original implementation will be done with the app | |
| 133 // is able to run to the point of interaction and debugging can happen. | |
| 134 // I would prefer to leave this here rather than deleting because it is close | |
| 135 // to the implementation that will be used client gestures integration. | |
| 136 // This is a new class that was derived from the original source which had | |
| 137 // the implementation mixed in with the host controller and was a huge mess. | |
| 138 | |
| 139 // Resize the view of the desktop - Zoom in/out. This can occur during a Pan. | 129 // Resize the view of the desktop - Zoom in/out. This can occur during a Pan. |
| 140 - (IBAction)pinchGestureTriggered:(UIPinchGestureRecognizer*)sender { | 130 - (IBAction)pinchGestureTriggered:(UIPinchGestureRecognizer*)sender { |
| 141 // LOG_TRACE(INFO) << "pinchGestureTriggered"; | |
| 142 CGPoint pivot = [sender locationInView:_view]; | 131 CGPoint pivot = [sender locationInView:_view]; |
| 143 _client.gestureInterpreter->Zoom(pivot.x, pivot.y, sender.scale, | 132 _client.gestureInterpreter->Zoom(pivot.x, pivot.y, sender.scale, |
| 144 toGestureState([sender state])); | 133 toGestureState([sender state])); |
| 145 | 134 |
| 146 sender.scale = 1.0; // reset scale so next iteration is a relative ratio | 135 sender.scale = 1.0; // reset scale so next iteration is a relative ratio |
| 147 } | 136 } |
| 148 | 137 |
| 149 - (IBAction)tapGestureTriggered:(UITapGestureRecognizer*)sender { | 138 - (IBAction)tapGestureTriggered:(UITapGestureRecognizer*)sender { |
| 150 CGPoint touchPoint = [sender locationInView:_view]; | 139 CGPoint touchPoint = [sender locationInView:_view]; |
| 151 _client.gestureInterpreter->Tap(touchPoint.x, touchPoint.y); | 140 _client.gestureInterpreter->Tap(touchPoint.x, touchPoint.y); |
| 152 } | 141 } |
| 153 | 142 |
| 154 // Change position of scene. This can occur during a pinch or long press. | 143 // Change position of the viewport. This can occur during a pinch or long press. |
| 155 // Or perform a Mouse Wheel Scroll. | |
| 156 - (IBAction)panGestureTriggered:(UIPanGestureRecognizer*)sender { | 144 - (IBAction)panGestureTriggered:(UIPanGestureRecognizer*)sender { |
| 157 if ([sender state] == UIGestureRecognizerStateChanged) { | 145 if ([sender state] == UIGestureRecognizerStateChanged) { |
| 158 CGPoint translation = [sender translationInView:_view]; | 146 CGPoint translation = [sender translationInView:_view]; |
| 159 _client.gestureInterpreter->Pan(translation.x, translation.y); | 147 _client.gestureInterpreter->Pan(translation.x, translation.y); |
| 160 | 148 |
| 161 // Reset translation so next iteration is relative | 149 // Reset translation so next iteration is relative |
| 162 [sender setTranslation:CGPointZero inView:_view]; | 150 [sender setTranslation:CGPointZero inView:_view]; |
| 163 } | 151 } |
| 164 | |
| 165 // LOG_TRACE(INFO) << "panGestureTriggered"; | |
| 166 // CGPoint translation = [sender translationInView:self.view]; | |
| 167 // // If we start with 2 touches, and the pinch gesture is not in progress | |
| 168 // yet, | |
| 169 // // then disable it, so mouse scrolling and zoom do not occur at the same | |
| 170 // // time. | |
| 171 // if ([sender numberOfTouches] == 2 && | |
| 172 // [sender state] == UIGestureRecognizerStateBegan && | |
| 173 // !(_pinchRecognizer.state == UIGestureRecognizerStateBegan || | |
| 174 // _pinchRecognizer.state == UIGestureRecognizerStateChanged)) { | |
| 175 // _pinchRecognizer.enabled = NO; | |
| 176 // } | |
| 177 // | |
| 178 // if (!_pinchRecognizer.enabled) { | |
| 179 // // Began with 2 touches, so this is a scroll event. | |
| 180 // translation.x *= kMouseWheelSensitivity; | |
| 181 // translation.y *= kMouseWheelSensitivity; | |
| 182 // // [Utility mouseScroll:_clientToHostProxy | |
| 183 // // at:_scene.mousePosition | |
| 184 // // delta:webrtc::DesktopVector(translation.x, | |
| 185 // translation.y)]; | |
| 186 // } else { | |
| 187 // // Did not begin with 2 touches, doing a pan event. | |
| 188 // if ([sender state] == UIGestureRecognizerStateChanged) { | |
| 189 // CGPoint translation = [sender translationInView:self.view]; | |
| 190 // BOOL shouldApplyPanAndTapBounding = | |
| 191 // _inputScheme == HostInputSchemeTouch && | |
| 192 // [_longPressRecognizer state] != UIGestureRecognizerStateChanged; | |
| 193 // | |
| 194 // if (shouldApplyPanAndTapBounding) { | |
| 195 // // Reverse the orientation on both axes. | |
| 196 // translation = CGPointMake(-translation.x, -translation.y); | |
| 197 // } | |
| 198 // | |
| 199 // // if (shouldApplyPanAndTapBounding) { | |
| 200 // // // Stop the translation as soon as the view becomes anchored. | |
| 201 // // if ([SceneView | |
| 202 // // couldMouseMoveTowardAnchorWithTranslation:translation.x | |
| 203 // // isAnchoredLow:_scene.anchored.left | |
| 204 // // isAnchoredHigh:_scene.anchored | |
| 205 // // .right]) { | |
| 206 // // translation = CGPointMake(0, translation.y); | |
| 207 // // } | |
| 208 // // | |
| 209 // // if ([SceneView | |
| 210 // // couldMouseMoveTowardAnchorWithTranslation:translation.y | |
| 211 // // isAnchoredLow:_scene.anchored.top | |
| 212 // // isAnchoredHigh:_scene.anchored | |
| 213 // // .bottom]) | |
| 214 // { | |
| 215 // // translation = CGPointMake(translation.x, 0); | |
| 216 // // } | |
| 217 // // } | |
| 218 // | |
| 219 // [self applySceneChange:translation scaleBy:1.0]; | |
| 220 // | |
| 221 // if (_inputScheme == HostInputSchemeTouch && | |
| 222 // [_longPressRecognizer state] == UIGestureRecognizerStateChanged | |
| 223 // && | |
| 224 // [sender numberOfTouches] == 1) { | |
| 225 // // [_scene | |
| 226 // // setMouseLocationFromLocationInView:[sender | |
| 227 // // locationInView:self.view]]; | |
| 228 // | |
| 229 // // [Utility moveMouse:_clientToHostProxy at:_scene.mousePosition]; | |
| 230 // } | |
| 231 // | |
| 232 // } else if ([sender state] == UIGestureRecognizerStateEnded) { | |
| 233 // // After user removes their fingers from the screen | |
| 234 // // apply an acceleration effect. | |
| 235 // CGPoint velocity = [sender velocityInView:self.view]; | |
| 236 // | |
| 237 // if (_inputScheme == HostInputSchemeTouch) { | |
| 238 // // Reverse the orientation on both axes. | |
| 239 // velocity = CGPointMake(-velocity.x, -velocity.y); | |
| 240 // } | |
| 241 // // [_scene setPanVelocity:velocity]; | |
| 242 // } | |
| 243 // } | |
| 244 // | |
| 245 // // Finished the event chain. | |
| 246 // if (!([sender state] == UIGestureRecognizerStateBegan || | |
| 247 // [sender state] == UIGestureRecognizerStateChanged)) { | |
| 248 // _pinchRecognizer.enabled = YES; | |
| 249 // } | |
| 250 // | |
| 251 // // Reset translation so next iteration is relative. Wait until a changed | |
| 252 // // event in order to also capture the portion of the translation that | |
| 253 // occurred | |
| 254 // // between the Began and Changed States. | |
| 255 // if ([sender state] == UIGestureRecognizerStateChanged) { | |
| 256 // [sender setTranslation:CGPointZero inView:self.view]; | |
| 257 // } | |
| 258 } | 152 } |
| 259 | 153 |
| 260 // Do fling on the viewport. This will happen at the end of the one-finger | 154 // Do fling on the viewport. This will happen at the end of the one-finger |
| 261 // panning. | 155 // panning. |
| 262 - (IBAction)flingGestureTriggered:(UIPanGestureRecognizer*)sender { | 156 - (IBAction)flingGestureTriggered:(UIPanGestureRecognizer*)sender { |
| 263 if ([sender state] == UIGestureRecognizerStateEnded) { | 157 if ([sender state] == UIGestureRecognizerStateEnded) { |
| 264 CGPoint velocity = [sender velocityInView:_view]; | 158 CGPoint velocity = [sender velocityInView:_view]; |
| 265 if (velocity.x != 0 || velocity.y != 0) { | 159 if (velocity.x != 0 || velocity.y != 0) { |
| 266 _client.gestureInterpreter->OneFingerFling(velocity.x, velocity.y); | 160 _client.gestureInterpreter->OneFingerFling(velocity.x, velocity.y); |
| 267 } | 161 } |
| 268 } | 162 } |
| 269 } | 163 } |
| 270 | 164 |
| 165 // Handles the two finger scrolling gesture. |
| 271 - (IBAction)scrollGestureTriggered:(UIPanGestureRecognizer*)sender { | 166 - (IBAction)scrollGestureTriggered:(UIPanGestureRecognizer*)sender { |
| 272 if ([sender state] == UIGestureRecognizerStateEnded) { | 167 if ([sender state] == UIGestureRecognizerStateEnded) { |
| 273 CGPoint velocity = [sender velocityInView:_view]; | 168 CGPoint velocity = [sender velocityInView:_view]; |
| 274 _client.gestureInterpreter->ScrollWithVelocity(velocity.x, velocity.y); | 169 _client.gestureInterpreter->ScrollWithVelocity(velocity.x, velocity.y); |
| 275 return; | 170 return; |
| 276 } | 171 } |
| 277 | 172 |
| 278 CGPoint scrollPoint = [sender locationInView:_view]; | 173 CGPoint scrollPoint = [sender locationInView:_view]; |
| 279 CGPoint translation = [sender translationInView:_view]; | 174 CGPoint translation = [sender translationInView:_view]; |
| 280 _client.gestureInterpreter->Scroll(scrollPoint.x, scrollPoint.y, | 175 _client.gestureInterpreter->Scroll(scrollPoint.x, scrollPoint.y, |
| 281 translation.x, translation.y); | 176 translation.x, translation.y); |
| 282 | 177 |
| 283 // Reset translation so next iteration is relative | 178 // Reset translation so next iteration is relative |
| 284 [sender setTranslation:CGPointZero inView:_view]; | 179 [sender setTranslation:CGPointZero inView:_view]; |
| 285 } | 180 } |
| 286 | 181 |
| 287 // Click-Drag mouse operation. This can occur during a Pan. | 182 // Click-Drag mouse operation. This can occur during a Pan. |
| 288 - (IBAction)longPressGestureTriggered:(UILongPressGestureRecognizer*)sender { | 183 - (IBAction)longPressGestureTriggered:(UILongPressGestureRecognizer*)sender { |
| 289 CGPoint touchPoint = [sender locationInView:_view]; | 184 CGPoint touchPoint = [sender locationInView:_view]; |
| 290 _client.gestureInterpreter->Drag(touchPoint.x, touchPoint.y, | 185 _client.gestureInterpreter->Drag(touchPoint.x, touchPoint.y, |
| 291 toGestureState([sender state])); | 186 toGestureState([sender state])); |
| 292 | |
| 293 // LOG_TRACE(INFO) << "longPressGestureTriggered"; | |
| 294 // if ([sender state] == UIGestureRecognizerStateBegan) { | |
| 295 // if (_inputScheme == HostInputSchemeTouch) { | |
| 296 // CGPoint touchPoint = [sender locationInView:self.view]; | |
| 297 // [_scene setMouseLocationFromLocationInView:touchPoint]; | |
| 298 // } | |
| 299 // [_clientToHostProxy mouseAction:_scene.mousePosition | |
| 300 // wheelDelta:webrtc::DesktopVector(0, 0) | |
| 301 // whichButton:1 | |
| 302 // buttonDown:YES]; | |
| 303 // if (_inputScheme == HostInputSchemeTouch) { | |
| 304 // // location is going to be under the user's finger | |
| 305 // // create a bigger bubble. | |
| 306 // _circle.expandedRadius = 110.0f; | |
| 307 // } else { | |
| 308 // _circle.expandedRadius = 11.0f; | |
| 309 // } | |
| 310 // | |
| 311 // [_circle doExpandingAnimationAtLocation:[_scene mouseLocationInView]]; | |
| 312 // } else if (!([sender state] == UIGestureRecognizerStateBegan || | |
| 313 // [sender state] == UIGestureRecognizerStateChanged)) { | |
| 314 // [_clientToHostProxy mouseAction:_scene.mousePosition | |
| 315 // wheelDelta:webrtc::DesktopVector(0, 0) | |
| 316 // whichButton:1 | |
| 317 // buttonDown:NO]; | |
| 318 // if (_inputScheme == HostInputSchemeTouch) { | |
| 319 // // Return to the center. | |
| 320 // [_scene centerMouseInView]; | |
| 321 // } | |
| 322 // } | |
| 323 } | 187 } |
| 324 | 188 |
| 325 - (IBAction)twoFingerTapGestureTriggered:(UITapGestureRecognizer*)sender { | 189 - (IBAction)twoFingerTapGestureTriggered:(UITapGestureRecognizer*)sender { |
| 326 CGPoint touchPoint = [sender locationInView:_view]; | 190 CGPoint touchPoint = [sender locationInView:_view]; |
| 327 _client.gestureInterpreter->TwoFingerTap(touchPoint.x, touchPoint.y); | 191 _client.gestureInterpreter->TwoFingerTap(touchPoint.x, touchPoint.y); |
| 328 } | 192 } |
| 329 | 193 |
| 330 - (IBAction)threeFingerTapGestureTriggered:(UITapGestureRecognizer*)sender { | 194 - (IBAction)threeFingerTapGestureTriggered:(UITapGestureRecognizer*)sender { |
| 331 CGPoint touchPoint = [sender locationInView:_view]; | 195 CGPoint touchPoint = [sender locationInView:_view]; |
| 332 _client.gestureInterpreter->ThreeFingerTap(touchPoint.x, touchPoint.y); | 196 _client.gestureInterpreter->ThreeFingerTap(touchPoint.x, touchPoint.y); |
| 333 } | 197 } |
| 334 | 198 |
| 335 - (IBAction)threeFingerPanGestureTriggered:(UIPanGestureRecognizer*)sender { | 199 - (IBAction)threeFingerPanGestureTriggered:(UIPanGestureRecognizer*)sender { |
| 336 // LOG_TRACE(INFO) << "threeFingerPanGestureTriggered"; | |
| 337 if ([sender state] != UIGestureRecognizerStateEnded) { | 200 if ([sender state] != UIGestureRecognizerStateEnded) { |
| 338 return; | 201 return; |
| 339 } | 202 } |
| 340 | 203 |
| 341 CGPoint translation = [sender translationInView:_view]; | 204 CGPoint translation = [sender translationInView:_view]; |
| 342 if (translation.y > 0) { | 205 if (translation.y > 0) { |
| 343 // Swiped down - hide keyboard (for now) | 206 // Swiped down - hide keyboard (for now) |
| 344 [_delegate keyboardShouldHide]; | 207 [_delegate keyboardShouldHide]; |
| 345 } else if (translation.y < 0) { | 208 } else if (translation.y < 0) { |
| 346 // Swiped up - show keyboard | 209 // Swiped up - show keyboard |
| 347 [_delegate keyboardShouldShow]; | 210 [_delegate keyboardShouldShow]; |
| 348 } | 211 } |
| 349 } | 212 } |
| 350 | 213 |
| 351 - (IBAction)edgeGestureTriggered:(UIScreenEdgePanGestureRecognizer*)sender { | |
| 352 // LOG_TRACE(INFO) << "edgeGestureTriggered"; | |
| 353 } | |
| 354 | |
| 355 - (IBAction)swipeGestureTriggered:(UISwipeGestureRecognizer*)sender { | |
| 356 // LOG_TRACE(INFO) << "swipeGestureTriggered"; | |
| 357 } | |
| 358 | |
| 359 #pragma mark - UIGestureRecognizerDelegate | 214 #pragma mark - UIGestureRecognizerDelegate |
| 360 | 215 |
| 361 // Allow panning and zooming to occur simultaneously. | 216 // Allow panning and zooming to occur simultaneously. |
| 362 // Allow panning and long press to occur simultaneously. | 217 // Allow panning and long press to occur simultaneously. |
| 363 // Pinch requires 2 touches, and long press requires a single touch, so they are | 218 // Pinch requires 2 touches, and long press requires a single touch, so they are |
| 364 // mutually exclusive regardless of if panning is the initiating gesture. | 219 // mutually exclusive regardless of if panning is the initiating gesture. |
| 220 // Pinch and Scroll are both two-finger gestures. They are mutually exclusive |
| 221 // and whatever comes first should disable the other gesture recognizer. |
| 365 - (BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizer | 222 - (BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizer |
| 366 shouldRecognizeSimultaneouslyWithGestureRecognizer: | 223 shouldRecognizeSimultaneouslyWithGestureRecognizer: |
| 367 (UIGestureRecognizer*)otherGestureRecognizer { | 224 (UIGestureRecognizer*)otherGestureRecognizer { |
| 368 if (gestureRecognizer == _pinchRecognizer || | 225 if (gestureRecognizer == _pinchRecognizer || |
| 369 (gestureRecognizer == _panRecognizer)) { | 226 (gestureRecognizer == _panRecognizer)) { |
| 370 if (otherGestureRecognizer == _pinchRecognizer || | 227 if (otherGestureRecognizer == _pinchRecognizer || |
| 371 otherGestureRecognizer == _panRecognizer) { | 228 otherGestureRecognizer == _panRecognizer) { |
| 372 return YES; | 229 return YES; |
| 373 } | 230 } |
| 374 } | 231 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 387 otherGestureRecognizer == _panRecognizer) { | 244 otherGestureRecognizer == _panRecognizer) { |
| 388 return YES; | 245 return YES; |
| 389 } | 246 } |
| 390 } | 247 } |
| 391 | 248 |
| 392 if (gestureRecognizer == _twoFingerTapRecognizer && | 249 if (gestureRecognizer == _twoFingerTapRecognizer && |
| 393 otherGestureRecognizer == _longPressRecognizer) { | 250 otherGestureRecognizer == _longPressRecognizer) { |
| 394 return YES; | 251 return YES; |
| 395 } | 252 } |
| 396 | 253 |
| 397 if (gestureRecognizer == _panRecognizer && | |
| 398 otherGestureRecognizer == _edgeGesture) { | |
| 399 return YES; | |
| 400 } | |
| 401 // TODO(nicholss): If we return NO here, it dismisses the other reconizers. | 254 // TODO(nicholss): If we return NO here, it dismisses the other reconizers. |
| 402 // As we add more types of reconizers, they need to be accounted for in the | 255 // As we add more types of reconizers, they need to be accounted for in the |
| 403 // above logic. | 256 // above logic. |
| 404 return NO; | 257 return NO; |
| 405 } | 258 } |
| 406 | 259 |
| 407 @end | 260 @end |
| OLD | NEW |