OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "remoting/client/ui/direct_input_strategy.h" | |
6 #include "remoting/client/ui/desktop_viewport.h" | |
7 | |
8 namespace remoting { | |
9 | |
10 namespace { | |
11 | |
12 const float kTapFeedbackRadius = 25.f; | |
13 const float kDragFeedbackRadius = 55.f; | |
14 | |
15 } // namespace | |
16 | |
17 DirectInputStrategy::DirectInputStrategy() {} | |
18 | |
19 DirectInputStrategy::~DirectInputStrategy() {} | |
20 | |
21 void DirectInputStrategy::HandleZoom(const ViewMatrix::Point& pivot, | |
22 float scale, | |
23 DesktopViewport* viewport) { | |
24 viewport->ScaleDesktop(pivot.x, pivot.y, scale); | |
25 } | |
26 | |
27 bool DirectInputStrategy::HandlePan(const ViewMatrix::Vector2D& translation, | |
28 Gesture simultaneous_gesture, | |
29 DesktopViewport* viewport) { | |
30 if (simultaneous_gesture == DRAG) { | |
31 // If the user is dragging something, we should synchronize the movement | |
32 // with the object that the user is trying to move on the desktop, rather | |
33 // than moving the desktop around. | |
34 ViewMatrix::Vector2D viewport_movement = | |
35 viewport->GetTransformation().Invert().MapVector(translation); | |
36 viewport->MoveViewport(viewport_movement.x, viewport_movement.y); | |
37 return false; | |
38 } | |
39 | |
40 viewport->MoveDesktop(translation.x, translation.y); | |
41 return false; | |
42 } | |
43 | |
44 void DirectInputStrategy::TrackTouchInput(const ViewMatrix::Point& touch_point, | |
45 const DesktopViewport& viewport) { | |
46 cursor_position_ = | |
47 viewport.GetTransformation().Invert().MapPoint(touch_point); | |
48 } | |
49 | |
50 ViewMatrix::Point DirectInputStrategy::GetCursorPosition() const { | |
51 return cursor_position_; | |
52 } | |
53 | |
54 ViewMatrix::Vector2D DirectInputStrategy::MapScreenVectorToDesktop( | |
55 const ViewMatrix::Vector2D& delta, | |
56 const DesktopViewport& viewport) const { | |
57 return viewport.GetTransformation().Invert().MapVector(delta); | |
58 } | |
59 | |
60 float DirectInputStrategy::GetFeedbackRadius(InputFeedbackType type) const { | |
61 switch (type) { | |
62 case InputFeedbackType::TAP_FEEDBACK: | |
63 return kTapFeedbackRadius; | |
64 case InputFeedbackType::DRAG_FEEDBACK: | |
65 return kDragFeedbackRadius; | |
66 } | |
67 NOTREACHED(); | |
68 return 0.f; | |
69 } | |
70 | |
71 bool DirectInputStrategy::IsCursorVisible() const { | |
72 return false; | |
73 } | |
74 | |
75 } // namespace remoting | |
OLD | NEW |