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

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

Issue 2856933007: [Remoting iOS] Basic viewport manipulation support (Closed)
Patch Set: Resolve Feedbacks 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 10
11 #include "remoting/client/gesture_interpreter.h"
nicholss 2017/05/03 22:47:35 style says #imports before #includes per level, j
Yuwei 2017/05/04 00:28:07 Done.
12
13 #import "remoting/client/ios/session/remoting_client.h"
14
11 @implementation ClientGestures 15 @implementation ClientGestures
12 16
13 - (id)initWithView:(UIView*)view { 17 - (instancetype)initWithView:(UIView*)view client:(RemotingClient*)client {
18 _view = view;
19 _client = client;
20
14 _inputScheme = HostInputSchemeTouch; 21 _inputScheme = HostInputSchemeTouch;
15 22
16 _longPressRecognizer = [[UILongPressGestureRecognizer alloc] 23 _longPressRecognizer = [[UILongPressGestureRecognizer alloc]
17 initWithTarget:self 24 initWithTarget:self
18 action:@selector(longPressGestureTriggered:)]; 25 action:@selector(longPressGestureTriggered:)];
19 _longPressRecognizer.delegate = self; 26 _longPressRecognizer.delegate = self;
20 [view addGestureRecognizer:_longPressRecognizer]; 27 [view addGestureRecognizer:_longPressRecognizer];
21 28
22 _panRecognizer = [[UIPanGestureRecognizer alloc] 29 _panRecognizer = [[UIPanGestureRecognizer alloc]
23 initWithTarget:self 30 initWithTarget:self
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 // Integreation with the original implementation will be done with the app 99 // Integreation with the original implementation will be done with the app
93 // is able to run to the point of interaction and debugging can happen. 100 // is able to run to the point of interaction and debugging can happen.
94 // I would prefer to leave this here rather than deleting because it is close 101 // I would prefer to leave this here rather than deleting because it is close
95 // to the implementation that will be used client gestures integration. 102 // to the implementation that will be used client gestures integration.
96 // This is a new class that was derived from the original source which had 103 // This is a new class that was derived from the original source which had
97 // the implementation mixed in with the host controller and was a huge mess. 104 // the implementation mixed in with the host controller and was a huge mess.
98 105
99 // Resize the view of the desktop - Zoom in/out. This can occur during a Pan. 106 // Resize the view of the desktop - Zoom in/out. This can occur during a Pan.
100 - (IBAction)pinchGestureTriggered:(UIPinchGestureRecognizer*)sender { 107 - (IBAction)pinchGestureTriggered:(UIPinchGestureRecognizer*)sender {
101 // LOG_TRACE(INFO) << "pinchGestureTriggered"; 108 // LOG_TRACE(INFO) << "pinchGestureTriggered";
102 // if ([sender state] == UIGestureRecognizerStateChanged) { 109 if ([sender state] == UIGestureRecognizerStateChanged) {
103 // [self applySceneChange:CGPointMake(0.0, 0.0) scaleBy:sender.scale]; 110 CGPoint pivot = [sender locationInView:_view];
104 // 111 _client.gestureInterpreter->Pinch(pivot.x, pivot.y, sender.scale);
105 // sender.scale = 1.0; // reset scale so next iteration is a relative ratio 112
106 // } 113 sender.scale = 1.0; // reset scale so next iteration is a relative ratio
114 }
107 } 115 }
108 116
109 - (IBAction)tapGestureTriggered:(UITapGestureRecognizer*)sender { 117 - (IBAction)tapGestureTriggered:(UITapGestureRecognizer*)sender {
110 // LOG_TRACE(INFO) << "tapGestureTriggered"; 118 // LOG_TRACE(INFO) << "tapGestureTriggered";
111 // CGPoint touchPoint = [sender locationInView:self.view]; 119 // CGPoint touchPoint = [sender locationInView:self.view];
112 // if ([_scene containsTouchPoint:touchPoint]) { 120 // if ([_scene containsTouchPoint:touchPoint]) {
113 // if (_inputScheme == HostInputSchemeTouch) { 121 // if (_inputScheme == HostInputSchemeTouch) {
114 // [_scene setMouseLocationFromLocationInView:touchPoint]; 122 // [_scene setMouseLocationFromLocationInView:touchPoint];
115 // _circle.expandedRadius = 11.0f; 123 // _circle.expandedRadius = 11.0f;
116 // [_circle doExpandingAnimationAtLocation:[_scene mouseLocationInView]]; 124 // [_circle doExpandingAnimationAtLocation:[_scene mouseLocationInView]];
117 // } 125 // }
118 // [Utility leftClickOn:_clientToHostProxy at:_scene.mousePosition]; 126 // [Utility leftClickOn:_clientToHostProxy at:_scene.mousePosition];
119 // } 127 // }
120 } 128 }
121 129
122 // Change position of scene. This can occur during a pinch or long press. 130 // Change position of scene. This can occur during a pinch or long press.
123 // Or perform a Mouse Wheel Scroll. 131 // Or perform a Mouse Wheel Scroll.
132 // TODO(yuweih): The comment above doesn't seem right. Non-panning gestures
133 // should be moved out of this method.
124 - (IBAction)panGestureTriggered:(UIPanGestureRecognizer*)sender { 134 - (IBAction)panGestureTriggered:(UIPanGestureRecognizer*)sender {
135 // TODO(yuweih): Need deceleration animation, probably in another class.
136 if ([sender state] == UIGestureRecognizerStateChanged &&
137 [sender numberOfTouches] == 1) {
138 CGPoint translation = [sender translationInView:_view];
139 _client.gestureInterpreter->Pan(translation.x, translation.y);
140
141 // Reset translation so next iteration is relative
142 [sender setTranslation:CGPointZero inView:_view];
143 }
144
125 // LOG_TRACE(INFO) << "panGestureTriggered"; 145 // LOG_TRACE(INFO) << "panGestureTriggered";
126 // CGPoint translation = [sender translationInView:self.view]; 146 // CGPoint translation = [sender translationInView:self.view];
127 // // If we start with 2 touches, and the pinch gesture is not in progress 147 // // If we start with 2 touches, and the pinch gesture is not in progress
128 // yet, 148 // yet,
129 // // then disable it, so mouse scrolling and zoom do not occur at the same 149 // // then disable it, so mouse scrolling and zoom do not occur at the same
130 // // time. 150 // // time.
131 // if ([sender numberOfTouches] == 2 && 151 // if ([sender numberOfTouches] == 2 &&
132 // [sender state] == UIGestureRecognizerStateBegan && 152 // [sender state] == UIGestureRecognizerStateBegan &&
133 // !(_pinchRecognizer.state == UIGestureRecognizerStateBegan || 153 // !(_pinchRecognizer.state == UIGestureRecognizerStateBegan ||
134 // _pinchRecognizer.state == UIGestureRecognizerStateChanged)) { 154 // _pinchRecognizer.state == UIGestureRecognizerStateChanged)) {
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 otherGestureRecognizer == _edgeGesture) { 350 otherGestureRecognizer == _edgeGesture) {
331 return YES; 351 return YES;
332 } 352 }
333 // TODO(nicholss): If we return NO here, it dismisses the other reconizers. 353 // TODO(nicholss): If we return NO here, it dismisses the other reconizers.
334 // As we add more types of reconizers, they need to be accounted for in the 354 // As we add more types of reconizers, they need to be accounted for in the
335 // above logic. 355 // above logic.
336 return NO; 356 return NO;
337 } 357 }
338 358
339 @end 359 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698