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

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 (comments) 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 84
85 // Amount of blur applied to the label shadow 85 // Amount of blur applied to the label shadow
86 static const int kShadowBlur = 10; 86 static const int kShadowBlur = 10;
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 // Opacity for fading out during closing a window.
95 static const float kClosingItemOpacity = 0.8f;
96
94 // Duration of background opacity transition for the selected label. 97 // Duration of background opacity transition for the selected label.
95 static const int kSelectorFadeInMilliseconds = 350; 98 static const int kSelectorFadeInMilliseconds = 350;
96 99
100 // Before closing a window animate both the window and the caption to shrink by
101 // this fraction of size.
102 static const float kPreCloseScale = 0.02f;
103
97 // Calculates the |window| bounds after being transformed to the selector's 104 // Calculates the |window| bounds after being transformed to the selector's
98 // space. The returned Rect is in virtual screen coordinates. 105 // space. The returned Rect is in virtual screen coordinates.
99 gfx::Rect GetTransformedBounds(WmWindow* window) { 106 gfx::Rect GetTransformedBounds(WmWindow* window) {
100 gfx::RectF bounds( 107 gfx::RectF bounds(
101 window->GetRootWindow()->ConvertRectToScreen(window->GetTargetBounds())); 108 window->GetRootWindow()->ConvertRectToScreen(window->GetTargetBounds()));
102 gfx::Transform new_transform = TransformAboutPivot( 109 gfx::Transform new_transform = TransformAboutPivot(
103 gfx::Point(bounds.x(), bounds.y()), window->GetTargetTransform()); 110 gfx::Point(bounds.x(), bounds.y()), window->GetTargetTransform());
104 new_transform.TransformRect(&bounds); 111 new_transform.TransformRect(&bounds);
105 112
106 // With Material Design the preview title is shown above the preview window. 113 // 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 } 391 }
385 392
386 void WindowSelectorItem::SetDimmed(bool dimmed) { 393 void WindowSelectorItem::SetDimmed(bool dimmed) {
387 dimmed_ = dimmed; 394 dimmed_ = dimmed;
388 SetOpacity(dimmed ? kDimmedItemOpacity : 1.0f); 395 SetOpacity(dimmed ? kDimmedItemOpacity : 1.0f);
389 } 396 }
390 397
391 void WindowSelectorItem::ButtonPressed(views::Button* sender, 398 void WindowSelectorItem::ButtonPressed(views::Button* sender,
392 const ui::Event& event) { 399 const ui::Event& event) {
393 if (sender == close_button_) { 400 if (sender == close_button_) {
401 if (ash::MaterialDesignController::IsOverviewMaterial()) {
402 gfx::Rect inset_bounds(target_bounds_);
403 inset_bounds.Inset(target_bounds_.width() * kPreCloseScale,
404 target_bounds_.height() * kPreCloseScale);
405 OverviewAnimationType animation_type =
406 OverviewAnimationType::OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM;
407 // Scale down both the window and label.
408 SetBounds(inset_bounds, animation_type);
409 // First animate opacity to an intermediate value concurrently with the
410 // scaling animation.
411 AnimateOpacity(kClosingItemOpacity, animation_type);
412
413 // Fade out the window and the label, effectively hiding them.
414 AnimateOpacity(
415 0.0, OverviewAnimationType::OVERVIEW_ANIMATION_CLOSE_SELECTOR_ITEM);
416 }
394 transform_window_.Close(); 417 transform_window_.Close();
395 return; 418 return;
396 } 419 }
397 CHECK(sender == window_label_button_view_); 420 CHECK(sender == window_label_button_view_);
398 window_selector_->SelectWindow(transform_window_.window()); 421 window_selector_->SelectWindow(transform_window_.window());
399 } 422 }
400 423
401 void WindowSelectorItem::OnWindowDestroying(WmWindow* window) { 424 void WindowSelectorItem::OnWindowDestroying(WmWindow* window) {
402 window->RemoveObserver(this); 425 window->RemoveObserver(this);
403 transform_window_.OnWindowDestroyed(); 426 transform_window_.OnWindowDestroyed();
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 566
544 if (!window_label_button_view_->visible()) { 567 if (!window_label_button_view_->visible()) {
545 window_label_button_view_->SetVisible(true); 568 window_label_button_view_->SetVisible(true);
546 SetupFadeInAfterLayout(window_label_.get()); 569 SetupFadeInAfterLayout(window_label_.get());
547 SetupFadeInAfterLayout(window_label_selector_.get()); 570 SetupFadeInAfterLayout(window_label_selector_.get());
548 } 571 }
549 WmWindow* window_label_window = 572 WmWindow* window_label_window =
550 WmLookup::Get()->GetWindowForWidget(window_label_.get()); 573 WmLookup::Get()->GetWindowForWidget(window_label_.get());
551 WmWindow* window_label_selector_window = 574 WmWindow* window_label_selector_window =
552 WmLookup::Get()->GetWindowForWidget(window_label_selector_.get()); 575 WmLookup::Get()->GetWindowForWidget(window_label_selector_.get());
576 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings =
577 ScopedOverviewAnimationSettingsFactory::Get()
578 ->CreateOverviewAnimationSettings(animation_type,
579 window_label_window);
580 std::unique_ptr<ScopedOverviewAnimationSettings>
581 animation_settings_selector =
582 ScopedOverviewAnimationSettingsFactory::Get()
583 ->CreateOverviewAnimationSettings(animation_type,
584 window_label_selector_window);
553 window_label_selector_window->SetBounds(label_rect); 585 window_label_selector_window->SetBounds(label_rect);
554 // |window_label_window| covers both the transformed window and the header 586 // |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 587 // as well as the gap between the windows to prevent events from reaching
556 // the window including its sizing borders. 588 // the window including its sizing borders.
557 label_rect.set_height(label_rect.height() + 589 label_rect.set_height(label_rect.height() +
558 transformed_window_bounds.height()); 590 transformed_window_bounds.height());
559 label_rect.Inset(-kWindowSelectorMargin, -kWindowSelectorMargin); 591 label_rect.Inset(-kWindowSelectorMargin, -kWindowSelectorMargin);
560 window_label_window->SetBounds(label_rect); 592 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; 593 gfx::Transform label_transform;
566 label_transform.Translate(transformed_window_bounds.x(), 594 label_transform.Translate(transformed_window_bounds.x(),
567 transformed_window_bounds.y()); 595 transformed_window_bounds.y());
568 window_label_window->SetTransform(label_transform); 596 window_label_window->SetTransform(label_transform);
569 window_label_selector_window->SetTransform(label_transform); 597 window_label_selector_window->SetTransform(label_transform);
570 } else { 598 } else {
571 if (!close_button_->visible()) { 599 if (!close_button_->visible()) {
572 close_button_->SetVisible(true); 600 close_button_->SetVisible(true);
573 SetupFadeInAfterLayout(close_button_widget_.get()); 601 SetupFadeInAfterLayout(close_button_widget_.get());
574 } 602 }
575 WmWindow* close_button_widget_window = 603 WmWindow* close_button_widget_window =
576 WmLookup::Get()->GetWindowForWidget(close_button_widget_.get()); 604 WmLookup::Get()->GetWindowForWidget(close_button_widget_.get());
577 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings = 605 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings =
578 ScopedOverviewAnimationSettingsFactory::Get() 606 ScopedOverviewAnimationSettingsFactory::Get()
579 ->CreateOverviewAnimationSettings(animation_type, 607 ->CreateOverviewAnimationSettings(animation_type,
580 close_button_widget_window); 608 close_button_widget_window);
581 609
582 gfx::Transform close_button_transform; 610 gfx::Transform close_button_transform;
583 close_button_transform.Translate(transformed_window_bounds.right(), 611 close_button_transform.Translate(transformed_window_bounds.right(),
584 transformed_window_bounds.y()); 612 transformed_window_bounds.y());
585 close_button_widget_window->SetTransform(close_button_transform); 613 close_button_widget_window->SetTransform(close_button_transform);
586 } 614 }
587 } 615 }
588 616
617 void WindowSelectorItem::AnimateOpacity(float opacity,
618 OverviewAnimationType animation_type) {
619 DCHECK_GE(opacity, 0.f);
620 DCHECK_LE(opacity, 1.f);
621 ScopedTransformOverviewWindow::ScopedAnimationSettings animation_settings;
622 transform_window_.BeginScopedAnimation(animation_type, &animation_settings);
623 transform_window_.SetOpacity(opacity);
624
625 WmWindow* window_label_window =
626 WmLookup::Get()->GetWindowForWidget(window_label_.get());
627 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings_label =
628 ScopedOverviewAnimationSettingsFactory::Get()
629 ->CreateOverviewAnimationSettings(animation_type,
630 window_label_window);
631 window_label_window->SetOpacity(opacity);
632
633 WmWindow* window_label_selector_window =
634 WmLookup::Get()->GetWindowForWidget(window_label_selector_.get());
635 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings_selector =
636 ScopedOverviewAnimationSettingsFactory::Get()
637 ->CreateOverviewAnimationSettings(animation_type,
638 window_label_selector_window);
639 window_label_selector_window->SetOpacity(opacity);
640 }
641
589 void WindowSelectorItem::UpdateCloseButtonAccessibilityName() { 642 void WindowSelectorItem::UpdateCloseButtonAccessibilityName() {
590 close_button_->SetAccessibleName(l10n_util::GetStringFUTF16( 643 close_button_->SetAccessibleName(l10n_util::GetStringFUTF16(
591 IDS_ASH_OVERVIEW_CLOSE_ITEM_BUTTON_ACCESSIBLE_NAME, 644 IDS_ASH_OVERVIEW_CLOSE_ITEM_BUTTON_ACCESSIBLE_NAME,
592 GetWindow()->GetTitle())); 645 GetWindow()->GetTitle()));
593 } 646 }
594 647
595 } // namespace ash 648 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698