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

Unified Diff: remoting/client/direct_input_strategy.cc

Issue 2879743002: [CRD iOS] Hook the touch input feedback (Closed)
Patch Set: Just use ViewMatrix::Point. No more out-pointers... 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 side-by-side diff with in-line comments
Download patch
Index: remoting/client/direct_input_strategy.cc
diff --git a/remoting/client/direct_input_strategy.cc b/remoting/client/direct_input_strategy.cc
index 13d54faa9d881cafbb5e6ce6ca6fd546530fae15..f3d62b9782fb2c8493758af591e9be69d210bb0f 100644
--- a/remoting/client/direct_input_strategy.cc
+++ b/remoting/client/direct_input_strategy.cc
@@ -3,23 +3,29 @@
// found in the LICENSE file.
#include "remoting/client/direct_input_strategy.h"
+
#include "remoting/client/desktop_viewport.h"
namespace remoting {
+namespace {
+
+const float kTapFeedbackRadius = 25.f;
+const float kLongPressFeedbackRadius = 55.f;
+
+} // namespace
+
DirectInputStrategy::DirectInputStrategy() {}
DirectInputStrategy::~DirectInputStrategy() {}
-void DirectInputStrategy::HandlePinch(float pivot_x,
- float pivot_y,
+void DirectInputStrategy::HandlePinch(const ViewMatrix::Point& pivot,
float scale,
DesktopViewport* viewport) {
- viewport->ScaleDesktop(pivot_x, pivot_y, scale);
+ viewport->ScaleDesktop(pivot.x, pivot.y, scale);
}
-void DirectInputStrategy::HandlePan(float translation_x,
- float translation_y,
+void DirectInputStrategy::HandlePan(const ViewMatrix::Vector2D& translation,
bool is_dragging_mode,
DesktopViewport* viewport) {
if (is_dragging_mode) {
@@ -27,24 +33,33 @@ void DirectInputStrategy::HandlePan(float translation_x,
// with the object that the user is trying to move on the desktop, rather
// than moving the desktop around.
ViewMatrix::Vector2D viewport_movement =
- viewport->GetTransformation().Invert().MapVector(
- {translation_x, translation_y});
+ viewport->GetTransformation().Invert().MapVector(translation);
viewport->MoveViewport(viewport_movement.x, viewport_movement.y);
return;
}
- viewport->MoveDesktop(translation_x, translation_y);
+ viewport->MoveDesktop(translation.x, translation.y);
}
-void DirectInputStrategy::FindCursorPositions(float touch_x,
- float touch_y,
- const DesktopViewport& viewport,
- float* cursor_x,
- float* cursor_y) {
- ViewMatrix::Point cursor_position =
- viewport.GetTransformation().Invert().MapPoint({touch_x, touch_y});
- *cursor_x = cursor_position.x;
- *cursor_y = cursor_position.y;
+void DirectInputStrategy::TrackTouchInput(const ViewMatrix::Point& touch_point,
+ const DesktopViewport& viewport) {
+ cursor_position_ =
+ viewport.GetTransformation().Invert().MapPoint(touch_point);
+}
+
+ViewMatrix::Point DirectInputStrategy::GetCursorPosition() const {
+ return cursor_position_;
+}
+
+float DirectInputStrategy::GetFeedbackRadius(InputFeedbackType type) const {
+ switch (type) {
+ case InputFeedbackType::TAP_FEEDBACK:
+ return kTapFeedbackRadius;
+ case InputFeedbackType::LONG_PRESS_FEEDBACK:
+ return kLongPressFeedbackRadius;
+ default:
+ NOTREACHED();
+ }
}
bool DirectInputStrategy::IsCursorVisible() const {

Powered by Google App Engine
This is Rietveld 408576698