| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef REMOTING_CLIENT_UI_INPUT_STRATEGY_H_ | |
| 6 #define REMOTING_CLIENT_UI_INPUT_STRATEGY_H_ | |
| 7 | |
| 8 #include "remoting/client/ui/view_matrix.h" | |
| 9 | |
| 10 namespace remoting { | |
| 11 | |
| 12 class DesktopViewport; | |
| 13 | |
| 14 // This is an interface used by GestureInterpreter to customize the way gestures | |
| 15 // are handled. | |
| 16 class InputStrategy { | |
| 17 public: | |
| 18 enum InputFeedbackType { | |
| 19 TAP_FEEDBACK, | |
| 20 DRAG_FEEDBACK, | |
| 21 }; | |
| 22 | |
| 23 enum Gesture { | |
| 24 NONE, | |
| 25 ZOOM, | |
| 26 DRAG, | |
| 27 }; | |
| 28 | |
| 29 virtual ~InputStrategy() {} | |
| 30 | |
| 31 // Called when the GestureInterpreter receives a zoom gesture. The | |
| 32 // implementation is responsible for modifying the viewport and observing the | |
| 33 // change. | |
| 34 virtual void HandleZoom(const ViewMatrix::Point& pivot, | |
| 35 float scale, | |
| 36 DesktopViewport* viewport) = 0; | |
| 37 | |
| 38 // Called when the GestureInterpreter receives a pan gesture. The | |
| 39 // implementation is responsible for modifying the viewport and observing the | |
| 40 // change. | |
| 41 // simultaneous_gesture: Gesture that is simultaneously in progress. | |
| 42 // Returns true if this changes the cursor position. | |
| 43 virtual bool HandlePan(const ViewMatrix::Vector2D& translation, | |
| 44 Gesture simultaneous_gesture, | |
| 45 DesktopViewport* viewport) = 0; | |
| 46 | |
| 47 // Called when a touch input (which will end up injecting a mouse event at | |
| 48 // certain position in the host) is done at |touch_point|. | |
| 49 // The implementation should move the cursor to proper position. | |
| 50 virtual void TrackTouchInput(const ViewMatrix::Point& touch_point, | |
| 51 const DesktopViewport& viewport) = 0; | |
| 52 | |
| 53 // Returns the current cursor position. | |
| 54 virtual ViewMatrix::Point GetCursorPosition() const = 0; | |
| 55 | |
| 56 // Maps a vector (or movement) in the surface coordinate to the vector to be | |
| 57 // used on the desktop. For example it can be used to map a scroll gesture | |
| 58 // on the screen to change in mouse wheel position. | |
| 59 virtual ViewMatrix::Vector2D MapScreenVectorToDesktop( | |
| 60 const ViewMatrix::Vector2D& delta, | |
| 61 const DesktopViewport& viewport) const = 0; | |
| 62 | |
| 63 // Returns the maximum radius of the feedback animation on the surface's | |
| 64 // coordinate for the given input type. The feedback will then be shown on the | |
| 65 // cursor positions returned by GetCursorPosition(). Return 0 if no feedback | |
| 66 // should be shown. | |
| 67 virtual float GetFeedbackRadius(InputFeedbackType type) const = 0; | |
| 68 | |
| 69 // Returns true if the input strategy maintains a visible cursor on the | |
| 70 // desktop. | |
| 71 virtual bool IsCursorVisible() const = 0; | |
| 72 }; | |
| 73 | |
| 74 } // namespace remoting | |
| 75 #endif // REMOTING_CLIENT_UI_INPUT_STRATEGY_H_ | |
| OLD | NEW |