| 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_UI_INPUT_STRATEGY_H_ | 5 #ifndef REMOTING_CLIENT_UI_INPUT_STRATEGY_H_ |
| 6 #define REMOTING_CLIENT_UI_INPUT_STRATEGY_H_ | 6 #define REMOTING_CLIENT_UI_INPUT_STRATEGY_H_ |
| 7 | 7 |
| 8 #include "remoting/client/ui/view_matrix.h" |
| 9 |
| 8 namespace remoting { | 10 namespace remoting { |
| 9 | 11 |
| 10 class DesktopViewport; | 12 class DesktopViewport; |
| 11 | 13 |
| 12 // This is an interface used by GestureInterpreter to customize the way gestures | 14 // This is an interface used by GestureInterpreter to customize the way gestures |
| 13 // are handled. | 15 // are handled. |
| 14 class InputStrategy { | 16 class InputStrategy { |
| 15 public: | 17 public: |
| 18 enum InputFeedbackType { |
| 19 TAP_FEEDBACK, |
| 20 LONG_PRESS_FEEDBACK, |
| 21 }; |
| 22 |
| 16 virtual ~InputStrategy() {} | 23 virtual ~InputStrategy() {} |
| 17 | 24 |
| 18 // Called when the GestureInterpreter receives a pinch gesture. The | 25 // Called when the GestureInterpreter receives a pinch gesture. The |
| 19 // implementation is responsible for modifying the viewport and observing the | 26 // implementation is responsible for modifying the viewport and observing the |
| 20 // change. | 27 // change. |
| 21 virtual void HandlePinch(float pivot_x, | 28 virtual void HandlePinch(const ViewMatrix::Point& pivot, |
| 22 float pivot_y, | |
| 23 float scale, | 29 float scale, |
| 24 DesktopViewport* viewport) = 0; | 30 DesktopViewport* viewport) = 0; |
| 25 | 31 |
| 26 // Called when the GestureInterpreter receives a pan gesture. The | 32 // Called when the GestureInterpreter receives a pan gesture. The |
| 27 // implementation is responsible for modifying the viewport and observing the | 33 // implementation is responsible for modifying the viewport and observing the |
| 28 // change. | 34 // change. |
| 29 // is_dragging_mode: true if the user is trying to drag something while | 35 // is_dragging_mode: true if the user is trying to drag something while |
| 30 // panning on the screen. | 36 // panning on the screen. |
| 31 virtual void HandlePan(float translation_x, | 37 virtual void HandlePan(const ViewMatrix::Vector2D& translation, |
| 32 float translation_y, | |
| 33 bool is_dragging_mode, | 38 bool is_dragging_mode, |
| 34 DesktopViewport* viewport) = 0; | 39 DesktopViewport* viewport) = 0; |
| 35 | 40 |
| 36 // Called when a gesture is done at location (touch_x, touch_y) and the | 41 // Called when a touch input (which will end up injecting a mouse event at |
| 37 // GestureInterpreter needs to get back the cursor position to inject mouse | 42 // certain position in the host) is done at |touch_point|. |
| 38 // the mouse event. | 43 // The implementation should move the cursor to proper position. |
| 39 virtual void FindCursorPositions(float touch_x, | 44 virtual void TrackTouchInput(const ViewMatrix::Point& touch_point, |
| 40 float touch_y, | 45 const DesktopViewport& viewport) = 0; |
| 41 const DesktopViewport& viewport, | 46 |
| 42 float* cursor_x, | 47 // Returns the current cursor position. |
| 43 float* cursor_y) = 0; | 48 virtual ViewMatrix::Point GetCursorPosition() const = 0; |
| 49 |
| 50 // Returns the maximum radius of the feedback animation on the surface's |
| 51 // coordinate for the given input type. The feedback will then be shown on the |
| 52 // cursor positions returned by GetCursorPosition(). Return 0 if no feedback |
| 53 // should be shown. |
| 54 virtual float GetFeedbackRadius(InputFeedbackType type) const = 0; |
| 44 | 55 |
| 45 // Returns true if the input strategy maintains a visible cursor on the | 56 // Returns true if the input strategy maintains a visible cursor on the |
| 46 // desktop. | 57 // desktop. |
| 47 virtual bool IsCursorVisible() const = 0; | 58 virtual bool IsCursorVisible() const = 0; |
| 48 }; | 59 }; |
| 49 | 60 |
| 50 } // namespace remoting | 61 } // namespace remoting |
| 51 #endif // REMOTING_CLIENT_UI_INPUT_STRATEGY_H_ | 62 #endif // REMOTING_CLIENT_UI_INPUT_STRATEGY_H_ |
| OLD | NEW |