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

Unified Diff: remoting/client/ui/trackpad_input_strategy.cc

Issue 2891603002: [CRD iOS] Trackpad Input Mode (Closed)
Patch Set: Fix 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
« no previous file with comments | « remoting/client/ui/trackpad_input_strategy.h ('k') | remoting/ios/app/host_view_controller.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/client/ui/trackpad_input_strategy.cc
diff --git a/remoting/client/ui/trackpad_input_strategy.cc b/remoting/client/ui/trackpad_input_strategy.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f2f5719eb9858db3149690378ea07dc848721d35
--- /dev/null
+++ b/remoting/client/ui/trackpad_input_strategy.cc
@@ -0,0 +1,88 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "remoting/client/ui/trackpad_input_strategy.h"
+
+#include "remoting/client/ui/desktop_viewport.h"
+
+namespace remoting {
+
+namespace {
+
+// Trackpad mode does not need tap feedback.
+const float kTapFeedbackRadius = 0.f;
+
+const float kDragFeedbackRadius = 8.f;
+
+} // namespace
+
+TrackpadInputStrategy::TrackpadInputStrategy(const DesktopViewport& viewport)
+ : cursor_position_(viewport.GetViewportCenter()) {}
+
+TrackpadInputStrategy::~TrackpadInputStrategy() {}
+
+void TrackpadInputStrategy::HandleZoom(const ViewMatrix::Point& pivot,
+ float scale,
+ DesktopViewport* viewport) {
+ // The cursor position is the pivot point.
+ ViewMatrix::Point cursor_pivot =
+ viewport->GetTransformation().MapPoint(cursor_position_);
+ viewport->ScaleDesktop(cursor_pivot.x, cursor_pivot.y, scale);
+
+ // Keep the cursor on focus.
+ viewport->SetViewportCenter(cursor_position_.x, cursor_position_.y);
+}
+
+bool TrackpadInputStrategy::HandlePan(const ViewMatrix::Vector2D& translation,
+ Gesture simultaneous_gesture,
+ DesktopViewport* viewport) {
+ if (simultaneous_gesture == ZOOM) {
+ // Don't move the cursor if the user is scaling the viewport.
+ return false;
+ }
+ ViewMatrix::Vector2D translation_on_desktop =
+ viewport->GetTransformation().Invert().MapVector(translation);
+
+ cursor_position_.x += translation_on_desktop.x;
+ cursor_position_.y += translation_on_desktop.y;
+
+ cursor_position_ = viewport->ConstrainPointToDesktop(cursor_position_);
+
+ // Keep the cursor on focus.
+ viewport->SetViewportCenter(cursor_position_.x, cursor_position_.y);
+ return true;
+}
+
+void TrackpadInputStrategy::TrackTouchInput(
+ const ViewMatrix::Point& touch_point,
+ const DesktopViewport& viewport) {
+ // Do nothing. The cursor position is independent of the touch position.
+}
+
+ViewMatrix::Point TrackpadInputStrategy::GetCursorPosition() const {
+ return cursor_position_;
+}
+
+ViewMatrix::Vector2D TrackpadInputStrategy::MapScreenVectorToDesktop(
+ const ViewMatrix::Vector2D& delta,
+ const DesktopViewport& viewport) const {
+ // No conversion is needed for trackpad mode.
+ return delta;
+}
+
+float TrackpadInputStrategy::GetFeedbackRadius(InputFeedbackType type) const {
+ switch (type) {
+ case InputFeedbackType::TAP_FEEDBACK:
+ return kTapFeedbackRadius;
+ case InputFeedbackType::DRAG_FEEDBACK:
+ return kDragFeedbackRadius;
+ }
+ NOTREACHED();
+ return 0.f;
+}
+
+bool TrackpadInputStrategy::IsCursorVisible() const {
+ return true;
+}
+} // namespace remoting
« no previous file with comments | « remoting/client/ui/trackpad_input_strategy.h ('k') | remoting/ios/app/host_view_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698