OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 CC_INPUT_INPUT_HANDLER_H_ | 5 #ifndef CC_INPUT_INPUT_HANDLER_H_ |
6 #define CC_INPUT_INPUT_HANDLER_H_ | 6 #define CC_INPUT_INPUT_HANDLER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 59 |
60 // The InputHandler is a way for the embedders to interact with the impl thread | 60 // The InputHandler is a way for the embedders to interact with the impl thread |
61 // side of the compositor implementation. There is one InputHandler per | 61 // side of the compositor implementation. There is one InputHandler per |
62 // LayerTreeHost. To use the input handler, implement the InputHanderClient | 62 // LayerTreeHost. To use the input handler, implement the InputHanderClient |
63 // interface and bind it to the handler on the compositor thread. | 63 // interface and bind it to the handler on the compositor thread. |
64 class CC_EXPORT InputHandler { | 64 class CC_EXPORT InputHandler { |
65 public: | 65 public: |
66 // Note these are used in a histogram. Do not reorder or delete existing | 66 // Note these are used in a histogram. Do not reorder or delete existing |
67 // entries. | 67 // entries. |
68 enum ScrollStatus { | 68 enum ScrollStatus { |
69 SCROLL_ON_MAIN_THREAD = 0, | 69 ScrollOnMainThread = 0, |
70 SCROLL_STARTED, | 70 ScrollStarted, |
71 SCROLL_IGNORED, | 71 ScrollIgnored, |
72 SCROLL_UNKNOWN, | 72 ScrollUnknown, |
73 // This must be the last entry. | 73 // This must be the last entry. |
74 ScrollStatusCount | 74 ScrollStatusCount |
75 }; | 75 }; |
76 enum ScrollInputType { GESTURE, WHEEL, NON_BUBBLING_GESTURE }; | 76 enum ScrollInputType { Gesture, Wheel, NonBubblingGesture }; |
77 | 77 |
78 // Binds a client to this handler to receive notifications. Only one client | 78 // Binds a client to this handler to receive notifications. Only one client |
79 // can be bound to an InputHandler. The client must live at least until the | 79 // can be bound to an InputHandler. The client must live at least until the |
80 // handler calls WillShutdown() on the client. | 80 // handler calls WillShutdown() on the client. |
81 virtual void BindToClient(InputHandlerClient* client) = 0; | 81 virtual void BindToClient(InputHandlerClient* client) = 0; |
82 | 82 |
83 // Selects a layer to be scrolled at a given point in viewport (logical | 83 // Selects a layer to be scrolled at a given point in viewport (logical |
84 // pixel) coordinates. Returns SCROLL_STARTED if the layer at the coordinates | 84 // pixel) coordinates. Returns ScrollStarted if the layer at the coordinates |
85 // can be scrolled, SCROLL_ON_MAIN_THREAD if the scroll event should instead | 85 // can be scrolled, ScrollOnMainThread if the scroll event should instead be |
86 // be delegated to the main thread, or SCROLL_IGNORED if there is nothing to | 86 // delegated to the main thread, or ScrollIgnored if there is nothing to be |
87 // be scrolled at the given coordinates. | 87 // scrolled at the given coordinates. |
88 virtual ScrollStatus ScrollBegin(const gfx::Point& viewport_point, | 88 virtual ScrollStatus ScrollBegin(const gfx::Point& viewport_point, |
89 ScrollInputType type) = 0; | 89 ScrollInputType type) = 0; |
90 | 90 |
91 virtual ScrollStatus ScrollAnimated(const gfx::Point& viewport_point, | 91 virtual ScrollStatus ScrollAnimated(const gfx::Point& viewport_point, |
92 const gfx::Vector2dF& scroll_delta) = 0; | 92 const gfx::Vector2dF& scroll_delta) = 0; |
93 | 93 |
94 // Scroll the selected layer starting at the given position. If the scroll | 94 // Scroll the selected layer starting at the given position. If the scroll |
95 // type given to ScrollBegin was a gesture, then the scroll point and delta | 95 // type given to ScrollBegin was a gesture, then the scroll point and delta |
96 // should be in viewport (logical pixel) coordinates. Otherwise they are in | 96 // should be in viewport (logical pixel) coordinates. Otherwise they are in |
97 // scrolling layer's (logical pixel) space. If there is no room to move the | 97 // scrolling layer's (logical pixel) space. If there is no room to move the |
98 // layer in the requested direction, its first ancestor layer that can be | 98 // layer in the requested direction, its first ancestor layer that can be |
99 // scrolled will be moved instead. The return value's |did_scroll| field is | 99 // scrolled will be moved instead. The return value's |did_scroll| field is |
100 // set to false if no layer can be moved in the requested direction at all, | 100 // set to false if no layer can be moved in the requested direction at all, |
101 // and set to true if any layer is moved. | 101 // and set to true if any layer is moved. |
102 // If the scroll delta hits the root layer, and the layer can no longer move, | 102 // If the scroll delta hits the root layer, and the layer can no longer move, |
103 // the root overscroll accumulated within this ScrollBegin() scope is reported | 103 // the root overscroll accumulated within this ScrollBegin() scope is reported |
104 // in the return value's |accumulated_overscroll| field. | 104 // in the return value's |accumulated_overscroll| field. |
105 // Should only be called if ScrollBegin() returned SCROLL_STARTED. | 105 // Should only be called if ScrollBegin() returned ScrollStarted. |
106 virtual InputHandlerScrollResult ScrollBy( | 106 virtual InputHandlerScrollResult ScrollBy( |
107 const gfx::Point& viewport_point, | 107 const gfx::Point& viewport_point, |
108 const gfx::Vector2dF& scroll_delta) = 0; | 108 const gfx::Vector2dF& scroll_delta) = 0; |
109 | 109 |
110 virtual bool ScrollVerticallyByPage(const gfx::Point& viewport_point, | 110 virtual bool ScrollVerticallyByPage(const gfx::Point& viewport_point, |
111 ScrollDirection direction) = 0; | 111 ScrollDirection direction) = 0; |
112 | 112 |
113 // Returns SCROLL_STARTED if a layer was being actively being scrolled, | 113 // Returns ScrollStarted if a layer was being actively being scrolled, |
114 // SCROLL_IGNORED if not. | 114 // ScrollIgnored if not. |
115 virtual ScrollStatus FlingScrollBegin() = 0; | 115 virtual ScrollStatus FlingScrollBegin() = 0; |
116 | 116 |
117 virtual void MouseMoveAt(const gfx::Point& mouse_position) = 0; | 117 virtual void MouseMoveAt(const gfx::Point& mouse_position) = 0; |
118 | 118 |
119 // Stop scrolling the selected layer. Should only be called if ScrollBegin() | 119 // Stop scrolling the selected layer. Should only be called if ScrollBegin() |
120 // returned SCROLL_STARTED. | 120 // returned ScrollStarted. |
121 virtual void ScrollEnd() = 0; | 121 virtual void ScrollEnd() = 0; |
122 | 122 |
123 virtual void SetRootLayerScrollOffsetDelegate( | 123 virtual void SetRootLayerScrollOffsetDelegate( |
124 LayerScrollOffsetDelegate* root_layer_scroll_offset_delegate) = 0; | 124 LayerScrollOffsetDelegate* root_layer_scroll_offset_delegate) = 0; |
125 | 125 |
126 // Called when the value returned by | 126 // Called when the value returned by |
127 // LayerScrollOffsetDelegate.GetTotalScrollOffset has changed for reasons | 127 // LayerScrollOffsetDelegate.GetTotalScrollOffset has changed for reasons |
128 // other than a SetTotalScrollOffset call. | 128 // other than a SetTotalScrollOffset call. |
129 // NOTE: This should only called after a valid delegate was set via a call to | 129 // NOTE: This should only called after a valid delegate was set via a call to |
130 // SetRootLayerScrollOffsetDelegate. | 130 // SetRootLayerScrollOffsetDelegate. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 InputHandler() {} | 162 InputHandler() {} |
163 virtual ~InputHandler() {} | 163 virtual ~InputHandler() {} |
164 | 164 |
165 private: | 165 private: |
166 DISALLOW_COPY_AND_ASSIGN(InputHandler); | 166 DISALLOW_COPY_AND_ASSIGN(InputHandler); |
167 }; | 167 }; |
168 | 168 |
169 } // namespace cc | 169 } // namespace cc |
170 | 170 |
171 #endif // CC_INPUT_INPUT_HANDLER_H_ | 171 #endif // CC_INPUT_INPUT_HANDLER_H_ |
OLD | NEW |