OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 VIEWS_TOUCHUI_GESTURE_MANAGER_H_ | 5 #ifndef VIEWS_TOUCHUI_GESTURE_MANAGER_H_ |
6 #define VIEWS_TOUCHUI_GESTURE_MANAGER_H_ | 6 #define VIEWS_TOUCHUI_GESTURE_MANAGER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/singleton.h" | 9 #include "base/singleton.h" |
10 | 10 |
11 namespace views { | 11 namespace views { |
12 class View; | 12 class View; |
13 class TouchEvent; | 13 class TouchEvent; |
14 | 14 |
15 | 15 |
16 // A GestureManager singleton detects gestures occurring in the | 16 // A GestureManager singleton detects gestures occurring in the |
17 // incoming feed of touch events across all of the RootViews in | 17 // incoming feed of touch events across all of the RootViews in |
18 // the system. In response to a given touch event, the GestureManager | 18 // the system. In response to a given touch event, the GestureManager |
19 // updates its internal state and optionally dispatches synthetic | 19 // updates its internal state and optionally dispatches synthetic |
20 // events to the invoking view. | 20 // events to the invoking view. |
21 // | 21 // |
22 class GestureManager { | 22 class GestureManager { |
23 public: | 23 public: |
24 virtual ~GestureManager(); | 24 virtual ~GestureManager(); |
25 | 25 |
26 static GestureManager* Get(); | 26 static GestureManager* GetInstance(); |
27 | 27 |
28 // Invoked for each touch event that could contribute to the current gesture. | 28 // Invoked for each touch event that could contribute to the current gesture. |
29 // Takes the event and the View that originated it and which will also | 29 // Takes the event and the View that originated it and which will also |
30 // be the target of any generated synthetic event. Finally, handled | 30 // be the target of any generated synthetic event. Finally, handled |
31 // specifies if the event was actually handled explicitly by a view so that | 31 // specifies if the event was actually handled explicitly by a view so that |
32 // GestureManager state can correctly reflect events that are handled | 32 // GestureManager state can correctly reflect events that are handled |
33 // already. | 33 // already. |
34 // Returns true if the event resulted in firing a synthetic event. | 34 // Returns true if the event resulted in firing a synthetic event. |
35 virtual bool ProcessTouchEventForGesture(const TouchEvent& event, | 35 virtual bool ProcessTouchEventForGesture(const TouchEvent& event, |
36 View* source, | 36 View* source, |
37 bool previouslyHandled); | 37 bool previouslyHandled); |
38 | 38 |
39 // TODO(rjkroege): Write the remainder of this class. | 39 // TODO(rjkroege): Write the remainder of this class. |
40 // It will appear in a subsequent CL. | 40 // It will appear in a subsequent CL. |
41 | 41 |
42 protected: | 42 protected: |
43 GestureManager(); | 43 GestureManager(); |
44 | 44 |
45 private: | 45 private: |
46 friend struct DefaultSingletonTraits<GestureManager>; | 46 friend struct DefaultSingletonTraits<GestureManager>; |
47 | 47 |
48 DISALLOW_COPY_AND_ASSIGN(GestureManager); | 48 DISALLOW_COPY_AND_ASSIGN(GestureManager); |
49 }; | 49 }; |
50 | 50 |
51 | 51 |
52 } // namespace views | 52 } // namespace views |
53 | 53 |
54 #endif // VIEWS_TOUCHUI_GESTURE_MANAGER_H_ | 54 #endif // VIEWS_TOUCHUI_GESTURE_MANAGER_H_ |
OLD | NEW |