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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 // entries. | 67 // entries. |
68 enum ScrollStatus { | 68 enum ScrollStatus { |
69 SCROLL_ON_MAIN_THREAD = 0, | 69 SCROLL_ON_MAIN_THREAD = 0, |
70 SCROLL_STARTED, | 70 SCROLL_STARTED, |
71 SCROLL_IGNORED, | 71 SCROLL_IGNORED, |
72 SCROLL_UNKNOWN, | 72 SCROLL_UNKNOWN, |
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, NON_BUBBLING_GESTURE }; |
| 77 enum RailsMode { |
| 78 RAILS_MODE_FREE, |
| 79 RAILS_MODE_HORIZONTAL, |
| 80 RAILS_MODE_VERTICAL |
| 81 }; |
77 | 82 |
78 // Binds a client to this handler to receive notifications. Only one client | 83 // 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 | 84 // can be bound to an InputHandler. The client must live at least until the |
80 // handler calls WillShutdown() on the client. | 85 // handler calls WillShutdown() on the client. |
81 virtual void BindToClient(InputHandlerClient* client) = 0; | 86 virtual void BindToClient(InputHandlerClient* client) = 0; |
82 | 87 |
83 // Selects a layer to be scrolled at a given point in viewport (logical | 88 // 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 | 89 // pixel) coordinates. Returns SCROLL_STARTED if the layer at the coordinates |
85 // can be scrolled, SCROLL_ON_MAIN_THREAD if the scroll event should instead | 90 // can be scrolled, SCROLL_ON_MAIN_THREAD if the scroll event should instead |
86 // be delegated to the main thread, or SCROLL_IGNORED if there is nothing to | 91 // be delegated to the main thread, or SCROLL_IGNORED if there is nothing to |
87 // be scrolled at the given coordinates. | 92 // be scrolled at the given coordinates. |
88 virtual ScrollStatus ScrollBegin(const gfx::Point& viewport_point, | 93 virtual ScrollStatus ScrollBegin(const gfx::Point& viewport_point, |
89 ScrollInputType type) = 0; | 94 ScrollInputType type) = 0; |
90 | 95 |
91 virtual ScrollStatus ScrollAnimated(const gfx::Point& viewport_point, | 96 virtual ScrollStatus ScrollAnimated(const gfx::Point& viewport_point, |
92 const gfx::Vector2dF& scroll_delta) = 0; | 97 const gfx::Vector2dF& scroll_delta) = 0; |
93 | 98 |
94 // Scroll the selected layer starting at the given position. If the scroll | 99 // 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 | 100 // 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 | 101 // 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 | 102 // 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 | 103 // 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 | 104 // 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, | 105 // 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. | 106 // 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, | 107 // 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 | 108 // the root overscroll accumulated within this ScrollBegin() scope is reported |
104 // in the return value's |accumulated_overscroll| field. | 109 // in the return value's |accumulated_overscroll| field. |
105 // Should only be called if ScrollBegin() returned SCROLL_STARTED. | 110 // Should only be called if ScrollBegin() returned SCROLL_STARTED. |
106 virtual InputHandlerScrollResult ScrollBy( | 111 virtual InputHandlerScrollResult ScrollBy(const gfx::Point& viewport_point, |
107 const gfx::Point& viewport_point, | 112 const gfx::Vector2dF& scroll_delta, |
108 const gfx::Vector2dF& scroll_delta) = 0; | 113 RailsMode rails_mode) = 0; |
109 | 114 |
110 virtual bool ScrollVerticallyByPage(const gfx::Point& viewport_point, | 115 virtual bool ScrollVerticallyByPage(const gfx::Point& viewport_point, |
111 ScrollDirection direction) = 0; | 116 ScrollDirection direction) = 0; |
112 | 117 |
113 // Returns SCROLL_STARTED if a layer was being actively being scrolled, | 118 // Returns SCROLL_STARTED if a layer was being actively being scrolled, |
114 // SCROLL_IGNORED if not. | 119 // SCROLL_IGNORED if not. |
115 virtual ScrollStatus FlingScrollBegin() = 0; | 120 virtual ScrollStatus FlingScrollBegin() = 0; |
116 | 121 |
117 virtual void MouseMoveAt(const gfx::Point& mouse_position) = 0; | 122 virtual void MouseMoveAt(const gfx::Point& mouse_position) = 0; |
118 | 123 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 InputHandler() {} | 167 InputHandler() {} |
163 virtual ~InputHandler() {} | 168 virtual ~InputHandler() {} |
164 | 169 |
165 private: | 170 private: |
166 DISALLOW_COPY_AND_ASSIGN(InputHandler); | 171 DISALLOW_COPY_AND_ASSIGN(InputHandler); |
167 }; | 172 }; |
168 | 173 |
169 } // namespace cc | 174 } // namespace cc |
170 | 175 |
171 #endif // CC_INPUT_INPUT_HANDLER_H_ | 176 #endif // CC_INPUT_INPUT_HANDLER_H_ |
OLD | NEW |