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 CCInputHandler_h | 5 #ifndef CCInputHandler_h |
6 #define CCInputHandler_h | 6 #define CCInputHandler_h |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 | 10 |
| 11 namespace gfx { |
| 12 class Point; |
| 13 } |
| 14 |
11 namespace cc { | 15 namespace cc { |
12 | 16 |
13 class IntPoint; | 17 class IntPoint; |
14 class IntSize; | 18 class IntSize; |
15 | 19 |
16 // The InputHandler is a way for the embedders to interact with | 20 // The InputHandler is a way for the embedders to interact with |
17 // the impl thread side of the compositor implementation. | 21 // the impl thread side of the compositor implementation. |
18 // | 22 // |
19 // There is one InputHandler for every LayerTreeHost. It is | 23 // There is one InputHandler for every LayerTreeHost. It is |
20 // created on the main thread and used only on the impl thread. | 24 // created on the main thread and used only on the impl thread. |
21 // | 25 // |
22 // The InputHandler is constructed with a InputHandlerClient, which is the | 26 // The InputHandler is constructed with a InputHandlerClient, which is the |
23 // interface by which the handler can manipulate the LayerTree. | 27 // interface by which the handler can manipulate the LayerTree. |
24 class InputHandlerClient { | 28 class InputHandlerClient { |
25 public: | 29 public: |
26 enum ScrollStatus { ScrollOnMainThread, ScrollStarted, ScrollIgnored }; | 30 enum ScrollStatus { ScrollOnMainThread, ScrollStarted, ScrollIgnored }; |
27 enum ScrollInputType { Gesture, Wheel }; | 31 enum ScrollInputType { Gesture, Wheel }; |
28 | 32 |
29 // Selects a layer to be scrolled at a given point in viewport (logical | 33 // Selects a layer to be scrolled at a given point in viewport (logical |
30 // pixel) coordinates. Returns ScrollStarted if the layer at the coordinates | 34 // pixel) coordinates. Returns ScrollStarted if the layer at the coordinates |
31 // can be scrolled, ScrollOnMainThread if the scroll event should instead be | 35 // can be scrolled, ScrollOnMainThread if the scroll event should instead be |
32 // delegated to the main thread, or ScrollIgnored if there is nothing to be | 36 // delegated to the main thread, or ScrollIgnored if there is nothing to be |
33 // scrolled at the given coordinates. | 37 // scrolled at the given coordinates. |
34 virtual ScrollStatus scrollBegin(const IntPoint&, ScrollInputType) = 0; | 38 virtual ScrollStatus scrollBegin(const gfx::Point&, ScrollInputType) = 0; |
35 | 39 |
36 // Scroll the selected layer starting at the given position. If the scroll | 40 // Scroll the selected layer starting at the given position. If the scroll |
37 // type given to scrollBegin was a gesture, then the scroll point and delta | 41 // type given to scrollBegin was a gesture, then the scroll point and delta |
38 // should be in viewport (logical pixel) coordinates. Otherwise they are in | 42 // should be in viewport (logical pixel) coordinates. Otherwise they are in |
39 // scrolling layer's (logical pixel) space. If there is no room to move the | 43 // scrolling layer's (logical pixel) space. If there is no room to move the |
40 // layer in the requested direction, its first ancestor layer that can be | 44 // layer in the requested direction, its first ancestor layer that can be |
41 // scrolled will be moved instead. Should only be called if scrollBegin() | 45 // scrolled will be moved instead. Should only be called if scrollBegin() |
42 // returned ScrollStarted. | 46 // returned ScrollStarted. |
43 virtual void scrollBy(const IntPoint&, const IntSize&) = 0; | 47 virtual void scrollBy(const gfx::Point&, const IntSize&) = 0; |
44 | 48 |
45 // Stop scrolling the selected layer. Should only be called if scrollBegin() | 49 // Stop scrolling the selected layer. Should only be called if scrollBegin() |
46 // returned ScrollStarted. | 50 // returned ScrollStarted. |
47 virtual void scrollEnd() = 0; | 51 virtual void scrollEnd() = 0; |
48 | 52 |
49 virtual void pinchGestureBegin() = 0; | 53 virtual void pinchGestureBegin() = 0; |
50 virtual void pinchGestureUpdate(float magnifyDelta, const IntPoint& anchor)
= 0; | 54 virtual void pinchGestureUpdate(float magnifyDelta, const IntPoint& anchor)
= 0; |
51 virtual void pinchGestureEnd() = 0; | 55 virtual void pinchGestureEnd() = 0; |
52 | 56 |
53 virtual void startPageScaleAnimation(const IntSize& targetPosition, | 57 virtual void startPageScaleAnimation(const IntSize& targetPosition, |
(...skipping 23 matching lines...) Expand all Loading... |
77 protected: | 81 protected: |
78 InputHandler() { } | 82 InputHandler() { } |
79 | 83 |
80 private: | 84 private: |
81 DISALLOW_COPY_AND_ASSIGN(InputHandler); | 85 DISALLOW_COPY_AND_ASSIGN(InputHandler); |
82 }; | 86 }; |
83 | 87 |
84 } | 88 } |
85 | 89 |
86 #endif | 90 #endif |
OLD | NEW |