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

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

Issue 2882653004: [CRD iOS] Injecting scroll events w/ fling animation (Closed)
Patch Set: Rebase 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/gesture_interpreter.h ('k') | remoting/client/ui/input_strategy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/client/ui/gesture_interpreter.cc
diff --git a/remoting/client/ui/gesture_interpreter.cc b/remoting/client/ui/gesture_interpreter.cc
index fda5560790bc13bef34a69478b6f4b26089b21c4..2284149ad45ffecdb7046b776112030333bef2be 100644
--- a/remoting/client/ui/gesture_interpreter.cc
+++ b/remoting/client/ui/gesture_interpreter.cc
@@ -13,6 +13,7 @@
namespace {
const float kOneFingerFlingTimeConstant = 325.f;
+const float kScrollFlingTimeConstant = 120.f;
} // namespace
@@ -23,7 +24,11 @@ GestureInterpreter::GestureInterpreter(RendererProxy* renderer,
input_stub_(input_stub),
pan_animation_(kOneFingerFlingTimeConstant,
base::Bind(&GestureInterpreter::PanWithoutAbortAnimations,
- base::Unretained(this))) {
+ base::Unretained(this))),
+ scroll_animation_(
+ kScrollFlingTimeConstant,
+ base::Bind(&GestureInterpreter::ScrollWithoutAbortAnimations,
+ base::Unretained(this))) {
viewport_.RegisterOnTransformationChangedCallback(
base::Bind(&RendererProxy::SetTransformation,
base::Unretained(renderer_)),
@@ -87,10 +92,31 @@ void GestureInterpreter::OneFingerFling(float velocity_x, float velocity_y) {
pan_animation_.Tick();
}
+void GestureInterpreter::Scroll(float x, float y, float dx, float dy) {
+ AbortAnimations();
+
+ ViewMatrix::Point cursor_position = TrackAndGetPosition(x, y);
+
+ // Inject the cursor position to the host so that scrolling can happen on the
+ // right place.
+ input_stub_->SendMouseEvent(cursor_position.x, cursor_position.y,
+ protocol::MouseEvent_MouseButton_BUTTON_UNDEFINED,
+ false);
+
+ ScrollWithoutAbortAnimations(dx, dy);
+}
+
+void GestureInterpreter::ScrollWithVelocity(float velocity_x,
+ float velocity_y) {
+ AbortAnimations();
+
+ scroll_animation_.SetVelocity(velocity_x, velocity_y);
+ scroll_animation_.Tick();
+}
+
void GestureInterpreter::ProcessAnimations() {
- if (pan_animation_.IsAnimationInProgress()) {
- pan_animation_.Tick();
- }
+ pan_animation_.Tick();
+ scroll_animation_.Tick();
}
void GestureInterpreter::OnSurfaceSizeChanged(int width, int height) {
@@ -108,6 +134,12 @@ void GestureInterpreter::PanWithoutAbortAnimations(float translation_x,
SetCursorPositionOnRenderer();
}
+void GestureInterpreter::ScrollWithoutAbortAnimations(float dx, float dy) {
+ ViewMatrix::Point desktopDelta =
+ input_strategy_->MapScreenVectorToDesktop({dx, dy}, viewport_);
+ input_stub_->SendMouseWheelEvent(desktopDelta.x, desktopDelta.y);
+}
+
void GestureInterpreter::AbortAnimations() {
pan_animation_.Abort();
}
« no previous file with comments | « remoting/client/ui/gesture_interpreter.h ('k') | remoting/client/ui/input_strategy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698