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

Side by Side Diff: app/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 | « no previous file | app/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 4
5 #ifndef APP_ANIMATION_H_ 5 #ifndef APP_ANIMATION_H_
6 #define APP_ANIMATION_H_ 6 #define APP_ANIMATION_H_
7 #pragma once 7 #pragma once
8 8
9 #include "app/animation_container_element.h" 9 #include "ui/base/animation/animation.h"
10 #include "base/ref_counted.h"
11 #include "base/time.h"
12 10
13 namespace gfx { 11 using ui::Animation;
14 class Rect;
15 }
16
17 class AnimationContainer;
18 class AnimationDelegate;
19
20 // Base class used in implementing animations. You only need use this class if
21 // you're implementing a new animation type, otherwise you'll likely want one of
22 // LinearAnimation, SlideAnimation, ThrobAnimation or MultiAnimation.
23 //
24 // To subclass override Step, which is invoked as the animation progresses and
25 // GetCurrentValue() to return the value appropriate to the animation.
26 class Animation : public AnimationContainerElement {
27 public:
28 explicit Animation(base::TimeDelta timer_interval);
29 virtual ~Animation();
30
31 // Starts the animation. Does nothing if the animation is already running.
32 void Start();
33
34 // Stops the animation. Does nothing if the animation is not running.
35 void Stop();
36
37 // Gets the value for the current state, according to the animation
38 // curve in use.
39 virtual double GetCurrentValue() const = 0;
40
41 // Convenience for returning a value between |start| and |target| based on
42 // the current value. This is (target - start) * GetCurrentValue() + start.
43 double CurrentValueBetween(double start, double target) const;
44 int CurrentValueBetween(int start, int target) const;
45 gfx::Rect CurrentValueBetween(const gfx::Rect& start_bounds,
46 const gfx::Rect& target_bounds) const;
47
48 // Sets the delegate.
49 void set_delegate(AnimationDelegate* delegate) { delegate_ = delegate; }
50
51 // Sets the container used to manage the timer. A value of NULL results in
52 // creating a new AnimationContainer.
53 void SetContainer(AnimationContainer* container);
54
55 bool is_animating() const { return is_animating_; }
56
57 base::TimeDelta timer_interval() const { return timer_interval_; }
58
59 // Returns true if rich animations should be rendered.
60 // Looks at session type (e.g. remote desktop) and accessibility settings
61 // to give guidance for heavy animations such as "start download" arrow.
62 static bool ShouldRenderRichAnimation();
63
64 protected:
65 // Invoked from Start to allow subclasses to prepare for the animation.
66 virtual void AnimationStarted() {}
67
68 // Invoked from Stop after we're removed from the container but before the
69 // delegate has been invoked.
70 virtual void AnimationStopped() {}
71
72 // Invoked from stop to determine if cancel should be invoked. If this returns
73 // true the delegate is notified the animation was canceled, otherwise the
74 // delegate is notified the animation stopped.
75 virtual bool ShouldSendCanceledFromStop();
76
77 AnimationContainer* container() { return container_.get(); }
78 base::TimeTicks start_time() const { return start_time_; }
79 AnimationDelegate* delegate() { return delegate_; }
80
81 // AnimationContainer::Element overrides
82 virtual void SetStartTime(base::TimeTicks start_time);
83 virtual void Step(base::TimeTicks time_now) = 0;
84 virtual base::TimeDelta GetTimerInterval() const;
85
86 private:
87 // Interval for the animation.
88 const base::TimeDelta timer_interval_;
89
90 // If true we're running.
91 bool is_animating_;
92
93 // Our delegate; may be null.
94 AnimationDelegate* delegate_;
95
96 // Container we're in. If non-null we're animating.
97 scoped_refptr<AnimationContainer> container_;
98
99 // Time we started at.
100 base::TimeTicks start_time_;
101
102 DISALLOW_COPY_AND_ASSIGN(Animation);
103 };
104 12
105 #endif // APP_ANIMATION_H_ 13 #endif // APP_ANIMATION_H_
OLDNEW
« no previous file with comments | « no previous file | app/animation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698