summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-18 21:48:18 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-18 21:48:18 +0000
commitff7c7ed36be6942c7cb88ded9894f4e0faf5d58c (patch)
tree52a4b67ab286a67e1f9789a900ced14904152783
parent4a6d55db2d03a33c35e205e85d4b610ed88ce64f (diff)
downloadchromium_src-ff7c7ed36be6942c7cb88ded9894f4e0faf5d58c.zip
chromium_src-ff7c7ed36be6942c7cb88ded9894f4e0faf5d58c.tar.gz
chromium_src-ff7c7ed36be6942c7cb88ded9894f4e0faf5d58c.tar.bz2
More animation cleanup.
BUG=none TEST=none Review URL: http://codereview.chromium.org/5154006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66683 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--app/animation.cc1
-rw-r--r--app/animation.h5
-rw-r--r--app/animation_container.cc7
-rw-r--r--app/animation_container.h50
-rw-r--r--app/animation_container_element.h30
-rw-r--r--app/animation_container_observer.h27
-rw-r--r--app/animation_container_unittest.cc3
-rw-r--r--app/app_base.gypi2
-rw-r--r--app/linear_animation.cc1
-rw-r--r--app/multi_animation.cc1
-rw-r--r--app/multi_animation_unittest.cc17
-rw-r--r--chrome/browser/chromeos/volume_bubble.h1
-rw-r--r--views/animation/bounds_animator.cc1
-rw-r--r--views/animation/bounds_animator.h8
-rw-r--r--views/controls/button/text_button.cc1
15 files changed, 99 insertions, 56 deletions
diff --git a/app/animation.cc b/app/animation.cc
index 40f53f9..595af9f 100644
--- a/app/animation.cc
+++ b/app/animation.cc
@@ -4,6 +4,7 @@
#include "app/animation.h"
+#include "app/animation_container.h"
#include "app/animation_delegate.h"
#include "app/tween.h"
#include "gfx/rect.h"
diff --git a/app/animation.h b/app/animation.h
index 06ccf52..87dc43f 100644
--- a/app/animation.h
+++ b/app/animation.h
@@ -6,7 +6,7 @@
#define APP_ANIMATION_H_
#pragma once
-#include "app/animation_container.h"
+#include "app/animation_container_element.h"
#include "base/ref_counted.h"
#include "base/time.h"
@@ -14,6 +14,7 @@ namespace gfx {
class Rect;
}
+class AnimationContainer;
class AnimationDelegate;
// Base class used in implementing animations. You only need use this class if
@@ -22,7 +23,7 @@ class AnimationDelegate;
//
// To subclass override Step, which is invoked as the animation progresses and
// GetCurrentValue() to return the value appropriate to the animation.
-class Animation : public AnimationContainer::Element {
+class Animation : public AnimationContainerElement {
public:
explicit Animation(base::TimeDelta timer_interval);
virtual ~Animation();
diff --git a/app/animation_container.cc b/app/animation_container.cc
index a601222..cba3d4b 100644
--- a/app/animation_container.cc
+++ b/app/animation_container.cc
@@ -4,6 +4,9 @@
#include "app/animation_container.h"
+#include "app/animation_container_element.h"
+#include "app/animation_container_observer.h"
+
using base::TimeDelta;
using base::TimeTicks;
@@ -18,7 +21,7 @@ AnimationContainer::~AnimationContainer() {
DCHECK(elements_.empty());
}
-void AnimationContainer::Start(Element* element) {
+void AnimationContainer::Start(AnimationContainerElement* element) {
DCHECK(elements_.count(element) == 0); // Start should only be invoked if the
// element isn't running.
@@ -33,7 +36,7 @@ void AnimationContainer::Start(Element* element) {
elements_.insert(element);
}
-void AnimationContainer::Stop(Element* element) {
+void AnimationContainer::Stop(AnimationContainerElement* element) {
DCHECK(elements_.count(element) > 0); // The element must be running.
elements_.erase(element);
diff --git a/app/animation_container.h b/app/animation_container.h
index 806b4e1..3d92699 100644
--- a/app/animation_container.h
+++ b/app/animation_container.h
@@ -12,6 +12,9 @@
#include "base/time.h"
#include "base/timer.h"
+class AnimationContainerElement;
+class AnimationContainerObserver;
+
// AnimationContainer is used by Animation to manage the underlying timer.
// Internally each Animation creates a single AnimationContainer. You can
// group a set of Animations into the same AnimationContainer by way of
@@ -22,55 +25,22 @@
// AnimationContainer own it.
class AnimationContainer : public base::RefCounted<AnimationContainer> {
public:
- // The observer is notified after every update of the animations managed by
- // the container.
- class Observer {
- public:
- // Invoked on every tick of the timer managed by the container and after
- // all the animations have updated.
- virtual void AnimationContainerProgressed(
- AnimationContainer* container) = 0;
-
- // Invoked when no more animations are being managed by this container.
- virtual void AnimationContainerEmpty(AnimationContainer* container) = 0;
-
- protected:
- virtual ~Observer() {}
- };
-
- // Interface for the elements the AnimationContainer contains. This is
- // implemented by Animation.
- class Element {
- public:
- // Sets the start of the animation. This is invoked from
- // AnimationContainer::Start.
- virtual void SetStartTime(base::TimeTicks start_time) = 0;
-
- // Invoked when the animation is to progress.
- virtual void Step(base::TimeTicks time_now) = 0;
-
- // Returns the time interval of the animation. If an Element needs to change
- // this it should first invoke Stop, then Start.
- virtual base::TimeDelta GetTimerInterval() const = 0;
-
- protected:
- virtual ~Element() {}
- };
-
AnimationContainer();
// Invoked by Animation when it needs to start. Starts the timer if necessary.
// NOTE: This is invoked by Animation for you, you shouldn't invoke this
// directly.
- void Start(Element* animation);
+ void Start(AnimationContainerElement* animation);
// Invoked by Animation when it needs to stop. If there are no more animations
// running the timer stops.
// NOTE: This is invoked by Animation for you, you shouldn't invoke this
// directly.
- void Stop(Element* animation);
+ void Stop(AnimationContainerElement* animation);
- void set_observer(Observer* observer) { observer_ = observer; }
+ void set_observer(AnimationContainerObserver* observer) {
+ observer_ = observer;
+ }
// The time the last animation ran at.
base::TimeTicks last_tick_time() const { return last_tick_time_; }
@@ -81,7 +51,7 @@ class AnimationContainer : public base::RefCounted<AnimationContainer> {
private:
friend class base::RefCounted<AnimationContainer>;
- typedef std::set<Element*> Elements;
+ typedef std::set<AnimationContainerElement*> Elements;
~AnimationContainer();
@@ -108,7 +78,7 @@ class AnimationContainer : public base::RefCounted<AnimationContainer> {
base::RepeatingTimer<AnimationContainer> timer_;
- Observer* observer_;
+ AnimationContainerObserver* observer_;
DISALLOW_COPY_AND_ASSIGN(AnimationContainer);
};
diff --git a/app/animation_container_element.h b/app/animation_container_element.h
new file mode 100644
index 0000000..57793f6
--- /dev/null
+++ b/app/animation_container_element.h
@@ -0,0 +1,30 @@
+// Copyright (c) 2010 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.
+
+#ifndef APP_ANIMATION_CONTAINER_ELEMENT_H_
+#define APP_ANIMATION_CONTAINER_ELEMENT_H_
+#pragma once
+
+#include "base/time.h"
+
+// Interface for the elements the AnimationContainer contains. This is
+// implemented by Animation.
+class AnimationContainerElement {
+ public:
+ // Sets the start of the animation. This is invoked from
+ // AnimationContainer::Start.
+ virtual void SetStartTime(base::TimeTicks start_time) = 0;
+
+ // Invoked when the animation is to progress.
+ virtual void Step(base::TimeTicks time_now) = 0;
+
+ // Returns the time interval of the animation. If an Element needs to change
+ // this it should first invoke Stop, then Start.
+ virtual base::TimeDelta GetTimerInterval() const = 0;
+
+ protected:
+ virtual ~AnimationContainerElement() {}
+};
+
+#endif // APP_ANIMATION_CONTAINER_ELEMENT_H_
diff --git a/app/animation_container_observer.h b/app/animation_container_observer.h
new file mode 100644
index 0000000..9f74a91
--- /dev/null
+++ b/app/animation_container_observer.h
@@ -0,0 +1,27 @@
+// Copyright (c) 2010 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.
+
+#ifndef APP_ANIMATION_CONTAINER_OBSERVER_H_
+#define APP_ANIMATION_CONTAINER_OBSERVER_H_
+#pragma once
+
+class AnimationContainer;
+
+// The observer is notified after every update of the animations managed by
+// the container.
+class AnimationContainerObserver {
+ public:
+ // Invoked on every tick of the timer managed by the container and after
+ // all the animations have updated.
+ virtual void AnimationContainerProgressed(
+ AnimationContainer* container) = 0;
+
+ // Invoked when no more animations are being managed by this container.
+ virtual void AnimationContainerEmpty(AnimationContainer* container) = 0;
+
+ protected:
+ virtual ~AnimationContainerObserver() {}
+};
+
+#endif // APP_ANIMATION_CONTAINER_OBSERVER_H_
diff --git a/app/animation_container_unittest.cc b/app/animation_container_unittest.cc
index d99531b..5375fc7 100644
--- a/app/animation_container_unittest.cc
+++ b/app/animation_container_unittest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "app/animation_container.h"
+#include "app/animation_container_observer.h"
#include "app/linear_animation.h"
#include "app/test_animation_delegate.h"
#include "base/scoped_ptr.h"
@@ -13,7 +14,7 @@ using testing::AtLeast;
namespace {
-class MockObserver : public AnimationContainer::Observer {
+class MockObserver : public AnimationContainerObserver {
public:
MockObserver() {}
diff --git a/app/app_base.gypi b/app/app_base.gypi
index 12e1701..37e0640 100644
--- a/app/app_base.gypi
+++ b/app/app_base.gypi
@@ -98,6 +98,8 @@
'active_window_watcher_x.h',
'animation_container.cc',
'animation_container.h',
+ 'animation_container_element.h',
+ 'animation_container_observer.h',
'animation.cc',
'animation.h',
'bidi_line_iterator.cc',
diff --git a/app/linear_animation.cc b/app/linear_animation.cc
index 533a435..5eb05dd 100644
--- a/app/linear_animation.cc
+++ b/app/linear_animation.cc
@@ -6,6 +6,7 @@
#include <math.h>
+#include "app/animation_container.h"
#include "app/animation_delegate.h"
using base::Time;
diff --git a/app/multi_animation.cc b/app/multi_animation.cc
index 3ba6715..411708c 100644
--- a/app/multi_animation.cc
+++ b/app/multi_animation.cc
@@ -5,6 +5,7 @@
#include "app/multi_animation.h"
#include "app/animation_delegate.h"
+#include "base/logging.h"
// Default interval, in ms.
static const int kDefaultInterval = 20;
diff --git a/app/multi_animation_unittest.cc b/app/multi_animation_unittest.cc
index e6e81f1..393b01c 100644
--- a/app/multi_animation_unittest.cc
+++ b/app/multi_animation_unittest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "app/animation_container_element.h"
#include "app/multi_animation.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -14,8 +15,8 @@ TEST_F(MultiAnimationTest, Basic) {
parts.push_back(MultiAnimation::Part(100, Tween::EASE_OUT));
MultiAnimation animation(parts);
- AnimationContainer::Element* as_element =
- static_cast<AnimationContainer::Element*>(&animation);
+ AnimationContainerElement* as_element =
+ static_cast<AnimationContainerElement*>(&animation);
as_element->SetStartTime(base::TimeTicks());
// Step to 50, which is half way through the first part.
@@ -43,8 +44,8 @@ TEST_F(MultiAnimationTest, DifferingStartAndEnd) {
parts[0].end_time_ms = 400;
MultiAnimation animation(parts);
- AnimationContainer::Element* as_element =
- static_cast<AnimationContainer::Element*>(&animation);
+ AnimationContainerElement* as_element =
+ static_cast<AnimationContainerElement*>(&animation);
as_element->SetStartTime(base::TimeTicks());
// Step to 0. Because the start_time is 100, this should be 100ms into the
@@ -62,8 +63,8 @@ TEST_F(MultiAnimationTest, DontCycle) {
MultiAnimation::Parts parts;
parts.push_back(MultiAnimation::Part(200, Tween::LINEAR));
MultiAnimation animation(parts);
- AnimationContainer::Element* as_element =
- static_cast<AnimationContainer::Element*>(&animation);
+ AnimationContainerElement* as_element =
+ static_cast<AnimationContainerElement*>(&animation);
as_element->SetStartTime(base::TimeTicks());
animation.set_continuous(false);
@@ -78,8 +79,8 @@ TEST_F(MultiAnimationTest, Cycle) {
MultiAnimation::Parts parts;
parts.push_back(MultiAnimation::Part(200, Tween::LINEAR));
MultiAnimation animation(parts);
- AnimationContainer::Element* as_element =
- static_cast<AnimationContainer::Element*>(&animation);
+ AnimationContainerElement* as_element =
+ static_cast<AnimationContainerElement*>(&animation);
as_element->SetStartTime(base::TimeTicks());
// Step to 300, which is greater than the cycle time.
diff --git a/chrome/browser/chromeos/volume_bubble.h b/chrome/browser/chromeos/volume_bubble.h
index addd7e47..7496055 100644
--- a/chrome/browser/chromeos/volume_bubble.h
+++ b/chrome/browser/chromeos/volume_bubble.h
@@ -9,6 +9,7 @@
#include "app/animation_delegate.h"
#include "app/slide_animation.h"
#include "base/singleton.h"
+#include "base/timer.h"
#include "chrome/browser/views/info_bubble.h"
namespace chromeos {
diff --git a/views/animation/bounds_animator.cc b/views/animation/bounds_animator.cc
index 6a16af5..ad17ec9 100644
--- a/views/animation/bounds_animator.cc
+++ b/views/animation/bounds_animator.cc
@@ -4,6 +4,7 @@
#include "views/animation/bounds_animator.h"
+#include "app/animation_container.h"
#include "app/slide_animation.h"
#include "base/scoped_ptr.h"
#include "views/view.h"
diff --git a/views/animation/bounds_animator.h b/views/animation/bounds_animator.h
index ce8dcb2..5e5d976 100644
--- a/views/animation/bounds_animator.h
+++ b/views/animation/bounds_animator.h
@@ -8,10 +8,12 @@
#include <map>
-#include "app/animation_container.h"
+#include "app/animation_container_observer.h"
#include "app/animation_delegate.h"
+#include "base/ref_counted.h"
#include "gfx/rect.h"
+class AnimationContainer;
class SlideAnimation;
namespace views {
@@ -36,7 +38,7 @@ class BoundsAnimatorObserver {
// by way of SetAnimationDelegate. Additionally you can attach an observer to
// the BoundsAnimator that is notified when all animations are complete.
class BoundsAnimator : public AnimationDelegate,
- public AnimationContainer::Observer {
+ public AnimationContainerObserver {
public:
// If |delete_when_done| is set to true in |SetAnimationDelegate| the
// |AnimationDelegate| must subclass this class.
@@ -147,7 +149,7 @@ class BoundsAnimator : public AnimationDelegate,
virtual void AnimationEnded(const Animation* animation);
virtual void AnimationCanceled(const Animation* animation);
- // AnimationContainer::Observer overrides.
+ // AnimationContainerObserver overrides.
virtual void AnimationContainerProgressed(AnimationContainer* container);
virtual void AnimationContainerEmpty(AnimationContainer* container);
diff --git a/views/controls/button/text_button.cc b/views/controls/button/text_button.cc
index f758910..578be80 100644
--- a/views/controls/button/text_button.cc
+++ b/views/controls/button/text_button.cc
@@ -8,6 +8,7 @@
#include "app/throb_animation.h"
#include "app/resource_bundle.h"
+#include "base/logging.h"
#include "gfx/canvas_skia.h"
#include "views/controls/button/button.h"
#include "views/event.h"