diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-15 02:52:05 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-15 02:53:06 +0000 |
commit | 226c729d9a7bd68d166a8b21328db674ced8d498 (patch) | |
tree | 5d0c7433ce5d3e5eb33f1e6a482c45b6b5a9cc06 | |
parent | a13d9f10d7a57fe2c64c12fc71a881f8abbf1ea1 (diff) | |
download | chromium_src-226c729d9a7bd68d166a8b21328db674ced8d498.zip chromium_src-226c729d9a7bd68d166a8b21328db674ced8d498.tar.gz chromium_src-226c729d9a7bd68d166a8b21328db674ced8d498.tar.bz2 |
compositor: Add a ClosureAnimationObserver to run a Closure at the end of the animation.
ClosureAnimationObserver maintains its own lifetime, destroying itself after
running the callback at the end of the animation.
BUG=none
R=ajuma@chromium.org, oshima@chromium.org, vollick@chromium.org
Review URL: https://codereview.chromium.org/470693002
Cr-Commit-Position: refs/heads/master@{#289749}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@289749 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | athena/athena.gyp | 2 | ||||
-rw-r--r-- | athena/wm/overview_toolbar.cc | 4 | ||||
-rw-r--r-- | athena/wm/split_view_controller.cc | 28 | ||||
-rw-r--r-- | athena/wm/title_drag_controller.cc | 4 | ||||
-rw-r--r-- | athena/wm/window_overview_mode.cc | 4 | ||||
-rw-r--r-- | ui/compositor/BUILD.gn | 2 | ||||
-rw-r--r-- | ui/compositor/closure_animation_observer.cc (renamed from athena/common/closure_animation_observer.cc) | 6 | ||||
-rw-r--r-- | ui/compositor/closure_animation_observer.h (renamed from athena/common/closure_animation_observer.h) | 17 | ||||
-rw-r--r-- | ui/compositor/compositor.gyp | 2 |
9 files changed, 25 insertions, 44 deletions
diff --git a/athena/athena.gyp b/athena/athena.gyp index eab29f9..e56502f 100644 --- a/athena/athena.gyp +++ b/athena/athena.gyp @@ -39,8 +39,6 @@ 'activity/public/activity_view_manager.h', 'activity/public/activity_view_model.h', 'athena_export.h', - 'common/closure_animation_observer.cc', - 'common/closure_animation_observer.h', 'common/container_priorities.h', 'common/fill_layout_manager.cc', 'common/fill_layout_manager.h', diff --git a/athena/wm/overview_toolbar.cc b/athena/wm/overview_toolbar.cc index 5c7de40..4537a04 100644 --- a/athena/wm/overview_toolbar.cc +++ b/athena/wm/overview_toolbar.cc @@ -4,13 +4,13 @@ #include "athena/wm/overview_toolbar.h" -#include "athena/common/closure_animation_observer.h" #include "athena/resources/grit/athena_resources.h" #include "base/bind.h" #include "base/strings/utf_string_conversions.h" #include "base/time/time.h" #include "ui/aura/window.h" #include "ui/base/resource/resource_bundle.h" +#include "ui/compositor/closure_animation_observer.h" #include "ui/compositor/layer.h" #include "ui/compositor/layer_delegate.h" #include "ui/compositor/scoped_layer_animation_settings.h" @@ -43,7 +43,7 @@ class ActionButton : public ui::LayerDelegate { static void DestroyAfterFadeout(scoped_ptr<ActionButton> button) { ui::Layer* layer = button->layer(); ui::ScopedLayerAnimationSettings settings(layer->GetAnimator()); - settings.AddObserver(new ClosureAnimationObserver( + settings.AddObserver(new ui::ClosureAnimationObserver( base::Bind(&ActionButton::DestroyImmediately, base::Passed(&button)))); layer->SetOpacity(0); } diff --git a/athena/wm/split_view_controller.cc b/athena/wm/split_view_controller.cc index cde4657..9e8984a 100644 --- a/athena/wm/split_view_controller.cc +++ b/athena/wm/split_view_controller.cc @@ -10,6 +10,7 @@ #include "athena/wm/public/window_manager.h" #include "base/bind.h" #include "ui/aura/window.h" +#include "ui/compositor/closure_animation_observer.h" #include "ui/compositor/layer_animation_observer.h" #include "ui/compositor/scoped_layer_animation_settings.h" #include "ui/events/event_handler.h" @@ -17,31 +18,6 @@ #include "ui/gfx/screen.h" namespace athena { -namespace { - -// An animation observer that runs a callback at the end of the animation, and -// destroys itself. -class CallbackAnimationObserver : public ui::ImplicitAnimationObserver { - public: - explicit CallbackAnimationObserver(const base::Closure& closure) - : closure_(closure) {} - - virtual ~CallbackAnimationObserver() {} - - private: - // Overridden from ui::ImplicitAnimationObserver: - virtual void OnImplicitAnimationsCompleted() OVERRIDE { - if (!closure_.is_null()) - closure_.Run(); - delete this; - } - - const base::Closure closure_; - - DISALLOW_COPY_AND_ASSIGN(CallbackAnimationObserver); -}; - -} // namespace SplitViewController::SplitViewController( aura::Window* container, @@ -143,7 +119,7 @@ void SplitViewController::SetWindowTransform(aura::Window* window, ui::ScopedLayerAnimationSettings settings(animator); settings.SetPreemptionStrategy( ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); - settings.AddObserver(new CallbackAnimationObserver( + settings.AddObserver(new ui::ClosureAnimationObserver( base::Bind(&SplitViewController::OnAnimationCompleted, weak_factory_.GetWeakPtr(), window))); diff --git a/athena/wm/title_drag_controller.cc b/athena/wm/title_drag_controller.cc index 597f50a..36bf8238 100644 --- a/athena/wm/title_drag_controller.cc +++ b/athena/wm/title_drag_controller.cc @@ -4,11 +4,11 @@ #include "athena/wm/title_drag_controller.h" -#include "athena/common/closure_animation_observer.h" #include "base/bind.h" #include "ui/aura/window.h" #include "ui/aura/window_delegate.h" #include "ui/base/hit_test.h" +#include "ui/compositor/closure_animation_observer.h" #include "ui/compositor/layer.h" #include "ui/compositor/scoped_layer_animation_settings.h" #include "ui/wm/core/shadow.h" @@ -46,7 +46,7 @@ void TitleDragController::EndTransition(aura::Window* window, bool complete) { ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); settings.SetPreemptionStrategy( ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); - settings.AddObserver(new ClosureAnimationObserver( + settings.AddObserver(new ui::ClosureAnimationObserver( base::Bind(&TitleDragController::OnTransitionEnd, weak_ptr_.GetWeakPtr(), window, diff --git a/athena/wm/window_overview_mode.cc b/athena/wm/window_overview_mode.cc index b36ec11..d8e0597 100644 --- a/athena/wm/window_overview_mode.cc +++ b/athena/wm/window_overview_mode.cc @@ -8,7 +8,6 @@ #include <functional> #include <vector> -#include "athena/common/closure_animation_observer.h" #include "athena/wm/overview_toolbar.h" #include "athena/wm/public/window_list_provider.h" #include "base/bind.h" @@ -19,6 +18,7 @@ #include "ui/aura/window_property.h" #include "ui/aura/window_targeter.h" #include "ui/aura/window_tree_host.h" +#include "ui/compositor/closure_animation_observer.h" #include "ui/compositor/compositor.h" #include "ui/compositor/compositor_animation_observer.h" #include "ui/compositor/scoped_layer_animation_settings.h" @@ -367,7 +367,7 @@ class WindowOverviewModeImpl : public WindowOverviewMode, dragged_window_->layer()->GetAnimator()); settings.SetPreemptionStrategy( ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); - settings.AddObserver(new ClosureAnimationObserver( + settings.AddObserver(new ui::ClosureAnimationObserver( base::Bind(&base::DeletePointer<aura::Window>, dragged_window_))); WindowOverviewState* dragged_state = diff --git a/ui/compositor/BUILD.gn b/ui/compositor/BUILD.gn index d3a2dff..59d5005 100644 --- a/ui/compositor/BUILD.gn +++ b/ui/compositor/BUILD.gn @@ -6,6 +6,8 @@ import("//build/config/ui.gni") component("compositor") { sources = [ + "closure_animation_observer.cc", + "closure_animation_observer.h", "compositor.cc", "compositor.h", "compositor_animation_observer.h", diff --git a/athena/common/closure_animation_observer.cc b/ui/compositor/closure_animation_observer.cc index 083aec0..2ac7f91 100644 --- a/athena/common/closure_animation_observer.cc +++ b/ui/compositor/closure_animation_observer.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "athena/common/closure_animation_observer.h" +#include "ui/compositor/closure_animation_observer.h" -namespace athena { +namespace ui { ClosureAnimationObserver::ClosureAnimationObserver(const base::Closure& closure) : closure_(closure) { @@ -19,4 +19,4 @@ void ClosureAnimationObserver::OnImplicitAnimationsCompleted() { delete this; } -} // namespace athena +} // namespace ui diff --git a/athena/common/closure_animation_observer.h b/ui/compositor/closure_animation_observer.h index 50e0ec8..320ea2b1 100644 --- a/athena/common/closure_animation_observer.h +++ b/ui/compositor/closure_animation_observer.h @@ -2,31 +2,34 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef ATHENA_COMMON_CLOSURE_ANIMATION_OBSERVER_H_ -#define ATHENA_COMMON_CLOSURE_ANIMATION_OBSERVER_H_ +#ifndef UI_COMPOSITOR_CLOSURE_ANIMATION_OBSERVER_H_ +#define UI_COMPOSITOR_CLOSURE_ANIMATION_OBSERVER_H_ #include "base/callback.h" #include "base/macros.h" +#include "ui/compositor/compositor_export.h" #include "ui/compositor/layer_animation_observer.h" -namespace athena { +namespace ui { // Runs a callback at the end of the animation. This observe also destroys // itself afterwards. -class ClosureAnimationObserver : public ui::ImplicitAnimationObserver { +class COMPOSITOR_EXPORT ClosureAnimationObserver + : public ImplicitAnimationObserver { public: explicit ClosureAnimationObserver(const base::Closure& closure); private: virtual ~ClosureAnimationObserver(); - // ui::ImplicitAnimationObserver: + // ImplicitAnimationObserver: virtual void OnImplicitAnimationsCompleted() OVERRIDE; const base::Closure closure_; DISALLOW_COPY_AND_ASSIGN(ClosureAnimationObserver); }; -} -#endif // ATHENA_COMMON_CLOSURE_ANIMATION_OBSERVER_H_ +} // namespace ui + +#endif // UI_COMPOSITOR_CLOSURE_ANIMATION_OBSERVER_H_ diff --git a/ui/compositor/compositor.gyp b/ui/compositor/compositor.gyp index b29b87b..0471140 100644 --- a/ui/compositor/compositor.gyp +++ b/ui/compositor/compositor.gyp @@ -24,6 +24,8 @@ 'COMPOSITOR_IMPLEMENTATION', ], 'sources': [ + 'closure_animation_observer.cc', + 'closure_animation_observer.h', 'compositor.cc', 'compositor.h', 'compositor_animation_observer.h', |