Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(345)

Side by Side Diff: ui/android/overscroll_refresh.h

Issue 2528823002: Separate SwipeRefreshHandler and ContentViewCore (Closed)
Patch Set: Fix non-Android compile issue Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 UI_ANDROID_OVERSCROLL_REFRESH_H_ 5 #ifndef UI_ANDROID_OVERSCROLL_REFRESH_H_
6 #define UI_ANDROID_OVERSCROLL_REFRESH_H_ 6 #define UI_ANDROID_OVERSCROLL_REFRESH_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "ui/android/overscroll_refresh_handler.h"
9 #include "ui/android/ui_android_export.h" 10 #include "ui/android/ui_android_export.h"
10 #include "ui/gfx/geometry/size_f.h" 11 #include "ui/gfx/geometry/size_f.h"
11 #include "ui/gfx/geometry/vector2d_f.h" 12 #include "ui/gfx/geometry/vector2d_f.h"
12 13
13 namespace ui { 14 namespace ui {
14 15
15 class UI_ANDROID_EXPORT OverscrollRefreshHandler {
16 public:
17 // Signals the start of an overscrolling pull. Returns whether the handler
18 // will consume the overscroll gesture, in which case it will receive the
19 // remaining pull updates.
20 virtual bool PullStart() = 0;
21
22 // Signals a pull update, where |delta| is in device pixels.
23 virtual void PullUpdate(float delta) = 0;
24
25 // Signals the release of the pull, and whether the release is allowed to
26 // trigger the refresh action.
27 virtual void PullRelease(bool allow_refresh) = 0;
28
29 // Reset the active pull state.
30 virtual void PullReset() = 0;
31
32 protected:
33 virtual ~OverscrollRefreshHandler() {}
34 };
35
36 // Simple pull-to-refresh styled effect. Listens to scroll events, conditionally 16 // Simple pull-to-refresh styled effect. Listens to scroll events, conditionally
37 // activating when: 17 // activating when:
38 // 1) The scroll begins when the page's root layer 1) has no vertical scroll 18 // 1) The scroll begins when the page's root layer 1) has no vertical scroll
39 // offset and 2) lacks the overflow-y:hidden property. 19 // offset and 2) lacks the overflow-y:hidden property.
40 // 2) The page doesn't consume the initial scroll events. 20 // 2) The page doesn't consume the initial scroll events.
41 // 3) The initial scroll direction is upward. 21 // 3) The initial scroll direction is upward.
42 // The actuall pull response, animation and action are delegated to the 22 // The actuall pull response, animation and action are delegated to the
43 // provided refresh handler. 23 // provided refresh handler.
44 class UI_ANDROID_EXPORT OverscrollRefresh { 24 class UI_ANDROID_EXPORT OverscrollRefresh {
45 public: 25 public:
46 // Minmum number of overscrolling pull events required to activate the effect. 26 // Minmum number of overscrolling pull events required to activate the effect.
47 // Useful for avoiding accidental triggering when a scroll janks (is delayed), 27 // Useful for avoiding accidental triggering when a scroll janks (is delayed),
48 // capping the impulse per event. 28 // capping the impulse per event.
49 enum { kMinPullsToActivate = 3 }; 29 enum { kMinPullsToActivate = 3 };
50 30
51 explicit OverscrollRefresh(OverscrollRefreshHandler* handler); 31 explicit OverscrollRefresh(ui::OverscrollRefreshHandler* handler);
boliu 2016/12/03 01:05:28 don't need this, already in the ui namespace here
rlanday 2016/12/05 19:53:57 Ok
52 ~OverscrollRefresh(); 32 ~OverscrollRefresh();
53 33
54 // Scroll event stream listening methods. 34 // Scroll event stream listening methods.
55 void OnScrollBegin(); 35 void OnScrollBegin();
56 // Returns whether the refresh was activated. 36 // Returns whether the refresh was activated.
57 void OnScrollEnd(const gfx::Vector2dF& velocity); 37 void OnScrollEnd(const gfx::Vector2dF& velocity);
58 38
59 // Scroll ack listener. The effect will only be activated if the initial 39 // Scroll ack listener. The effect will only be activated if the initial
60 // updates go unconsumed. 40 // updates go unconsumed.
61 void OnScrollUpdateAck(bool was_consumed); 41 void OnScrollUpdateAck(bool was_consumed);
(...skipping 25 matching lines...) Expand all
87 67
88 bool scrolled_to_top_; 68 bool scrolled_to_top_;
89 bool overflow_y_hidden_; 69 bool overflow_y_hidden_;
90 70
91 enum ScrollConsumptionState { 71 enum ScrollConsumptionState {
92 DISABLED, 72 DISABLED,
93 AWAITING_SCROLL_UPDATE_ACK, 73 AWAITING_SCROLL_UPDATE_ACK,
94 ENABLED, 74 ENABLED,
95 } scroll_consumption_state_; 75 } scroll_consumption_state_;
96 76
97 OverscrollRefreshHandler* const handler_; 77 ui::OverscrollRefreshHandler* handler_;
boliu 2016/12/03 01:05:28 ditto
rlanday 2016/12/05 19:53:57 Ok
98 78
99 DISALLOW_COPY_AND_ASSIGN(OverscrollRefresh); 79 DISALLOW_COPY_AND_ASSIGN(OverscrollRefresh);
100 }; 80 };
101 81
102 } // namespace content 82 } // namespace content
103 83
104 #endif // UI_ANDROID_OVERSCROLL_REFRESH_H_ 84 #endif // UI_ANDROID_OVERSCROLL_REFRESH_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698