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

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: Gardening. 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
OLDNEW
(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 "ui/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_
OLDNEW
« no previous file with comments | « no previous file | ui/views/animation/scroll_animator.cc » ('j') | ui/views/controls/menu/menu_host_root_view.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698