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

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

Issue 2869723007: [CRD iOS] Viewport fling animation (Closed)
Patch Set: Merge branch 'master' into feat-fling-animation 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
« no previous file with comments | « remoting/ios/client_gestures.h ('k') | remoting/ios/display/gl_display_handler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/ios/client_gestures.h" 9 #import "remoting/ios/client_gestures.h"
10 #import "remoting/ios/session/remoting_client.h" 10 #import "remoting/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) {
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 if (velocity.x != 0 || velocity.y != 0) {
241 _client.gestureInterpreter->OneFingerFling(velocity.x, velocity.y);
242 }
243 }
244 }
245
231 // Click-Drag mouse operation. This can occur during a Pan. 246 // Click-Drag mouse operation. This can occur during a Pan.
232 - (IBAction)longPressGestureTriggered:(UILongPressGestureRecognizer*)sender { 247 - (IBAction)longPressGestureTriggered:(UILongPressGestureRecognizer*)sender {
233 CGPoint touchPoint = [sender locationInView:_view]; 248 CGPoint touchPoint = [sender locationInView:_view];
234 remoting::GestureInterpreter::GestureState state; 249 remoting::GestureInterpreter::GestureState state;
235 switch ([sender state]) { 250 switch ([sender state]) {
236 case UIGestureRecognizerStateBegan: 251 case UIGestureRecognizerStateBegan:
237 state = remoting::GestureInterpreter::GESTURE_BEGAN; 252 state = remoting::GestureInterpreter::GESTURE_BEGAN;
238 break; 253 break;
239 case UIGestureRecognizerStateChanged: 254 case UIGestureRecognizerStateChanged:
240 state = remoting::GestureInterpreter::GESTURE_CHANGED; 255 state = remoting::GestureInterpreter::GESTURE_CHANGED;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 shouldRecognizeSimultaneouslyWithGestureRecognizer: 340 shouldRecognizeSimultaneouslyWithGestureRecognizer:
326 (UIGestureRecognizer*)otherGestureRecognizer { 341 (UIGestureRecognizer*)otherGestureRecognizer {
327 if (gestureRecognizer == _pinchRecognizer || 342 if (gestureRecognizer == _pinchRecognizer ||
328 (gestureRecognizer == _panRecognizer)) { 343 (gestureRecognizer == _panRecognizer)) {
329 if (otherGestureRecognizer == _pinchRecognizer || 344 if (otherGestureRecognizer == _pinchRecognizer ||
330 otherGestureRecognizer == _panRecognizer) { 345 otherGestureRecognizer == _panRecognizer) {
331 return YES; 346 return YES;
332 } 347 }
333 } 348 }
334 349
350 if (gestureRecognizer == _flingRecognizer ||
351 (gestureRecognizer == _panRecognizer)) {
352 if (otherGestureRecognizer == _flingRecognizer ||
353 otherGestureRecognizer == _panRecognizer) {
354 return YES;
355 }
356 }
357
335 if (gestureRecognizer == _longPressRecognizer || 358 if (gestureRecognizer == _longPressRecognizer ||
336 gestureRecognizer == _panRecognizer) { 359 gestureRecognizer == _panRecognizer) {
337 if (otherGestureRecognizer == _longPressRecognizer || 360 if (otherGestureRecognizer == _longPressRecognizer ||
338 otherGestureRecognizer == _panRecognizer) { 361 otherGestureRecognizer == _panRecognizer) {
339 return YES; 362 return YES;
340 } 363 }
341 } 364 }
342 365
343 if (gestureRecognizer == _twoFingerTapRecognizer && 366 if (gestureRecognizer == _twoFingerTapRecognizer &&
344 otherGestureRecognizer == _longPressRecognizer) { 367 otherGestureRecognizer == _longPressRecognizer) {
345 return YES; 368 return YES;
346 } 369 }
347 370
348 if (gestureRecognizer == _panRecognizer && 371 if (gestureRecognizer == _panRecognizer &&
349 otherGestureRecognizer == _edgeGesture) { 372 otherGestureRecognizer == _edgeGesture) {
350 return YES; 373 return YES;
351 } 374 }
352 // TODO(nicholss): If we return NO here, it dismisses the other reconizers. 375 // 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 376 // As we add more types of reconizers, they need to be accounted for in the
354 // above logic. 377 // above logic.
355 return NO; 378 return NO;
356 } 379 }
357 380
358 @end 381 @end
OLDNEW
« no previous file with comments | « remoting/ios/client_gestures.h ('k') | remoting/ios/display/gl_display_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698