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