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

Side by Side Diff: remoting/client/direct_input_strategy.cc

Issue 2879743002: [CRD iOS] Hook the touch input feedback (Closed)
Patch Set: Use the ui task poster 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 #include "remoting/client/direct_input_strategy.h" 5 #include "remoting/client/direct_input_strategy.h"
6
6 #include "remoting/client/desktop_viewport.h" 7 #include "remoting/client/desktop_viewport.h"
7 8
8 namespace remoting { 9 namespace remoting {
9 10
11 namespace {
12
13 const float kTapFeedbackRadius = 25.f;
14 const float kLongPressFeedbackRadius = 55.f;
15
16 } // namespace
17
10 DirectInputStrategy::DirectInputStrategy() {} 18 DirectInputStrategy::DirectInputStrategy() {}
11 19
12 DirectInputStrategy::~DirectInputStrategy() {} 20 DirectInputStrategy::~DirectInputStrategy() {}
13 21
14 void DirectInputStrategy::HandlePinch(float pivot_x, 22 void DirectInputStrategy::HandlePinch(float pivot_x,
15 float pivot_y, 23 float pivot_y,
16 float scale, 24 float scale,
17 DesktopViewport* viewport) { 25 DesktopViewport* viewport) {
18 viewport->ScaleDesktop(pivot_x, pivot_y, scale); 26 viewport->ScaleDesktop(pivot_x, pivot_y, scale);
19 } 27 }
20 28
21 void DirectInputStrategy::HandlePan(float translation_x, 29 void DirectInputStrategy::HandlePan(float translation_x,
22 float translation_y, 30 float translation_y,
23 bool is_dragging_mode, 31 bool is_dragging_mode,
24 DesktopViewport* viewport) { 32 DesktopViewport* viewport) {
25 if (is_dragging_mode) { 33 if (is_dragging_mode) {
26 // If the user is dragging something, we should synchronize the movement 34 // If the user is dragging something, we should synchronize the movement
27 // with the object that the user is trying to move on the desktop, rather 35 // with the object that the user is trying to move on the desktop, rather
28 // than moving the desktop around. 36 // than moving the desktop around.
29 ViewMatrix::Vector2D viewport_movement = 37 ViewMatrix::Vector2D viewport_movement =
30 viewport->GetTransformation().Invert().MapVector( 38 viewport->GetTransformation().Invert().MapVector(
31 {translation_x, translation_y}); 39 {translation_x, translation_y});
32 viewport->MoveViewport(viewport_movement.x, viewport_movement.y); 40 viewport->MoveViewport(viewport_movement.x, viewport_movement.y);
33 return; 41 return;
34 } 42 }
35 43
36 viewport->MoveDesktop(translation_x, translation_y); 44 viewport->MoveDesktop(translation_x, translation_y);
37 } 45 }
38 46
39 void DirectInputStrategy::FindCursorPositions(float touch_x, 47 void DirectInputStrategy::TrackTouchInput(float touch_x,
40 float touch_y, 48 float touch_y,
41 const DesktopViewport& viewport, 49 const DesktopViewport& viewport) {
42 float* cursor_x,
43 float* cursor_y) {
44 ViewMatrix::Point cursor_position = 50 ViewMatrix::Point cursor_position =
45 viewport.GetTransformation().Invert().MapPoint({touch_x, touch_y}); 51 viewport.GetTransformation().Invert().MapPoint({touch_x, touch_y});
46 *cursor_x = cursor_position.x; 52 cursor_x_ = cursor_position.x;
47 *cursor_y = cursor_position.y; 53 cursor_y_ = cursor_position.y;
54 }
55
56 void DirectInputStrategy::GetCursorPosition(float* cursor_x,
57 float* cursor_y) const {
58 *cursor_x = cursor_x_;
59 *cursor_y = cursor_y_;
60 }
61
62 float DirectInputStrategy::GetFeedbackRadius(InputFeedbackType type) const {
63 switch (type) {
64 case InputFeedbackType::TAP_FEEDBACK:
65 return kTapFeedbackRadius;
66 case InputFeedbackType::LONG_PRESS_FEEDBACK:
67 return kLongPressFeedbackRadius;
68 default:
69 NOTREACHED();
70 }
48 } 71 }
49 72
50 bool DirectInputStrategy::IsCursorVisible() const { 73 bool DirectInputStrategy::IsCursorVisible() const {
51 return false; 74 return false;
52 } 75 }
53 76
54 } // namespace remoting 77 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698