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/time/time.h" | 9 #include "base/time/time.h" |
10 #include "cc/base/cc_export.h" | 10 #include "cc/base/cc_export.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 // Binds a client to this handler to receive notifications. Only one client | 62 // Binds a client to this handler to receive notifications. Only one client |
63 // can be bound to an InputHandler. The client must live at least until the | 63 // can be bound to an InputHandler. The client must live at least until the |
64 // handler calls WillShutdown() on the client. | 64 // handler calls WillShutdown() on the client. |
65 virtual void BindToClient(InputHandlerClient* client) = 0; | 65 virtual void BindToClient(InputHandlerClient* client) = 0; |
66 | 66 |
67 // Selects a layer to be scrolled at a given point in viewport (logical | 67 // Selects a layer to be scrolled at a given point in viewport (logical |
68 // pixel) coordinates. Returns ScrollStarted if the layer at the coordinates | 68 // pixel) coordinates. Returns ScrollStarted if the layer at the coordinates |
69 // can be scrolled, ScrollOnMainThread if the scroll event should instead be | 69 // can be scrolled, ScrollOnMainThread if the scroll event should instead be |
70 // delegated to the main thread, or ScrollIgnored if there is nothing to be | 70 // delegated to the main thread, or ScrollIgnored if there is nothing to be |
71 // scrolled at the given coordinates. | 71 // scrolled at the given coordinates. |
72 virtual ScrollStatus ScrollBegin(gfx::Point viewport_point, | 72 virtual ScrollStatus ScrollBegin(const gfx::Point& viewport_point, |
73 ScrollInputType type) = 0; | 73 ScrollInputType type) = 0; |
74 | 74 |
75 // Scroll the selected layer starting at the given position. If the scroll | 75 // Scroll the selected layer starting at the given position. If the scroll |
76 // type given to ScrollBegin was a gesture, then the scroll point and delta | 76 // type given to ScrollBegin was a gesture, then the scroll point and delta |
77 // should be in viewport (logical pixel) coordinates. Otherwise they are in | 77 // should be in viewport (logical pixel) coordinates. Otherwise they are in |
78 // scrolling layer's (logical pixel) space. If there is no room to move the | 78 // scrolling layer's (logical pixel) space. If there is no room to move the |
79 // layer in the requested direction, its first ancestor layer that can be | 79 // layer in the requested direction, its first ancestor layer that can be |
80 // scrolled will be moved instead. If no layer can be moved in the requested | 80 // scrolled will be moved instead. If no layer can be moved in the requested |
81 // direction at all, then false is returned. If any layer is moved, then | 81 // direction at all, then false is returned. If any layer is moved, then |
82 // true is returned. | 82 // true is returned. |
83 // If the scroll delta hits the root layer, and the layer can no longer move, | 83 // If the scroll delta hits the root layer, and the layer can no longer move, |
84 // the root overscroll accumulated within this ScrollBegin() scope is reported | 84 // the root overscroll accumulated within this ScrollBegin() scope is reported |
85 // to the client. | 85 // to the client. |
86 // Should only be called if ScrollBegin() returned ScrollStarted. | 86 // Should only be called if ScrollBegin() returned ScrollStarted. |
87 virtual bool ScrollBy(gfx::Point viewport_point, | 87 virtual bool ScrollBy(const gfx::Point& viewport_point, |
88 const gfx::Vector2dF& scroll_delta) = 0; | 88 const gfx::Vector2dF& scroll_delta) = 0; |
89 | 89 |
90 virtual bool ScrollVerticallyByPage( | 90 virtual bool ScrollVerticallyByPage(const gfx::Point& viewport_point, |
91 gfx::Point viewport_point, | 91 ScrollDirection direction) = 0; |
92 ScrollDirection direction) = 0; | |
93 | 92 |
94 // Returns ScrollStarted if a layer was being actively being scrolled, | 93 // Returns ScrollStarted if a layer was being actively being scrolled, |
95 // ScrollIgnored if not. | 94 // ScrollIgnored if not. |
96 virtual ScrollStatus FlingScrollBegin() = 0; | 95 virtual ScrollStatus FlingScrollBegin() = 0; |
97 | 96 |
98 virtual void NotifyCurrentFlingVelocity(const gfx::Vector2dF& velocity) = 0; | 97 virtual void NotifyCurrentFlingVelocity(const gfx::Vector2dF& velocity) = 0; |
99 | 98 |
100 virtual void MouseMoveAt(gfx::Point mouse_position) = 0; | 99 virtual void MouseMoveAt(const gfx::Point& mouse_position) = 0; |
101 | 100 |
102 // Stop scrolling the selected layer. Should only be called if ScrollBegin() | 101 // Stop scrolling the selected layer. Should only be called if ScrollBegin() |
103 // returned ScrollStarted. | 102 // returned ScrollStarted. |
104 virtual void ScrollEnd() = 0; | 103 virtual void ScrollEnd() = 0; |
105 | 104 |
106 virtual void SetRootLayerScrollOffsetDelegate( | 105 virtual void SetRootLayerScrollOffsetDelegate( |
107 LayerScrollOffsetDelegate* root_layer_scroll_offset_delegate) = 0; | 106 LayerScrollOffsetDelegate* root_layer_scroll_offset_delegate) = 0; |
108 | 107 |
109 // Called when the value returned by | 108 // Called when the value returned by |
110 // LayerScrollOffsetDelegate.GetTotalScrollOffset has changed for reasons | 109 // LayerScrollOffsetDelegate.GetTotalScrollOffset has changed for reasons |
111 // other than a SetTotalScrollOffset call. | 110 // other than a SetTotalScrollOffset call. |
112 // NOTE: This should only called after a valid delegate was set via a call to | 111 // NOTE: This should only called after a valid delegate was set via a call to |
113 // SetRootLayerScrollOffsetDelegate. | 112 // SetRootLayerScrollOffsetDelegate. |
114 virtual void OnRootLayerDelegatedScrollOffsetChanged() = 0; | 113 virtual void OnRootLayerDelegatedScrollOffsetChanged() = 0; |
115 | 114 |
116 virtual void PinchGestureBegin() = 0; | 115 virtual void PinchGestureBegin() = 0; |
117 virtual void PinchGestureUpdate(float magnify_delta, gfx::Point anchor) = 0; | 116 virtual void PinchGestureUpdate(float magnify_delta, |
| 117 const gfx::Point& anchor) = 0; |
118 virtual void PinchGestureEnd() = 0; | 118 virtual void PinchGestureEnd() = 0; |
119 | 119 |
120 virtual void StartPageScaleAnimation(const gfx::Vector2d& target_offset, | 120 virtual void StartPageScaleAnimation(const gfx::Vector2d& target_offset, |
121 bool anchor_point, | 121 bool anchor_point, |
122 float page_scale, | 122 float page_scale, |
123 base::TimeDelta duration) = 0; | 123 base::TimeDelta duration) = 0; |
124 | 124 |
125 // Request another callback to InputHandlerClient::Animate(). | 125 // Request another callback to InputHandlerClient::Animate(). |
126 virtual void ScheduleAnimation() = 0; | 126 virtual void ScheduleAnimation() = 0; |
127 | 127 |
128 virtual bool HaveTouchEventHandlersAt(gfx::Point viewport_point) = 0; | 128 virtual bool HaveTouchEventHandlersAt(const gfx::Point& viewport_point) = 0; |
129 | 129 |
130 // Calling CreateLatencyInfoSwapPromiseMonitor() to get a scoped | 130 // Calling CreateLatencyInfoSwapPromiseMonitor() to get a scoped |
131 // LatencyInfoSwapPromiseMonitor. During the life time of the | 131 // LatencyInfoSwapPromiseMonitor. During the life time of the |
132 // LatencyInfoSwapPromiseMonitor, if SetNeedsRedraw() or SetNeedsRedrawRect() | 132 // LatencyInfoSwapPromiseMonitor, if SetNeedsRedraw() or SetNeedsRedrawRect() |
133 // is called on LayerTreeHostImpl, the original latency info will be turned | 133 // is called on LayerTreeHostImpl, the original latency info will be turned |
134 // into a LatencyInfoSwapPromise. | 134 // into a LatencyInfoSwapPromise. |
135 virtual scoped_ptr<SwapPromiseMonitor> CreateLatencyInfoSwapPromiseMonitor( | 135 virtual scoped_ptr<SwapPromiseMonitor> CreateLatencyInfoSwapPromiseMonitor( |
136 ui::LatencyInfo* latency) = 0; | 136 ui::LatencyInfo* latency) = 0; |
137 | 137 |
138 protected: | 138 protected: |
139 InputHandler() {} | 139 InputHandler() {} |
140 virtual ~InputHandler() {} | 140 virtual ~InputHandler() {} |
141 | 141 |
142 private: | 142 private: |
143 DISALLOW_COPY_AND_ASSIGN(InputHandler); | 143 DISALLOW_COPY_AND_ASSIGN(InputHandler); |
144 }; | 144 }; |
145 | 145 |
146 } // namespace cc | 146 } // namespace cc |
147 | 147 |
148 #endif // CC_INPUT_INPUT_HANDLER_H_ | 148 #endif // CC_INPUT_INPUT_HANDLER_H_ |
OLD | NEW |