| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_GLOW_H_ | 5 #ifndef UI_ANDROID_OVERSCROLL_GLOW_H_ |
| 6 #define UI_ANDROID_OVERSCROLL_GLOW_H_ | 6 #define UI_ANDROID_OVERSCROLL_GLOW_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 9 |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 12 #include "ui/android/edge_effect_base.h" | 13 #include "ui/android/edge_effect_base.h" |
| 13 #include "ui/android/ui_android_export.h" | 14 #include "ui/android/ui_android_export.h" |
| 14 #include "ui/gfx/geometry/size_f.h" | 15 #include "ui/gfx/geometry/size_f.h" |
| 15 #include "ui/gfx/geometry/vector2d_f.h" | 16 #include "ui/gfx/geometry/vector2d_f.h" |
| 16 | 17 |
| 17 namespace cc { | 18 namespace cc { |
| 18 class Layer; | 19 class Layer; |
| 19 } | 20 } |
| 20 | 21 |
| 21 namespace ui { | 22 namespace ui { |
| 22 | 23 |
| 23 // Provides lazy, customized EdgeEffect creation. | 24 // Provides lazy, customized EdgeEffect creation. |
| 24 class UI_ANDROID_EXPORT OverscrollGlowClient { | 25 class UI_ANDROID_EXPORT OverscrollGlowClient { |
| 25 public: | 26 public: |
| 26 virtual ~OverscrollGlowClient() {} | 27 virtual ~OverscrollGlowClient() {} |
| 27 | 28 |
| 28 // Called lazily, after the initial overscrolling event. | 29 // Called lazily, after the initial overscrolling event. |
| 29 virtual scoped_ptr<EdgeEffectBase> CreateEdgeEffect() = 0; | 30 virtual std::unique_ptr<EdgeEffectBase> CreateEdgeEffect() = 0; |
| 30 }; | 31 }; |
| 31 | 32 |
| 32 /* |OverscrollGlow| mirrors its Android counterpart, OverscrollGlow.java. | 33 /* |OverscrollGlow| mirrors its Android counterpart, OverscrollGlow.java. |
| 33 * Conscious tradeoffs were made to align this as closely as possible with the | 34 * Conscious tradeoffs were made to align this as closely as possible with the |
| 34 * original Android Java version. | 35 * original Android Java version. |
| 35 */ | 36 */ |
| 36 class UI_ANDROID_EXPORT OverscrollGlow { | 37 class UI_ANDROID_EXPORT OverscrollGlow { |
| 37 public: | 38 public: |
| 38 // |client| must be valid for the duration of the effect's lifetime. | 39 // |client| must be valid for the duration of the effect's lifetime. |
| 39 // The effect is enabled by default, but will remain dormant until the first | 40 // The effect is enabled by default, but will remain dormant until the first |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 const gfx::Vector2dF& overscroll_location); | 88 const gfx::Vector2dF& overscroll_location); |
| 88 void Absorb(base::TimeTicks current_time, | 89 void Absorb(base::TimeTicks current_time, |
| 89 const gfx::Vector2dF& velocity, | 90 const gfx::Vector2dF& velocity, |
| 90 bool x_overscroll_started, | 91 bool x_overscroll_started, |
| 91 bool y_overscroll_started); | 92 bool y_overscroll_started); |
| 92 void Release(base::TimeTicks current_time); | 93 void Release(base::TimeTicks current_time); |
| 93 | 94 |
| 94 EdgeEffectBase* GetOppositeEdge(int edge_index); | 95 EdgeEffectBase* GetOppositeEdge(int edge_index); |
| 95 | 96 |
| 96 OverscrollGlowClient* const client_; | 97 OverscrollGlowClient* const client_; |
| 97 scoped_ptr<EdgeEffectBase> edge_effects_[EDGE_COUNT]; | 98 std::unique_ptr<EdgeEffectBase> edge_effects_[EDGE_COUNT]; |
| 98 | 99 |
| 99 gfx::SizeF viewport_size_; | 100 gfx::SizeF viewport_size_; |
| 100 float edge_offsets_[EDGE_COUNT]; | 101 float edge_offsets_[EDGE_COUNT]; |
| 101 bool initialized_; | 102 bool initialized_; |
| 102 bool allow_horizontal_overscroll_; | 103 bool allow_horizontal_overscroll_; |
| 103 bool allow_vertical_overscroll_; | 104 bool allow_vertical_overscroll_; |
| 104 | 105 |
| 105 scoped_refptr<cc::Layer> root_layer_; | 106 scoped_refptr<cc::Layer> root_layer_; |
| 106 | 107 |
| 107 DISALLOW_COPY_AND_ASSIGN(OverscrollGlow); | 108 DISALLOW_COPY_AND_ASSIGN(OverscrollGlow); |
| 108 }; | 109 }; |
| 109 | 110 |
| 110 } // namespace ui | 111 } // namespace ui |
| 111 | 112 |
| 112 #endif // UI_ANDROID_OVERSCROLL_GLOW_H_ | 113 #endif // UI_ANDROID_OVERSCROLL_GLOW_H_ |
| OLD | NEW |