Index: ash/common/wm/overview/window_grid.cc |
diff --git a/ash/common/wm/overview/window_grid.cc b/ash/common/wm/overview/window_grid.cc |
index 10003074a2dd524a2c284f7ff9437a0cccf6b66e..de555e34b91ef6d229788259f663a57e86ab7c4d 100644 |
--- a/ash/common/wm/overview/window_grid.cc |
+++ b/ash/common/wm/overview/window_grid.cc |
@@ -12,6 +12,8 @@ |
#include "ash/common/ash_switches.h" |
#include "ash/common/material_design/material_design_controller.h" |
+#include "ash/common/shelf/shelf_types.h" |
+#include "ash/common/shelf/wm_shelf.h" |
#include "ash/common/shell_window_ids.h" |
#include "ash/common/wm/overview/scoped_overview_animation_settings.h" |
#include "ash/common/wm/overview/scoped_overview_animation_settings_factory.h" |
@@ -99,7 +101,8 @@ const int kMinCardsMajor = 3; |
const int kOverviewSelectorTransitionMilliseconds = 250; |
// The color and opacity of the screen shield in overview. |
-const SkColor kShieldColor = SkColorSetARGB(178, 0, 0, 0); |
+const SkColor kShieldColor = SkColorSetARGB(255, 0, 0, 0); |
+const float kShieldOpacity = 0.7f; |
// The color and opacity of the overview selector. |
const SkColor kWindowSelectionColor = SkColorSetARGB(128, 0, 0, 0); |
@@ -353,11 +356,13 @@ void ReorderItemsGreedyLeastMovement(std::vector<WmWindow*>* items, |
// |root_window|'s default container and having |background_color|. |
// When |border_thickness| is non-zero, a border is created having |
// |border_color|, otherwise |border_color| parameter is ignored. |
+// The new background widget starts with |initial_opacity| and then fades in. |
views::Widget* CreateBackgroundWidget(WmWindow* root_window, |
SkColor background_color, |
int border_thickness, |
int border_radius, |
- SkColor border_color) { |
+ SkColor border_color, |
+ float initial_opacity) { |
views::Widget* widget = new views::Widget; |
views::Widget::InitParams params; |
params.type = views::Widget::InitParams::TYPE_POPUP; |
@@ -395,8 +400,7 @@ views::Widget* CreateBackgroundWidget(WmWindow* root_window, |
widget->SetContentsView(content_view); |
widget_window->GetParent()->StackChildAtTop(widget_window); |
widget->Show(); |
- // New background widget starts with 0 opacity and then fades in. |
- widget_window->SetOpacity(0.f); |
+ widget_window->SetOpacity(initial_opacity); |
return widget; |
} |
@@ -433,6 +437,24 @@ WindowGrid::WindowGrid(WmWindow* root_window, |
WindowGrid::~WindowGrid() { |
for (WmWindow* window : observed_windows_) |
window->RemoveObserver(this); |
+ |
+ // Fade out the shield widget. This animation continues past the lifetime |
+ // of |this|. |
+ WmWindow* widget_window = |
+ WmLookup::Get()->GetWindowForWidget(shield_widget_.get()); |
+ ui::ScopedLayerAnimationSettings animation_settings( |
+ widget_window->GetLayer()->GetAnimator()); |
+ animation_settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( |
+ kOverviewSelectorTransitionMilliseconds)); |
+ animation_settings.SetTweenType(gfx::Tween::EASE_IN); |
+ animation_settings.SetPreemptionStrategy( |
+ ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
+ // CleanupWidgetAfterAnimationObserver will delete itself (and the |
+ // shield widget) when the opacity animation is complete. |
+ views::Widget* shield_widget = shield_widget_.get(); |
+ animation_settings.AddObserver( |
+ new CleanupWidgetAfterAnimationObserver(std::move(shield_widget_))); |
+ shield_widget->SetOpacity(0.f); |
} |
void WindowGrid::PrepareForOverview() { |
@@ -792,8 +814,14 @@ void WindowGrid::OnWindowBoundsChanged(WmWindow* window, |
} |
void WindowGrid::InitShieldWidget() { |
- shield_widget_.reset(CreateBackgroundWidget(root_window_, kShieldColor, 0, 0, |
- SK_ColorTRANSPARENT)); |
+ const float initial_opacity = |
+ (root_window_->GetRootWindowController() |
+ ->GetShelf() |
+ ->GetBackgroundType() == SHELF_BACKGROUND_MAXIMIZED) |
bruthig
2016/07/12 20:43:37
nit: This is currently based on some assumptions i
varkha
2016/07/12 20:50:09
Done.
|
+ ? 1.f |
+ : 0.f; |
+ shield_widget_.reset(CreateBackgroundWidget( |
+ root_window_, kShieldColor, 0, 0, SK_ColorTRANSPARENT, initial_opacity)); |
WmWindow* widget_window = |
WmLookup::Get()->GetWindowForWidget(shield_widget_.get()); |
@@ -807,7 +835,7 @@ void WindowGrid::InitShieldWidget() { |
animation_settings.SetTweenType(gfx::Tween::LINEAR_OUT_SLOW_IN); |
animation_settings.SetPreemptionStrategy( |
ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
- shield_widget_->SetOpacity(1.f); |
+ shield_widget_->SetOpacity(kShieldOpacity); |
} |
void WindowGrid::InitSelectionWidget(WindowSelector::Direction direction) { |
@@ -820,9 +848,9 @@ void WindowGrid::InitSelectionWidget(WindowSelector::Direction direction) { |
material ? kWindowSelectionColorMD : kWindowSelectionColor; |
const int border_radius = |
material ? kWindowSelectionRadiusMD : kWindowSelectionRadius; |
- selection_widget_.reset(CreateBackgroundWidget(root_window_, selection_color, |
- border_thickness, |
- border_radius, border_color)); |
+ selection_widget_.reset( |
+ CreateBackgroundWidget(root_window_, selection_color, border_thickness, |
+ border_radius, border_color, 0.f)); |
WmWindow* widget_window = |
WmLookup::Get()->GetWindowForWidget(selection_widget_.get()); |