| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/wm/window_animations.h" | 5 #include "ash/wm/window_animations.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/launcher/launcher.h" | 8 #include "ash/launcher/launcher.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
| 14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
| 15 #include "base/time.h" | 15 #include "base/time.h" |
| 16 #include "ui/aura/client/aura_constants.h" | 16 #include "ui/aura/client/aura_constants.h" |
| 17 #include "ui/aura/dip_util.h" | |
| 18 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
| 19 #include "ui/aura/window_observer.h" | 18 #include "ui/aura/window_observer.h" |
| 20 #include "ui/aura/window_property.h" | 19 #include "ui/aura/window_property.h" |
| 21 #include "ui/gfx/compositor/layer.h" | 20 #include "ui/gfx/compositor/layer.h" |
| 22 #include "ui/gfx/compositor/layer_animation_observer.h" | 21 #include "ui/gfx/compositor/layer_animation_observer.h" |
| 23 #include "ui/gfx/compositor/layer_animation_sequence.h" | 22 #include "ui/gfx/compositor/layer_animation_sequence.h" |
| 24 #include "ui/gfx/compositor/layer_animator.h" | 23 #include "ui/gfx/compositor/layer_animator.h" |
| 25 #include "ui/gfx/compositor/scoped_layer_animation_settings.h" | 24 #include "ui/gfx/compositor/scoped_layer_animation_settings.h" |
| 26 #include "ui/gfx/interpolated_transform.h" | 25 #include "ui/gfx/interpolated_transform.h" |
| 27 #include "ui/gfx/screen.h" | 26 #include "ui/gfx/screen.h" |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 | 228 |
| 230 window->layer()->SetOpacity(kWindowAnimation_HideOpacity); | 229 window->layer()->SetOpacity(kWindowAnimation_HideOpacity); |
| 231 window->layer()->SetTransform(end_transform); | 230 window->layer()->SetTransform(end_transform); |
| 232 } | 231 } |
| 233 | 232 |
| 234 // Show/Hide windows using a shrink animation. | 233 // Show/Hide windows using a shrink animation. |
| 235 void AnimateShowWindow_Drop(aura::Window* window) { | 234 void AnimateShowWindow_Drop(aura::Window* window) { |
| 236 ui::Transform transform; | 235 ui::Transform transform; |
| 237 transform.ConcatScale(kWindowAnimation_ScaleFactor, | 236 transform.ConcatScale(kWindowAnimation_ScaleFactor, |
| 238 kWindowAnimation_ScaleFactor); | 237 kWindowAnimation_ScaleFactor); |
| 239 gfx::Rect bounds = window->GetBoundsInPixel(); | 238 gfx::Rect bounds = window->bounds(); |
| 240 transform.ConcatTranslate( | 239 transform.ConcatTranslate( |
| 241 kWindowAnimation_TranslateFactor * bounds.width(), | 240 kWindowAnimation_TranslateFactor * bounds.width(), |
| 242 kWindowAnimation_TranslateFactor * bounds.height()); | 241 kWindowAnimation_TranslateFactor * bounds.height()); |
| 243 AnimateShowWindowCommon(window, transform, ui::Transform()); | 242 AnimateShowWindowCommon(window, transform, ui::Transform()); |
| 244 } | 243 } |
| 245 | 244 |
| 246 void AnimateHideWindow_Drop(aura::Window* window) { | 245 void AnimateHideWindow_Drop(aura::Window* window) { |
| 247 ui::Transform transform; | 246 ui::Transform transform; |
| 248 transform.ConcatScale(kWindowAnimation_ScaleFactor, | 247 transform.ConcatScale(kWindowAnimation_ScaleFactor, |
| 249 kWindowAnimation_ScaleFactor); | 248 kWindowAnimation_ScaleFactor); |
| 250 gfx::Rect bounds = window->GetBoundsInPixel(); | 249 gfx::Rect bounds = window->bounds(); |
| 251 transform.ConcatTranslate( | 250 transform.ConcatTranslate( |
| 252 kWindowAnimation_TranslateFactor * bounds.width(), | 251 kWindowAnimation_TranslateFactor * bounds.width(), |
| 253 kWindowAnimation_TranslateFactor * bounds.height()); | 252 kWindowAnimation_TranslateFactor * bounds.height()); |
| 254 AnimateHideWindowCommon(window, transform); | 253 AnimateHideWindowCommon(window, transform); |
| 255 } | 254 } |
| 256 | 255 |
| 257 // Show/Hide windows using a vertical Glenimation. | 256 // Show/Hide windows using a vertical Glenimation. |
| 258 void AnimateShowWindow_Vertical(aura::Window* window) { | 257 void AnimateShowWindow_Vertical(aura::Window* window) { |
| 259 ui::Transform transform; | 258 ui::Transform transform; |
| 260 transform.ConcatTranslate(0, kWindowAnimation_Vertical_TranslateY); | 259 transform.ConcatTranslate(0, kWindowAnimation_Vertical_TranslateY); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 274 | 273 |
| 275 void AnimateHideWindow_Fade(aura::Window* window) { | 274 void AnimateHideWindow_Fade(aura::Window* window) { |
| 276 AnimateHideWindowCommon(window, ui::Transform()); | 275 AnimateHideWindowCommon(window, ui::Transform()); |
| 277 } | 276 } |
| 278 | 277 |
| 279 // Builds the transform used when switching workspaces for the specified | 278 // Builds the transform used when switching workspaces for the specified |
| 280 // window. | 279 // window. |
| 281 ui::Transform BuildWorkspaceSwitchTransform(aura::Window* window) { | 280 ui::Transform BuildWorkspaceSwitchTransform(aura::Window* window) { |
| 282 // Animations for transitioning workspaces scale all windows. To give the | 281 // Animations for transitioning workspaces scale all windows. To give the |
| 283 // effect of scaling from the center of the screen the windows are translated. | 282 // effect of scaling from the center of the screen the windows are translated. |
| 284 gfx::Rect bounds = window->GetBoundsInPixel(); | 283 gfx::Rect bounds = window->bounds(); |
| 285 gfx::Rect parent_bounds(window->parent()->GetBoundsInPixel()); | 284 gfx::Rect parent_bounds(window->parent()->bounds()); |
| 286 | 285 |
| 287 float mid_x = static_cast<float>(parent_bounds.width()) / 2.0f; | 286 float mid_x = static_cast<float>(parent_bounds.width()) / 2.0f; |
| 288 float initial_x = | 287 float initial_x = |
| 289 (static_cast<float>(bounds.x()) - mid_x) * kWorkspaceScale + | 288 (static_cast<float>(bounds.x()) - mid_x) * kWorkspaceScale + |
| 290 mid_x; | 289 mid_x; |
| 291 float mid_y = static_cast<float>(parent_bounds.height()) / 2.0f; | 290 float mid_y = static_cast<float>(parent_bounds.height()) / 2.0f; |
| 292 float initial_y = | 291 float initial_y = |
| 293 (static_cast<float>(bounds.y()) - mid_y) * kWorkspaceScale + | 292 (static_cast<float>(bounds.y()) - mid_y) * kWorkspaceScale + |
| 294 mid_y; | 293 mid_y; |
| 295 | 294 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 gfx::Rect work_area = | 358 gfx::Rect work_area = |
| 360 gfx::Screen::GetMonitorNearestWindow(window).work_area(); | 359 gfx::Screen::GetMonitorNearestWindow(window).work_area(); |
| 361 target_bounds.SetRect(work_area.right(), work_area.bottom(), 0, 0); | 360 target_bounds.SetRect(work_area.right(), work_area.bottom(), 0, 0); |
| 362 } | 361 } |
| 363 return target_bounds; | 362 return target_bounds; |
| 364 } | 363 } |
| 365 | 364 |
| 366 void AddLayerAnimationsForMinimize(aura::Window* window, bool show) { | 365 void AddLayerAnimationsForMinimize(aura::Window* window, bool show) { |
| 367 // Recalculate the transform at restore time since the launcher item may have | 366 // Recalculate the transform at restore time since the launcher item may have |
| 368 // moved while the window was minimized. | 367 // moved while the window was minimized. |
| 369 gfx::Rect bounds = window->GetBoundsInPixel(); | 368 gfx::Rect bounds = window->bounds(); |
| 370 gfx::Rect target_bounds = | 369 gfx::Rect target_bounds = GetMinimizeRectForWindow(window); |
| 371 aura::ConvertRectToPixel(window, GetMinimizeRectForWindow(window)); | |
| 372 | 370 |
| 373 float scale_x = static_cast<float>(target_bounds.height()) / bounds.width(); | 371 float scale_x = static_cast<float>(target_bounds.height()) / bounds.width(); |
| 374 float scale_y = static_cast<float>(target_bounds.width()) / bounds.height(); | 372 float scale_y = static_cast<float>(target_bounds.width()) / bounds.height(); |
| 375 | 373 |
| 376 scoped_ptr<ui::InterpolatedTransform> scale( | 374 scoped_ptr<ui::InterpolatedTransform> scale( |
| 377 new ui::InterpolatedScale(gfx::Point3f(1, 1, 1), | 375 new ui::InterpolatedScale(gfx::Point3f(1, 1, 1), |
| 378 gfx::Point3f(scale_x, scale_y, 1))); | 376 gfx::Point3f(scale_x, scale_y, 1))); |
| 379 | 377 |
| 380 scoped_ptr<ui::InterpolatedTransform> translation( | 378 scoped_ptr<ui::InterpolatedTransform> translation( |
| 381 new ui::InterpolatedTranslation( | 379 new ui::InterpolatedTranslation( |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 } | 506 } |
| 509 | 507 |
| 510 } // namespace internal | 508 } // namespace internal |
| 511 | 509 |
| 512 ui::ImplicitAnimationObserver* CreateHidingWindowAnimationObserver( | 510 ui::ImplicitAnimationObserver* CreateHidingWindowAnimationObserver( |
| 513 aura::Window* window) { | 511 aura::Window* window) { |
| 514 return new internal::HidingWindowAnimationObserver(window); | 512 return new internal::HidingWindowAnimationObserver(window); |
| 515 } | 513 } |
| 516 | 514 |
| 517 } // namespace ash | 515 } // namespace ash |
| OLD | NEW |