OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/common/wm/overview/window_grid.h" | 5 #include "ash/common/wm/overview/window_grid.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "ash/common/ash_switches.h" | 13 #include "ash/common/ash_switches.h" |
14 #include "ash/common/material_design/material_design_controller.h" | 14 #include "ash/common/material_design/material_design_controller.h" |
15 #include "ash/common/shelf/shelf_types.h" | |
16 #include "ash/common/shelf/wm_shelf.h" | |
15 #include "ash/common/shell_window_ids.h" | 17 #include "ash/common/shell_window_ids.h" |
16 #include "ash/common/wm/overview/scoped_overview_animation_settings.h" | 18 #include "ash/common/wm/overview/scoped_overview_animation_settings.h" |
17 #include "ash/common/wm/overview/scoped_overview_animation_settings_factory.h" | 19 #include "ash/common/wm/overview/scoped_overview_animation_settings_factory.h" |
18 #include "ash/common/wm/overview/scoped_transform_overview_window.h" | 20 #include "ash/common/wm/overview/scoped_transform_overview_window.h" |
19 #include "ash/common/wm/overview/window_selector.h" | 21 #include "ash/common/wm/overview/window_selector.h" |
22 #include "ash/common/wm/overview/window_selector_delegate.h" | |
20 #include "ash/common/wm/overview/window_selector_item.h" | 23 #include "ash/common/wm/overview/window_selector_item.h" |
21 #include "ash/common/wm/window_state.h" | 24 #include "ash/common/wm/window_state.h" |
22 #include "ash/common/wm/wm_screen_util.h" | 25 #include "ash/common/wm/wm_screen_util.h" |
23 #include "ash/common/wm_lookup.h" | 26 #include "ash/common/wm_lookup.h" |
24 #include "ash/common/wm_root_window_controller.h" | 27 #include "ash/common/wm_root_window_controller.h" |
25 #include "ash/common/wm_window.h" | 28 #include "ash/common/wm_window.h" |
26 #include "base/command_line.h" | 29 #include "base/command_line.h" |
27 #include "base/i18n/string_search.h" | 30 #include "base/i18n/string_search.h" |
28 #include "base/memory/scoped_vector.h" | 31 #include "base/memory/scoped_vector.h" |
29 #include "third_party/skia/include/core/SkColor.h" | 32 #include "third_party/skia/include/core/SkColor.h" |
(...skipping 12 matching lines...) Expand all Loading... | |
42 #include "ui/views/widget/widget.h" | 45 #include "ui/views/widget/widget.h" |
43 #include "ui/wm/core/window_animations.h" | 46 #include "ui/wm/core/window_animations.h" |
44 | 47 |
45 namespace ash { | 48 namespace ash { |
46 namespace { | 49 namespace { |
47 | 50 |
48 using Windows = std::vector<WmWindow*>; | 51 using Windows = std::vector<WmWindow*>; |
49 | 52 |
50 // An observer which holds onto the passed widget until the animation is | 53 // An observer which holds onto the passed widget until the animation is |
51 // complete. | 54 // complete. |
52 class CleanupWidgetAfterAnimationObserver | 55 class CleanupWidgetAfterAnimationObserver |
bruthig
2016/07/15 17:05:38
Although this is a pretty small class there certai
varkha
2016/07/15 18:53:36
Done. See if you like this better while I am putti
| |
53 : public ui::ImplicitAnimationObserver { | 56 : public ui::ImplicitAnimationObserver, |
57 public DelayedAnimationObserver { | |
54 public: | 58 public: |
55 explicit CleanupWidgetAfterAnimationObserver( | 59 explicit CleanupWidgetAfterAnimationObserver( |
56 std::unique_ptr<views::Widget> widget); | 60 std::unique_ptr<views::Widget> widget); |
57 ~CleanupWidgetAfterAnimationObserver() override; | 61 ~CleanupWidgetAfterAnimationObserver() override; |
58 | 62 |
59 // ui::ImplicitAnimationObserver: | 63 // ui::ImplicitAnimationObserver: |
60 void OnImplicitAnimationsCompleted() override; | 64 void OnImplicitAnimationsCompleted() override; |
61 | 65 |
66 // DelayedAnimationObserver: | |
67 void SetDelegate(WindowSelectorDelegate* delegate) override; | |
68 void Shutdown() override; | |
69 | |
62 private: | 70 private: |
63 std::unique_ptr<views::Widget> widget_; | 71 std::unique_ptr<views::Widget> widget_; |
72 WindowSelectorDelegate* delegate_; | |
64 | 73 |
65 DISALLOW_COPY_AND_ASSIGN(CleanupWidgetAfterAnimationObserver); | 74 DISALLOW_COPY_AND_ASSIGN(CleanupWidgetAfterAnimationObserver); |
66 }; | 75 }; |
67 | 76 |
68 CleanupWidgetAfterAnimationObserver::CleanupWidgetAfterAnimationObserver( | 77 CleanupWidgetAfterAnimationObserver::CleanupWidgetAfterAnimationObserver( |
69 std::unique_ptr<views::Widget> widget) | 78 std::unique_ptr<views::Widget> widget) |
70 : widget_(std::move(widget)) {} | 79 : widget_(std::move(widget)), delegate_(nullptr) {} |
71 | 80 |
72 CleanupWidgetAfterAnimationObserver::~CleanupWidgetAfterAnimationObserver() {} | 81 CleanupWidgetAfterAnimationObserver::~CleanupWidgetAfterAnimationObserver() {} |
73 | 82 |
74 void CleanupWidgetAfterAnimationObserver::OnImplicitAnimationsCompleted() { | 83 void CleanupWidgetAfterAnimationObserver::OnImplicitAnimationsCompleted() { |
bruthig
2016/07/15 17:05:38
I was looking in to whether or not OnImplicitAnima
varkha
2016/07/15 18:53:36
Animations here are non-zero duration so this is p
| |
84 if (!widget_) | |
bruthig
2016/07/15 17:05:38
Is it accurate that this check will only be true d
varkha
2016/07/15 18:53:36
Done.
| |
85 return; | |
86 if (delegate_) { | |
87 delegate_->RemoveDelayedAnimationObserver(this); | |
88 return; | |
89 } | |
75 delete this; | 90 delete this; |
76 } | 91 } |
77 | 92 |
93 void CleanupWidgetAfterAnimationObserver::SetDelegate( | |
94 WindowSelectorDelegate* delegate) { | |
95 delegate_ = delegate; | |
96 } | |
97 | |
98 void CleanupWidgetAfterAnimationObserver::Shutdown() { | |
99 widget_.reset(); | |
100 delegate_ = nullptr; | |
101 } | |
102 | |
78 // A comparator for locating a given target window. | 103 // A comparator for locating a given target window. |
79 struct WindowSelectorItemComparator { | 104 struct WindowSelectorItemComparator { |
80 explicit WindowSelectorItemComparator(const WmWindow* target_window) | 105 explicit WindowSelectorItemComparator(const WmWindow* target_window) |
81 : target(target_window) {} | 106 : target(target_window) {} |
82 | 107 |
83 bool operator()(WindowSelectorItem* window) const { | 108 bool operator()(WindowSelectorItem* window) const { |
84 return window->GetWindow() == target; | 109 return window->GetWindow() == target; |
85 } | 110 } |
86 | 111 |
87 const WmWindow* target; | 112 const WmWindow* target; |
88 }; | 113 }; |
89 | 114 |
90 // Conceptually the window overview is a table or grid of cells having this | 115 // Conceptually the window overview is a table or grid of cells having this |
91 // fixed aspect ratio. The number of columns is determined by maximizing the | 116 // fixed aspect ratio. The number of columns is determined by maximizing the |
92 // area of them based on the number of window_list. | 117 // area of them based on the number of window_list. |
93 const float kCardAspectRatio = 4.0f / 3.0f; | 118 const float kCardAspectRatio = 4.0f / 3.0f; |
94 | 119 |
95 // The minimum number of cards along the major axis (i.e. horizontally on a | 120 // The minimum number of cards along the major axis (i.e. horizontally on a |
96 // landscape orientation). | 121 // landscape orientation). |
97 const int kMinCardsMajor = 3; | 122 const int kMinCardsMajor = 3; |
98 | 123 |
99 const int kOverviewSelectorTransitionMilliseconds = 250; | 124 const int kOverviewSelectorTransitionMilliseconds = 250; |
100 | 125 |
101 // The color and opacity of the screen shield in overview. | 126 // The color and opacity of the screen shield in overview. |
102 const SkColor kShieldColor = SkColorSetARGB(178, 0, 0, 0); | 127 const SkColor kShieldColor = SkColorSetARGB(255, 0, 0, 0); |
128 const float kShieldOpacity = 0.7f; | |
103 | 129 |
104 // The color and opacity of the overview selector. | 130 // The color and opacity of the overview selector. |
105 const SkColor kWindowSelectionColor = SkColorSetARGB(128, 0, 0, 0); | 131 const SkColor kWindowSelectionColor = SkColorSetARGB(128, 0, 0, 0); |
106 const SkColor kWindowSelectionColorMD = SkColorSetARGB(51, 255, 255, 255); | 132 const SkColor kWindowSelectionColorMD = SkColorSetARGB(51, 255, 255, 255); |
107 const SkColor kWindowSelectionBorderColor = SkColorSetARGB(38, 255, 255, 255); | 133 const SkColor kWindowSelectionBorderColor = SkColorSetARGB(38, 255, 255, 255); |
108 const SkColor kWindowSelectionBorderColorMD = SkColorSetARGB(76, 255, 255, 255); | 134 const SkColor kWindowSelectionBorderColorMD = SkColorSetARGB(76, 255, 255, 255); |
109 | 135 |
110 // Border thickness of overview selector. | 136 // Border thickness of overview selector. |
111 const int kWindowSelectionBorderThickness = 2; | 137 const int kWindowSelectionBorderThickness = 2; |
112 const int kWindowSelectionBorderThicknessMD = 1; | 138 const int kWindowSelectionBorderThicknessMD = 1; |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
346 } | 372 } |
347 if (swap_index > i) | 373 if (swap_index > i) |
348 std::swap((*items)[i], (*items)[swap_index]); | 374 std::swap((*items)[i], (*items)[swap_index]); |
349 } | 375 } |
350 } | 376 } |
351 | 377 |
352 // Creates and returns a background translucent widget parented in | 378 // Creates and returns a background translucent widget parented in |
353 // |root_window|'s default container and having |background_color|. | 379 // |root_window|'s default container and having |background_color|. |
354 // When |border_thickness| is non-zero, a border is created having | 380 // When |border_thickness| is non-zero, a border is created having |
355 // |border_color|, otherwise |border_color| parameter is ignored. | 381 // |border_color|, otherwise |border_color| parameter is ignored. |
382 // The new background widget starts with |initial_opacity| and then fades in. | |
356 views::Widget* CreateBackgroundWidget(WmWindow* root_window, | 383 views::Widget* CreateBackgroundWidget(WmWindow* root_window, |
357 SkColor background_color, | 384 SkColor background_color, |
358 int border_thickness, | 385 int border_thickness, |
359 int border_radius, | 386 int border_radius, |
360 SkColor border_color) { | 387 SkColor border_color, |
388 float initial_opacity) { | |
361 views::Widget* widget = new views::Widget; | 389 views::Widget* widget = new views::Widget; |
362 views::Widget::InitParams params; | 390 views::Widget::InitParams params; |
363 params.type = views::Widget::InitParams::TYPE_POPUP; | 391 params.type = views::Widget::InitParams::TYPE_POPUP; |
364 params.keep_on_top = false; | 392 params.keep_on_top = false; |
365 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 393 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
366 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 394 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
367 params.accept_events = false; | 395 params.accept_events = false; |
368 widget->set_focus_on_creation(false); | 396 widget->set_focus_on_creation(false); |
369 // Parenting in kShellWindowId_DesktopBackgroundContainer allows proper | 397 // Parenting in kShellWindowId_DesktopBackgroundContainer allows proper |
370 // layering of the shield and selection widgets. Since that container is | 398 // layering of the shield and selection widgets. Since that container is |
(...skipping 17 matching lines...) Expand all Loading... | |
388 content_view->set_background( | 416 content_view->set_background( |
389 views::Background::CreateSolidBackground(background_color)); | 417 views::Background::CreateSolidBackground(background_color)); |
390 if (border_thickness) { | 418 if (border_thickness) { |
391 content_view->SetBorder( | 419 content_view->SetBorder( |
392 views::Border::CreateSolidBorder(border_thickness, border_color)); | 420 views::Border::CreateSolidBorder(border_thickness, border_color)); |
393 } | 421 } |
394 } | 422 } |
395 widget->SetContentsView(content_view); | 423 widget->SetContentsView(content_view); |
396 widget_window->GetParent()->StackChildAtTop(widget_window); | 424 widget_window->GetParent()->StackChildAtTop(widget_window); |
397 widget->Show(); | 425 widget->Show(); |
398 // New background widget starts with 0 opacity and then fades in. | 426 widget_window->SetOpacity(initial_opacity); |
399 widget_window->SetOpacity(0.f); | |
400 return widget; | 427 return widget; |
401 } | 428 } |
402 | 429 |
403 } // namespace | 430 } // namespace |
404 | 431 |
405 WindowGrid::WindowGrid(WmWindow* root_window, | 432 WindowGrid::WindowGrid(WmWindow* root_window, |
406 const std::vector<WmWindow*>& windows, | 433 const std::vector<WmWindow*>& windows, |
407 WindowSelector* window_selector) | 434 WindowSelector* window_selector) |
408 : root_window_(root_window), | 435 : root_window_(root_window), |
409 window_selector_(window_selector), | 436 window_selector_(window_selector), |
(...skipping 18 matching lines...) Expand all Loading... | |
428 observed_windows_.insert(window); | 455 observed_windows_.insert(window); |
429 window_list_.push_back(new WindowSelectorItem(window, window_selector_)); | 456 window_list_.push_back(new WindowSelectorItem(window, window_selector_)); |
430 } | 457 } |
431 } | 458 } |
432 | 459 |
433 WindowGrid::~WindowGrid() { | 460 WindowGrid::~WindowGrid() { |
434 for (WmWindow* window : observed_windows_) | 461 for (WmWindow* window : observed_windows_) |
435 window->RemoveObserver(this); | 462 window->RemoveObserver(this); |
436 } | 463 } |
437 | 464 |
465 void WindowGrid::Shutdown() { | |
466 if (shield_widget_) { | |
467 // Fade out the shield widget. This animation continues past the lifetime | |
468 // of |this|. | |
469 WmWindow* widget_window = | |
470 WmLookup::Get()->GetWindowForWidget(shield_widget_.get()); | |
471 ui::ScopedLayerAnimationSettings animation_settings( | |
472 widget_window->GetLayer()->GetAnimator()); | |
473 animation_settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( | |
474 kOverviewSelectorTransitionMilliseconds)); | |
475 animation_settings.SetTweenType(gfx::Tween::EASE_IN); | |
476 animation_settings.SetPreemptionStrategy( | |
477 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | |
478 // CleanupWidgetAfterAnimationObserver will delete itself (and the shield | |
479 // widget) when the opacity animation is complete. | |
480 // Ownership over the observer is passed to the window_selector_->delegate() | |
481 // which has longer lifetime so that animations can continue even after the | |
482 // overview mode is shut down. | |
483 views::Widget* shield_widget = shield_widget_.get(); | |
484 std::unique_ptr<CleanupWidgetAfterAnimationObserver> observer( | |
485 new CleanupWidgetAfterAnimationObserver(std::move(shield_widget_))); | |
486 animation_settings.AddObserver(observer.get()); | |
487 window_selector_->delegate()->AddDelayedAnimationObserver( | |
488 std::move(observer)); | |
489 shield_widget->SetOpacity(0.f); | |
490 } | |
491 } | |
492 | |
438 void WindowGrid::PrepareForOverview() { | 493 void WindowGrid::PrepareForOverview() { |
439 if (ash::MaterialDesignController::IsOverviewMaterial()) | 494 if (ash::MaterialDesignController::IsOverviewMaterial()) |
440 InitShieldWidget(); | 495 InitShieldWidget(); |
441 for (auto iter = window_list_.begin(); iter != window_list_.end(); ++iter) | 496 for (auto iter = window_list_.begin(); iter != window_list_.end(); ++iter) |
442 (*iter)->PrepareForOverview(); | 497 (*iter)->PrepareForOverview(); |
443 } | 498 } |
444 | 499 |
445 void WindowGrid::PositionWindowsMD(bool animate) { | 500 void WindowGrid::PositionWindowsMD(bool animate) { |
446 if (window_list_.empty()) | 501 if (window_list_.empty()) |
447 return; | 502 return; |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
785 | 840 |
786 if (ash::MaterialDesignController::IsOverviewMaterial()) { | 841 if (ash::MaterialDesignController::IsOverviewMaterial()) { |
787 PositionWindows(false); | 842 PositionWindows(false); |
788 return; | 843 return; |
789 } | 844 } |
790 // Recompute the transform for the window. | 845 // Recompute the transform for the window. |
791 (*iter)->RecomputeWindowTransforms(); | 846 (*iter)->RecomputeWindowTransforms(); |
792 } | 847 } |
793 | 848 |
794 void WindowGrid::InitShieldWidget() { | 849 void WindowGrid::InitShieldWidget() { |
795 shield_widget_.reset(CreateBackgroundWidget(root_window_, kShieldColor, 0, 0, | 850 // TODO(varkha): The code assumes that SHELF_BACKGROUND_MAXIMIZED is |
796 SK_ColorTRANSPARENT)); | 851 // synonymous with a black shelf background. Update this code if that |
852 // assumption is no longer valid. | |
853 const float initial_opacity = | |
854 (root_window_->GetRootWindowController() | |
855 ->GetShelf() | |
856 ->GetBackgroundType() == SHELF_BACKGROUND_MAXIMIZED) | |
857 ? 1.f | |
858 : 0.f; | |
859 shield_widget_.reset(CreateBackgroundWidget( | |
860 root_window_, kShieldColor, 0, 0, SK_ColorTRANSPARENT, initial_opacity)); | |
797 | 861 |
798 WmWindow* widget_window = | 862 WmWindow* widget_window = |
799 WmLookup::Get()->GetWindowForWidget(shield_widget_.get()); | 863 WmLookup::Get()->GetWindowForWidget(shield_widget_.get()); |
800 const gfx::Rect bounds = widget_window->GetParent()->GetBounds(); | 864 const gfx::Rect bounds = widget_window->GetParent()->GetBounds(); |
801 widget_window->SetBounds(bounds); | 865 widget_window->SetBounds(bounds); |
802 | 866 |
803 ui::ScopedLayerAnimationSettings animation_settings( | 867 ui::ScopedLayerAnimationSettings animation_settings( |
804 widget_window->GetLayer()->GetAnimator()); | 868 widget_window->GetLayer()->GetAnimator()); |
805 animation_settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( | 869 animation_settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( |
806 kOverviewSelectorTransitionMilliseconds)); | 870 kOverviewSelectorTransitionMilliseconds)); |
807 animation_settings.SetTweenType(gfx::Tween::LINEAR_OUT_SLOW_IN); | 871 animation_settings.SetTweenType(gfx::Tween::LINEAR_OUT_SLOW_IN); |
808 animation_settings.SetPreemptionStrategy( | 872 animation_settings.SetPreemptionStrategy( |
809 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 873 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
810 shield_widget_->SetOpacity(1.f); | 874 shield_widget_->SetOpacity(kShieldOpacity); |
811 } | 875 } |
812 | 876 |
813 void WindowGrid::InitSelectionWidget(WindowSelector::Direction direction) { | 877 void WindowGrid::InitSelectionWidget(WindowSelector::Direction direction) { |
814 const bool material = ash::MaterialDesignController::IsOverviewMaterial(); | 878 const bool material = ash::MaterialDesignController::IsOverviewMaterial(); |
815 const int border_thickness = material ? kWindowSelectionBorderThicknessMD | 879 const int border_thickness = material ? kWindowSelectionBorderThicknessMD |
816 : kWindowSelectionBorderThickness; | 880 : kWindowSelectionBorderThickness; |
817 const int border_color = | 881 const int border_color = |
818 material ? kWindowSelectionBorderColorMD : kWindowSelectionBorderColor; | 882 material ? kWindowSelectionBorderColorMD : kWindowSelectionBorderColor; |
819 const int selection_color = | 883 const int selection_color = |
820 material ? kWindowSelectionColorMD : kWindowSelectionColor; | 884 material ? kWindowSelectionColorMD : kWindowSelectionColor; |
821 const int border_radius = | 885 const int border_radius = |
822 material ? kWindowSelectionRadiusMD : kWindowSelectionRadius; | 886 material ? kWindowSelectionRadiusMD : kWindowSelectionRadius; |
823 selection_widget_.reset(CreateBackgroundWidget(root_window_, selection_color, | 887 selection_widget_.reset( |
824 border_thickness, | 888 CreateBackgroundWidget(root_window_, selection_color, border_thickness, |
825 border_radius, border_color)); | 889 border_radius, border_color, 0.f)); |
826 | 890 |
827 WmWindow* widget_window = | 891 WmWindow* widget_window = |
828 WmLookup::Get()->GetWindowForWidget(selection_widget_.get()); | 892 WmLookup::Get()->GetWindowForWidget(selection_widget_.get()); |
829 const gfx::Rect target_bounds = | 893 const gfx::Rect target_bounds = |
830 root_window_->ConvertRectFromScreen(SelectedWindow()->target_bounds()); | 894 root_window_->ConvertRectFromScreen(SelectedWindow()->target_bounds()); |
831 gfx::Vector2d fade_out_direction = | 895 gfx::Vector2d fade_out_direction = |
832 GetSlideVectorForFadeIn(direction, target_bounds); | 896 GetSlideVectorForFadeIn(direction, target_bounds); |
833 widget_window->SetBounds(target_bounds - fade_out_direction); | 897 widget_window->SetBounds(target_bounds - fade_out_direction); |
834 } | 898 } |
835 | 899 |
(...skipping 11 matching lines...) Expand all Loading... | |
847 gfx::Vector2d fade_out_direction = | 911 gfx::Vector2d fade_out_direction = |
848 GetSlideVectorForFadeIn(direction, old_selection_window->GetBounds()); | 912 GetSlideVectorForFadeIn(direction, old_selection_window->GetBounds()); |
849 | 913 |
850 ui::ScopedLayerAnimationSettings animation_settings( | 914 ui::ScopedLayerAnimationSettings animation_settings( |
851 old_selection_window->GetLayer()->GetAnimator()); | 915 old_selection_window->GetLayer()->GetAnimator()); |
852 animation_settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( | 916 animation_settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( |
853 kOverviewSelectorTransitionMilliseconds)); | 917 kOverviewSelectorTransitionMilliseconds)); |
854 animation_settings.SetPreemptionStrategy( | 918 animation_settings.SetPreemptionStrategy( |
855 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 919 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
856 animation_settings.SetTweenType(gfx::Tween::FAST_OUT_LINEAR_IN); | 920 animation_settings.SetTweenType(gfx::Tween::FAST_OUT_LINEAR_IN); |
857 // CleanupWidgetAfterAnimationObserver will delete itself (and the | 921 // CleanupWidgetAfterAnimationObserver will delete itself (and the widget) |
858 // widget) when the movement animation is complete. | 922 // when the motion animation is complete. |
859 animation_settings.AddObserver( | 923 // Ownership over the observer is passed to the window_selector_->delegate() |
924 // which has longer lifetime so that animations can continue even after the | |
925 // overview mode is shut down. | |
926 std::unique_ptr<CleanupWidgetAfterAnimationObserver> observer( | |
860 new CleanupWidgetAfterAnimationObserver(std::move(selection_widget_))); | 927 new CleanupWidgetAfterAnimationObserver(std::move(selection_widget_))); |
928 animation_settings.AddObserver(observer.get()); | |
929 window_selector_->delegate()->AddDelayedAnimationObserver( | |
930 std::move(observer)); | |
861 old_selection->SetOpacity(0.f); | 931 old_selection->SetOpacity(0.f); |
862 old_selection_window->SetBounds(old_selection_window->GetBounds() + | 932 old_selection_window->SetBounds(old_selection_window->GetBounds() + |
863 fade_out_direction); | 933 fade_out_direction); |
864 old_selection->Hide(); | 934 old_selection->Hide(); |
865 } | 935 } |
866 if (out_of_bounds) | 936 if (out_of_bounds) |
867 return; | 937 return; |
868 | 938 |
869 if (!selection_widget_) | 939 if (!selection_widget_) |
870 InitSelectionWidget(direction); | 940 InitSelectionWidget(direction); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
961 *min_right = left; | 1031 *min_right = left; |
962 if (*max_right < left) | 1032 if (*max_right < left) |
963 *max_right = left; | 1033 *max_right = left; |
964 } | 1034 } |
965 *max_bottom = top + height; | 1035 *max_bottom = top + height; |
966 } | 1036 } |
967 return windows_fit; | 1037 return windows_fit; |
968 } | 1038 } |
969 | 1039 |
970 } // namespace ash | 1040 } // namespace ash |
OLD | NEW |