| 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" | 13 #include "base/logging.h" |
| 14 #include "remoting/client/gesture_interpreter.h" | 14 #include "remoting/client/gesture_interpreter.h" |
| 15 | 15 |
| 16 remoting::GestureInterpreter::GestureState toGestureState( | 16 remoting::GestureInterpreter::GestureState toGestureState( |
| 17 UIGestureRecognizerState state) { | 17 UIGestureRecognizerState state) { |
| 18 switch (state) { | 18 switch (state) { |
| 19 case UIGestureRecognizerStateBegan: | 19 case UIGestureRecognizerStateBegan: |
| 20 return remoting::GestureInterpreter::GESTURE_BEGAN; | 20 return remoting::GestureInterpreter::GESTURE_BEGAN; |
| 21 case UIGestureRecognizerStateChanged: | 21 case UIGestureRecognizerStateChanged: |
| 22 return remoting::GestureInterpreter::GESTURE_CHANGED; | 22 return remoting::GestureInterpreter::GESTURE_CHANGED; |
| 23 default: | 23 default: |
| 24 return remoting::GestureInterpreter::GESTURE_ENDED; | 24 return remoting::GestureInterpreter::GESTURE_ENDED; |
| 25 } | 25 } |
| 26 } | 26 } |
| 27 | 27 |
| 28 @implementation ClientGestures | 28 @implementation ClientGestures |
| 29 | 29 |
| 30 @synthesize delegate = _delegate; |
| 31 |
| 30 - (instancetype)initWithView:(UIView*)view client:(RemotingClient*)client { | 32 - (instancetype)initWithView:(UIView*)view client:(RemotingClient*)client { |
| 31 _view = view; | 33 _view = view; |
| 32 _client = client; | 34 _client = client; |
| 33 | 35 |
| 34 _inputScheme = HostInputSchemeTouch; | 36 _inputScheme = HostInputSchemeTouch; |
| 35 | 37 |
| 36 _longPressRecognizer = [[UILongPressGestureRecognizer alloc] | 38 _longPressRecognizer = [[UILongPressGestureRecognizer alloc] |
| 37 initWithTarget:self | 39 initWithTarget:self |
| 38 action:@selector(longPressGestureTriggered:)]; | 40 action:@selector(longPressGestureTriggered:)]; |
| 39 _longPressRecognizer.delegate = self; | 41 _longPressRecognizer.delegate = self; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 initWithTarget:self | 89 initWithTarget:self |
| 88 action:@selector(twoFingerTapGestureTriggered:)]; | 90 action:@selector(twoFingerTapGestureTriggered:)]; |
| 89 _twoFingerTapRecognizer.numberOfTouchesRequired = 2; | 91 _twoFingerTapRecognizer.numberOfTouchesRequired = 2; |
| 90 _twoFingerTapRecognizer.delegate = self; | 92 _twoFingerTapRecognizer.delegate = self; |
| 91 [view addGestureRecognizer:_twoFingerTapRecognizer]; | 93 [view addGestureRecognizer:_twoFingerTapRecognizer]; |
| 92 | 94 |
| 93 _threeFingerTapRecognizer = [[UITapGestureRecognizer alloc] | 95 _threeFingerTapRecognizer = [[UITapGestureRecognizer alloc] |
| 94 initWithTarget:self | 96 initWithTarget:self |
| 95 action:@selector(threeFingerTapGestureTriggered:)]; | 97 action:@selector(threeFingerTapGestureTriggered:)]; |
| 96 _threeFingerTapRecognizer.numberOfTouchesRequired = 3; | 98 _threeFingerTapRecognizer.numberOfTouchesRequired = 3; |
| 97 _threeFingerPanRecognizer.delegate = self; | 99 _threeFingerTapRecognizer.delegate = self; |
| 98 [view addGestureRecognizer:_threeFingerTapRecognizer]; | 100 [view addGestureRecognizer:_threeFingerTapRecognizer]; |
| 99 | 101 |
| 100 _inputScheme = HostInputSchemeTouch; | 102 _inputScheme = HostInputSchemeTouch; |
| 101 | 103 |
| 102 [_singleTapRecognizer requireGestureRecognizerToFail:_twoFingerTapRecognizer]; | 104 [_singleTapRecognizer requireGestureRecognizerToFail:_twoFingerTapRecognizer]; |
| 103 [_twoFingerTapRecognizer | 105 [_twoFingerTapRecognizer |
| 104 requireGestureRecognizerToFail:_threeFingerTapRecognizer]; | 106 requireGestureRecognizerToFail:_threeFingerTapRecognizer]; |
| 105 [_pinchRecognizer requireGestureRecognizerToFail:_singleTapRecognizer]; | 107 [_pinchRecognizer requireGestureRecognizerToFail:_singleTapRecognizer]; |
| 108 [_pinchRecognizer requireGestureRecognizerToFail:_threeFingerPanRecognizer]; |
| 106 [_panRecognizer requireGestureRecognizerToFail:_singleTapRecognizer]; | 109 [_panRecognizer requireGestureRecognizerToFail:_singleTapRecognizer]; |
| 107 [_threeFingerPanRecognizer | 110 [_threeFingerPanRecognizer |
| 108 requireGestureRecognizerToFail:_threeFingerTapRecognizer]; | 111 requireGestureRecognizerToFail:_threeFingerTapRecognizer]; |
| 109 [_panRecognizer requireGestureRecognizerToFail:_scrollRecognizer]; | 112 [_panRecognizer requireGestureRecognizerToFail:_scrollRecognizer]; |
| 110 | 113 |
| 111 _edgeGesture = [[UIScreenEdgePanGestureRecognizer alloc] | 114 _edgeGesture = [[UIScreenEdgePanGestureRecognizer alloc] |
| 112 initWithTarget:self | 115 initWithTarget:self |
| 113 action:@selector(edgeGestureTriggered:)]; | 116 action:@selector(edgeGestureTriggered:)]; |
| 114 //_edgeGesture.edges = UIRectEdgeLeft; | 117 //_edgeGesture.edges = UIRectEdgeLeft; |
| 115 _edgeGesture.delegate = self; | 118 _edgeGesture.delegate = self; |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 // } | 321 // } |
| 319 // } | 322 // } |
| 320 } | 323 } |
| 321 | 324 |
| 322 - (IBAction)twoFingerTapGestureTriggered:(UITapGestureRecognizer*)sender { | 325 - (IBAction)twoFingerTapGestureTriggered:(UITapGestureRecognizer*)sender { |
| 323 CGPoint touchPoint = [sender locationInView:_view]; | 326 CGPoint touchPoint = [sender locationInView:_view]; |
| 324 _client.gestureInterpreter->TwoFingerTap(touchPoint.x, touchPoint.y); | 327 _client.gestureInterpreter->TwoFingerTap(touchPoint.x, touchPoint.y); |
| 325 } | 328 } |
| 326 | 329 |
| 327 - (IBAction)threeFingerTapGestureTriggered:(UITapGestureRecognizer*)sender { | 330 - (IBAction)threeFingerTapGestureTriggered:(UITapGestureRecognizer*)sender { |
| 328 // LOG_TRACE(INFO) << "threeFingerTapGestureTriggered"; | 331 CGPoint touchPoint = [sender locationInView:_view]; |
| 329 if (_inputScheme == HostInputSchemeTouch) { | 332 _client.gestureInterpreter->ThreeFingerTap(touchPoint.x, touchPoint.y); |
| 330 // disabled | |
| 331 return; | |
| 332 } | |
| 333 | |
| 334 // if ([_scene containsTouchPoint:[sender locationInView:self.view]]) { | |
| 335 // [Utility middleClickOn:_clientToHostProxy at:_scene.mousePosition]; | |
| 336 // } | |
| 337 } | 333 } |
| 338 | 334 |
| 339 - (IBAction)threeFingerPanGestureTriggered:(UIPanGestureRecognizer*)sender { | 335 - (IBAction)threeFingerPanGestureTriggered:(UIPanGestureRecognizer*)sender { |
| 340 // LOG_TRACE(INFO) << "threeFingerPanGestureTriggered"; | 336 // LOG_TRACE(INFO) << "threeFingerPanGestureTriggered"; |
| 341 // if ([sender state] == UIGestureRecognizerStateChanged) { | 337 if ([sender state] != UIGestureRecognizerStateEnded) { |
| 342 // CGPoint translation = [sender translationInView:self.view]; | 338 return; |
| 343 // if (translation.y > 0) { | 339 } |
| 344 // // Swiped down - do nothing | 340 |
| 345 // } else if (translation.y < 0) { | 341 CGPoint translation = [sender translationInView:_view]; |
| 346 // // Swiped up | 342 if (translation.y > 0) { |
| 347 // [_keyEntryView becomeFirstResponder]; | 343 // Swiped down - hide keyboard (for now) |
| 348 // } | 344 [_delegate keyboardShouldHide]; |
| 349 // [sender setTranslation:CGPointZero inView:self.view]; | 345 } else if (translation.y < 0) { |
| 350 // } | 346 // Swiped up - show keyboard |
| 347 [_delegate keyboardShouldShow]; |
| 348 } |
| 351 } | 349 } |
| 352 | 350 |
| 353 - (IBAction)edgeGestureTriggered:(UIScreenEdgePanGestureRecognizer*)sender { | 351 - (IBAction)edgeGestureTriggered:(UIScreenEdgePanGestureRecognizer*)sender { |
| 354 // LOG_TRACE(INFO) << "edgeGestureTriggered"; | 352 // LOG_TRACE(INFO) << "edgeGestureTriggered"; |
| 355 } | 353 } |
| 356 | 354 |
| 357 - (IBAction)swipeGestureTriggered:(UISwipeGestureRecognizer*)sender { | 355 - (IBAction)swipeGestureTriggered:(UISwipeGestureRecognizer*)sender { |
| 358 // LOG_TRACE(INFO) << "swipeGestureTriggered"; | 356 // LOG_TRACE(INFO) << "swipeGestureTriggered"; |
| 359 } | 357 } |
| 360 | 358 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 otherGestureRecognizer == _edgeGesture) { | 398 otherGestureRecognizer == _edgeGesture) { |
| 401 return YES; | 399 return YES; |
| 402 } | 400 } |
| 403 // TODO(nicholss): If we return NO here, it dismisses the other reconizers. | 401 // TODO(nicholss): If we return NO here, it dismisses the other reconizers. |
| 404 // As we add more types of reconizers, they need to be accounted for in the | 402 // As we add more types of reconizers, they need to be accounted for in the |
| 405 // above logic. | 403 // above logic. |
| 406 return NO; | 404 return NO; |
| 407 } | 405 } |
| 408 | 406 |
| 409 @end | 407 @end |
| OLD | NEW |