Commit e5c3e1be authored by mukai@chromium.org's avatar mukai@chromium.org

Removes workspace_animations.(h,cc)

R=sky@chromium.org
BUG=264396
TEST=compilation succeeds

Review URL: https://chromiumcodereview.appspot.com/21966005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@215804 0039d316-1c4b-4281-b951-d872f2087c98
parent 49cfc0f6
...@@ -511,8 +511,6 @@ ...@@ -511,8 +511,6 @@
'wm/workspace/snap_sizer.cc', 'wm/workspace/snap_sizer.cc',
'wm/workspace/snap_sizer.h', 'wm/workspace/snap_sizer.h',
'wm/workspace/snap_types.h', 'wm/workspace/snap_types.h',
'wm/workspace/workspace_animations.cc',
'wm/workspace/workspace_animations.h',
'wm/workspace/workspace_event_handler.cc', 'wm/workspace/workspace_event_handler.cc',
'wm/workspace/workspace_event_handler.h', 'wm/workspace/workspace_event_handler.h',
'wm/workspace/workspace_layout_manager.cc', 'wm/workspace/workspace_layout_manager.cc',
......
...@@ -25,9 +25,9 @@ ...@@ -25,9 +25,9 @@
#include "ash/wm/gestures/shelf_gesture_handler.h" #include "ash/wm/gestures/shelf_gesture_handler.h"
#include "ash/wm/mru_window_tracker.h" #include "ash/wm/mru_window_tracker.h"
#include "ash/wm/property_util.h" #include "ash/wm/property_util.h"
#include "ash/wm/window_animations.h"
#include "ash/wm/window_properties.h" #include "ash/wm/window_properties.h"
#include "ash/wm/window_util.h" #include "ash/wm/window_util.h"
#include "ash/wm/workspace/workspace_animations.h"
#include "ash/wm/workspace_controller.h" #include "ash/wm/workspace_controller.h"
#include "base/auto_reset.h" #include "base/auto_reset.h"
#include "base/command_line.h" #include "base/command_line.h"
...@@ -599,7 +599,7 @@ void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) { ...@@ -599,7 +599,7 @@ void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) {
ui::ScopedLayerAnimationSettings launcher_animation_setter( ui::ScopedLayerAnimationSettings launcher_animation_setter(
GetLayer(shelf_)->GetAnimator()); GetLayer(shelf_)->GetAnimator());
launcher_animation_setter.SetTransitionDuration( launcher_animation_setter.SetTransitionDuration(
base::TimeDelta::FromMilliseconds(kWorkspaceSwitchTimeMS)); base::TimeDelta::FromMilliseconds(kCrossFadeDurationMS));
launcher_animation_setter.SetTweenType(ui::Tween::EASE_OUT); launcher_animation_setter.SetTweenType(ui::Tween::EASE_OUT);
launcher_animation_setter.SetPreemptionStrategy( launcher_animation_setter.SetPreemptionStrategy(
ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
...@@ -609,7 +609,7 @@ void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) { ...@@ -609,7 +609,7 @@ void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) {
ui::ScopedLayerAnimationSettings status_animation_setter( ui::ScopedLayerAnimationSettings status_animation_setter(
GetLayer(shelf_->status_area_widget())->GetAnimator()); GetLayer(shelf_->status_area_widget())->GetAnimator());
status_animation_setter.SetTransitionDuration( status_animation_setter.SetTransitionDuration(
base::TimeDelta::FromMilliseconds(kWorkspaceSwitchTimeMS)); base::TimeDelta::FromMilliseconds(kCrossFadeDurationMS));
status_animation_setter.SetTweenType(ui::Tween::EASE_OUT); status_animation_setter.SetTweenType(ui::Tween::EASE_OUT);
status_animation_setter.SetPreemptionStrategy( status_animation_setter.SetPreemptionStrategy(
ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "ash/shelf/shelf_widget.h" #include "ash/shelf/shelf_widget.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/wm/window_util.h" #include "ash/wm/window_util.h"
#include "ash/wm/workspace/workspace_animations.h"
#include "ash/wm/workspace_controller.h" #include "ash/wm/workspace_controller.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
...@@ -73,6 +72,8 @@ int64 Round64(float f) { ...@@ -73,6 +72,8 @@ int64 Round64(float f) {
} // namespace } // namespace
const int kCrossFadeDurationMS = 200;
void AddLayerAnimationsForMinimize(aura::Window* window, bool show) { void AddLayerAnimationsForMinimize(aura::Window* window, bool show) {
// Recalculate the transform at restore time since the launcher item may have // Recalculate the transform at restore time since the launcher item may have
// moved while the window was minimized. // moved while the window was minimized.
...@@ -436,12 +437,12 @@ base::TimeDelta GetCrossFadeDuration(const gfx::Rect& old_bounds, ...@@ -436,12 +437,12 @@ base::TimeDelta GetCrossFadeDuration(const gfx::Rect& old_bounds,
int max_area = std::max(old_area, new_area); int max_area = std::max(old_area, new_area);
// Avoid divide by zero. // Avoid divide by zero.
if (max_area == 0) if (max_area == 0)
return base::TimeDelta::FromMilliseconds(internal::kWorkspaceSwitchTimeMS); return base::TimeDelta::FromMilliseconds(kCrossFadeDurationMS);
int delta_area = std::abs(old_area - new_area); int delta_area = std::abs(old_area - new_area);
// If the area didn't change, the animation is instantaneous. // If the area didn't change, the animation is instantaneous.
if (delta_area == 0) if (delta_area == 0)
return base::TimeDelta::FromMilliseconds(internal::kWorkspaceSwitchTimeMS); return base::TimeDelta::FromMilliseconds(kCrossFadeDurationMS);
float factor = float factor =
static_cast<float>(delta_area) / static_cast<float>(max_area); static_cast<float>(delta_area) / static_cast<float>(max_area);
......
...@@ -37,6 +37,9 @@ enum LayerScaleAnimationDirection { ...@@ -37,6 +37,9 @@ enum LayerScaleAnimationDirection {
LAYER_SCALE_ANIMATION_BELOW, LAYER_SCALE_ANIMATION_BELOW,
}; };
// Amount of time for the cross fade animation.
extern const int kCrossFadeDurationMS;
// Animate a cross-fade of |window| from its current bounds to |new_bounds|. // Animate a cross-fade of |window| from its current bounds to |new_bounds|.
ASH_EXPORT void CrossFadeToBounds(aura::Window* window, ASH_EXPORT void CrossFadeToBounds(aura::Window* window,
const gfx::Rect& new_bounds); const gfx::Rect& new_bounds);
......
// Copyright (c) 2012 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 "ash/wm/workspace/workspace_animations.h"
#include "ash/wm/window_animations.h"
#include "ui/aura/window.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/views/corewm/window_animations.h"
namespace ash {
namespace internal {
const int kWorkspaceSwitchTimeMS = 200;
namespace {
// Tween type used when showing/hiding workspaces.
const ui::Tween::Type kWorkspaceTweenType = ui::Tween::EASE_OUT;
// If |details.duration| is not-empty it is returned, otherwise
// |kWorkspaceSwitchTimeMS| is returned.
base::TimeDelta DurationForWorkspaceShowOrHide(
const WorkspaceAnimationDetails& details) {
return details.duration == base::TimeDelta() ?
base::TimeDelta::FromMilliseconds(kWorkspaceSwitchTimeMS) :
details.duration;
}
} // namespace
WorkspaceAnimationDetails::WorkspaceAnimationDetails()
: direction(WORKSPACE_ANIMATE_UP),
animate(false),
animate_opacity(false),
animate_scale(false),
pause_time_ms(0) {
}
WorkspaceAnimationDetails::~WorkspaceAnimationDetails() {
}
void ShowWorkspace(aura::Window* window,
const WorkspaceAnimationDetails& details) {
window->Show();
if (!details.animate || views::corewm::WindowAnimationsDisabled(NULL)) {
window->layer()->SetOpacity(1.0f);
window->layer()->SetTransform(gfx::Transform());
return;
}
window->layer()->SetOpacity(details.animate_opacity ? 0.0f : 1.0f);
if (details.animate_scale) {
SetTransformForScaleAnimation(window->layer(),
details.direction == WORKSPACE_ANIMATE_UP ?
LAYER_SCALE_ANIMATION_BELOW : LAYER_SCALE_ANIMATION_BELOW);
} else {
window->layer()->SetTransform(gfx::Transform());
}
// In order for pause to work we need to stop animations.
window->layer()->GetAnimator()->StopAnimating();
{
ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
if (details.pause_time_ms > 0) {
settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION);
window->layer()->GetAnimator()->SchedulePauseForProperties(
base::TimeDelta::FromMilliseconds(details.pause_time_ms),
ui::LayerAnimationElement::TRANSFORM,
ui::LayerAnimationElement::OPACITY,
ui::LayerAnimationElement::BRIGHTNESS,
ui::LayerAnimationElement::VISIBILITY,
-1);
}
settings.SetTweenType(kWorkspaceTweenType);
settings.SetTransitionDuration(DurationForWorkspaceShowOrHide(details));
window->layer()->SetTransform(gfx::Transform());
window->layer()->SetOpacity(1.0f);
}
}
void HideWorkspace(aura::Window* window,
const WorkspaceAnimationDetails& details) {
window->layer()->SetTransform(gfx::Transform());
window->layer()->SetOpacity(1.0f);
window->layer()->GetAnimator()->StopAnimating();
if (!details.animate || views::corewm::WindowAnimationsDisabled(NULL)) {
window->Hide();
return;
}
ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
if (details.pause_time_ms > 0) {
settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION);
window->layer()->GetAnimator()->SchedulePauseForProperties(
base::TimeDelta::FromMilliseconds(details.pause_time_ms),
ui::LayerAnimationElement::TRANSFORM,
ui::LayerAnimationElement::OPACITY,
ui::LayerAnimationElement::BRIGHTNESS,
ui::LayerAnimationElement::VISIBILITY,
-1);
}
settings.SetTransitionDuration(DurationForWorkspaceShowOrHide(details));
settings.SetTweenType(kWorkspaceTweenType);
if (details.animate_scale) {
SetTransformForScaleAnimation(window->layer(),
details.direction == WORKSPACE_ANIMATE_UP ?
LAYER_SCALE_ANIMATION_ABOVE : LAYER_SCALE_ANIMATION_BELOW);
} else {
window->layer()->SetTransform(gfx::Transform());
}
// NOTE: Hide() must be before SetOpacity(), else
// VisibilityController::UpdateLayerVisibility doesn't pass the false to the
// layer so that the layer and window end up out of sync and confused.
window->Hide();
if (details.animate_opacity)
window->layer()->SetOpacity(0.0f);
// After the animation completes snap the transform back to the identity,
// otherwise any one that asks for screen bounds gets a slightly scaled
// version.
settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION);
settings.SetTransitionDuration(base::TimeDelta());
window->layer()->SetTransform(gfx::Transform());
}
} // namespace internal
} // namespace ash
// Copyright (c) 2012 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 ASH_WM_WORKSPACE_WORKSPACE_ANIMATIONS_H_
#define ASH_WM_WORKSPACE_WORKSPACE_ANIMATIONS_H_
#include "ash/ash_export.h"
#include "base/time/time.h"
namespace aura {
class Window;
}
// Collection of functions and types needed for animating workspaces.
namespace ash {
namespace internal {
// Indicates the direction the workspace should appear to go.
enum WorkspaceAnimationDirection {
WORKSPACE_ANIMATE_UP,
WORKSPACE_ANIMATE_DOWN,
};
// The details of this dictate how the show/hide should be animated.
struct WorkspaceAnimationDetails {
WorkspaceAnimationDetails();
~WorkspaceAnimationDetails();
// Direction to animate.
WorkspaceAnimationDirection direction;
// Whether to animate. If false the show/hide is immediate, otherwise it
// animates.
bool animate;
// Whether the opacity should be animated.
bool animate_opacity;
// Whether the scale should be animated.
bool animate_scale;
// The duration of the animation. If empty the default is used.
base::TimeDelta duration;
// Amount of time (in milliseconds) to pause before animating.
int pause_time_ms;
};
// Amount of time for the workspace switch animation.
extern const int kWorkspaceSwitchTimeMS;
// Shows or hides the workspace animating based on |details|.
ASH_EXPORT void ShowWorkspace(aura::Window* window,
const WorkspaceAnimationDetails& details);
ASH_EXPORT void HideWorkspace(aura::Window* window,
const WorkspaceAnimationDetails& details);
} // namespace internal
} // namespace ash
#endif // ASH_WM_WORKSPACE_WORKSPACE_ANIMATIONS_H_
...@@ -9,15 +9,17 @@ ...@@ -9,15 +9,17 @@
#include "ash/shell_window_ids.h" #include "ash/shell_window_ids.h"
#include "ash/wm/base_layout_manager.h" #include "ash/wm/base_layout_manager.h"
#include "ash/wm/property_util.h" #include "ash/wm/property_util.h"
#include "ash/wm/window_animations.h"
#include "ash/wm/window_properties.h" #include "ash/wm/window_properties.h"
#include "ash/wm/window_util.h" #include "ash/wm/window_util.h"
#include "ash/wm/workspace/workspace_animations.h"
#include "ash/wm/workspace/workspace_event_handler.h" #include "ash/wm/workspace/workspace_event_handler.h"
#include "ash/wm/workspace/workspace_layout_manager.h" #include "ash/wm/workspace/workspace_layout_manager.h"
#include "ui/aura/client/activation_client.h" #include "ui/aura/client/activation_client.h"
#include "ui/aura/client/aura_constants.h" #include "ui/aura/client/aura_constants.h"
#include "ui/aura/root_window.h" #include "ui/aura/root_window.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/views/corewm/visibility_controller.h" #include "ui/views/corewm/visibility_controller.h"
#include "ui/views/corewm/window_animations.h" #include "ui/views/corewm/window_animations.h"
...@@ -94,10 +96,34 @@ void WorkspaceController::SetShelf(ShelfLayoutManager* shelf) { ...@@ -94,10 +96,34 @@ void WorkspaceController::SetShelf(ShelfLayoutManager* shelf) {
} }
void WorkspaceController::DoInitialAnimation() { void WorkspaceController::DoInitialAnimation() {
WorkspaceAnimationDetails details; viewport_->Show();
details.animate = details.animate_opacity = details.animate_scale = true;
details.pause_time_ms = kInitialPauseTimeMS; viewport_->layer()->SetOpacity(0.0f);
ash::internal::ShowWorkspace(viewport_, details); SetTransformForScaleAnimation(
viewport_->layer(), LAYER_SCALE_ANIMATION_ABOVE);
// In order for pause to work we need to stop animations.
viewport_->layer()->GetAnimator()->StopAnimating();
{
ui::ScopedLayerAnimationSettings settings(
viewport_->layer()->GetAnimator());
settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION);
viewport_->layer()->GetAnimator()->SchedulePauseForProperties(
base::TimeDelta::FromMilliseconds(kInitialPauseTimeMS),
ui::LayerAnimationElement::TRANSFORM,
ui::LayerAnimationElement::OPACITY,
ui::LayerAnimationElement::BRIGHTNESS,
ui::LayerAnimationElement::VISIBILITY,
-1);
settings.SetTweenType(ui::Tween::EASE_OUT);
settings.SetTransitionDuration(
base::TimeDelta::FromMilliseconds(kCrossFadeDurationMS));
viewport_->layer()->SetTransform(gfx::Transform());
viewport_->layer()->SetOpacity(1.0f);
}
} }
} // namespace internal } // namespace internal
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment