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

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

Issue 2903623002: Moving input related classes to the input folder. (Closed)
Patch Set: Working the build files to pull in the correct imports as needed. 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/trackpad_input_strategy.h"
6
7 #include "remoting/client/ui/desktop_viewport.h"
8
9 namespace remoting {
10
11 namespace {
12
13 // Trackpad mode does not need tap feedback.
14 const float kTapFeedbackRadius = 0.f;
15
16 const float kDragFeedbackRadius = 8.f;
17
18 } // namespace
19
20 TrackpadInputStrategy::TrackpadInputStrategy(const DesktopViewport& viewport)
21 : cursor_position_(viewport.GetViewportCenter()) {}
22
23 TrackpadInputStrategy::~TrackpadInputStrategy() {}
24
25 void TrackpadInputStrategy::HandleZoom(const ViewMatrix::Point& pivot,
26 float scale,
27 DesktopViewport* viewport) {
28 // The cursor position is the pivot point.
29 ViewMatrix::Point cursor_pivot =
30 viewport->GetTransformation().MapPoint(cursor_position_);
31 viewport->ScaleDesktop(cursor_pivot.x, cursor_pivot.y, scale);
32
33 // Keep the cursor on focus.
34 viewport->SetViewportCenter(cursor_position_.x, cursor_position_.y);
35 }
36
37 bool TrackpadInputStrategy::HandlePan(const ViewMatrix::Vector2D& translation,
38 Gesture simultaneous_gesture,
39 DesktopViewport* viewport) {
40 if (simultaneous_gesture == ZOOM) {
41 // Don't move the cursor if the user is scaling the viewport.
42 return false;
43 }
44 ViewMatrix::Vector2D translation_on_desktop =
45 viewport->GetTransformation().Invert().MapVector(translation);
46
47 cursor_position_.x += translation_on_desktop.x;
48 cursor_position_.y += translation_on_desktop.y;
49
50 cursor_position_ = viewport->ConstrainPointToDesktop(cursor_position_);
51
52 // Keep the cursor on focus.
53 viewport->SetViewportCenter(cursor_position_.x, cursor_position_.y);
54 return true;
55 }
56
57 void TrackpadInputStrategy::TrackTouchInput(
58 const ViewMatrix::Point& touch_point,
59 const DesktopViewport& viewport) {
60 // Do nothing. The cursor position is independent of the touch position.
61 }
62
63 ViewMatrix::Point TrackpadInputStrategy::GetCursorPosition() const {
64 return cursor_position_;
65 }
66
67 ViewMatrix::Vector2D TrackpadInputStrategy::MapScreenVectorToDesktop(
68 const ViewMatrix::Vector2D& delta,
69 const DesktopViewport& viewport) const {
70 // No conversion is needed for trackpad mode.
71 return delta;
72 }
73
74 float TrackpadInputStrategy::GetFeedbackRadius(InputFeedbackType type) const {
75 switch (type) {
76 case InputFeedbackType::TAP_FEEDBACK:
77 return kTapFeedbackRadius;
78 case InputFeedbackType::DRAG_FEEDBACK:
79 return kDragFeedbackRadius;
80 }
81 NOTREACHED();
82 return 0.f;
83 }
84
85 bool TrackpadInputStrategy::IsCursorVisible() const {
86 return true;
87 }
88 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698