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 #ifndef REMOTING_CLIENT_GESTURE_INTERPRETER_H_ | 5 #ifndef REMOTING_CLIENT_GESTURE_INTERPRETER_H_ |
6 #define REMOTING_CLIENT_GESTURE_INTERPRETER_H_ | 6 #define REMOTING_CLIENT_GESTURE_INTERPRETER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "remoting/client/chromoting_session.h" | 10 #include "remoting/client/chromoting_session.h" |
11 #include "remoting/client/desktop_viewport.h" | 11 #include "remoting/client/desktop_viewport.h" |
| 12 #include "remoting/client/fling_animation.h" |
12 #include "remoting/proto/event.pb.h" | 13 #include "remoting/proto/event.pb.h" |
13 | 14 |
14 namespace remoting { | 15 namespace remoting { |
15 | 16 |
16 class InputStrategy; | 17 class InputStrategy; |
17 | 18 |
18 // This is a class for interpreting a raw touch input into actions like moving | 19 // This is a class for interpreting a raw touch input into actions like moving |
19 // the viewport and injecting mouse clicks. | 20 // the viewport and injecting mouse clicks. |
20 class GestureInterpreter { | 21 class GestureInterpreter { |
21 public: | 22 public: |
22 enum GestureState { GESTURE_BEGAN, GESTURE_CHANGED, GESTURE_ENDED }; | 23 enum GestureState { GESTURE_BEGAN, GESTURE_CHANGED, GESTURE_ENDED }; |
23 | 24 |
24 GestureInterpreter( | 25 GestureInterpreter( |
25 const DesktopViewport::TransformationCallback& on_transformation_changed, | 26 const DesktopViewport::TransformationCallback& on_transformation_changed, |
26 ChromotingSession* input_stub); | 27 ChromotingSession* input_stub); |
27 ~GestureInterpreter(); | 28 ~GestureInterpreter(); |
28 | 29 |
29 // Coordinates of the OpenGL view surface will be used. | 30 // Coordinates of the OpenGL view surface will be used. |
| 31 |
| 32 // This can happen in conjunction with Pan(). |
30 void Pinch(float pivot_x, float pivot_y, float scale); | 33 void Pinch(float pivot_x, float pivot_y, float scale); |
| 34 |
| 35 // Called whenever the user did a pan gesture. It can be one-finger pan, no |
| 36 // matter long-press in on or not, or two-finger pan in conjunction with the |
| 37 // pinch gesture. Two-finger pan without pinch is consider a scroll gesture. |
31 void Pan(float translation_x, float translation_y); | 38 void Pan(float translation_x, float translation_y); |
| 39 |
| 40 // Called when the user did a one-finger tap. |
32 void Tap(float x, float y); | 41 void Tap(float x, float y); |
| 42 |
33 void TwoFingerTap(float x, float y); | 43 void TwoFingerTap(float x, float y); |
34 | 44 |
35 // Caller is expected to call both Pan() and LongPress() when long-press is in | 45 // Caller is expected to call both Pan() and LongPress() when long-press is in |
36 // progress. | 46 // progress. |
37 void LongPress(float x, float y, GestureState state); | 47 void LongPress(float x, float y, GestureState state); |
38 | 48 |
| 49 // Called when the user has just done a one-finger pan (no long-press or |
| 50 // pinching) and the pan gesture still has some final velocity. |
| 51 void OneFingerFling(float velocity_x, float velocity_y); |
| 52 |
| 53 // Called to process one animation frame. |
| 54 void ProcessAnimations(); |
| 55 |
39 void OnSurfaceSizeChanged(int width, int height); | 56 void OnSurfaceSizeChanged(int width, int height); |
40 void OnDesktopSizeChanged(int width, int height); | 57 void OnDesktopSizeChanged(int width, int height); |
41 | 58 |
42 private: | 59 private: |
| 60 void PanWithoutAbortAnimations(float translation_x, float translation_y); |
| 61 |
| 62 void AbortAnimations(); |
| 63 |
43 void InjectMouseClick(float x, | 64 void InjectMouseClick(float x, |
44 float y, | 65 float y, |
45 protocol::MouseEvent_MouseButton button); | 66 protocol::MouseEvent_MouseButton button); |
46 | 67 |
47 std::unique_ptr<InputStrategy> input_strategy_; | 68 std::unique_ptr<InputStrategy> input_strategy_; |
48 DesktopViewport viewport_; | 69 DesktopViewport viewport_; |
49 ChromotingSession* input_stub_; | 70 ChromotingSession* input_stub_; |
50 bool is_dragging_mode_ = false; | 71 bool is_dragging_mode_ = false; |
51 | 72 |
| 73 FlingAnimation pan_animation_; |
| 74 |
52 // GestureInterpreter is neither copyable nor movable. | 75 // GestureInterpreter is neither copyable nor movable. |
53 GestureInterpreter(const GestureInterpreter&) = delete; | 76 GestureInterpreter(const GestureInterpreter&) = delete; |
54 GestureInterpreter& operator=(const GestureInterpreter&) = delete; | 77 GestureInterpreter& operator=(const GestureInterpreter&) = delete; |
55 }; | 78 }; |
56 | 79 |
57 } // namespace remoting | 80 } // namespace remoting |
58 #endif // REMOTING_CLIENT_GESTURE_INTERPRETER_H_ | 81 #endif // REMOTING_CLIENT_GESTURE_INTERPRETER_H_ |
OLD | NEW |