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