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