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

Side by Side Diff: app/linear_animation.h

Issue 6154001: Move animation code to new ui/base/animation directory.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 | « app/app_base.gypi ('k') | app/linear_animation.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 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 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 // Inspired by NSAnimation
5 4
6 #ifndef APP_LINEAR_ANIMATION_H_ 5 #ifndef APP_LINEAR_ANIMATION_H_
7 #define APP_LINEAR_ANIMATION_H_ 6 #define APP_LINEAR_ANIMATION_H_
8 #pragma once 7 #pragma once
9 8
10 #include "app/animation.h" 9 #include "ui/base/animation/linear_animation.h"
11 #include "base/time.h"
12 10
13 class AnimationDelegate; 11 using ui::LinearAnimation;
14
15 // Linear time bounded animation. As the animation progresses AnimateToState is
16 // invoked.
17 class LinearAnimation : public Animation {
18 public:
19 // Initializes everything except the duration.
20 //
21 // Caller must make sure to call SetDuration() if they use this
22 // constructor; it is preferable to use the full one, but sometimes
23 // duration can change between calls to Start() and we need to
24 // expose this interface.
25 LinearAnimation(int frame_rate, AnimationDelegate* delegate);
26
27 // Initializes all fields.
28 LinearAnimation(int duration, int frame_rate, AnimationDelegate* delegate);
29
30 // Gets the value for the current state, according to the animation curve in
31 // use. This class provides only for a linear relationship, however subclasses
32 // can override this to provide others.
33 virtual double GetCurrentValue() const;
34
35 // Skip to the end of the current animation.
36 void End();
37
38 // Changes the length of the animation. This resets the current
39 // state of the animation to the beginning.
40 void SetDuration(int duration);
41
42 protected:
43 // Called when the animation progresses. Subclasses override this to
44 // efficiently update their state.
45 virtual void AnimateToState(double state) = 0;
46
47 // Invoked by the AnimationContainer when the animation is running to advance
48 // the animation. Use |time_now| rather than Time::Now to avoid multiple
49 // animations running at the same time diverging.
50 virtual void Step(base::TimeTicks time_now);
51
52 // Overriden to advance to the end (if End was invoked).
53 virtual void AnimationStopped();
54
55 // Overriden to return true if state is not 1.
56 virtual bool ShouldSendCanceledFromStop();
57
58 private:
59 base::TimeDelta duration_;
60
61 // Current state, on a scale from 0.0 to 1.0.
62 double state_;
63
64 // If true, we're in end. This is used to determine if the animation should
65 // be advanced to the end from AnimationStopped.
66 bool in_end_;
67
68 DISALLOW_COPY_AND_ASSIGN(LinearAnimation);
69 };
70 12
71 #endif // APP_LINEAR_ANIMATION_H_ 13 #endif // APP_LINEAR_ANIMATION_H_
OLDNEW
« no previous file with comments | « app/app_base.gypi ('k') | app/linear_animation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698