| 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/key_input.h" | 11 #import "remoting/ios/key_input.h" |
| 12 #import "remoting/ios/session/remoting_client.h" | 12 #import "remoting/ios/session/remoting_client.h" |
| 13 | 13 |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "remoting/client/ui/gesture_interpreter.h" | 15 #include "remoting/client/ui/gesture_interpreter.h" |
| 16 | 16 |
| 17 remoting::GestureInterpreter::GestureState toGestureState( |
| 18 UIGestureRecognizerState state) { |
| 19 switch (state) { |
| 20 case UIGestureRecognizerStateBegan: |
| 21 return remoting::GestureInterpreter::GESTURE_BEGAN; |
| 22 case UIGestureRecognizerStateChanged: |
| 23 return remoting::GestureInterpreter::GESTURE_CHANGED; |
| 24 default: |
| 25 return remoting::GestureInterpreter::GESTURE_ENDED; |
| 26 } |
| 27 } |
| 28 |
| 17 @implementation ClientGestures | 29 @implementation ClientGestures |
| 18 | 30 |
| 19 - (instancetype)initWithView:(UIView*)view client:(RemotingClient*)client { | 31 - (instancetype)initWithView:(UIView*)view client:(RemotingClient*)client { |
| 20 _view = view; | 32 _view = view; |
| 21 _client = client; | 33 _client = client; |
| 22 | 34 |
| 23 _inputScheme = HostInputSchemeTouch; | 35 _inputScheme = HostInputSchemeTouch; |
| 24 | 36 |
| 25 _longPressRecognizer = [[UILongPressGestureRecognizer alloc] | 37 _longPressRecognizer = [[UILongPressGestureRecognizer alloc] |
| 26 initWithTarget:self | 38 initWithTarget:self |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 // Integreation with the original implementation will be done with the app | 130 // Integreation with the original implementation will be done with the app |
| 119 // is able to run to the point of interaction and debugging can happen. | 131 // is able to run to the point of interaction and debugging can happen. |
| 120 // I would prefer to leave this here rather than deleting because it is close | 132 // I would prefer to leave this here rather than deleting because it is close |
| 121 // to the implementation that will be used client gestures integration. | 133 // to the implementation that will be used client gestures integration. |
| 122 // This is a new class that was derived from the original source which had | 134 // This is a new class that was derived from the original source which had |
| 123 // the implementation mixed in with the host controller and was a huge mess. | 135 // the implementation mixed in with the host controller and was a huge mess. |
| 124 | 136 |
| 125 // Resize the view of the desktop - Zoom in/out. This can occur during a Pan. | 137 // Resize the view of the desktop - Zoom in/out. This can occur during a Pan. |
| 126 - (IBAction)pinchGestureTriggered:(UIPinchGestureRecognizer*)sender { | 138 - (IBAction)pinchGestureTriggered:(UIPinchGestureRecognizer*)sender { |
| 127 // LOG_TRACE(INFO) << "pinchGestureTriggered"; | 139 // LOG_TRACE(INFO) << "pinchGestureTriggered"; |
| 128 if ([sender state] == UIGestureRecognizerStateChanged) { | 140 CGPoint pivot = [sender locationInView:_view]; |
| 129 CGPoint pivot = [sender locationInView:_view]; | 141 _client.gestureInterpreter->Zoom(pivot.x, pivot.y, sender.scale, |
| 130 _client.gestureInterpreter->Pinch(pivot.x, pivot.y, sender.scale); | 142 toGestureState([sender state])); |
| 131 | 143 |
| 132 sender.scale = 1.0; // reset scale so next iteration is a relative ratio | 144 sender.scale = 1.0; // reset scale so next iteration is a relative ratio |
| 133 } | |
| 134 } | 145 } |
| 135 | 146 |
| 136 - (IBAction)tapGestureTriggered:(UITapGestureRecognizer*)sender { | 147 - (IBAction)tapGestureTriggered:(UITapGestureRecognizer*)sender { |
| 137 CGPoint touchPoint = [sender locationInView:_view]; | 148 CGPoint touchPoint = [sender locationInView:_view]; |
| 138 _client.gestureInterpreter->Tap(touchPoint.x, touchPoint.y); | 149 _client.gestureInterpreter->Tap(touchPoint.x, touchPoint.y); |
| 139 } | 150 } |
| 140 | 151 |
| 141 // Change position of scene. This can occur during a pinch or long press. | 152 // Change position of scene. This can occur during a pinch or long press. |
| 142 // Or perform a Mouse Wheel Scroll. | 153 // Or perform a Mouse Wheel Scroll. |
| 143 - (IBAction)panGestureTriggered:(UIPanGestureRecognizer*)sender { | 154 - (IBAction)panGestureTriggered:(UIPanGestureRecognizer*)sender { |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 _client.gestureInterpreter->Scroll(scrollPoint.x, scrollPoint.y, | 278 _client.gestureInterpreter->Scroll(scrollPoint.x, scrollPoint.y, |
| 268 translation.x, translation.y); | 279 translation.x, translation.y); |
| 269 | 280 |
| 270 // Reset translation so next iteration is relative | 281 // Reset translation so next iteration is relative |
| 271 [sender setTranslation:CGPointZero inView:_view]; | 282 [sender setTranslation:CGPointZero inView:_view]; |
| 272 } | 283 } |
| 273 | 284 |
| 274 // Click-Drag mouse operation. This can occur during a Pan. | 285 // Click-Drag mouse operation. This can occur during a Pan. |
| 275 - (IBAction)longPressGestureTriggered:(UILongPressGestureRecognizer*)sender { | 286 - (IBAction)longPressGestureTriggered:(UILongPressGestureRecognizer*)sender { |
| 276 CGPoint touchPoint = [sender locationInView:_view]; | 287 CGPoint touchPoint = [sender locationInView:_view]; |
| 277 remoting::GestureInterpreter::GestureState state; | 288 _client.gestureInterpreter->Drag(touchPoint.x, touchPoint.y, |
| 278 switch ([sender state]) { | 289 toGestureState([sender state])); |
| 279 case UIGestureRecognizerStateBegan: | |
| 280 state = remoting::GestureInterpreter::GESTURE_BEGAN; | |
| 281 break; | |
| 282 case UIGestureRecognizerStateChanged: | |
| 283 state = remoting::GestureInterpreter::GESTURE_CHANGED; | |
| 284 break; | |
| 285 default: | |
| 286 state = remoting::GestureInterpreter::GESTURE_ENDED; | |
| 287 } | |
| 288 _client.gestureInterpreter->LongPress(touchPoint.x, touchPoint.y, state); | |
| 289 | 290 |
| 290 // LOG_TRACE(INFO) << "longPressGestureTriggered"; | 291 // LOG_TRACE(INFO) << "longPressGestureTriggered"; |
| 291 // if ([sender state] == UIGestureRecognizerStateBegan) { | 292 // if ([sender state] == UIGestureRecognizerStateBegan) { |
| 292 // if (_inputScheme == HostInputSchemeTouch) { | 293 // if (_inputScheme == HostInputSchemeTouch) { |
| 293 // CGPoint touchPoint = [sender locationInView:self.view]; | 294 // CGPoint touchPoint = [sender locationInView:self.view]; |
| 294 // [_scene setMouseLocationFromLocationInView:touchPoint]; | 295 // [_scene setMouseLocationFromLocationInView:touchPoint]; |
| 295 // } | 296 // } |
| 296 // [_clientToHostProxy mouseAction:_scene.mousePosition | 297 // [_clientToHostProxy mouseAction:_scene.mousePosition |
| 297 // wheelDelta:webrtc::DesktopVector(0, 0) | 298 // wheelDelta:webrtc::DesktopVector(0, 0) |
| 298 // whichButton:1 | 299 // whichButton:1 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 otherGestureRecognizer == _edgeGesture) { | 401 otherGestureRecognizer == _edgeGesture) { |
| 401 return YES; | 402 return YES; |
| 402 } | 403 } |
| 403 // TODO(nicholss): If we return NO here, it dismisses the other reconizers. | 404 // 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 | 405 // As we add more types of reconizers, they need to be accounted for in the |
| 405 // above logic. | 406 // above logic. |
| 406 return NO; | 407 return NO; |
| 407 } | 408 } |
| 408 | 409 |
| 409 @end | 410 @end |
| OLD | NEW |