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

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

Issue 2903623002: Moving input related classes to the input folder. (Closed)
Patch Set: Hide gesture code from nacl. 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
(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 bool DirectInputStrategy::TrackTouchInput(const ViewMatrix::Point& touch_point,
45 const DesktopViewport& viewport) {
46 ViewMatrix::Point new_position =
47 viewport.GetTransformation().Invert().MapPoint(touch_point);
48 if (!viewport.IsPointWithinDesktopBounds(new_position)) {
49 return false;
50 }
51 cursor_position_ = new_position;
52 return true;
53 }
54
55 ViewMatrix::Point DirectInputStrategy::GetCursorPosition() const {
56 return cursor_position_;
57 }
58
59 ViewMatrix::Vector2D DirectInputStrategy::MapScreenVectorToDesktop(
60 const ViewMatrix::Vector2D& delta,
61 const DesktopViewport& viewport) const {
62 return viewport.GetTransformation().Invert().MapVector(delta);
63 }
64
65 float DirectInputStrategy::GetFeedbackRadius(InputFeedbackType type) const {
66 switch (type) {
67 case InputFeedbackType::TAP_FEEDBACK:
68 return kTapFeedbackRadius;
69 case InputFeedbackType::DRAG_FEEDBACK:
70 return kDragFeedbackRadius;
71 }
72 NOTREACHED();
73 return 0.f;
74 }
75
76 bool DirectInputStrategy::IsCursorVisible() const {
77 return false;
78 }
79
80 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698