| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2011 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 UI_VIEWS_ANIMATION_SCROLL_ANIMATOR_H_ |
| 6 #define UI_VIEWS_ANIMATION_SCROLL_ANIMATOR_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "ui/base/animation/animation_delegate.h" |
| 11 #pragma once |
| 12 |
| 13 #include "views/views_export.h" |
| 14 |
| 15 namespace ui { |
| 16 class SlideAnimation; |
| 17 } |
| 18 |
| 19 namespace views { |
| 20 |
| 21 class VIEWS_EXPORT ScrollDelegate { |
| 22 public: |
| 23 virtual void OnScroll(float dx, float dy) = 0; |
| 24 |
| 25 protected: |
| 26 ~ScrollDelegate() {} |
| 27 }; |
| 28 |
| 29 class VIEWS_EXPORT ScrollAnimator : public ui::AnimationDelegate { |
| 30 public: |
| 31 // The ScrollAnimator does not own the delegate. Uses default acceleration. |
| 32 explicit ScrollAnimator(ScrollDelegate* delegate); |
| 33 virtual ~ScrollAnimator(); |
| 34 |
| 35 // Use this if you would prefer different acceleration than the default. |
| 36 void set_acceleration(float acceleration) { acceleration_ = acceleration; } |
| 37 |
| 38 void Start(float velocity_x, float velocity_y); |
| 39 void Stop(); |
| 40 |
| 41 bool is_scrolling() const { return animation_.get(); } |
| 42 |
| 43 private: |
| 44 // Implementation of ui::AnimationDelegate. |
| 45 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; |
| 46 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; |
| 47 virtual void AnimationCanceled(const ui::Animation* animation) OVERRIDE; |
| 48 |
| 49 ScrollDelegate* delegate_; |
| 50 |
| 51 float velocity_x_; |
| 52 float velocity_y_; |
| 53 float last_t_; |
| 54 float duration_; |
| 55 float acceleration_; |
| 56 |
| 57 scoped_ptr<ui::SlideAnimation> animation_; |
| 58 |
| 59 DISALLOW_COPY_AND_ASSIGN(ScrollAnimator); |
| 60 }; |
| 61 |
| 62 } // namespace views |
| 63 |
| 64 #endif // UI_VIEWS_ANIMATION_SCROLL_ANIMATOR_H_ |
| OLD | NEW |