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

Side by Side Diff: ui/views/animation/scroll_animator.h

Issue 8508024: Support touch scroll gestures in menus. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix win_aura Created 8 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/views/animation/scroll_animator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 UI_VIEWS_ANIMATION_SCROLL_ANIMATOR_H_
6 #define UI_VIEWS_ANIMATION_SCROLL_ANIMATOR_H_
7 #pragma once
8
9 #include "base/basictypes.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "ui/base/animation/animation_delegate.h"
12 #include "ui/views/views_export.h"
13
14 namespace ui {
15 class SlideAnimation;
16 }
17
18 namespace views {
19
20 class VIEWS_EXPORT ScrollDelegate {
21 public:
22 virtual void OnScroll(float dx, float dy) = 0;
23
24 protected:
25 ~ScrollDelegate() {}
26 };
27
28 class VIEWS_EXPORT ScrollAnimator : public ui::AnimationDelegate {
29 public:
30 // The ScrollAnimator does not own the delegate. Uses default acceleration.
31 explicit ScrollAnimator(ScrollDelegate* delegate);
32 virtual ~ScrollAnimator();
33
34 // Use this if you would prefer different acceleration than the default.
35 void set_acceleration(float acceleration) { acceleration_ = acceleration; }
36
37 void Start(float velocity_x, float velocity_y);
38 void Stop();
39
40 bool is_scrolling() const { return !!animation_.get(); }
41
42 private:
43 // Implementation of ui::AnimationDelegate.
44 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE;
45 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE;
46 virtual void AnimationCanceled(const ui::Animation* animation) OVERRIDE;
47
48 ScrollDelegate* delegate_;
49
50 float velocity_x_;
51 float velocity_y_;
52 float last_t_;
53 float duration_;
54 float acceleration_;
55
56 scoped_ptr<ui::SlideAnimation> animation_;
57
58 DISALLOW_COPY_AND_ASSIGN(ScrollAnimator);
59 };
60
61 } // namespace views
62
63 #endif // UI_VIEWS_ANIMATION_SCROLL_ANIMATOR_H_
OLDNEW
« no previous file with comments | « no previous file | ui/views/animation/scroll_animator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698