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/client/ios/client_gestures.h" | 9 #import "remoting/client/ios/client_gestures.h" |
10 | 10 |
11 @implementation ClientGestures | 11 @implementation ClientGestures |
12 | 12 |
13 - (id)initWithView:(UIView*)view { | 13 - (instancetype)initWithView:(UIView*)view |
14 viewport:(remoting::DesktopViewport*)vp { | |
15 _view = view; | |
16 _viewport = vp; | |
17 | |
14 _inputScheme = HostInputSchemeTouch; | 18 _inputScheme = HostInputSchemeTouch; |
15 | 19 |
16 _longPressRecognizer = [[UILongPressGestureRecognizer alloc] | 20 _longPressRecognizer = [[UILongPressGestureRecognizer alloc] |
17 initWithTarget:self | 21 initWithTarget:self |
18 action:@selector(longPressGestureTriggered:)]; | 22 action:@selector(longPressGestureTriggered:)]; |
19 _longPressRecognizer.delegate = self; | 23 _longPressRecognizer.delegate = self; |
20 [view addGestureRecognizer:_longPressRecognizer]; | 24 [view addGestureRecognizer:_longPressRecognizer]; |
21 | 25 |
22 _panRecognizer = [[UIPanGestureRecognizer alloc] | 26 _panRecognizer = [[UIPanGestureRecognizer alloc] |
23 initWithTarget:self | 27 initWithTarget:self |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 // Integreation with the original implementation will be done with the app | 96 // 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. | 97 // 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 | 98 // 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. | 99 // 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 | 100 // 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. | 101 // the implementation mixed in with the host controller and was a huge mess. |
98 | 102 |
99 // Resize the view of the desktop - Zoom in/out. This can occur during a Pan. | 103 // Resize the view of the desktop - Zoom in/out. This can occur during a Pan. |
100 - (IBAction)pinchGestureTriggered:(UIPinchGestureRecognizer*)sender { | 104 - (IBAction)pinchGestureTriggered:(UIPinchGestureRecognizer*)sender { |
101 // LOG_TRACE(INFO) << "pinchGestureTriggered"; | 105 // LOG_TRACE(INFO) << "pinchGestureTriggered"; |
102 // if ([sender state] == UIGestureRecognizerStateChanged) { | 106 if ([sender state] == UIGestureRecognizerStateChanged) { |
103 // [self applySceneChange:CGPointMake(0.0, 0.0) scaleBy:sender.scale]; | 107 CGPoint pivot = [sender locationInView:_view]; |
Yuwei
2017/05/03 05:52:35
I'm planning on creating a new C++ class to be sha
nicholss
2017/05/03 15:33:50
Note this class is copy/paste from the original ba
| |
104 // | 108 _viewport->ScaleDesktop(pivot.x, pivot.y, sender.scale); |
105 // sender.scale = 1.0; // reset scale so next iteration is a relative ratio | 109 |
106 // } | 110 sender.scale = 1.0; // reset scale so next iteration is a relative ratio |
111 } | |
107 } | 112 } |
108 | 113 |
109 - (IBAction)tapGestureTriggered:(UITapGestureRecognizer*)sender { | 114 - (IBAction)tapGestureTriggered:(UITapGestureRecognizer*)sender { |
110 // LOG_TRACE(INFO) << "tapGestureTriggered"; | 115 // LOG_TRACE(INFO) << "tapGestureTriggered"; |
111 // CGPoint touchPoint = [sender locationInView:self.view]; | 116 // CGPoint touchPoint = [sender locationInView:self.view]; |
112 // if ([_scene containsTouchPoint:touchPoint]) { | 117 // if ([_scene containsTouchPoint:touchPoint]) { |
113 // if (_inputScheme == HostInputSchemeTouch) { | 118 // if (_inputScheme == HostInputSchemeTouch) { |
114 // [_scene setMouseLocationFromLocationInView:touchPoint]; | 119 // [_scene setMouseLocationFromLocationInView:touchPoint]; |
115 // _circle.expandedRadius = 11.0f; | 120 // _circle.expandedRadius = 11.0f; |
116 // [_circle doExpandingAnimationAtLocation:[_scene mouseLocationInView]]; | 121 // [_circle doExpandingAnimationAtLocation:[_scene mouseLocationInView]]; |
117 // } | 122 // } |
118 // [Utility leftClickOn:_clientToHostProxy at:_scene.mousePosition]; | 123 // [Utility leftClickOn:_clientToHostProxy at:_scene.mousePosition]; |
119 // } | 124 // } |
120 } | 125 } |
121 | 126 |
122 // Change position of scene. This can occur during a pinch or long press. | 127 // Change position of scene. This can occur during a pinch or long press. |
123 // Or perform a Mouse Wheel Scroll. | 128 // Or perform a Mouse Wheel Scroll. |
129 // TODO(yuweih): The comment above doesn't seem right. Non-panning gestures | |
130 // should be moved out of this method. | |
124 - (IBAction)panGestureTriggered:(UIPanGestureRecognizer*)sender { | 131 - (IBAction)panGestureTriggered:(UIPanGestureRecognizer*)sender { |
132 // TODO(yuweih): Need deceleration animation, probably in another class. | |
133 if ([sender state] == UIGestureRecognizerStateChanged && | |
134 [sender numberOfTouches] == 1) { | |
135 CGPoint translation = [sender translationInView:_view]; | |
136 _viewport->MoveDesktop(translation.x, translation.y); | |
137 | |
138 // Reset translation so next iteration is relative | |
139 [sender setTranslation:CGPointZero inView:_view]; | |
140 } | |
141 | |
125 // LOG_TRACE(INFO) << "panGestureTriggered"; | 142 // LOG_TRACE(INFO) << "panGestureTriggered"; |
126 // CGPoint translation = [sender translationInView:self.view]; | 143 // CGPoint translation = [sender translationInView:self.view]; |
127 // // If we start with 2 touches, and the pinch gesture is not in progress | 144 // // If we start with 2 touches, and the pinch gesture is not in progress |
128 // yet, | 145 // yet, |
129 // // then disable it, so mouse scrolling and zoom do not occur at the same | 146 // // then disable it, so mouse scrolling and zoom do not occur at the same |
130 // // time. | 147 // // time. |
131 // if ([sender numberOfTouches] == 2 && | 148 // if ([sender numberOfTouches] == 2 && |
132 // [sender state] == UIGestureRecognizerStateBegan && | 149 // [sender state] == UIGestureRecognizerStateBegan && |
133 // !(_pinchRecognizer.state == UIGestureRecognizerStateBegan || | 150 // !(_pinchRecognizer.state == UIGestureRecognizerStateBegan || |
134 // _pinchRecognizer.state == UIGestureRecognizerStateChanged)) { | 151 // _pinchRecognizer.state == UIGestureRecognizerStateChanged)) { |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
330 otherGestureRecognizer == _edgeGesture) { | 347 otherGestureRecognizer == _edgeGesture) { |
331 return YES; | 348 return YES; |
332 } | 349 } |
333 // TODO(nicholss): If we return NO here, it dismisses the other reconizers. | 350 // 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 | 351 // As we add more types of reconizers, they need to be accounted for in the |
335 // above logic. | 352 // above logic. |
336 return NO; | 353 return NO; |
337 } | 354 } |
338 | 355 |
339 @end | 356 @end |
OLD | NEW |