Chromium Code Reviews| Index: content/browser/android/overscroll_glow.h |
| diff --git a/content/browser/android/overscroll_glow.h b/content/browser/android/overscroll_glow.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a9b160c4b15aeb5af0d84b27da56bf33cd9899f5 |
| --- /dev/null |
| +++ b/content/browser/android/overscroll_glow.h |
| @@ -0,0 +1,80 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_BROWSER_ANDROID_OVERSCROLL_GLOW_H_ |
| +#define CONTENT_BROWSER_ANDROID_OVERSCROLL_GLOW_H_ |
| + |
| +#include "base/memory/ref_counted.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/time.h" |
| +#include "content/browser/android/edge_effect.h" |
| +#include "ui/gfx/size_f.h" |
| +#include "ui/gfx/vector2d_f.h" |
| + |
| +class SkBitmap; |
| + |
| +namespace cc { |
| +class Layer; |
| +} |
| + |
| +namespace content { |
| + |
| +/* |OverscrollGlow| mirrors its Android counterpart, EdgeEffect.java. |
| + * Conscious tradeoffs were made to align this as closely as possible with the |
| + * original Android java version. |
| + */ |
| +class OverscrollGlow { |
| + public: |
| + static scoped_ptr<OverscrollGlow> Create(); |
| + |
| + ~OverscrollGlow(); |
| + |
| + void OnOverscrolled(base::TimeTicks current_time, |
| + gfx::Vector2dF overscroll, |
| + gfx::Vector2dF velocity); |
| + // Returns true if the effect still needs animation ticks. |
| + bool Animate(base::TimeTicks current_time); |
| + void Finish(); |
| + |
| + // Returns true if the effect needs animation ticks. |
| + bool IsActive() const; |
| + |
| + 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
|
| + void set_vertical_overscroll_enabled(bool enabled); |
| + void set_size(gfx::SizeF size); |
| + void set_parent_layer(scoped_refptr<cc::Layer> parent_layer); |
| + |
| + private: |
| + enum Axis { AXIS_X, AXIS_Y }; |
| + |
| + OverscrollGlow(const SkBitmap& edge, const SkBitmap& glow); |
| + |
| + void Pull(base::TimeTicks current_time, |
| + gfx::Vector2dF added_overscroll); |
| + void Absorb(base::TimeTicks current_time, |
| + gfx::Vector2dF velocity, |
| + gfx::Vector2dF overscroll, |
| + gfx::Vector2dF old_overscroll); |
| + |
| + void Release(base::TimeTicks current_time); |
| + void Release(Axis axis, base::TimeTicks current_time); |
| + |
| + EdgeEffect* GetOppositeEdge(int edge_index); |
| + |
| + scoped_ptr<EdgeEffect> edge_effects_[EdgeEffect::EDGE_COUNT]; |
| + |
| + gfx::SizeF size_; |
| + gfx::Vector2dF old_overscroll_; |
| + gfx::Vector2dF old_velocity_; |
| + bool horizontal_overscroll_enabled_; |
| + bool vertical_overscroll_enabled_; |
| + |
| + scoped_refptr<cc::Layer> parent_layer_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(OverscrollGlow); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_ANDROID_SCROLL_GLOW_H_ |