OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CC_INPUT_SCROLL_STATE_H_ | |
6 #define CC_INPUT_SCROLL_STATE_H_ | |
7 | |
8 #include <list> | |
9 | |
10 #include "cc/base/cc_export.h" | |
11 | |
12 namespace cc { | |
13 | |
14 class LayerImpl; | |
15 | |
16 // ScrollState is based on the proposal for scroll customization in blink, found | |
17 // here: https://goo.gl/1ipTpP. | |
18 class CC_EXPORT ScrollState { | |
19 public: | |
20 ScrollState(double delta_x, | |
21 double delta_y, | |
22 int start_position_x, | |
23 int start_position_y, | |
24 bool in_inertial_phase, | |
25 bool should_propagate, | |
26 bool delta_consumed_for_scroll_sequence, | |
27 bool is_direct_manipulation); | |
28 ~ScrollState(); | |
29 | |
30 // Reduce deltas by x, y. | |
31 void ConsumeDelta(double x, double y); | |
32 // Pops the first layer off of |scroll_chain_| and calls | |
33 // |DistributeScroll| on it. | |
34 void DistributeToScrollChainDescendant(); | |
35 // Positive when scrolling left. | |
36 double delta_x() const { return delta_x_; } | |
37 // Positive when scrolling up. | |
38 double delta_y() const { return delta_y_; } | |
39 // The location the scroll started at. For touch, the starting | |
40 // position of the finger. For mouse, the location of the cursor. | |
41 int start_position_x() const { return start_position_x_; } | |
42 int start_position_y() const { return start_position_y_; } | |
43 | |
44 // True for events dispatched after the users's gesture has finished. | |
45 bool in_inertial_phase() const { return in_inertial_phase_; } | |
46 // True if this scroll is allowed to bubble upwards. | |
47 bool should_propagate() const { return should_propagate_; } | |
48 // True if the user interacts directly with the screen, e.g., via touch. | |
49 bool is_direct_manipulation() const { return is_direct_manipulation_; } | |
50 | |
51 void set_scroll_chain(const std::list<LayerImpl*>& scroll_chain) { | |
52 scroll_chain_ = scroll_chain; | |
53 } | |
54 | |
55 void set_current_native_scrolling_layer(LayerImpl* layer) { | |
56 current_native_scrolling_layer_ = layer; | |
57 } | |
58 | |
59 LayerImpl* current_native_scrolling_layer() const { | |
60 return current_native_scrolling_layer_; | |
61 } | |
62 | |
63 bool delta_consumed_for_scroll_sequence() const { | |
64 return delta_consumed_for_scroll_sequence_; | |
65 } | |
66 | |
67 bool FullyConsumed() const { return !delta_x_ && !delta_y_; } | |
68 | |
69 private: | |
70 ScrollState(); | |
71 double delta_x_; | |
72 double delta_y_; | |
73 double start_position_x_; | |
74 double start_position_y_; | |
75 | |
76 bool in_inertial_phase_; | |
77 bool should_propagate_; | |
78 | |
79 // The last layer to respond to a scroll, or null if none exists. | |
80 LayerImpl* current_native_scrolling_layer_; | |
81 // Whether the scroll sequence has had any delta consumed, in the | |
82 // current frame, or any child frames. | |
83 bool delta_consumed_for_scroll_sequence_; | |
84 // True if the user interacts directly with the display, e.g., via | |
85 // touch. | |
86 bool is_direct_manipulation_; | |
87 | |
88 std::list<LayerImpl*> scroll_chain_; | |
Ian Vollick
2015/07/09 14:03:55
I'm a little nervous about the LayerImpl pointers
tdresser
2015/07/09 16:07:45
We'll absolutely want to introduce a layer of abst
Ian Vollick
2015/07/09 16:46:51
Please put a TODO here, then, and link to the scro
tdresser
2015/07/16 14:04:49
Done.
| |
89 }; | |
90 | |
91 } // namespace cc | |
92 | |
93 #endif // CC_INPUT_SCROLL_STATE_H_ | |
OLD | NEW |