Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: remoting/client/ios/client_gestures.mm

Issue 2869723007: [CRD iOS] Viewport fling animation (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/client/ios/client_gestures.h" 9 #import "remoting/client/ios/client_gestures.h"
10 #import "remoting/client/ios/session/remoting_client.h" 10 #import "remoting/client/ios/session/remoting_client.h"
(...skipping 15 matching lines...) Expand all
26 [view addGestureRecognizer:_longPressRecognizer]; 26 [view addGestureRecognizer:_longPressRecognizer];
27 27
28 _panRecognizer = [[UIPanGestureRecognizer alloc] 28 _panRecognizer = [[UIPanGestureRecognizer alloc]
29 initWithTarget:self 29 initWithTarget:self
30 action:@selector(panGestureTriggered:)]; 30 action:@selector(panGestureTriggered:)];
31 _panRecognizer.minimumNumberOfTouches = 1; 31 _panRecognizer.minimumNumberOfTouches = 1;
32 _panRecognizer.maximumNumberOfTouches = 2; 32 _panRecognizer.maximumNumberOfTouches = 2;
33 _panRecognizer.delegate = self; 33 _panRecognizer.delegate = self;
34 [view addGestureRecognizer:_panRecognizer]; 34 [view addGestureRecognizer:_panRecognizer];
35 35
36 _flingRecognizer = [[UIPanGestureRecognizer alloc]
37 initWithTarget:self
38 action:@selector(flingGestureTriggered:)];
39 _flingRecognizer.minimumNumberOfTouches = 1;
40 _flingRecognizer.maximumNumberOfTouches = 1;
41 _flingRecognizer.delegate = self;
42 [view addGestureRecognizer:_flingRecognizer];
43
36 _threeFingerPanRecognizer = [[UIPanGestureRecognizer alloc] 44 _threeFingerPanRecognizer = [[UIPanGestureRecognizer alloc]
37 initWithTarget:self 45 initWithTarget:self
38 action:@selector(threeFingerPanGestureTriggered:)]; 46 action:@selector(threeFingerPanGestureTriggered:)];
39 _threeFingerPanRecognizer.minimumNumberOfTouches = 3; 47 _threeFingerPanRecognizer.minimumNumberOfTouches = 3;
40 _threeFingerPanRecognizer.maximumNumberOfTouches = 3; 48 _threeFingerPanRecognizer.maximumNumberOfTouches = 3;
41 _threeFingerPanRecognizer.delegate = self; 49 _threeFingerPanRecognizer.delegate = self;
42 [view addGestureRecognizer:_threeFingerPanRecognizer]; 50 [view addGestureRecognizer:_threeFingerPanRecognizer];
43 51
44 _pinchRecognizer = [[UIPinchGestureRecognizer alloc] 52 _pinchRecognizer = [[UIPinchGestureRecognizer alloc]
45 initWithTarget:self 53 initWithTarget:self
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } 121 }
114 } 122 }
115 123
116 - (IBAction)tapGestureTriggered:(UITapGestureRecognizer*)sender { 124 - (IBAction)tapGestureTriggered:(UITapGestureRecognizer*)sender {
117 CGPoint touchPoint = [sender locationInView:_view]; 125 CGPoint touchPoint = [sender locationInView:_view];
118 _client.gestureInterpreter->Tap(touchPoint.x, touchPoint.y); 126 _client.gestureInterpreter->Tap(touchPoint.x, touchPoint.y);
119 } 127 }
120 128
121 // Change position of scene. This can occur during a pinch or long press. 129 // Change position of scene. This can occur during a pinch or long press.
122 // Or perform a Mouse Wheel Scroll. 130 // Or perform a Mouse Wheel Scroll.
123 // TODO(yuweih): The comment above doesn't seem right. Non-panning gestures
124 // should be moved out of this method.
125 - (IBAction)panGestureTriggered:(UIPanGestureRecognizer*)sender { 131 - (IBAction)panGestureTriggered:(UIPanGestureRecognizer*)sender {
126 // TODO(yuweih): Need deceleration animation, probably in another class. 132 if ([sender state] == UIGestureRecognizerStateChanged) {
Yuwei 2017/05/10 06:53:03 Removed the |numberOfTouches| check since it seems
127 if ([sender state] == UIGestureRecognizerStateChanged &&
128 [sender numberOfTouches] == 1) {
129 CGPoint translation = [sender translationInView:_view]; 133 CGPoint translation = [sender translationInView:_view];
130 _client.gestureInterpreter->Pan(translation.x, translation.y); 134 _client.gestureInterpreter->Pan(translation.x, translation.y);
131 135
132 // Reset translation so next iteration is relative 136 // Reset translation so next iteration is relative
133 [sender setTranslation:CGPointZero inView:_view]; 137 [sender setTranslation:CGPointZero inView:_view];
134 } 138 }
135 139
136 // LOG_TRACE(INFO) << "panGestureTriggered"; 140 // LOG_TRACE(INFO) << "panGestureTriggered";
137 // CGPoint translation = [sender translationInView:self.view]; 141 // CGPoint translation = [sender translationInView:self.view];
138 // // If we start with 2 touches, and the pinch gesture is not in progress 142 // // If we start with 2 touches, and the pinch gesture is not in progress
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 // 225 //
222 // // Reset translation so next iteration is relative. Wait until a changed 226 // // Reset translation so next iteration is relative. Wait until a changed
223 // // event in order to also capture the portion of the translation that 227 // // event in order to also capture the portion of the translation that
224 // occurred 228 // occurred
225 // // between the Began and Changed States. 229 // // between the Began and Changed States.
226 // if ([sender state] == UIGestureRecognizerStateChanged) { 230 // if ([sender state] == UIGestureRecognizerStateChanged) {
227 // [sender setTranslation:CGPointZero inView:self.view]; 231 // [sender setTranslation:CGPointZero inView:self.view];
228 // } 232 // }
229 } 233 }
230 234
235 // Do fling on the viewport. This will happen at the end of the one-finger
236 // panning.
237 - (IBAction)flingGestureTriggered:(UIPanGestureRecognizer*)sender {
238 if ([sender state] == UIGestureRecognizerStateEnded) {
239 CGPoint velocity = [sender velocityInView:_view];
240 _client.gestureInterpreter->OneFingerFling(velocity.x, velocity.y);
241 }
242 }
243
231 // Click-Drag mouse operation. This can occur during a Pan. 244 // Click-Drag mouse operation. This can occur during a Pan.
232 - (IBAction)longPressGestureTriggered:(UILongPressGestureRecognizer*)sender { 245 - (IBAction)longPressGestureTriggered:(UILongPressGestureRecognizer*)sender {
233 CGPoint touchPoint = [sender locationInView:_view]; 246 CGPoint touchPoint = [sender locationInView:_view];
234 remoting::GestureInterpreter::GestureState state; 247 remoting::GestureInterpreter::GestureState state;
235 switch ([sender state]) { 248 switch ([sender state]) {
236 case UIGestureRecognizerStateBegan: 249 case UIGestureRecognizerStateBegan:
237 state = remoting::GestureInterpreter::GESTURE_BEGAN; 250 state = remoting::GestureInterpreter::GESTURE_BEGAN;
238 break; 251 break;
239 case UIGestureRecognizerStateChanged: 252 case UIGestureRecognizerStateChanged:
240 state = remoting::GestureInterpreter::GESTURE_CHANGED; 253 state = remoting::GestureInterpreter::GESTURE_CHANGED;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 shouldRecognizeSimultaneouslyWithGestureRecognizer: 338 shouldRecognizeSimultaneouslyWithGestureRecognizer:
326 (UIGestureRecognizer*)otherGestureRecognizer { 339 (UIGestureRecognizer*)otherGestureRecognizer {
327 if (gestureRecognizer == _pinchRecognizer || 340 if (gestureRecognizer == _pinchRecognizer ||
328 (gestureRecognizer == _panRecognizer)) { 341 (gestureRecognizer == _panRecognizer)) {
329 if (otherGestureRecognizer == _pinchRecognizer || 342 if (otherGestureRecognizer == _pinchRecognizer ||
330 otherGestureRecognizer == _panRecognizer) { 343 otherGestureRecognizer == _panRecognizer) {
331 return YES; 344 return YES;
332 } 345 }
333 } 346 }
334 347
348 if (gestureRecognizer == _flingRecognizer ||
349 (gestureRecognizer == _panRecognizer)) {
350 if (otherGestureRecognizer == _flingRecognizer ||
351 otherGestureRecognizer == _panRecognizer) {
352 return YES;
353 }
354 }
355
335 if (gestureRecognizer == _longPressRecognizer || 356 if (gestureRecognizer == _longPressRecognizer ||
336 gestureRecognizer == _panRecognizer) { 357 gestureRecognizer == _panRecognizer) {
337 if (otherGestureRecognizer == _longPressRecognizer || 358 if (otherGestureRecognizer == _longPressRecognizer ||
338 otherGestureRecognizer == _panRecognizer) { 359 otherGestureRecognizer == _panRecognizer) {
339 return YES; 360 return YES;
340 } 361 }
341 } 362 }
342 363
343 if (gestureRecognizer == _twoFingerTapRecognizer && 364 if (gestureRecognizer == _twoFingerTapRecognizer &&
344 otherGestureRecognizer == _longPressRecognizer) { 365 otherGestureRecognizer == _longPressRecognizer) {
345 return YES; 366 return YES;
346 } 367 }
347 368
348 if (gestureRecognizer == _panRecognizer && 369 if (gestureRecognizer == _panRecognizer &&
349 otherGestureRecognizer == _edgeGesture) { 370 otherGestureRecognizer == _edgeGesture) {
350 return YES; 371 return YES;
351 } 372 }
352 // TODO(nicholss): If we return NO here, it dismisses the other reconizers. 373 // TODO(nicholss): If we return NO here, it dismisses the other reconizers.
353 // As we add more types of reconizers, they need to be accounted for in the 374 // As we add more types of reconizers, they need to be accounted for in the
354 // above logic. 375 // above logic.
355 return NO; 376 return NO;
356 } 377 }
357 378
358 @end 379 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698