Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(612)

Side by Side Diff: ash/common/wm/overview/window_selector_item.cc

Issue 2101843003: [ash-md] Animates a window closed while in overview mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: [ash-md] Animates a window closed while in overview mode Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_selector_item.h" 5 #include "ash/common/wm/overview/window_selector_item.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/common/material_design/material_design_controller.h" 10 #include "ash/common/material_design/material_design_controller.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 87
88 // Height of an item header in Material Design. 88 // Height of an item header in Material Design.
89 static const int kHeaderHeight = 32; 89 static const int kHeaderHeight = 32;
90 90
91 // Opacity for dimmed items. 91 // Opacity for dimmed items.
92 static const float kDimmedItemOpacity = 0.5f; 92 static const float kDimmedItemOpacity = 0.5f;
93 93
94 // Duration of background opacity transition for the selected label. 94 // Duration of background opacity transition for the selected label.
95 static const int kSelectorFadeInMilliseconds = 350; 95 static const int kSelectorFadeInMilliseconds = 350;
96 96
97 // 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.
98 static const float kPreCloseScale = 0.02f;
99
97 // Calculates the |window| bounds after being transformed to the selector's 100 // Calculates the |window| bounds after being transformed to the selector's
98 // space. The returned Rect is in virtual screen coordinates. 101 // space. The returned Rect is in virtual screen coordinates.
99 gfx::Rect GetTransformedBounds(WmWindow* window) { 102 gfx::Rect GetTransformedBounds(WmWindow* window) {
100 gfx::RectF bounds( 103 gfx::RectF bounds(
101 window->GetRootWindow()->ConvertRectToScreen(window->GetTargetBounds())); 104 window->GetRootWindow()->ConvertRectToScreen(window->GetTargetBounds()));
102 gfx::Transform new_transform = TransformAboutPivot( 105 gfx::Transform new_transform = TransformAboutPivot(
103 gfx::Point(bounds.x(), bounds.y()), window->GetTargetTransform()); 106 gfx::Point(bounds.x(), bounds.y()), window->GetTargetTransform());
104 new_transform.TransformRect(&bounds); 107 new_transform.TransformRect(&bounds);
105 108
106 // With Material Design the preview title is shown above the preview window. 109 // With Material Design the preview title is shown above the preview window.
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 } 387 }
385 388
386 void WindowSelectorItem::SetDimmed(bool dimmed) { 389 void WindowSelectorItem::SetDimmed(bool dimmed) {
387 dimmed_ = dimmed; 390 dimmed_ = dimmed;
388 SetOpacity(dimmed ? kDimmedItemOpacity : 1.0f); 391 SetOpacity(dimmed ? kDimmedItemOpacity : 1.0f);
389 } 392 }
390 393
391 void WindowSelectorItem::ButtonPressed(views::Button* sender, 394 void WindowSelectorItem::ButtonPressed(views::Button* sender,
392 const ui::Event& event) { 395 const ui::Event& event) {
393 if (sender == close_button_) { 396 if (sender == close_button_) {
397 if (ash::MaterialDesignController::IsOverviewMaterial()) {
398 gfx::Rect inset_bounds(target_bounds_);
399 inset_bounds.Inset(target_bounds_.width() * kPreCloseScale,
400 target_bounds_.height() * kPreCloseScale);
401 OverviewAnimationType animation_type =
402 OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS;
403 SetBounds(inset_bounds, animation_type);
404 // 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.
405 // shrinking the tile.
406 AnimateOpacity(kDimmedItemOpacity, animation_type);
407
408 // Fade out the tile effectively hiding it.
tdanderson 2016/06/28 15:28:02 nit: tile,
varkha 2016/06/28 23:50:36 Done.
409 AnimateOpacity(
410 0.0, OverviewAnimationType::OVERVIEW_ANIMATION_CLOSE_SELECTOR_ITEM);
411 }
394 transform_window_.Close(); 412 transform_window_.Close();
395 return; 413 return;
396 } 414 }
397 CHECK(sender == window_label_button_view_); 415 CHECK(sender == window_label_button_view_);
398 window_selector_->SelectWindow(transform_window_.window()); 416 window_selector_->SelectWindow(transform_window_.window());
399 } 417 }
400 418
401 void WindowSelectorItem::OnWindowDestroying(WmWindow* window) { 419 void WindowSelectorItem::OnWindowDestroying(WmWindow* window) {
402 window->RemoveObserver(this); 420 window->RemoveObserver(this);
403 transform_window_.OnWindowDestroyed(); 421 transform_window_.OnWindowDestroyed();
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 561
544 if (!window_label_button_view_->visible()) { 562 if (!window_label_button_view_->visible()) {
545 window_label_button_view_->SetVisible(true); 563 window_label_button_view_->SetVisible(true);
546 SetupFadeInAfterLayout(window_label_.get()); 564 SetupFadeInAfterLayout(window_label_.get());
547 SetupFadeInAfterLayout(window_label_selector_.get()); 565 SetupFadeInAfterLayout(window_label_selector_.get());
548 } 566 }
549 WmWindow* window_label_window = 567 WmWindow* window_label_window =
550 WmLookup::Get()->GetWindowForWidget(window_label_.get()); 568 WmLookup::Get()->GetWindowForWidget(window_label_.get());
551 WmWindow* window_label_selector_window = 569 WmWindow* window_label_selector_window =
552 WmLookup::Get()->GetWindowForWidget(window_label_selector_.get()); 570 WmLookup::Get()->GetWindowForWidget(window_label_selector_.get());
571 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings =
572 ScopedOverviewAnimationSettingsFactory::Get()
573 ->CreateOverviewAnimationSettings(animation_type,
574 window_label_window);
575 std::unique_ptr<ScopedOverviewAnimationSettings>
576 animation_settings_selector =
577 ScopedOverviewAnimationSettingsFactory::Get()
578 ->CreateOverviewAnimationSettings(animation_type,
579 window_label_selector_window);
553 window_label_selector_window->SetBounds(label_rect); 580 window_label_selector_window->SetBounds(label_rect);
554 // |window_label_window| covers both the transformed window and the header 581 // |window_label_window| covers both the transformed window and the header
555 // as well as the gap between the windows to prevent events from reaching 582 // as well as the gap between the windows to prevent events from reaching
556 // the window including its sizing borders. 583 // the window including its sizing borders.
557 label_rect.set_height(label_rect.height() + 584 label_rect.set_height(label_rect.height() +
558 transformed_window_bounds.height()); 585 transformed_window_bounds.height());
559 label_rect.Inset(-kWindowSelectorMargin, -kWindowSelectorMargin); 586 label_rect.Inset(-kWindowSelectorMargin, -kWindowSelectorMargin);
560 window_label_window->SetBounds(label_rect); 587 window_label_window->SetBounds(label_rect);
561 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings =
562 ScopedOverviewAnimationSettingsFactory::Get()
563 ->CreateOverviewAnimationSettings(animation_type,
564 window_label_window);
565 gfx::Transform label_transform; 588 gfx::Transform label_transform;
566 label_transform.Translate(transformed_window_bounds.x(), 589 label_transform.Translate(transformed_window_bounds.x(),
567 transformed_window_bounds.y()); 590 transformed_window_bounds.y());
568 window_label_window->SetTransform(label_transform); 591 window_label_window->SetTransform(label_transform);
569 window_label_selector_window->SetTransform(label_transform); 592 window_label_selector_window->SetTransform(label_transform);
570 } else { 593 } else {
571 if (!close_button_->visible()) { 594 if (!close_button_->visible()) {
572 close_button_->SetVisible(true); 595 close_button_->SetVisible(true);
573 SetupFadeInAfterLayout(close_button_widget_.get()); 596 SetupFadeInAfterLayout(close_button_widget_.get());
574 } 597 }
575 WmWindow* close_button_widget_window = 598 WmWindow* close_button_widget_window =
576 WmLookup::Get()->GetWindowForWidget(close_button_widget_.get()); 599 WmLookup::Get()->GetWindowForWidget(close_button_widget_.get());
577 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings = 600 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings =
578 ScopedOverviewAnimationSettingsFactory::Get() 601 ScopedOverviewAnimationSettingsFactory::Get()
579 ->CreateOverviewAnimationSettings(animation_type, 602 ->CreateOverviewAnimationSettings(animation_type,
580 close_button_widget_window); 603 close_button_widget_window);
581 604
582 gfx::Transform close_button_transform; 605 gfx::Transform close_button_transform;
583 close_button_transform.Translate(transformed_window_bounds.right(), 606 close_button_transform.Translate(transformed_window_bounds.right(),
584 transformed_window_bounds.y()); 607 transformed_window_bounds.y());
585 close_button_widget_window->SetTransform(close_button_transform); 608 close_button_widget_window->SetTransform(close_button_transform);
586 } 609 }
587 } 610 }
588 611
612 void WindowSelectorItem::AnimateOpacity(float opacity,
613 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.
614 ScopedTransformOverviewWindow::ScopedAnimationSettings animation_settings;
615 transform_window_.BeginScopedAnimation(animation_type, &animation_settings);
616 transform_window_.SetOpacity(opacity);
617
618 WmWindow* window_label_window =
619 WmLookup::Get()->GetWindowForWidget(window_label_.get());
620 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings_label =
621 ScopedOverviewAnimationSettingsFactory::Get()
622 ->CreateOverviewAnimationSettings(animation_type,
623 window_label_window);
624 window_label_window->SetOpacity(opacity);
625
626 WmWindow* window_label_selector_window =
627 WmLookup::Get()->GetWindowForWidget(window_label_selector_.get());
628 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings_selector =
629 ScopedOverviewAnimationSettingsFactory::Get()
630 ->CreateOverviewAnimationSettings(animation_type,
631 window_label_selector_window);
632 window_label_selector_window->SetOpacity(opacity);
633 }
634
589 void WindowSelectorItem::UpdateCloseButtonAccessibilityName() { 635 void WindowSelectorItem::UpdateCloseButtonAccessibilityName() {
590 close_button_->SetAccessibleName(l10n_util::GetStringFUTF16( 636 close_button_->SetAccessibleName(l10n_util::GetStringFUTF16(
591 IDS_ASH_OVERVIEW_CLOSE_ITEM_BUTTON_ACCESSIBLE_NAME, 637 IDS_ASH_OVERVIEW_CLOSE_ITEM_BUTTON_ACCESSIBLE_NAME,
592 GetWindow()->GetTitle())); 638 GetWindow()->GetTitle()));
593 } 639 }
594 640
595 } // namespace ash 641 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698