Index: ash/common/wm/overview/window_selector_item.cc |
diff --git a/ash/common/wm/overview/window_selector_item.cc b/ash/common/wm/overview/window_selector_item.cc |
index ba829505eb11f8edc0f28531a10391218cb9bf76..fecd31e38d563dbf6a46582394405eb9050c1da8 100644 |
--- a/ash/common/wm/overview/window_selector_item.cc |
+++ b/ash/common/wm/overview/window_selector_item.cc |
@@ -94,6 +94,9 @@ static const float kDimmedItemOpacity = 0.5f; |
// Duration of background opacity transition for the selected label. |
static const int kSelectorFadeInMilliseconds = 350; |
+// Before closing window animate the tile to shrink by this fraction of size. |
tdanderson
2016/06/28 15:28:02
Maybe specify what is meant by 'tile' (here and li
varkha
2016/06/28 23:50:36
Done.
|
+static const float kPreCloseScale = 0.02f; |
+ |
// Calculates the |window| bounds after being transformed to the selector's |
// space. The returned Rect is in virtual screen coordinates. |
gfx::Rect GetTransformedBounds(WmWindow* window) { |
@@ -391,6 +394,21 @@ void WindowSelectorItem::SetDimmed(bool dimmed) { |
void WindowSelectorItem::ButtonPressed(views::Button* sender, |
const ui::Event& event) { |
if (sender == close_button_) { |
+ if (ash::MaterialDesignController::IsOverviewMaterial()) { |
+ gfx::Rect inset_bounds(target_bounds_); |
+ inset_bounds.Inset(target_bounds_.width() * kPreCloseScale, |
+ target_bounds_.height() * kPreCloseScale); |
+ OverviewAnimationType animation_type = |
+ OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS; |
+ SetBounds(inset_bounds, animation_type); |
+ // First animate opacity first to intermediate value at the same time as |
tdanderson
2016/06/28 15:28:02
nit: remove one first
varkha
2016/06/28 23:50:36
Done.
|
+ // shrinking the tile. |
+ AnimateOpacity(kDimmedItemOpacity, animation_type); |
+ |
+ // Fade out the tile effectively hiding it. |
tdanderson
2016/06/28 15:28:02
nit: tile,
varkha
2016/06/28 23:50:36
Done.
|
+ AnimateOpacity( |
+ 0.0, OverviewAnimationType::OVERVIEW_ANIMATION_CLOSE_SELECTOR_ITEM); |
+ } |
transform_window_.Close(); |
return; |
} |
@@ -550,6 +568,15 @@ void WindowSelectorItem::UpdateHeaderLayout( |
WmLookup::Get()->GetWindowForWidget(window_label_.get()); |
WmWindow* window_label_selector_window = |
WmLookup::Get()->GetWindowForWidget(window_label_selector_.get()); |
+ std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings = |
+ ScopedOverviewAnimationSettingsFactory::Get() |
+ ->CreateOverviewAnimationSettings(animation_type, |
+ window_label_window); |
+ std::unique_ptr<ScopedOverviewAnimationSettings> |
+ animation_settings_selector = |
+ ScopedOverviewAnimationSettingsFactory::Get() |
+ ->CreateOverviewAnimationSettings(animation_type, |
+ window_label_selector_window); |
window_label_selector_window->SetBounds(label_rect); |
// |window_label_window| covers both the transformed window and the header |
// as well as the gap between the windows to prevent events from reaching |
@@ -558,10 +585,6 @@ void WindowSelectorItem::UpdateHeaderLayout( |
transformed_window_bounds.height()); |
label_rect.Inset(-kWindowSelectorMargin, -kWindowSelectorMargin); |
window_label_window->SetBounds(label_rect); |
- std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings = |
- ScopedOverviewAnimationSettingsFactory::Get() |
- ->CreateOverviewAnimationSettings(animation_type, |
- window_label_window); |
gfx::Transform label_transform; |
label_transform.Translate(transformed_window_bounds.x(), |
transformed_window_bounds.y()); |
@@ -586,6 +609,29 @@ void WindowSelectorItem::UpdateHeaderLayout( |
} |
} |
+void WindowSelectorItem::AnimateOpacity(float opacity, |
+ OverviewAnimationType animation_type) { |
tdanderson
2016/06/28 15:28:02
consider a DCHECK or similar to verify |opacity| i
varkha
2016/06/28 23:50:36
Done.
|
+ ScopedTransformOverviewWindow::ScopedAnimationSettings animation_settings; |
+ transform_window_.BeginScopedAnimation(animation_type, &animation_settings); |
+ transform_window_.SetOpacity(opacity); |
+ |
+ WmWindow* window_label_window = |
+ WmLookup::Get()->GetWindowForWidget(window_label_.get()); |
+ std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings_label = |
+ ScopedOverviewAnimationSettingsFactory::Get() |
+ ->CreateOverviewAnimationSettings(animation_type, |
+ window_label_window); |
+ window_label_window->SetOpacity(opacity); |
+ |
+ WmWindow* window_label_selector_window = |
+ WmLookup::Get()->GetWindowForWidget(window_label_selector_.get()); |
+ std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings_selector = |
+ ScopedOverviewAnimationSettingsFactory::Get() |
+ ->CreateOverviewAnimationSettings(animation_type, |
+ window_label_selector_window); |
+ window_label_selector_window->SetOpacity(opacity); |
+} |
+ |
void WindowSelectorItem::UpdateCloseButtonAccessibilityName() { |
close_button_->SetAccessibleName(l10n_util::GetStringFUTF16( |
IDS_ASH_OVERVIEW_CLOSE_ITEM_BUTTON_ACCESSIBLE_NAME, |