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

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

Issue 2879743002: [CRD iOS] Hook the touch input feedback (Closed)
Patch Set: Fix dependency and race condition 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
« no previous file with comments | « remoting/client/ui/direct_input_strategy.h ('k') | remoting/client/ui/gesture_interpreter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/ui/direct_input_strategy.h" 5 #include "remoting/client/ui/direct_input_strategy.h"
6 #include "remoting/client/ui/desktop_viewport.h" 6 #include "remoting/client/ui/desktop_viewport.h"
7 7
8 namespace remoting { 8 namespace remoting {
9 9
10 namespace {
11
12 const float kTapFeedbackRadius = 25.f;
13 const float kLongPressFeedbackRadius = 55.f;
14
15 } // namespace
16
10 DirectInputStrategy::DirectInputStrategy() {} 17 DirectInputStrategy::DirectInputStrategy() {}
11 18
12 DirectInputStrategy::~DirectInputStrategy() {} 19 DirectInputStrategy::~DirectInputStrategy() {}
13 20
14 void DirectInputStrategy::HandlePinch(float pivot_x, 21 void DirectInputStrategy::HandlePinch(const ViewMatrix::Point& pivot,
15 float pivot_y,
16 float scale, 22 float scale,
17 DesktopViewport* viewport) { 23 DesktopViewport* viewport) {
18 viewport->ScaleDesktop(pivot_x, pivot_y, scale); 24 viewport->ScaleDesktop(pivot.x, pivot.y, scale);
19 } 25 }
20 26
21 void DirectInputStrategy::HandlePan(float translation_x, 27 void DirectInputStrategy::HandlePan(const ViewMatrix::Vector2D& translation,
22 float translation_y,
23 bool is_dragging_mode, 28 bool is_dragging_mode,
24 DesktopViewport* viewport) { 29 DesktopViewport* viewport) {
25 if (is_dragging_mode) { 30 if (is_dragging_mode) {
26 // If the user is dragging something, we should synchronize the movement 31 // 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 32 // with the object that the user is trying to move on the desktop, rather
28 // than moving the desktop around. 33 // than moving the desktop around.
29 ViewMatrix::Vector2D viewport_movement = 34 ViewMatrix::Vector2D viewport_movement =
30 viewport->GetTransformation().Invert().MapVector( 35 viewport->GetTransformation().Invert().MapVector(translation);
31 {translation_x, translation_y});
32 viewport->MoveViewport(viewport_movement.x, viewport_movement.y); 36 viewport->MoveViewport(viewport_movement.x, viewport_movement.y);
33 return; 37 return;
34 } 38 }
35 39
36 viewport->MoveDesktop(translation_x, translation_y); 40 viewport->MoveDesktop(translation.x, translation.y);
37 } 41 }
38 42
39 void DirectInputStrategy::FindCursorPositions(float touch_x, 43 void DirectInputStrategy::TrackTouchInput(const ViewMatrix::Point& touch_point,
40 float touch_y, 44 const DesktopViewport& viewport) {
41 const DesktopViewport& viewport, 45 cursor_position_ =
42 float* cursor_x, 46 viewport.GetTransformation().Invert().MapPoint(touch_point);
43 float* cursor_y) { 47 }
44 ViewMatrix::Point cursor_position = 48
45 viewport.GetTransformation().Invert().MapPoint({touch_x, touch_y}); 49 ViewMatrix::Point DirectInputStrategy::GetCursorPosition() const {
46 *cursor_x = cursor_position.x; 50 return cursor_position_;
47 *cursor_y = cursor_position.y; 51 }
52
53 float DirectInputStrategy::GetFeedbackRadius(InputFeedbackType type) const {
54 switch (type) {
55 case InputFeedbackType::TAP_FEEDBACK:
56 return kTapFeedbackRadius;
57 case InputFeedbackType::LONG_PRESS_FEEDBACK:
58 return kLongPressFeedbackRadius;
59 }
60 NOTREACHED();
61 return 0.f;
48 } 62 }
49 63
50 bool DirectInputStrategy::IsCursorVisible() const { 64 bool DirectInputStrategy::IsCursorVisible() const {
51 return false; 65 return false;
52 } 66 }
53 67
54 } // namespace remoting 68 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/ui/direct_input_strategy.h ('k') | remoting/client/ui/gesture_interpreter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698