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 <math.h> | 7 #include <math.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "ash/aura/wm_window_aura.h" | 12 #include "ash/aura/wm_window_aura.h" |
13 #include "ash/common/shelf/shelf.h" | |
14 #include "ash/common/shelf/shelf_layout_manager.h" | |
15 #include "ash/common/shelf/shelf_widget.h" | |
16 #include "ash/common/shelf/wm_shelf.h" | 13 #include "ash/common/shelf/wm_shelf.h" |
17 #include "ash/common/wm/window_animation_types.h" | 14 #include "ash/common/wm/window_animation_types.h" |
18 #include "ash/screen_util.h" | 15 #include "ash/screen_util.h" |
19 #include "ash/wm/window_util.h" | 16 #include "ash/wm/window_util.h" |
20 #include "ash/wm/workspace_controller.h" | 17 #include "ash/wm/workspace_controller.h" |
21 #include "base/command_line.h" | 18 #include "base/i18n/rtl.h" |
22 #include "base/compiler_specific.h" | |
23 #include "base/logging.h" | 19 #include "base/logging.h" |
24 #include "base/message_loop/message_loop.h" | |
25 #include "base/stl_util.h" | 20 #include "base/stl_util.h" |
26 #include "base/time/time.h" | 21 #include "base/time/time.h" |
27 #include "ui/aura/client/aura_constants.h" | 22 #include "ui/aura/client/aura_constants.h" |
28 #include "ui/aura/window.h" | 23 #include "ui/aura/window.h" |
29 #include "ui/aura/window_observer.h" | 24 #include "ui/aura/window_observer.h" |
30 #include "ui/aura/window_property.h" | 25 #include "ui/aura/window_property.h" |
31 #include "ui/compositor/compositor_observer.h" | 26 #include "ui/compositor/compositor_observer.h" |
32 #include "ui/compositor/layer.h" | 27 #include "ui/compositor/layer.h" |
33 #include "ui/compositor/layer_animation_observer.h" | 28 #include "ui/compositor/layer_animation_observer.h" |
34 #include "ui/compositor/layer_animation_sequence.h" | 29 #include "ui/compositor/layer_animation_sequence.h" |
35 #include "ui/compositor/layer_animator.h" | 30 #include "ui/compositor/layer_animator.h" |
36 #include "ui/compositor/layer_tree_owner.h" | 31 #include "ui/compositor/layer_tree_owner.h" |
37 #include "ui/compositor/scoped_layer_animation_settings.h" | 32 #include "ui/compositor/scoped_layer_animation_settings.h" |
38 #include "ui/display/display.h" | 33 #include "ui/display/display.h" |
39 #include "ui/display/screen.h" | 34 #include "ui/display/screen.h" |
40 #include "ui/gfx/geometry/vector3d_f.h" | |
41 #include "ui/gfx/interpolated_transform.h" | 35 #include "ui/gfx/interpolated_transform.h" |
42 #include "ui/gfx/transform.h" | 36 #include "ui/gfx/transform.h" |
43 #include "ui/views/view.h" | |
44 #include "ui/views/widget/widget.h" | |
45 #include "ui/wm/core/window_util.h" | 37 #include "ui/wm/core/window_util.h" |
46 | 38 |
47 namespace ash { | 39 namespace ash { |
48 namespace { | 40 namespace { |
49 | 41 |
50 const int kLayerAnimationsForMinimizeDurationMS = 200; | 42 const int kLayerAnimationsForMinimizeDurationMS = 200; |
51 | 43 |
52 // Durations for the cross-fade animation, in milliseconds. | 44 // Durations for the cross-fade animation, in milliseconds. |
53 const float kCrossFadeDurationMinMs = 200.f; | 45 const float kCrossFadeDurationMinMs = 200.f; |
54 const float kCrossFadeDurationMaxMs = 400.f; | 46 const float kCrossFadeDurationMaxMs = 400.f; |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 | 421 |
430 std::vector<ui::LayerAnimationSequence*> animations; | 422 std::vector<ui::LayerAnimationSequence*> animations; |
431 animations.push_back(brightness_sequence.release()); | 423 animations.push_back(brightness_sequence.release()); |
432 animations.push_back(grayscale_sequence.release()); | 424 animations.push_back(grayscale_sequence.release()); |
433 | 425 |
434 return animations; | 426 return animations; |
435 } | 427 } |
436 | 428 |
437 gfx::Rect GetMinimizeAnimationTargetBoundsInScreen(aura::Window* window) { | 429 gfx::Rect GetMinimizeAnimationTargetBoundsInScreen(aura::Window* window) { |
438 WmWindow* wm_window = WmWindowAura::Get(window); | 430 WmWindow* wm_window = WmWindowAura::Get(window); |
439 Shelf* shelf = Shelf::ForWindow(wm_window); | 431 WmShelf* shelf = WmShelf::ForWindow(wm_window); |
440 // Shelf is created lazily and can be NULL. | |
441 if (!shelf) | |
442 return gfx::Rect(); | |
443 gfx::Rect item_rect = shelf->GetScreenBoundsOfItemIconForWindow(wm_window); | 432 gfx::Rect item_rect = shelf->GetScreenBoundsOfItemIconForWindow(wm_window); |
444 | 433 |
445 // The launcher item is visible and has an icon. | 434 // The launcher item is visible and has an icon. |
446 if (!item_rect.IsEmpty()) | 435 if (!item_rect.IsEmpty()) |
447 return item_rect; | 436 return item_rect; |
448 | 437 |
449 // If both the icon width and height are 0, then there is no icon in the | 438 // If both the icon width and height are 0, then there is no icon in the |
450 // launcher for |window|. If the launcher is auto hidden, one of the height or | 439 // launcher for |window|. If the launcher is auto hidden, one of the height or |
451 // width will be 0 but the position in the launcher and the major dimension | 440 // width will be 0 but the position in the launcher and the major dimension |
452 // are still reported correctly and the window can be animated to the launcher | 441 // are still reported correctly and the window can be animated to the launcher |
453 // item's light bar. | 442 // item's light bar. |
454 if (item_rect.width() != 0 || item_rect.height() != 0) { | 443 if (item_rect.width() != 0 || item_rect.height() != 0) { |
455 if (shelf->shelf_layout_manager()->visibility_state() == SHELF_AUTO_HIDE) { | 444 if (shelf->GetVisibilityState() == SHELF_AUTO_HIDE) { |
456 gfx::Rect shelf_bounds = shelf->shelf_widget()->GetWindowBoundsInScreen(); | 445 gfx::Rect shelf_bounds = shelf->GetWindow()->GetBoundsInScreen(); |
457 if (shelf->wm_shelf()->alignment() == SHELF_ALIGNMENT_LEFT) | 446 if (shelf->alignment() == SHELF_ALIGNMENT_LEFT) |
458 item_rect.set_x(shelf_bounds.right()); | 447 item_rect.set_x(shelf_bounds.right()); |
459 else if (shelf->wm_shelf()->alignment() == SHELF_ALIGNMENT_RIGHT) | 448 else if (shelf->alignment() == SHELF_ALIGNMENT_RIGHT) |
460 item_rect.set_x(shelf_bounds.x()); | 449 item_rect.set_x(shelf_bounds.x()); |
461 else | 450 else |
462 item_rect.set_y(shelf_bounds.y()); | 451 item_rect.set_y(shelf_bounds.y()); |
463 return item_rect; | 452 return item_rect; |
464 } | 453 } |
465 } | 454 } |
466 | 455 |
467 // Coming here, there is no visible icon of that shelf item and we zoom back | 456 // Coming here, there is no visible icon of that shelf item and we zoom back |
468 // to the location of the application launcher (which is fixed as first item | 457 // to the location of the application launcher (which is fixed as first item |
469 // of the shelf). | 458 // of the shelf). |
470 gfx::Rect work_area = | 459 gfx::Rect work_area = |
471 display::Screen::GetScreen()->GetDisplayNearestWindow(window).work_area(); | 460 display::Screen::GetScreen()->GetDisplayNearestWindow(window).work_area(); |
472 int ltr_adjusted_x = base::i18n::IsRTL() ? work_area.right() : work_area.x(); | 461 int ltr_adjusted_x = base::i18n::IsRTL() ? work_area.right() : work_area.x(); |
473 switch (shelf->wm_shelf()->alignment()) { | 462 switch (shelf->alignment()) { |
474 case SHELF_ALIGNMENT_BOTTOM: | 463 case SHELF_ALIGNMENT_BOTTOM: |
475 case SHELF_ALIGNMENT_BOTTOM_LOCKED: | 464 case SHELF_ALIGNMENT_BOTTOM_LOCKED: |
476 return gfx::Rect(ltr_adjusted_x, work_area.bottom(), 0, 0); | 465 return gfx::Rect(ltr_adjusted_x, work_area.bottom(), 0, 0); |
477 case SHELF_ALIGNMENT_LEFT: | 466 case SHELF_ALIGNMENT_LEFT: |
478 return gfx::Rect(work_area.x(), work_area.y(), 0, 0); | 467 return gfx::Rect(work_area.x(), work_area.y(), 0, 0); |
479 case SHELF_ALIGNMENT_RIGHT: | 468 case SHELF_ALIGNMENT_RIGHT: |
480 return gfx::Rect(work_area.right(), work_area.y(), 0, 0); | 469 return gfx::Rect(work_area.right(), work_area.y(), 0, 0); |
481 } | 470 } |
482 NOTREACHED(); | 471 NOTREACHED(); |
483 return gfx::Rect(); | 472 return gfx::Rect(); |
484 } | 473 } |
485 | 474 |
486 } // namespace ash | 475 } // namespace ash |
OLD | NEW |