diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-21 02:01:10 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-21 02:01:10 +0000 |
commit | 326828b11895bb9753bbd9efd42800a9f4d67d6d (patch) | |
tree | 0ef95b36057b2bbe3cc86775c46e28d9468792c7 | |
parent | af81ff12c3a199c0a5a0b6ad44771ff61325ed40 (diff) | |
download | chromium_src-326828b11895bb9753bbd9efd42800a9f4d67d6d.zip chromium_src-326828b11895bb9753bbd9efd42800a9f4d67d6d.tar.gz chromium_src-326828b11895bb9753bbd9efd42800a9f4d67d6d.tar.bz2 |
Animate desktop rotations.
. Adds a LayerDelegate method to notify of the end of an animation.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/8364030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106658 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ui/aura/desktop.cc | 20 | ||||
-rw-r--r-- | ui/aura/desktop.h | 6 | ||||
-rw-r--r-- | ui/aura/window.cc | 3 | ||||
-rw-r--r-- | ui/aura/window.h | 3 | ||||
-rw-r--r-- | ui/gfx/compositor/layer_animator.cc | 2 | ||||
-rw-r--r-- | ui/gfx/compositor/layer_delegate.h | 5 | ||||
-rw-r--r-- | ui/gfx/compositor/layer_unittest.cc | 6 | ||||
-rw-r--r-- | views/view.cc | 3 | ||||
-rw-r--r-- | views/view.h | 1 |
9 files changed, 34 insertions, 15 deletions
diff --git a/ui/aura/desktop.cc b/ui/aura/desktop.cc index 64c07f4..56c990b 100644 --- a/ui/aura/desktop.cc +++ b/ui/aura/desktop.cc @@ -172,14 +172,15 @@ bool Desktop::DispatchKeyEvent(KeyEvent* event) { transform.ConcatTranslate(0, size.height()); break; case 1: - transform.ConcatRotate(90.0f); - transform.ConcatTranslate(size.width(), 0); - break; - case 2: transform.ConcatRotate(180.0f); transform.ConcatTranslate(size.width(), size.height()); break; + case 2: + transform.ConcatRotate(90.0f); + transform.ConcatTranslate(size.width(), 0); + break; } + layer()->SetAnimation(CreateDefaultAnimation()); SetTransform(transform); count = (count + 1) % 4; return true; @@ -363,13 +364,6 @@ void Desktop::ScheduleDraw() { } } -void Desktop::SetTransform(const ui::Transform& transform) { - Window::SetTransform(transform); - - // The transform can effect the size of the desktop. - OnHostResized(host_->GetSize()); -} - bool Desktop::CanFocus() const { return IsVisible(); } @@ -382,6 +376,10 @@ Desktop* Desktop::GetDesktop() { return this; } +void Desktop::OnLayerAnimationEnded(const ui::Animation* animation) { + OnHostResized(host_->GetSize()); +} + void Desktop::SetFocusedWindow(Window* focused_window) { if (focused_window == focused_window_ || (focused_window && !focused_window->CanFocus())) { diff --git a/ui/aura/desktop.h b/ui/aura/desktop.h index 1ba0ded..b510855 100644 --- a/ui/aura/desktop.h +++ b/ui/aura/desktop.h @@ -128,9 +128,6 @@ class AURA_EXPORT Desktop : public ui::CompositorDelegate, // If |window| has mouse capture, the current capture window is set to NULL. void ReleaseCapture(Window* window); - // Overridden from Window: - virtual void SetTransform(const ui::Transform& transform) OVERRIDE; - private: // Called whenever the mouse moves, tracks the current |mouse_moved_handler_|, // sending exited and entered events as its value changes. @@ -144,6 +141,9 @@ class AURA_EXPORT Desktop : public ui::CompositorDelegate, virtual internal::FocusManager* GetFocusManager() OVERRIDE; virtual Desktop* GetDesktop() OVERRIDE; + // Overridden from ui::LayerDelegate: + virtual void OnLayerAnimationEnded(const ui::Animation* animation) OVERRIDE; + // Overridden from FocusManager: virtual void SetFocusedWindow(Window* window) OVERRIDE; virtual Window* GetFocusedWindow() OVERRIDE; diff --git a/ui/aura/window.cc b/ui/aura/window.cc index 8e288a0..8ded1d2 100644 --- a/ui/aura/window.cc +++ b/ui/aura/window.cc @@ -486,4 +486,7 @@ void Window::OnPaintLayer(gfx::Canvas* canvas) { delegate_->OnPaint(canvas); } +void Window::OnLayerAnimationEnded(const ui::Animation* animation) { +} + } // namespace aura diff --git a/ui/aura/window.h b/ui/aura/window.h index 0eb8d98..e46a241 100644 --- a/ui/aura/window.h +++ b/ui/aura/window.h @@ -116,7 +116,7 @@ class AURA_EXPORT Window : public ui::LayerDelegate { virtual ToplevelWindowContainer* AsToplevelWindowContainer(); virtual const ToplevelWindowContainer* AsToplevelWindowContainer() const; - virtual void SetTransform(const ui::Transform& transform); + void SetTransform(const ui::Transform& transform); // Assigns a LayoutManager to size and place child windows. // The Window takes ownership of the LayoutManager. @@ -286,6 +286,7 @@ class AURA_EXPORT Window : public ui::LayerDelegate { // Overridden from ui::LayerDelegate: virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE; + virtual void OnLayerAnimationEnded(const ui::Animation* animation) OVERRIDE; int type_; diff --git a/ui/gfx/compositor/layer_animator.cc b/ui/gfx/compositor/layer_animator.cc index 5f2c63c..c9a7bca 100644 --- a/ui/gfx/compositor/layer_animator.cc +++ b/ui/gfx/compositor/layer_animator.cc @@ -170,6 +170,8 @@ void LayerAnimator::AnimationProgressed(const ui::Animation* animation) { void LayerAnimator::AnimationEnded(const ui::Animation* animation) { AnimationProgressed(animation); + if (layer_->delegate()) + layer_->delegate()->OnLayerAnimationEnded(animation); } void LayerAnimator::StopAnimating(AnimationProperty property) { diff --git a/ui/gfx/compositor/layer_delegate.h b/ui/gfx/compositor/layer_delegate.h index 1f494b1..973d12f 100644 --- a/ui/gfx/compositor/layer_delegate.h +++ b/ui/gfx/compositor/layer_delegate.h @@ -14,6 +14,8 @@ class Canvas; namespace ui { +class Animation; + // A delegate interface implemented by an object that renders to a Layer. class COMPOSITOR_EXPORT LayerDelegate { public: @@ -21,6 +23,9 @@ class COMPOSITOR_EXPORT LayerDelegate { // clipped to the Layer's invalid rect. virtual void OnPaintLayer(gfx::Canvas* canvas) = 0; + // Called when |animation| ends. + virtual void OnLayerAnimationEnded(const ui::Animation* animation) = 0; + protected: virtual ~LayerDelegate() {} }; diff --git a/ui/gfx/compositor/layer_unittest.cc b/ui/gfx/compositor/layer_unittest.cc index 6c5efb7..69999a3 100644 --- a/ui/gfx/compositor/layer_unittest.cc +++ b/ui/gfx/compositor/layer_unittest.cc @@ -118,6 +118,8 @@ class TestLayerDelegate : public LayerDelegate { contents.height()); color_index_ = (color_index_ + 1) % static_cast<int>(colors_.size()); } + virtual void OnLayerAnimationEnded(const ui::Animation* animation) OVERRIDE { + } private: Layer* owner_; @@ -145,6 +147,8 @@ class DrawTreeLayerDelegate : public LayerDelegate { virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE { painted_ = true; } + virtual void OnLayerAnimationEnded(const ui::Animation* animation) OVERRIDE { + } bool painted_; @@ -161,6 +165,8 @@ class NullLayerDelegate : public LayerDelegate { // Overridden from LayerDelegate: virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE { } + virtual void OnLayerAnimationEnded(const ui::Animation* animation) OVERRIDE { + } DISALLOW_COPY_AND_ASSIGN(NullLayerDelegate); }; diff --git a/views/view.cc b/views/view.cc index 925a40f..e4ffbe8 100644 --- a/views/view.cc +++ b/views/view.cc @@ -1171,6 +1171,9 @@ void View::OnPaintLayer(gfx::Canvas* canvas) { PaintCommon(canvas); } +void View::OnLayerAnimationEnded(const ui::Animation* animation) { +} + void View::ReorderLayers() { View* v = this; while (v && !v->layer()) diff --git a/views/view.h b/views/view.h index 9d3bfbe..0e06113 100644 --- a/views/view.h +++ b/views/view.h @@ -989,6 +989,7 @@ class VIEWS_EXPORT View : public ui::LayerDelegate, // Overridden from ui::LayerDelegate: virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE; + virtual void OnLayerAnimationEnded(const ui::Animation* animation) OVERRIDE; // Finds the layer that this view paints to (it may belong to an ancestor // view), then reorders the immediate children of that layer to match the |