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/direct_input_strategy.cc

Issue 2879743002: [CRD iOS] Hook the touch input feedback (Closed)
Patch Set: Just use ViewMatrix::Point. No more out-pointers... 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(const ViewMatrix::Point& pivot,
15 float pivot_y,
16 float scale, 23 float scale,
17 DesktopViewport* viewport) { 24 DesktopViewport* viewport) {
18 viewport->ScaleDesktop(pivot_x, pivot_y, scale); 25 viewport->ScaleDesktop(pivot.x, pivot.y, scale);
19 } 26 }
20 27
21 void DirectInputStrategy::HandlePan(float translation_x, 28 void DirectInputStrategy::HandlePan(const ViewMatrix::Vector2D& translation,
22 float translation_y,
23 bool is_dragging_mode, 29 bool is_dragging_mode,
24 DesktopViewport* viewport) { 30 DesktopViewport* viewport) {
25 if (is_dragging_mode) { 31 if (is_dragging_mode) {
26 // If the user is dragging something, we should synchronize the movement 32 // 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 33 // with the object that the user is trying to move on the desktop, rather
28 // than moving the desktop around. 34 // than moving the desktop around.
29 ViewMatrix::Vector2D viewport_movement = 35 ViewMatrix::Vector2D viewport_movement =
30 viewport->GetTransformation().Invert().MapVector( 36 viewport->GetTransformation().Invert().MapVector(translation);
31 {translation_x, translation_y});
32 viewport->MoveViewport(viewport_movement.x, viewport_movement.y); 37 viewport->MoveViewport(viewport_movement.x, viewport_movement.y);
33 return; 38 return;
34 } 39 }
35 40
36 viewport->MoveDesktop(translation_x, translation_y); 41 viewport->MoveDesktop(translation.x, translation.y);
37 } 42 }
38 43
39 void DirectInputStrategy::FindCursorPositions(float touch_x, 44 void DirectInputStrategy::TrackTouchInput(const ViewMatrix::Point& touch_point,
40 float touch_y, 45 const DesktopViewport& viewport) {
41 const DesktopViewport& viewport, 46 cursor_position_ =
42 float* cursor_x, 47 viewport.GetTransformation().Invert().MapPoint(touch_point);
43 float* cursor_y) { 48 }
44 ViewMatrix::Point cursor_position = 49
45 viewport.GetTransformation().Invert().MapPoint({touch_x, touch_y}); 50 ViewMatrix::Point DirectInputStrategy::GetCursorPosition() const {
46 *cursor_x = cursor_position.x; 51 return cursor_position_;
47 *cursor_y = cursor_position.y; 52 }
53
54 float DirectInputStrategy::GetFeedbackRadius(InputFeedbackType type) const {
55 switch (type) {
56 case InputFeedbackType::TAP_FEEDBACK:
57 return kTapFeedbackRadius;
58 case InputFeedbackType::LONG_PRESS_FEEDBACK:
59 return kLongPressFeedbackRadius;
60 default:
61 NOTREACHED();
62 }
48 } 63 }
49 64
50 bool DirectInputStrategy::IsCursorVisible() const { 65 bool DirectInputStrategy::IsCursorVisible() const {
51 return false; 66 return false;
52 } 67 }
53 68
54 } // namespace remoting 69 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698