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

Unified Diff: ui/base/animation/linear_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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/animation/linear_animation.h ('k') | ui/base/animation/multi_animation.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/animation/linear_animation.cc
diff --git a/ui/base/animation/linear_animation.cc b/ui/base/animation/linear_animation.cc
deleted file mode 100644
index 33bd1d1a4818effafad12a00056cdb28048aaa64..0000000000000000000000000000000000000000
--- a/ui/base/animation/linear_animation.cc
+++ /dev/null
@@ -1,108 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/base/animation/linear_animation.h"
-
-#include <math.h>
-
-#include "ui/base/animation/animation_container.h"
-#include "ui/base/animation/animation_delegate.h"
-
-using base::Time;
-using base::TimeDelta;
-
-namespace ui {
-
-static TimeDelta CalculateInterval(int frame_rate) {
- int timer_interval = 1000000 / frame_rate;
- if (timer_interval < 10000)
- timer_interval = 10000;
- return TimeDelta::FromMicroseconds(timer_interval);
-}
-
-LinearAnimation::LinearAnimation(int frame_rate,
- AnimationDelegate* delegate)
- : Animation(CalculateInterval(frame_rate)),
- state_(0.0),
- in_end_(false) {
- set_delegate(delegate);
-}
-
-LinearAnimation::LinearAnimation(int duration,
- int frame_rate,
- AnimationDelegate* delegate)
- : Animation(CalculateInterval(frame_rate)),
- duration_(TimeDelta::FromMilliseconds(duration)),
- state_(0.0),
- in_end_(false) {
- set_delegate(delegate);
- SetDuration(duration);
-}
-
-double LinearAnimation::GetCurrentValue() const {
- // Default is linear relationship, subclass to adapt.
- return state_;
-}
-
-void LinearAnimation::SetCurrentValue(double new_value) {
- new_value = std::max(0.0, std::min(1.0, new_value));
- base::TimeDelta time_delta = base::TimeDelta::FromMicroseconds(
- duration_.InMicroseconds() * (new_value - state_));
- SetStartTime(start_time() - time_delta);
- state_ = new_value;
-}
-
-void LinearAnimation::End() {
- if (!is_animating())
- return;
-
- // NOTE: We don't use AutoReset here as Stop may end up deleting us (by way
- // of the delegate).
- in_end_ = true;
- Stop();
-}
-
-void LinearAnimation::SetDuration(int duration) {
- duration_ = TimeDelta::FromMilliseconds(duration);
- if (duration_ < timer_interval())
- duration_ = timer_interval();
- if (is_animating())
- SetStartTime(container()->last_tick_time());
-}
-
-void LinearAnimation::Step(base::TimeTicks time_now) {
- TimeDelta elapsed_time = time_now - start_time();
- state_ = static_cast<double>(elapsed_time.InMicroseconds()) /
- static_cast<double>(duration_.InMicroseconds());
- if (state_ >= 1.0)
- state_ = 1.0;
-
- AnimateToState(state_);
-
- if (delegate())
- delegate()->AnimationProgressed(this);
-
- if (state_ == 1.0)
- Stop();
-}
-
-void LinearAnimation::AnimationStarted() {
- state_ = 0.0;
-}
-
-void LinearAnimation::AnimationStopped() {
- if (!in_end_)
- return;
-
- in_end_ = false;
- // Set state_ to ensure we send ended to delegate and not canceled.
- state_ = 1;
- AnimateToState(1.0);
-}
-
-bool LinearAnimation::ShouldSendCanceledFromStop() {
- return state_ != 1;
-}
-
-} // namespace ui
« no previous file with comments | « ui/base/animation/linear_animation.h ('k') | ui/base/animation/multi_animation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698