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