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

Side by Side Diff: ui/base/animation/animation.cc

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

Powered by Google App Engine
This is Rietveld 408576698