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

Side by Side Diff: app/animation.cc

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/animation.h ('k') | app/animation_container.h » ('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) 2010 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 #include "app/animation.h"
6
7 #include "app/animation_container.h"
8 #include "app/animation_delegate.h"
9 #include "app/tween.h"
10 #include "gfx/rect.h"
11
12 #if defined(OS_WIN)
13 #include "base/win/windows_version.h"
14 #endif
15
16 Animation::Animation(base::TimeDelta timer_interval)
17 : timer_interval_(timer_interval),
18 is_animating_(false),
19 delegate_(NULL) {
20 }
21
22 Animation::~Animation() {
23 // Don't send out notification from the destructor. Chances are the delegate
24 // owns us and is being deleted as well.
25 if (is_animating_)
26 container_->Stop(this);
27 }
28
29 void Animation::Start() {
30 if (is_animating_)
31 return;
32
33 if (!container_.get())
34 container_ = new AnimationContainer();
35
36 is_animating_ = true;
37
38 container_->Start(this);
39
40 AnimationStarted();
41 }
42
43 void Animation::Stop() {
44 if (!is_animating_)
45 return;
46
47 is_animating_ = false;
48
49 // Notify the container first as the delegate may delete us.
50 container_->Stop(this);
51
52 AnimationStopped();
53
54 if (delegate_) {
55 if (ShouldSendCanceledFromStop())
56 delegate_->AnimationCanceled(this);
57 else
58 delegate_->AnimationEnded(this);
59 }
60 }
61
62 double Animation::CurrentValueBetween(double start, double target) const {
63 return Tween::ValueBetween(GetCurrentValue(), start, target);
64 }
65
66 int Animation::CurrentValueBetween(int start, int target) const {
67 return Tween::ValueBetween(GetCurrentValue(), start, target);
68 }
69
70 gfx::Rect Animation::CurrentValueBetween(const gfx::Rect& start_bounds,
71 const gfx::Rect& target_bounds) const {
72 return Tween::ValueBetween(GetCurrentValue(), start_bounds, target_bounds);
73 }
74
75 void Animation::SetContainer(AnimationContainer* container) {
76 if (container == container_.get())
77 return;
78
79 if (is_animating_)
80 container_->Stop(this);
81
82 if (container)
83 container_ = container;
84 else
85 container_ = new AnimationContainer();
86
87 if (is_animating_)
88 container_->Start(this);
89 }
90
91 // static
92 bool Animation::ShouldRenderRichAnimation() {
93 #if defined(OS_WIN)
94 if (base::win::GetVersion() >= base::win::VERSION_VISTA) {
95 BOOL result;
96 // Get "Turn off all unnecessary animations" value.
97 if (::SystemParametersInfo(SPI_GETCLIENTAREAANIMATION, 0, &result, 0)) {
98 // There seems to be a typo in the MSDN document (as of May 2009):
99 // http://msdn.microsoft.com/en-us/library/ms724947(VS.85).aspx
100 // The document states that the result is TRUE when animations are
101 // _disabled_, but in fact, it is TRUE when they are _enabled_.
102 return !!result;
103 }
104 }
105 return !::GetSystemMetrics(SM_REMOTESESSION);
106 #endif
107 return true;
108 }
109
110 bool Animation::ShouldSendCanceledFromStop() {
111 return false;
112 }
113
114 void Animation::SetStartTime(base::TimeTicks start_time) {
115 start_time_ = start_time;
116 }
117
118 base::TimeDelta Animation::GetTimerInterval() const {
119 return timer_interval_;
120 }
OLDNEW
« no previous file with comments | « app/animation.h ('k') | app/animation_container.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698