summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-28 22:24:34 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-28 22:24:34 +0000
commitf82017820fe06b6dd5fe5a782919971c9e8ff7f4 (patch)
tree9c7e728b90c24fdb8ea3d51c8b522593e0994841 /ash
parent664b93c14564c47d4c99cee4a6d14d2386ccbf3f (diff)
downloadchromium_src-f82017820fe06b6dd5fe5a782919971c9e8ff7f4.zip
chromium_src-f82017820fe06b6dd5fe5a782919971c9e8ff7f4.tar.gz
chromium_src-f82017820fe06b6dd5fe5a782919971c9e8ff7f4.tar.bz2
Split window_animations, moving basic animations to views/corewm.
The base definition of the animation type enum also moves to corewm, and the API now allows downstream libraries (like ash) to extend the set of animations available. This will allow us to more easily use "core" animations in desktop-aura. I also removed the internal namespace from window_animations that remained in ash, since the use of namespaces in that file had begun to confuse me. http://crbug.com/158115 R=sky@chromium.org Review URL: https://codereview.chromium.org/11412223 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170071 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/desktop_background/desktop_background_view.cc17
-rw-r--r--ash/desktop_background/user_wallpaper_delegate.h4
-rw-r--r--ash/launcher/launcher_tooltip_manager.cc10
-rw-r--r--ash/shell.cc4
-rw-r--r--ash/system/tray/tray_background_view.cc10
-rw-r--r--ash/wm/base_layout_manager.cc3
-rw-r--r--ash/wm/system_modal_container_layout_manager.cc2
-rw-r--r--ash/wm/window_animations.cc553
-rw-r--r--ash/wm/window_animations.h76
-rw-r--r--ash/wm/window_animations_unittest.cc10
-rw-r--r--ash/wm/window_modality_controller.cc6
-rw-r--r--ash/wm/window_util.cc26
-rw-r--r--ash/wm/window_util.h15
-rw-r--r--ash/wm/workspace/desktop_background_fade_controller.cc5
-rw-r--r--ash/wm/workspace/multi_window_resize_controller.cc4
-rw-r--r--ash/wm/workspace/workspace.cc2
-rw-r--r--ash/wm/workspace/workspace_layout_manager.cc5
-rw-r--r--ash/wm/workspace/workspace_window_resizer.cc5
18 files changed, 108 insertions, 649 deletions
diff --git a/ash/desktop_background/desktop_background_view.cc b/ash/desktop_background/desktop_background_view.cc
index 86175a4..3590853 100644
--- a/ash/desktop_background/desktop_background_view.cc
+++ b/ash/desktop_background/desktop_background_view.cc
@@ -191,20 +191,19 @@ views::Widget* CreateDesktopBackground(aura::RootWindow* root_window,
params.parent = root_window->GetChildById(container_id);
desktop_widget->Init(params);
desktop_widget->SetContentsView(new DesktopBackgroundView());
- ash::WindowVisibilityAnimationType animation_type =
- wallpaper_delegate->GetAnimationType();
- ash::SetWindowVisibilityAnimationType(desktop_widget->GetNativeView(),
- animation_type);
+ int animation_type = wallpaper_delegate->GetAnimationType();
+ views::corewm::SetWindowVisibilityAnimationType(
+ desktop_widget->GetNativeView(), animation_type);
// Disable animation when creating the first widget. Otherwise, wallpaper
// will animate from a white screen. Note that boot animation is different.
// It animates from a white background.
- if (animation_type == ash::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE &&
+ if (animation_type == views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE &&
root_window->GetProperty(kAnimatingDesktopController) == NULL) {
- ash::SetWindowVisibilityAnimationTransition(desktop_widget->GetNativeView(),
- ash::ANIMATE_NONE);
+ views::corewm::SetWindowVisibilityAnimationTransition(
+ desktop_widget->GetNativeView(), views::corewm::ANIMATE_NONE);
} else {
- ash::SetWindowVisibilityAnimationTransition(desktop_widget->GetNativeView(),
- ash::ANIMATE_SHOW);
+ views::corewm::SetWindowVisibilityAnimationTransition(
+ desktop_widget->GetNativeView(), views::corewm::ANIMATE_SHOW);
}
desktop_widget->SetBounds(params.parent->bounds());
ui::ScopedLayerAnimationSettings settings(
diff --git a/ash/desktop_background/user_wallpaper_delegate.h b/ash/desktop_background/user_wallpaper_delegate.h
index 15c6d62..440d284 100644
--- a/ash/desktop_background/user_wallpaper_delegate.h
+++ b/ash/desktop_background/user_wallpaper_delegate.h
@@ -6,7 +6,7 @@
#define ASH_DESKTOP_BACKGROUND_USER_WALLPAPER_DELEGATE_H_
#include "ash/ash_export.h"
-#include "ash/wm/window_animations.h"
+#include "ui/views/corewm/window_animations.h"
namespace ash {
@@ -16,7 +16,7 @@ class ASH_EXPORT UserWallpaperDelegate {
// Returns the type of window animation that should be used when showing the
// wallpaper.
- virtual WindowVisibilityAnimationType GetAnimationType() = 0;
+ virtual int GetAnimationType() = 0;
// Should the slower initial animation be shown (as opposed to the faster
// animation that's used e.g. when switching from one user's wallpaper to
diff --git a/ash/launcher/launcher_tooltip_manager.cc b/ash/launcher/launcher_tooltip_manager.cc
index 047aabf..4263bd6 100644
--- a/ash/launcher/launcher_tooltip_manager.cc
+++ b/ash/launcher/launcher_tooltip_manager.cc
@@ -348,7 +348,8 @@ void LauncherTooltipManager::CancelHidingAnimation() {
return;
gfx::NativeView native_view = widget_->GetNativeView();
- SetWindowVisibilityAnimationTransition(native_view, ANIMATE_NONE);
+ views::corewm::SetWindowVisibilityAnimationTransition(
+ native_view, views::corewm::ANIMATE_NONE);
}
void LauncherTooltipManager::CloseSoon() {
@@ -376,9 +377,10 @@ void LauncherTooltipManager::CreateBubble(views::View* anchor,
view_->SetText(text_);
gfx::NativeView native_view = widget_->GetNativeView();
- SetWindowVisibilityAnimationType(
- native_view, WINDOW_VISIBILITY_ANIMATION_TYPE_VERTICAL);
- SetWindowVisibilityAnimationTransition(native_view, ANIMATE_HIDE);
+ views::corewm::SetWindowVisibilityAnimationType(
+ native_view, views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_VERTICAL);
+ views::corewm::SetWindowVisibilityAnimationTransition(
+ native_view, views::corewm::ANIMATE_HIDE);
}
} // namespace internal
diff --git a/ash/shell.cc b/ash/shell.cc
index 2a8e895..57193ed 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -121,8 +121,8 @@ class DummyUserWallpaperDelegate : public UserWallpaperDelegate {
virtual ~DummyUserWallpaperDelegate() {}
- virtual ash::WindowVisibilityAnimationType GetAnimationType() OVERRIDE {
- return WINDOW_VISIBILITY_ANIMATION_TYPE_FADE;
+ virtual int GetAnimationType() OVERRIDE {
+ return views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE;
}
virtual bool ShouldShowInitialAnimation() OVERRIDE {
diff --git a/ash/system/tray/tray_background_view.cc b/ash/system/tray/tray_background_view.cc
index 7ec4ed1..f32271a 100644
--- a/ash/system/tray/tray_background_view.cc
+++ b/ash/system/tray/tray_background_view.cc
@@ -288,13 +288,13 @@ void TrayBackgroundView::SetBorder() {
void TrayBackgroundView::InitializeBubbleAnimations(
views::Widget* bubble_widget) {
- ash::SetWindowVisibilityAnimationType(
+ views::corewm::SetWindowVisibilityAnimationType(
bubble_widget->GetNativeWindow(),
- ash::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE);
- ash::SetWindowVisibilityAnimationTransition(
+ views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE);
+ views::corewm::SetWindowVisibilityAnimationTransition(
bubble_widget->GetNativeWindow(),
- ash::ANIMATE_HIDE);
- ash::SetWindowVisibilityAnimationDuration(
+ views::corewm::ANIMATE_HIDE);
+ views::corewm::SetWindowVisibilityAnimationDuration(
bubble_widget->GetNativeWindow(),
base::TimeDelta::FromMilliseconds(kAnimationDurationForPopupMS));
}
diff --git a/ash/wm/base_layout_manager.cc b/ash/wm/base_layout_manager.cc
index 166bc54..770a609 100644
--- a/ash/wm/base_layout_manager.cc
+++ b/ash/wm/base_layout_manager.cc
@@ -17,6 +17,7 @@
#include "ui/base/ui_base_types.h"
#include "ui/compositor/layer.h"
#include "ui/gfx/screen.h"
+#include "ui/views/corewm/window_util.h"
namespace ash {
namespace internal {
@@ -153,7 +154,7 @@ void BaseLayoutManager::ShowStateChanged(aura::Window* window,
if (wm::IsWindowMinimized(window)) {
// Save the previous show state so that we can correctly restore it.
window->SetProperty(internal::kRestoreShowStateKey, last_show_state);
- SetWindowVisibilityAnimationType(
+ views::corewm::SetWindowVisibilityAnimationType(
window, WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE);
// Hide the window.
diff --git a/ash/wm/system_modal_container_layout_manager.cc b/ash/wm/system_modal_container_layout_manager.cc
index e6976ab..45cd204 100644
--- a/ash/wm/system_modal_container_layout_manager.cc
+++ b/ash/wm/system_modal_container_layout_manager.cc
@@ -205,7 +205,7 @@ void SystemModalContainerLayoutManager::DestroyModalBackground() {
ui::ScopedLayerAnimationSettings settings(
modal_background_->GetNativeView()->layer()->GetAnimator());
modal_background_->Close();
- settings.AddObserver(CreateHidingWindowAnimationObserver(
+ settings.AddObserver(views::corewm::CreateHidingWindowAnimationObserver(
modal_background_->GetNativeView()));
modal_background_->GetNativeView()->layer()->SetOpacity(0.0f);
modal_background_ = NULL;
diff --git a/ash/wm/window_animations.cc b/ash/wm/window_animations.cc
index 33546ae..d35e465 100644
--- a/ash/wm/window_animations.cc
+++ b/ash/wm/window_animations.cc
@@ -35,40 +35,12 @@
#include "ui/gfx/interpolated_transform.h"
#include "ui/gfx/screen.h"
#include "ui/gfx/vector3d_f.h"
+#include "ui/views/corewm/window_util.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
-DECLARE_WINDOW_PROPERTY_TYPE(int)
-DECLARE_WINDOW_PROPERTY_TYPE(ash::WindowVisibilityAnimationType)
-DECLARE_WINDOW_PROPERTY_TYPE(ash::WindowVisibilityAnimationTransition)
-DECLARE_WINDOW_PROPERTY_TYPE(float)
-DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(ASH_EXPORT, bool)
-
-using aura::Window;
-using base::TimeDelta;
-using ui::Layer;
-
namespace ash {
-namespace internal {
-namespace {
-const float kWindowAnimation_Vertical_TranslateY = 15.f;
-
-} // namespace
-
-DEFINE_WINDOW_PROPERTY_KEY(WindowVisibilityAnimationType,
- kWindowVisibilityAnimationTypeKey,
- WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT);
-DEFINE_WINDOW_PROPERTY_KEY(int, kWindowVisibilityAnimationDurationKey, 0);
-DEFINE_WINDOW_PROPERTY_KEY(WindowVisibilityAnimationTransition,
- kWindowVisibilityAnimationTransitionKey,
- ANIMATE_BOTH);
-DEFINE_WINDOW_PROPERTY_KEY(float,
- kWindowVisibilityAnimationVerticalPositionKey,
- kWindowAnimation_Vertical_TranslateY);
-
namespace {
-
-const int kDefaultAnimationDurationForMenuMS = 150;
const int kLayerAnimationsForMinimizeDurationMS = 200;
// Durations for the cross-fade animation, in milliseconds.
@@ -84,22 +56,9 @@ const float kWindowAnimation_ShowBrightnessGrayscale = 0.f;
const float kWindowAnimation_HideOpacity = 0.f;
const float kWindowAnimation_ShowOpacity = 1.f;
-const float kWindowAnimation_TranslateFactor = 0.025f;
-const float kWindowAnimation_ScaleFactor = .95f;
// TODO(sky): if we end up sticking with 0, nuke the code doing the rotation.
const float kWindowAnimation_MinimizeRotate = 0.f;
-const int kWindowAnimation_Rotate_DurationMS = 180;
-const int kWindowAnimation_Rotate_OpacityDurationPercent = 90;
-const float kWindowAnimation_Rotate_TranslateY = -20.f;
-const float kWindowAnimation_Rotate_PerspectiveDepth = 500.f;
-const float kWindowAnimation_Rotate_DegreesX = 5.f;
-const float kWindowAnimation_Rotate_ScaleFactor = .99f;
-
-const float kWindowAnimation_Bounce_Scale = 1.02f;
-const int kWindowAnimation_Bounce_DurationMS = 180;
-const int kWindowAnimation_Bounce_GrowShrinkDurationPercent = 40;
-
// Tween type when cross fading a workspace window.
const ui::Tween::Type kCrossFadeTweenType = ui::Tween::EASE_IN_OUT;
@@ -107,223 +66,6 @@ int64 Round64(float f) {
return static_cast<int64>(f + 0.5f);
}
-base::TimeDelta GetWindowVisibilityAnimationDuration(aura::Window* window) {
- int duration =
- window->GetProperty(kWindowVisibilityAnimationDurationKey);
- if (duration == 0 && window->type() == aura::client::WINDOW_TYPE_MENU) {
- return base::TimeDelta::FromMilliseconds(
- kDefaultAnimationDurationForMenuMS);
- }
- return TimeDelta::FromInternalValue(duration);
-}
-
-bool HasWindowVisibilityAnimationTransition(
- aura::Window* window,
- WindowVisibilityAnimationTransition transition) {
- WindowVisibilityAnimationTransition prop = window->GetProperty(
- kWindowVisibilityAnimationTransitionKey);
- return (prop & transition) != 0;
-}
-
-// Gets/sets the WindowVisibilityAnimationType associated with a window.
-WindowVisibilityAnimationType GetWindowVisibilityAnimationType(
- aura::Window* window) {
- WindowVisibilityAnimationType type =
- window->GetProperty(kWindowVisibilityAnimationTypeKey);
- if (type == WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT) {
- return (window->type() == aura::client::WINDOW_TYPE_MENU ||
- window->type() == aura::client::WINDOW_TYPE_TOOLTIP) ?
- WINDOW_VISIBILITY_ANIMATION_TYPE_FADE :
- WINDOW_VISIBILITY_ANIMATION_TYPE_DROP;
- }
- return type;
-}
-
-// Observes a hide animation.
-// A window can be hidden for a variety of reasons. Sometimes, Hide() will be
-// called and life is simple. Sometimes, the window is actually bound to a
-// views::Widget and that Widget is closed, and life is a little more
-// complicated. When a Widget is closed the aura::Window* is actually not
-// destroyed immediately - it is actually just immediately hidden and then
-// destroyed when the stack unwinds. To handle this case, we start the hide
-// animation immediately when the window is hidden, then when the window is
-// subsequently destroyed this object acquires ownership of the window's layer,
-// so that it can continue animating it until the animation completes.
-// Regardless of whether or not the window is destroyed, this object deletes
-// itself when the animation completes.
-class HidingWindowAnimationObserver : public ui::ImplicitAnimationObserver,
- public aura::WindowObserver {
- public:
- explicit HidingWindowAnimationObserver(aura::Window* window)
- : window_(window) {
- window_->AddObserver(this);
- }
- virtual ~HidingWindowAnimationObserver() {
- STLDeleteElements(&layers_);
- }
-
- private:
- // Overridden from ui::ImplicitAnimationObserver:
- virtual void OnImplicitAnimationsCompleted() OVERRIDE {
- // Window may have been destroyed by this point.
- if (window_)
- window_->RemoveObserver(this);
- delete this;
- }
-
- // Overridden from aura::WindowObserver:
- virtual void OnWindowDestroying(aura::Window* window) OVERRIDE {
- DCHECK_EQ(window, window_);
- DCHECK(layers_.empty());
- AcquireAllLayers(window_);
-
- // If the Widget has views with layers, then it is necessary to take
- // ownership of those layers too.
- views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window_);
- const views::Widget* const_widget = widget;
- if (widget && const_widget->GetRootView() && widget->GetContentsView())
- AcquireAllViewLayers(widget->GetContentsView());
- window_->RemoveObserver(this);
- window_ = NULL;
- }
-
- void AcquireAllLayers(aura::Window* window) {
- ui::Layer* layer = window->AcquireLayer();
- DCHECK(layer);
- layers_.push_back(layer);
- for (aura::Window::Windows::const_iterator it = window->children().begin();
- it != window->children().end();
- ++it)
- AcquireAllLayers(*it);
- }
-
- void AcquireAllViewLayers(views::View* view) {
- for (int i = 0; i < view->child_count(); ++i)
- AcquireAllViewLayers(view->child_at(i));
- if (view->layer()) {
- ui::Layer* layer = view->RecreateLayer();
- if (layer) {
- layer->SuppressPaint();
- layers_.push_back(layer);
- }
- }
- }
-
- aura::Window* window_;
- std::vector<ui::Layer*> layers_;
-
- DISALLOW_COPY_AND_ASSIGN(HidingWindowAnimationObserver);
-};
-
-// ImplicitAnimationObserver used when switching workspaces. Resets the layer
-// visibility to 'false' when done. This doesn't need the complexity of
-// HidingWindowAnimationObserver as the window isn't closing, and if it does a
-// HidingWindowAnimationObserver will be created.
-class WorkspaceHidingWindowAnimationObserver
- : public ui::ImplicitAnimationObserver {
- public:
- explicit WorkspaceHidingWindowAnimationObserver(aura::Window* window)
- : layer_(window->layer()) {
- }
- virtual ~WorkspaceHidingWindowAnimationObserver() {
- }
-
- private:
- // Overridden from ui::ImplicitAnimationObserver:
- virtual void OnImplicitAnimationsCompleted() OVERRIDE {
- // Restore the correct visibility value (overridden for the duration of the
- // animation in AnimateHideWindow()).
- layer_->SetVisible(false);
- delete this;
- }
-
- ui::Layer* layer_;
-
- DISALLOW_COPY_AND_ASSIGN(WorkspaceHidingWindowAnimationObserver);
-};
-
-// Shows a window using an animation, animating its opacity from 0.f to 1.f,
-// its visibility to true, and its transform from |start_transform| to
-// |end_transform|.
-void AnimateShowWindowCommon(aura::Window* window,
- const gfx::Transform& start_transform,
- const gfx::Transform& end_transform) {
- window->layer()->set_delegate(window);
- window->layer()->SetOpacity(kWindowAnimation_HideOpacity);
- window->layer()->SetTransform(start_transform);
- window->layer()->SetVisible(true);
-
- {
- // Property sets within this scope will be implicitly animated.
- ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
- base::TimeDelta duration = GetWindowVisibilityAnimationDuration(window);
- if (duration.ToInternalValue() > 0)
- settings.SetTransitionDuration(duration);
-
- window->layer()->SetTransform(end_transform);
- window->layer()->SetOpacity(kWindowAnimation_ShowOpacity);
- }
-}
-
-// Hides a window using an animation, animating its opacity from 1.f to 0.f,
-// its visibility to false, and its transform to |end_transform|.
-void AnimateHideWindowCommon(aura::Window* window,
- const gfx::Transform& end_transform) {
- window->layer()->set_delegate(NULL);
-
- // Property sets within this scope will be implicitly animated.
- ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
- settings.AddObserver(new HidingWindowAnimationObserver(window));
-
- base::TimeDelta duration = GetWindowVisibilityAnimationDuration(window);
- if (duration.ToInternalValue() > 0)
- settings.SetTransitionDuration(duration);
-
- window->layer()->SetOpacity(kWindowAnimation_HideOpacity);
- window->layer()->SetTransform(end_transform);
- window->layer()->SetVisible(false);
-}
-
-static gfx::Transform GetScaleForWindow(aura::Window* window) {
- gfx::Rect bounds = window->bounds();
- gfx::Transform scale = gfx::GetScaleTransform(
- gfx::Point(kWindowAnimation_TranslateFactor * bounds.width(),
- kWindowAnimation_TranslateFactor * bounds.height()),
- kWindowAnimation_ScaleFactor);
- return scale;
-}
-
-// Show/Hide windows using a shrink animation.
-void AnimateShowWindow_Drop(aura::Window* window) {
- AnimateShowWindowCommon(window, GetScaleForWindow(window), gfx::Transform());
-}
-
-void AnimateHideWindow_Drop(aura::Window* window) {
- AnimateHideWindowCommon(window, GetScaleForWindow(window));
-}
-
-// Show/Hide windows using a vertical Glenimation.
-void AnimateShowWindow_Vertical(aura::Window* window) {
- gfx::Transform transform;
- transform.Translate(0, window->GetProperty(
- kWindowVisibilityAnimationVerticalPositionKey));
- AnimateShowWindowCommon(window, transform, gfx::Transform());
-}
-
-void AnimateHideWindow_Vertical(aura::Window* window) {
- gfx::Transform transform;
- transform.Translate(0, window->GetProperty(
- kWindowVisibilityAnimationVerticalPositionKey));
- AnimateHideWindowCommon(window, transform);
-}
-
-// Show/Hide windows using a fade.
-void AnimateShowWindow_Fade(aura::Window* window) {
- AnimateShowWindowCommon(window, gfx::Transform(), gfx::Transform());
-}
-
-void AnimateHideWindow_Fade(aura::Window* window) {
- AnimateHideWindowCommon(window, gfx::Transform());
}
gfx::Rect GetMinimizeRectForWindow(aura::Window* window) {
@@ -391,13 +133,13 @@ void AddLayerAnimationsForMinimize(aura::Window* window, bool show) {
new ui::LayerAnimationSequence(transition.release()));
// When hiding a window, turn off blending until the animation is 3 / 4 done
- // to save bandwidth and reduce jank
+ // to save bandwidth and reduce jank.
if (!show) {
window->layer()->GetAnimator()->SchedulePauseForProperties(
(duration * 3 ) / 4, ui::LayerAnimationElement::OPACITY, -1);
}
- // Fade in and out quickly when the window is small to reduce jank
+ // Fade in and out quickly when the window is small to reduce jank.
float opacity = show ? 1.0f : 0.0f;
window->layer()->GetAnimator()->ScheduleAnimation(
new ui::LayerAnimationSequence(
@@ -412,8 +154,8 @@ void AnimateShowWindow_Minimize(aura::Window* window) {
// Now that the window has been restored, we need to clear its animation style
// to default so that normal animation applies.
- SetWindowVisibilityAnimationType(
- window, WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT);
+ views::corewm::SetWindowVisibilityAnimationType(
+ window, views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT);
}
void AnimateHideWindow_Minimize(aura::Window* window) {
@@ -424,7 +166,8 @@ void AnimateHideWindow_Minimize(aura::Window* window) {
base::TimeDelta duration = base::TimeDelta::FromMilliseconds(
kLayerAnimationsForMinimizeDurationMS);
settings.SetTransitionDuration(duration);
- settings.AddObserver(new HidingWindowAnimationObserver(window));
+ settings.AddObserver(
+ views::corewm::CreateHidingWindowAnimationObserver(window));
window->layer()->SetVisible(false);
AddLayerAnimationsForMinimize(window, false);
@@ -455,13 +198,14 @@ void AnimateShowHideWindowCommon_BrightnessGrayscale(aura::Window* window,
ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
settings.SetTransitionDuration(duration);
- if (!show)
- settings.AddObserver(new HidingWindowAnimationObserver(window));
+ if (!show) {
+ settings.AddObserver(
+ views::corewm::CreateHidingWindowAnimationObserver(window));
+ }
window->layer()->GetAnimator()->
ScheduleTogether(
- internal::CreateBrightnessGrayscaleAnimationSequence(end_value,
- duration));
+ CreateBrightnessGrayscaleAnimationSequence(end_value, duration));
if (!show) {
window->layer()->SetOpacity(kWindowAnimation_HideOpacity);
window->layer()->SetVisible(false);
@@ -476,141 +220,21 @@ void AnimateHideWindow_BrightnessGrayscale(aura::Window* window) {
AnimateShowHideWindowCommon_BrightnessGrayscale(window, false);
}
-ui::LayerAnimationElement* CreateGrowShrinkElement(
- aura::Window* window, bool grow) {
- scoped_ptr<ui::InterpolatedTransform> scale(new ui::InterpolatedScale(
- gfx::Point3F(kWindowAnimation_Bounce_Scale,
- kWindowAnimation_Bounce_Scale,
- 1),
- gfx::Point3F(1, 1, 1)));
- scoped_ptr<ui::InterpolatedTransform> scale_about_pivot(
- new ui::InterpolatedTransformAboutPivot(
- gfx::Point(window->bounds().width() * 0.5,
- window->bounds().height() * 0.5),
- scale.release()));
- scale_about_pivot->SetReversed(grow);
- scoped_ptr<ui::LayerAnimationElement> transition(
- ui::LayerAnimationElement::CreateInterpolatedTransformElement(
- scale_about_pivot.release(),
- base::TimeDelta::FromMilliseconds(
- kWindowAnimation_Bounce_DurationMS *
- kWindowAnimation_Bounce_GrowShrinkDurationPercent / 100)));
- transition->set_tween_type(grow ? ui::Tween::EASE_OUT : ui::Tween::EASE_IN);
- return transition.release();
-}
-
-void AnimateBounce(aura::Window* window) {
- ui::ScopedLayerAnimationSettings scoped_settings(
- window->layer()->GetAnimator());
- scoped_settings.SetPreemptionStrategy(
- ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
- window->layer()->set_delegate(window);
- scoped_ptr<ui::LayerAnimationSequence> sequence(
- new ui::LayerAnimationSequence);
- sequence->AddElement(CreateGrowShrinkElement(window, true));
- ui::LayerAnimationElement::AnimatableProperties paused_properties;
- paused_properties.insert(ui::LayerAnimationElement::BOUNDS);
- sequence->AddElement(ui::LayerAnimationElement::CreatePauseElement(
- paused_properties,
- base::TimeDelta::FromMilliseconds(
- kWindowAnimation_Bounce_DurationMS *
- (100 - 2 * kWindowAnimation_Bounce_GrowShrinkDurationPercent) /
- 100)));
- sequence->AddElement(CreateGrowShrinkElement(window, false));
- window->layer()->GetAnimator()->StartAnimation(sequence.release());
-}
-
-void AddLayerAnimationsForRotate(aura::Window* window, bool show) {
- window->layer()->set_delegate(window);
- if (show)
- window->layer()->SetOpacity(kWindowAnimation_HideOpacity);
-
- base::TimeDelta duration = base::TimeDelta::FromMilliseconds(
- kWindowAnimation_Rotate_DurationMS);
-
- if (!show) {
- new HidingWindowAnimationObserver(window);
- window->layer()->GetAnimator()->SchedulePauseForProperties(
- duration * (100 - kWindowAnimation_Rotate_OpacityDurationPercent) / 100,
- ui::LayerAnimationElement::OPACITY,
- -1);
- }
- scoped_ptr<ui::LayerAnimationElement> opacity(
- ui::LayerAnimationElement::CreateOpacityElement(
- show ? kWindowAnimation_ShowOpacity : kWindowAnimation_HideOpacity,
- duration * kWindowAnimation_Rotate_OpacityDurationPercent / 100));
- opacity->set_tween_type(ui::Tween::EASE_IN_OUT);
- window->layer()->GetAnimator()->ScheduleAnimation(
- new ui::LayerAnimationSequence(opacity.release()));
-
- float xcenter = window->bounds().width() * 0.5;
-
- gfx::Transform transform;
- transform.Translate(xcenter, 0);
- transform.ApplyPerspectiveDepth(kWindowAnimation_Rotate_PerspectiveDepth);
- transform.Translate(-xcenter, 0);
- scoped_ptr<ui::InterpolatedTransform> perspective(
- new ui::InterpolatedConstantTransform(transform));
-
- scoped_ptr<ui::InterpolatedTransform> scale(
- new ui::InterpolatedScale(1, kWindowAnimation_Rotate_ScaleFactor));
- scoped_ptr<ui::InterpolatedTransform> scale_about_pivot(
- new ui::InterpolatedTransformAboutPivot(
- gfx::Point(xcenter, kWindowAnimation_Rotate_TranslateY),
- scale.release()));
-
- scoped_ptr<ui::InterpolatedTransform> translation(
- new ui::InterpolatedTranslation(gfx::Point(), gfx::Point(
- 0, kWindowAnimation_Rotate_TranslateY)));
-
- scoped_ptr<ui::InterpolatedTransform> rotation(
- new ui::InterpolatedAxisAngleRotation(
- gfx::Vector3dF(1, 0, 0), 0, kWindowAnimation_Rotate_DegreesX));
-
- scale_about_pivot->SetChild(perspective.release());
- translation->SetChild(scale_about_pivot.release());
- rotation->SetChild(translation.release());
- rotation->SetReversed(show);
-
- scoped_ptr<ui::LayerAnimationElement> transition(
- ui::LayerAnimationElement::CreateInterpolatedTransformElement(
- rotation.release(), duration));
-
- window->layer()->GetAnimator()->ScheduleAnimation(
- new ui::LayerAnimationSequence(transition.release()));
-}
-
-void AnimateShowWindow_Rotate(aura::Window* window) {
- AddLayerAnimationsForRotate(window, true);
-}
-void AnimateHideWindow_Rotate(aura::Window* window) {
- AddLayerAnimationsForRotate(window, false);
-}
bool AnimateShowWindow(aura::Window* window) {
- if (!HasWindowVisibilityAnimationTransition(window, ANIMATE_SHOW))
+ if (!views::corewm::HasWindowVisibilityAnimationTransition(
+ window, views::corewm::ANIMATE_SHOW)) {
return false;
+ }
- switch (GetWindowVisibilityAnimationType(window)) {
- case WINDOW_VISIBILITY_ANIMATION_TYPE_DROP:
- AnimateShowWindow_Drop(window);
- return true;
- case WINDOW_VISIBILITY_ANIMATION_TYPE_VERTICAL:
- AnimateShowWindow_Vertical(window);
- return true;
- case WINDOW_VISIBILITY_ANIMATION_TYPE_FADE:
- AnimateShowWindow_Fade(window);
- return true;
+ switch (views::corewm::GetWindowVisibilityAnimationType(window)) {
case WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE:
AnimateShowWindow_Minimize(window);
return true;
case WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE:
AnimateShowWindow_BrightnessGrayscale(window);
return true;
- case WINDOW_VISIBILITY_ANIMATION_TYPE_ROTATE:
- AnimateShowWindow_Rotate(window);
- return true;
default:
NOTREACHED();
return false;
@@ -618,28 +242,18 @@ bool AnimateShowWindow(aura::Window* window) {
}
bool AnimateHideWindow(aura::Window* window) {
- if (!HasWindowVisibilityAnimationTransition(window, ANIMATE_HIDE))
+ if (!views::corewm::HasWindowVisibilityAnimationTransition(
+ window, views::corewm::ANIMATE_HIDE)) {
return false;
+ }
- switch (GetWindowVisibilityAnimationType(window)) {
- case WINDOW_VISIBILITY_ANIMATION_TYPE_DROP:
- AnimateHideWindow_Drop(window);
- return true;
- case WINDOW_VISIBILITY_ANIMATION_TYPE_VERTICAL:
- AnimateHideWindow_Vertical(window);
- return true;
- case WINDOW_VISIBILITY_ANIMATION_TYPE_FADE:
- AnimateHideWindow_Fade(window);
- return true;
+ switch (views::corewm::GetWindowVisibilityAnimationType(window)) {
case WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE:
AnimateHideWindow_Minimize(window);
return true;
case WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE:
AnimateHideWindow_BrightnessGrayscale(window);
return true;
- case WINDOW_VISIBILITY_ANIMATION_TYPE_ROTATE:
- AnimateHideWindow_Rotate(window);
- return true;
default:
NOTREACHED();
return false;
@@ -655,7 +269,7 @@ class CrossFadeObserver : public ui::CompositorObserver,
public:
// Observes |window| for destruction, but does not take ownership.
// Takes ownership of |layer| and its child layers.
- CrossFadeObserver(Window* window, Layer* layer)
+ CrossFadeObserver(aura::Window* window, ui::Layer* layer)
: window_(window),
layer_(layer) {
window_->AddObserver(this);
@@ -665,7 +279,7 @@ class CrossFadeObserver : public ui::CompositorObserver,
window_->RemoveObserver(this);
window_ = NULL;
layer_->GetCompositor()->RemoveObserver(this);
- wm::DeepDeleteLayers(layer_);
+ views::corewm::DeepDeleteLayers(layer_);
layer_ = NULL;
}
@@ -685,7 +299,7 @@ class CrossFadeObserver : public ui::CompositorObserver,
}
// aura::WindowObserver overrides:
- virtual void OnWindowDestroying(Window* window) OVERRIDE {
+ virtual void OnWindowDestroying(aura::Window* window) OVERRIDE {
// Triggers OnImplicitAnimationsCompleted() to be called and deletes us.
layer_->GetAnimator()->StopAnimating();
}
@@ -696,31 +310,26 @@ class CrossFadeObserver : public ui::CompositorObserver,
}
private:
- Window* window_; // not owned
- Layer* layer_; // owned
+ aura::Window* window_; // not owned
+ ui::Layer* layer_; // owned
DISALLOW_COPY_AND_ASSIGN(CrossFadeObserver);
};
-} // namespace
-} // namespace internal
-
-namespace {
-
// Implementation of cross fading. Window is the window being cross faded. It
// should be at the target bounds. |old_layer| the previous layer from |window|.
// This takes ownership of |old_layer| and deletes when the animation is done.
// |pause_duration| is the duration to pause at the current bounds before
// animating. Returns the duration of the fade.
-TimeDelta CrossFadeImpl(aura::Window* window,
- ui::Layer* old_layer,
- ui::Tween::Type tween_type) {
+base::TimeDelta CrossFadeImpl(aura::Window* window,
+ ui::Layer* old_layer,
+ ui::Tween::Type tween_type) {
const gfx::Rect old_bounds(old_layer->bounds());
const gfx::Rect new_bounds(window->bounds());
const bool old_on_top = (old_bounds.width() > new_bounds.width());
// Shorten the animation if there's not much visual movement.
- const TimeDelta duration = GetCrossFadeDuration(old_bounds, new_bounds);
+ const base::TimeDelta duration = GetCrossFadeDuration(old_bounds, new_bounds);
// Scale up the old layer while translating to new position.
{
@@ -728,7 +337,7 @@ TimeDelta CrossFadeImpl(aura::Window* window,
ui::ScopedLayerAnimationSettings settings(old_layer->GetAnimator());
// Animation observer owns the old layer and deletes itself.
- settings.AddObserver(new internal::CrossFadeObserver(window, old_layer));
+ settings.AddObserver(new CrossFadeObserver(window, old_layer));
settings.SetTransitionDuration(duration);
settings.SetTweenType(tween_type);
gfx::Transform out_transform;
@@ -743,7 +352,7 @@ TimeDelta CrossFadeImpl(aura::Window* window,
if (old_on_top) {
// The old layer is on top, and should fade out. The new layer below will
// stay opaque to block the desktop.
- old_layer->SetOpacity(0.f);
+ old_layer->SetOpacity(kWindowAnimation_HideOpacity);
}
// In tests |old_layer| is deleted here, as animations have zero duration.
old_layer = NULL;
@@ -763,7 +372,7 @@ TimeDelta CrossFadeImpl(aura::Window* window,
if (!old_on_top) {
// The new layer is on top and should fade in. The old layer below will
// stay opaque and block the desktop.
- window->layer()->SetOpacity(0.f);
+ window->layer()->SetOpacity(kWindowAnimation_HideOpacity);
}
{
// Animate the new layer to the identity transform, so the window goes to
@@ -774,51 +383,12 @@ TimeDelta CrossFadeImpl(aura::Window* window,
window->layer()->SetTransform(gfx::Transform());
if (!old_on_top) {
// New layer is on top, fade it in.
- window->layer()->SetOpacity(1.f);
+ window->layer()->SetOpacity(kWindowAnimation_ShowOpacity);
}
}
return duration;
}
-} // namespace
-
-////////////////////////////////////////////////////////////////////////////////
-// External interface
-
-void SetWindowVisibilityAnimationType(aura::Window* window,
- WindowVisibilityAnimationType type) {
- window->SetProperty(internal::kWindowVisibilityAnimationTypeKey, type);
-}
-
-WindowVisibilityAnimationType GetWindowVisibilityAnimationType(
- aura::Window* window) {
- return window->GetProperty(internal::kWindowVisibilityAnimationTypeKey);
-}
-
-void SetWindowVisibilityAnimationTransition(
- aura::Window* window,
- WindowVisibilityAnimationTransition transition) {
- window->SetProperty(internal::kWindowVisibilityAnimationTransitionKey,
- transition);
-}
-
-void SetWindowVisibilityAnimationDuration(aura::Window* window,
- const TimeDelta& duration) {
- window->SetProperty(internal::kWindowVisibilityAnimationDurationKey,
- static_cast<int>(duration.ToInternalValue()));
-}
-
-void SetWindowVisibilityAnimationVerticalPosition(aura::Window* window,
- float position) {
- window->SetProperty(internal::kWindowVisibilityAnimationVerticalPositionKey,
- position);
-}
-
-ui::ImplicitAnimationObserver* CreateHidingWindowAnimationObserver(
- aura::Window* window) {
- return new internal::HidingWindowAnimationObserver(window);
-}
-
void CrossFadeToBounds(aura::Window* window, const gfx::Rect& new_bounds) {
DCHECK(window->TargetVisibility());
const gfx::Rect old_bounds = window->bounds();
@@ -826,7 +396,7 @@ void CrossFadeToBounds(aura::Window* window, const gfx::Rect& new_bounds) {
// Create fresh layers for the window and all its children to paint into.
// Takes ownership of the old layer and all its children, which will be
// cleaned up after the animation completes.
- ui::Layer* old_layer = wm::RecreateWindowLayers(window, false);
+ ui::Layer* old_layer = views::corewm::RecreateWindowLayers(window, false);
ui::Layer* new_layer = window->layer();
// Resize the window to the new size, which will force a layout and paint.
@@ -853,13 +423,12 @@ void CrossFadeWindowBetweenWorkspaces(aura::Window* new_workspace,
else
layer_parent->StackBelow(old_layer, new_workspace->layer());
- CrossFadeImpl(window, old_layer, internal::kCrossFadeTweenType);
+ CrossFadeImpl(window, old_layer, kCrossFadeTweenType);
}
-TimeDelta GetCrossFadeDuration(const gfx::Rect& old_bounds,
- const gfx::Rect& new_bounds) {
- if (CommandLine::ForCurrentProcess()->HasSwitch(
- ash::switches::kAshWindowAnimationsDisabled))
+base::TimeDelta GetCrossFadeDuration(const gfx::Rect& old_bounds,
+ const gfx::Rect& new_bounds) {
+ if (views::corewm::WindowAnimationsDisabled(NULL))
return base::TimeDelta();
int old_area = old_bounds.width() * old_bounds.height();
@@ -867,36 +436,34 @@ TimeDelta GetCrossFadeDuration(const gfx::Rect& old_bounds,
int max_area = std::max(old_area, new_area);
// Avoid divide by zero.
if (max_area == 0)
- return TimeDelta::FromMilliseconds(internal::kWorkspaceSwitchTimeMS);
+ return base::TimeDelta::FromMilliseconds(internal::kWorkspaceSwitchTimeMS);
int delta_area = std::abs(old_area - new_area);
// If the area didn't change, the animation is instantaneous.
if (delta_area == 0)
- return TimeDelta::FromMilliseconds(internal::kWorkspaceSwitchTimeMS);
+ return base::TimeDelta::FromMilliseconds(internal::kWorkspaceSwitchTimeMS);
float factor =
static_cast<float>(delta_area) / static_cast<float>(max_area);
- const float kRange = internal::kCrossFadeDurationMaxMs -
- internal::kCrossFadeDurationMinMs;
- return TimeDelta::FromMilliseconds(
- internal::Round64(internal::kCrossFadeDurationMinMs + (factor * kRange)));
+ const float kRange = kCrossFadeDurationMaxMs - kCrossFadeDurationMinMs;
+ return base::TimeDelta::FromMilliseconds(
+ Round64(kCrossFadeDurationMinMs + (factor * kRange)));
}
-namespace internal {
-
bool AnimateOnChildWindowVisibilityChanged(aura::Window* window, bool visible) {
- if (window->GetProperty(aura::client::kAnimationsDisabledKey) ||
- CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kAshWindowAnimationsDisabled)) {
+ if (views::corewm::WindowAnimationsDisabled(window))
return false;
- }
- if (visible) {
+
+ // Attempt to run CoreWm supplied animation types.
+ if (views::corewm::AnimateOnChildWindowVisibilityChanged(window, visible))
+ return true;
+
+ // Otherwise try to run an Ash-specific animation.
+ if (visible)
return AnimateShowWindow(window);
- } else {
- // Don't start hiding the window again if it's already being hidden.
- return window->layer()->GetTargetOpacity() != 0.0f &&
- AnimateHideWindow(window);
- }
+ // Don't start hiding the window again if it's already being hidden.
+ return window->layer()->GetTargetOpacity() != 0.0f &&
+ AnimateHideWindow(window);
}
std::vector<ui::LayerAnimationSequence*>
@@ -934,16 +501,4 @@ CreateBrightnessGrayscaleAnimationSequence(float target_value,
return animations;
}
-bool AnimateWindow(aura::Window* window, WindowAnimationType type) {
- switch (type) {
- case WINDOW_ANIMATION_TYPE_BOUNCE:
- AnimateBounce(window);
- return true;
- default:
- NOTREACHED();
- return false;
- }
-}
-
-} // namespace internal
} // namespace ash
diff --git a/ash/wm/window_animations.h b/ash/wm/window_animations.h
index 8d08982..5be60fa 100644
--- a/ash/wm/window_animations.h
+++ b/ash/wm/window_animations.h
@@ -5,83 +5,30 @@
#ifndef ASH_WM_WINDOW_ANIMATIONS_H_
#define ASH_WM_WINDOW_ANIMATIONS_H_
-#include <vector>
-
#include "ash/ash_export.h"
+#include "ui/views/corewm/window_animations.h"
namespace aura {
class Window;
}
-namespace base {
-class TimeDelta;
-}
-namespace gfx {
-class Rect;
-}
namespace ui {
-class ImplicitAnimationObserver;
class Layer;
-class LayerAnimationSequence;
}
+// This is only for animations specific to Ash. For window animations shared
+// with desktop Chrome, see ui/views/corewm/window_animations.h.
namespace ash {
-// A variety of canned animations for window transitions.
+// An extension of the window animations provided by CoreWm. These should be
+// Ash-specific only.
enum WindowVisibilityAnimationType {
- WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT = 0, // Default. Lets the system
- // decide based on window
- // type.
- WINDOW_VISIBILITY_ANIMATION_TYPE_DROP, // Window shrinks in.
- WINDOW_VISIBILITY_ANIMATION_TYPE_VERTICAL, // Vertical Glenimation.
- WINDOW_VISIBILITY_ANIMATION_TYPE_FADE, // Fades in/out.
- WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE, // Window scale/rotates down
- // to its launcher icon.
+ // Window scale/rotates down to its launcher icon.
+ WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE =
+ views::corewm::WINDOW_VISIBILITY_ANIMATION_MAX,
// Fade in/out using brightness and grayscale web filters.
- WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE,
- WINDOW_VISIBILITY_ANIMATION_TYPE_ROTATE, // Window rotates in.
-};
-
-// Canned animations that take effect once but don't have a symmetric pair as
-// visiblity animations do.
-enum WindowAnimationType {
- WINDOW_ANIMATION_TYPE_BOUNCE = 0, // Window scales up and down.
-};
-
-// Type of visibility change transition that a window should animate.
-// Default behavior is to animate both show and hide.
-enum WindowVisibilityAnimationTransition {
- ANIMATE_SHOW = 0x1,
- ANIMATE_HIDE = 0x2,
- ANIMATE_BOTH = ANIMATE_SHOW | ANIMATE_HIDE,
- ANIMATE_NONE = 0x4,
+ WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE
};
-ASH_EXPORT void SetWindowVisibilityAnimationType(
- aura::Window* window,
- WindowVisibilityAnimationType type);
-
-ASH_EXPORT WindowVisibilityAnimationType GetWindowVisibilityAnimationType(
- aura::Window* window);
-
-ASH_EXPORT void SetWindowVisibilityAnimationTransition(
- aura::Window* window,
- WindowVisibilityAnimationTransition transition);
-
-ASH_EXPORT void SetWindowVisibilityAnimationDuration(
- aura::Window* window,
- const base::TimeDelta& duration);
-
-ASH_EXPORT void SetWindowVisibilityAnimationVerticalPosition(
- aura::Window* window,
- float position);
-
-// Creates an ImplicitAnimationObserver that takes ownership of the layers
-// associated with a Window so that the animation can continue after the Window
-// has been destroyed.
-// The returned object deletes itself when the animations are done.
-ASH_EXPORT ui::ImplicitAnimationObserver* CreateHidingWindowAnimationObserver(
- aura::Window* window);
-
// Animate a cross-fade of |window| from its current bounds to |new_bounds|.
ASH_EXPORT void CrossFadeToBounds(aura::Window* window,
const gfx::Rect& new_bounds);
@@ -99,12 +46,8 @@ ASH_EXPORT void CrossFadeWindowBetweenWorkspaces(aura::Window* new_workspace,
ASH_EXPORT base::TimeDelta GetCrossFadeDuration(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds);
-namespace internal {
-
-// Returns false if the |window| didn't animate.
ASH_EXPORT bool AnimateOnChildWindowVisibilityChanged(aura::Window* window,
bool visible);
-ASH_EXPORT bool AnimateWindow(aura::Window* window, WindowAnimationType type);
// Creates vector of animation sequences that lasts for |duration| and changes
// brightness and grayscale to |target_value|. Caller takes ownership of
@@ -113,7 +56,6 @@ ASH_EXPORT std::vector<ui::LayerAnimationSequence*>
CreateBrightnessGrayscaleAnimationSequence(float target_value,
base::TimeDelta duration);
-} // namespace internal
} // namespace ash
diff --git a/ash/wm/window_animations_unittest.cc b/ash/wm/window_animations_unittest.cc
index 34e821b..2f9d95c 100644
--- a/ash/wm/window_animations_unittest.cc
+++ b/ash/wm/window_animations_unittest.cc
@@ -39,21 +39,19 @@ TEST_F(WindowAnimationsTest, HideShowBrightnessGrayscaleAnimation) {
EXPECT_TRUE(window->layer()->visible());
// Hiding.
- SetWindowVisibilityAnimationType(
+ views::corewm::SetWindowVisibilityAnimationType(
window.get(),
WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE);
- ash::internal::AnimateOnChildWindowVisibilityChanged(
- window.get(), false);
+ AnimateOnChildWindowVisibilityChanged(window.get(), false);
EXPECT_EQ(0.0f, window->layer()->GetTargetOpacity());
EXPECT_FALSE(window->layer()->GetTargetVisibility());
EXPECT_FALSE(window->layer()->visible());
// Showing.
- SetWindowVisibilityAnimationType(
+ views::corewm::SetWindowVisibilityAnimationType(
window.get(),
WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE);
- ash::internal::AnimateOnChildWindowVisibilityChanged(
- window.get(), true);
+ AnimateOnChildWindowVisibilityChanged(window.get(), true);
EXPECT_EQ(0.0f, window->layer()->GetTargetBrightness());
EXPECT_EQ(0.0f, window->layer()->GetTargetGrayscale());
EXPECT_TRUE(window->layer()->visible());
diff --git a/ash/wm/window_modality_controller.cc b/ash/wm/window_modality_controller.cc
index 760c5d0..c16e562 100644
--- a/ash/wm/window_modality_controller.cc
+++ b/ash/wm/window_modality_controller.cc
@@ -6,7 +6,6 @@
#include <algorithm>
-#include "ash/wm/window_animations.h"
#include "ash/wm/window_properties.h"
#include "ash/wm/window_util.h"
#include "ui/aura/client/aura_constants.h"
@@ -16,6 +15,7 @@
#include "ui/aura/window.h"
#include "ui/base/events/event.h"
#include "ui/base/ui_base_types.h"
+#include "ui/views/corewm/window_animations.h"
namespace ash {
@@ -151,8 +151,8 @@ bool WindowModalityController::ProcessLocatedEvent(aura::Window* target,
aura::Window* modal_transient_child = wm::GetModalTransient(target);
if (modal_transient_child && (event->type() == ui::ET_MOUSE_PRESSED ||
event->type() == ui::ET_TOUCH_PRESSED)) {
- ash::internal::AnimateWindow(modal_transient_child,
- ash::WINDOW_ANIMATION_TYPE_BOUNCE);
+ views::corewm::AnimateWindow(modal_transient_child,
+ views::corewm::WINDOW_ANIMATION_TYPE_BOUNCE);
}
return !!modal_transient_child;
}
diff --git a/ash/wm/window_util.cc b/ash/wm/window_util.cc
index 3adb296..c579acc 100644
--- a/ash/wm/window_util.cc
+++ b/ash/wm/window_util.cc
@@ -139,32 +139,6 @@ void CenterWindow(aura::Window* window) {
window->SetBounds(center);
}
-ui::Layer* RecreateWindowLayers(aura::Window* window, bool set_bounds) {
- const gfx::Rect bounds = window->bounds();
- ui::Layer* old_layer = window->RecreateLayer();
- DCHECK(old_layer);
- for (aura::Window::Windows::const_iterator it = window->children().begin();
- it != window->children().end();
- ++it) {
- // Maintain the hierarchy of the detached layers.
- old_layer->Add(RecreateWindowLayers(*it, set_bounds));
- }
- if (set_bounds)
- window->SetBounds(bounds);
- return old_layer;
-}
-
-void DeepDeleteLayers(ui::Layer* layer) {
- std::vector<ui::Layer*> children = layer->children();
- for (std::vector<ui::Layer*>::const_iterator it = children.begin();
- it != children.end();
- ++it) {
- ui::Layer* child = *it;
- DeepDeleteLayers(child);
- }
- delete layer;
-}
-
bool IsWindowPositionManaged(const aura::Window* window) {
return window->GetProperty(ash::internal::kWindowPositionManagedKey);
}
diff --git a/ash/wm/window_util.h b/ash/wm/window_util.h
index f1da5b8..80343a4 100644
--- a/ash/wm/window_util.h
+++ b/ash/wm/window_util.h
@@ -84,21 +84,6 @@ ASH_EXPORT void ToggleMaximizedWindow(aura::Window* window);
// Moves the window to the center of the display.
ASH_EXPORT void CenterWindow(aura::Window* window);
-// Returns the existing Layer for |window| (and all its descendants) and creates
-// a new layer for |window| and all its descendants. This is intended for
-// animations that want to animate between the existing visuals and a new window
-// state. The caller owns the return value.
-//
-// As a result of this |window| has freshly created layers, meaning the layers
-// are all empty (nothing has been painted to them) and are sized to 0x0. Soon
-// after this call you need to reset the bounds of the window. Or, you can pass
-// true as the second argument to let the function do that.
-ASH_EXPORT ui::Layer* RecreateWindowLayers(aura::Window* window,
- bool set_bounds) WARN_UNUSED_RESULT;
-
-// Deletes |layer| and all its child layers.
-ASH_EXPORT void DeepDeleteLayers(ui::Layer* layer);
-
// Returns true if |window|'s position can automatically be managed.
ASH_EXPORT bool IsWindowPositionManaged(const aura::Window* window);
diff --git a/ash/wm/workspace/desktop_background_fade_controller.cc b/ash/wm/workspace/desktop_background_fade_controller.cc
index 444cd43..68628b88 100644
--- a/ash/wm/workspace/desktop_background_fade_controller.cc
+++ b/ash/wm/workspace/desktop_background_fade_controller.cc
@@ -39,8 +39,9 @@ DesktopBackgroundFadeController::DesktopBackgroundFadeController(
parent->StackChildBelow(fade_window, position_above);
parent->StackChildAbove(fade_window, position_above);
window_controller_->SetColor(start_color);
- SetWindowVisibilityAnimationTransition(
- window_controller_->GetWidget()->GetNativeView(), ANIMATE_NONE);
+ views::corewm::SetWindowVisibilityAnimationTransition(
+ window_controller_->GetWidget()->GetNativeView(),
+ views::corewm::ANIMATE_NONE);
window_controller_->GetWidget()->Show();
{
ui::ScopedLayerAnimationSettings scoped_setter(
diff --git a/ash/wm/workspace/multi_window_resize_controller.cc b/ash/wm/workspace/multi_window_resize_controller.cc
index b692b23..1dea17d 100644
--- a/ash/wm/workspace/multi_window_resize_controller.cc
+++ b/ash/wm/workspace/multi_window_resize_controller.cc
@@ -393,9 +393,9 @@ void MultiWindowResizeController::ShowNow() {
ResizeView* view = new ResizeView(this, windows_.direction);
resize_widget_->set_focus_on_creation(false);
resize_widget_->Init(params);
- SetWindowVisibilityAnimationType(
+ views::corewm::SetWindowVisibilityAnimationType(
resize_widget_->GetNativeWindow(),
- WINDOW_VISIBILITY_ANIMATION_TYPE_FADE);
+ views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE);
resize_widget_->GetNativeWindow()->SetName("MultiWindowResizeController");
resize_widget_->SetContentsView(view);
show_bounds_in_screen_ = ScreenAsh::ConvertRectToScreen(
diff --git a/ash/wm/workspace/workspace.cc b/ash/wm/workspace/workspace.cc
index 48f994f..7f515fc 100644
--- a/ash/wm/workspace/workspace.cc
+++ b/ash/wm/workspace/workspace.cc
@@ -27,7 +27,7 @@ Workspace::Workspace(WorkspaceManager* manager,
workspace_layout_manager_(NULL) {
window_->SetProperty(internal::kChildWindowVisibilityChangesAnimatedKey,
true);
- SetWindowVisibilityAnimationTransition(window_, ANIMATE_NONE);
+ SetWindowVisibilityAnimationTransition(window_, views::corewm::ANIMATE_NONE);
window_->set_id(kShellWindowId_WorkspaceContainer);
window_->SetName("WorkspaceContainer");
window_->Init(ui::LAYER_NOT_DRAWN);
diff --git a/ash/wm/workspace/workspace_layout_manager.cc b/ash/wm/workspace/workspace_layout_manager.cc
index 639ad77..e3aff8d 100644
--- a/ash/wm/workspace/workspace_layout_manager.cc
+++ b/ash/wm/workspace/workspace_layout_manager.cc
@@ -23,6 +23,7 @@
#include "ui/aura/window_observer.h"
#include "ui/base/events/event.h"
#include "ui/base/ui_base_types.h"
+#include "ui/views/corewm/window_util.h"
using aura::Window;
@@ -200,7 +201,7 @@ void WorkspaceLayoutManager::OnWindowPropertyChanged(Window* window,
WorkspaceManager::IsMaximizedState(old_state) &&
new_state != ui::SHOW_STATE_MINIMIZED))) {
BuildWindowBoundsMap(window, &bounds_map);
- cloned_layer = wm::RecreateWindowLayers(window, false);
+ cloned_layer = views::corewm::RecreateWindowLayers(window, false);
// Constrained windows don't get their bounds reset when we update the
// window bounds. Leaving them empty is unexpected, so we reset them now.
ResetConstrainedWindowBoundsIfNecessary(bounds_map, window);
@@ -251,7 +252,7 @@ void WorkspaceLayoutManager::ShowStateChanged(
DCHECK(!cloned_layer);
// Save the previous show state so that we can correctly restore it.
window->SetProperty(internal::kRestoreShowStateKey, last_show_state);
- SetWindowVisibilityAnimationType(
+ views::corewm::SetWindowVisibilityAnimationType(
window, WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE);
workspace_manager()->OnWorkspaceWindowShowStateChanged(
workspace_, window, last_show_state, NULL);
diff --git a/ash/wm/workspace/workspace_window_resizer.cc b/ash/wm/workspace/workspace_window_resizer.cc
index cd8996a..b452a12 100644
--- a/ash/wm/workspace/workspace_window_resizer.cc
+++ b/ash/wm/workspace/workspace_window_resizer.cc
@@ -29,6 +29,7 @@
#include "ui/compositor/layer.h"
#include "ui/gfx/screen.h"
#include "ui/gfx/transform.h"
+#include "ui/views/corewm/window_util.h"
namespace ash {
@@ -317,7 +318,7 @@ WorkspaceWindowResizer::~WorkspaceWindowResizer() {
drag_phantom_window_controller_.reset();
if (layer_)
- wm::DeepDeleteLayers(layer_);
+ views::corewm::DeepDeleteLayers(layer_);
if (destroyed_)
*destroyed_ = true;
@@ -960,7 +961,7 @@ bool WorkspaceWindowResizer::ShouldAllowMouseWarp() const {
void WorkspaceWindowResizer::RecreateWindowLayers() {
DCHECK(!layer_);
- layer_ = wm::RecreateWindowLayers(window(), true);
+ layer_ = views::corewm::RecreateWindowLayers(window(), true);
layer_->set_delegate(window()->layer()->delegate());
// Place the layer at (0, 0) of the PhantomWindowController's window.
gfx::Rect layer_bounds = layer_->bounds();