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

Side by Side Diff: content/browser/android/overscroll_glow.h

Issue 14268004: Add overscroll edge effect animations for Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase + CR. Avoid round-trip animation requests on animate(). Created 7 years, 7 months 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
(Empty)
1 // Copyright (c) 2012 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 CONTENT_BROWSER_ANDROID_OVERSCROLL_GLOW_H_
6 #define CONTENT_BROWSER_ANDROID_OVERSCROLL_GLOW_H_
7
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/time.h"
11 #include "content/browser/android/edge_effect.h"
12 #include "ui/gfx/size_f.h"
13 #include "ui/gfx/vector2d_f.h"
14
15 class SkBitmap;
16
17 namespace cc {
18 class Layer;
19 }
20
21 namespace content {
22
23 /* |OverscrollGlow| mirrors its Android counterpart, EdgeEffect.java.
24 * Conscious tradeoffs were made to align this as closely as possible with the
25 * original Android java version.
26 */
27 class OverscrollGlow {
28 public:
29 static scoped_ptr<OverscrollGlow> Create();
30
31 ~OverscrollGlow();
32
33 void OnOverscrolled(base::TimeTicks current_time,
34 gfx::Vector2dF overscroll,
35 gfx::Vector2dF velocity);
36 // Returns true if the effect still needs animation ticks.
37 bool Animate(base::TimeTicks current_time);
38 void Finish();
39
40 // Returns true if the effect needs animation ticks.
41 bool IsActive() const;
42
43 void set_horizontal_overscroll_enabled(bool enabled);
no sievers 2013/05/13 18:38:24 nit: SetHorizontalOverscrollEnabled(), and same fo
jdduke (slow) 2013/05/13 20:44:24 Why? It's a trivial setter?
no sievers 2013/05/13 20:53:22 I think lower-case with underscores is normally us
44 void set_vertical_overscroll_enabled(bool enabled);
45 void set_size(gfx::SizeF size);
46 void set_parent_layer(scoped_refptr<cc::Layer> parent_layer);
47
48 private:
49 enum Axis { AXIS_X, AXIS_Y };
50
51 OverscrollGlow(const SkBitmap& edge, const SkBitmap& glow);
52
53 void Pull(base::TimeTicks current_time,
54 gfx::Vector2dF added_overscroll);
55 void Absorb(base::TimeTicks current_time,
56 gfx::Vector2dF velocity,
57 gfx::Vector2dF overscroll,
58 gfx::Vector2dF old_overscroll);
59
60 void Release(base::TimeTicks current_time);
61 void Release(Axis axis, base::TimeTicks current_time);
62
63 EdgeEffect* GetOppositeEdge(int edge_index);
64
65 scoped_ptr<EdgeEffect> edge_effects_[EdgeEffect::EDGE_COUNT];
66
67 gfx::SizeF size_;
68 gfx::Vector2dF old_overscroll_;
69 gfx::Vector2dF old_velocity_;
70 bool horizontal_overscroll_enabled_;
71 bool vertical_overscroll_enabled_;
72
73 scoped_refptr<cc::Layer> parent_layer_;
74
75 DISALLOW_COPY_AND_ASSIGN(OverscrollGlow);
76 };
77
78 } // namespace content
79
80 #endif // CONTENT_BROWSER_ANDROID_SCROLL_GLOW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698