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

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

Issue 2239233002: [ash-md] Fades overview header in and out (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: [ash-md] Fades overview header in and out (fixed a new test assertion) Created 4 years, 3 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
« no previous file with comments | « ash/common/wm/overview/window_grid.h ('k') | ash/common/wm/overview/window_selector_item.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 } 403 }
404 404
405 if (!ash::MaterialDesignController::IsOverviewMaterial() && 405 if (!ash::MaterialDesignController::IsOverviewMaterial() &&
406 base::CommandLine::ForCurrentProcess()->HasSwitch( 406 base::CommandLine::ForCurrentProcess()->HasSwitch(
407 switches::kAshEnableStableOverviewOrder)) { 407 switches::kAshEnableStableOverviewOrder)) {
408 // Reorder windows to try to minimize movement to target overview positions. 408 // Reorder windows to try to minimize movement to target overview positions.
409 // This also creates a stable window ordering. 409 // This also creates a stable window ordering.
410 ReorderItemsGreedyLeastMovement(&windows_in_root, root_window_, 410 ReorderItemsGreedyLeastMovement(&windows_in_root, root_window_,
411 window_selector_->text_filter_bottom()); 411 window_selector_->text_filter_bottom());
412 } 412 }
413 PrepareForUsingMasksOrShapes(windows_in_root.size());
413 for (auto* window : windows_in_root) { 414 for (auto* window : windows_in_root) {
414 window_observer_.Add(window); 415 window_observer_.Add(window);
415 window_list_.push_back(new WindowSelectorItem(window, window_selector_)); 416 window_list_.push_back(new WindowSelectorItem(window, window_selector_));
416 } 417 }
417 } 418 }
418 419
419 WindowGrid::~WindowGrid() {} 420 WindowGrid::~WindowGrid() {}
420 421
421 void WindowGrid::Shutdown() { 422 void WindowGrid::Shutdown() {
423 for (auto iter = window_list_.begin(); iter != window_list_.end(); ++iter)
424 (*iter)->Shutdown();
425
422 if (shield_widget_) { 426 if (shield_widget_) {
423 // Fade out the shield widget. This animation continues past the lifetime 427 // Fade out the shield widget. This animation continues past the lifetime
424 // of |this|. 428 // of |this|.
425 WmWindow* widget_window = 429 WmWindow* widget_window =
426 WmLookup::Get()->GetWindowForWidget(shield_widget_.get()); 430 WmLookup::Get()->GetWindowForWidget(shield_widget_.get());
427 ui::ScopedLayerAnimationSettings animation_settings( 431 ui::ScopedLayerAnimationSettings animation_settings(
428 widget_window->GetLayer()->GetAnimator()); 432 widget_window->GetLayer()->GetAnimator());
429 animation_settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( 433 animation_settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(
430 kOverviewSelectorTransitionMilliseconds)); 434 kOverviewSelectorTransitionMilliseconds));
431 animation_settings.SetTweenType(gfx::Tween::EASE_IN); 435 animation_settings.SetTweenType(gfx::Tween::EASE_IN_2);
432 animation_settings.SetPreemptionStrategy( 436 animation_settings.SetPreemptionStrategy(
433 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 437 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
434 // CleanupAnimationObserver will delete itself (and the shield widget) when 438 // CleanupAnimationObserver will delete itself (and the shield widget) when
435 // the opacity animation is complete. 439 // the opacity animation is complete.
436 // Ownership over the observer is passed to the window_selector_->delegate() 440 // Ownership over the observer is passed to the window_selector_->delegate()
437 // which has longer lifetime so that animations can continue even after the 441 // which has longer lifetime so that animations can continue even after the
438 // overview mode is shut down. 442 // overview mode is shut down.
439 views::Widget* shield_widget = shield_widget_.get(); 443 views::Widget* shield_widget = shield_widget_.get();
440 std::unique_ptr<CleanupAnimationObserver> observer( 444 std::unique_ptr<CleanupAnimationObserver> observer(
441 new CleanupAnimationObserver(std::move(shield_widget_))); 445 new CleanupAnimationObserver(std::move(shield_widget_)));
442 animation_settings.AddObserver(observer.get()); 446 animation_settings.AddObserver(observer.get());
443 window_selector_->delegate()->AddDelayedAnimationObserver( 447 window_selector_->delegate()->AddDelayedAnimationObserver(
444 std::move(observer)); 448 std::move(observer));
445 shield_widget->SetOpacity(0.f); 449 shield_widget->SetOpacity(0.f);
446 } 450 }
447 } 451 }
448 452
449 void WindowGrid::PrepareForOverview() { 453 void WindowGrid::PrepareForOverview() {
450 if (ash::MaterialDesignController::IsOverviewMaterial()) 454 if (ash::MaterialDesignController::IsOverviewMaterial())
451 InitShieldWidget(); 455 InitShieldWidget();
452 for (auto iter = window_list_.begin(); iter != window_list_.end(); ++iter) 456 for (auto iter = window_list_.begin(); iter != window_list_.end(); ++iter)
453 (*iter)->PrepareForOverview(); 457 (*iter)->PrepareForOverview();
454 prepared_for_overview_ = true; 458 prepared_for_overview_ = true;
455 } 459 }
456 460
457 void WindowGrid::PositionWindowsMD(bool animate) { 461 void WindowGrid::PositionWindowsMD(bool animate) {
458 if (window_list_.empty()) 462 if (window_list_.empty())
459 return; 463 return;
460 464 PrepareForUsingMasksOrShapes(window_list_.size());
461 const int kUnlimited = -1;
462 const size_t windows_count = window_list_.size();
463 const base::CommandLine* command_line =
464 base::CommandLine::ForCurrentProcess();
465 int windows_to_use_masks = kMaxWindowsCountToHideHeaderWithMasks;
466 if (command_line->HasSwitch(switches::kAshMaxWindowsToUseMaskInOverview) &&
467 (!base::StringToInt(command_line->GetSwitchValueASCII(
468 switches::kAshMaxWindowsToUseMaskInOverview),
469 &windows_to_use_masks) ||
470 windows_to_use_masks <= kUnlimited)) {
471 windows_to_use_masks = kMaxWindowsCountToHideHeaderWithMasks;
472 }
473 int windows_to_use_shapes = kUnlimited;
474 if (command_line->HasSwitch(switches::kAshMaxWindowsToUseShapeInOverview) &&
475 (!base::StringToInt(command_line->GetSwitchValueASCII(
476 switches::kAshMaxWindowsToUseShapeInOverview),
477 &windows_to_use_shapes) ||
478 windows_to_use_shapes <= kUnlimited)) {
479 windows_to_use_shapes = kUnlimited;
480 }
481 WindowSelectorItem::set_use_mask(windows_to_use_masks <= kUnlimited ||
482 static_cast<int>(windows_count) <=
483 windows_to_use_masks);
484 WindowSelectorItem::set_use_shape(windows_to_use_shapes <= kUnlimited ||
485 static_cast<int>(windows_count) <=
486 windows_to_use_shapes);
487
488 gfx::Rect total_bounds = 465 gfx::Rect total_bounds =
489 root_window_->ConvertRectToScreen(wm::GetDisplayWorkAreaBoundsInParent( 466 root_window_->ConvertRectToScreen(wm::GetDisplayWorkAreaBoundsInParent(
490 root_window_->GetChildByShellWindowId( 467 root_window_->GetChildByShellWindowId(
491 kShellWindowId_DefaultContainer))); 468 kShellWindowId_DefaultContainer)));
492 // Windows occupy vertically centered area with additional vertical insets. 469 // Windows occupy vertically centered area with additional vertical insets.
493 int horizontal_inset = 470 int horizontal_inset =
494 gfx::ToFlooredInt(std::min(kOverviewInsetRatio * total_bounds.width(), 471 gfx::ToFlooredInt(std::min(kOverviewInsetRatio * total_bounds.width(),
495 kOverviewInsetRatio * total_bounds.height())); 472 kOverviewInsetRatio * total_bounds.height()));
496 int vertical_inset = 473 int vertical_inset =
497 horizontal_inset + 474 horizontal_inset +
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 // |right_bound| was reverted. Perform one last pass to position the |rects|. 563 // |right_bound| was reverted. Perform one last pass to position the |rects|.
587 if (make_last_adjustment) { 564 if (make_last_adjustment) {
588 gfx::Rect overview_bounds(total_bounds); 565 gfx::Rect overview_bounds(total_bounds);
589 overview_bounds.set_width(right_bound - total_bounds.x()); 566 overview_bounds.set_width(right_bound - total_bounds.x());
590 FitWindowRectsInBounds(overview_bounds, 567 FitWindowRectsInBounds(overview_bounds,
591 std::min(kMaxHeight + 2 * kWindowMarginMD, height), 568 std::min(kMaxHeight + 2 * kWindowMarginMD, height),
592 &rects, &max_bottom, &min_right, &max_right); 569 &rects, &max_bottom, &min_right, &max_right);
593 } 570 }
594 // Position the windows centering the left-aligned rows vertically. 571 // Position the windows centering the left-aligned rows vertically.
595 gfx::Vector2d offset(0, (total_bounds.bottom() - max_bottom) / 2); 572 gfx::Vector2d offset(0, (total_bounds.bottom() - max_bottom) / 2);
596 for (size_t i = 0; i < windows_count; ++i) { 573 for (size_t i = 0; i < window_list_.size(); ++i) {
597 window_list_[i]->SetBounds( 574 window_list_[i]->SetBounds(
598 rects[i] + offset, 575 rects[i] + offset,
599 animate 576 animate
600 ? OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS 577 ? OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS
601 : OverviewAnimationType::OVERVIEW_ANIMATION_NONE); 578 : OverviewAnimationType::OVERVIEW_ANIMATION_NONE);
602 } 579 }
603 580
604 // If the selection widget is active, reposition it without any animation. 581 // If the selection widget is active, reposition it without any animation.
605 if (selection_widget_) 582 if (selection_widget_)
606 MoveSelectionWidgetToTarget(animate); 583 MoveSelectionWidgetToTarget(animate);
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 WmWindow* widget_window = 832 WmWindow* widget_window =
856 WmLookup::Get()->GetWindowForWidget(shield_widget_.get()); 833 WmLookup::Get()->GetWindowForWidget(shield_widget_.get());
857 const gfx::Rect bounds = widget_window->GetParent()->GetBounds(); 834 const gfx::Rect bounds = widget_window->GetParent()->GetBounds();
858 widget_window->SetBounds(bounds); 835 widget_window->SetBounds(bounds);
859 widget_window->SetName("OverviewModeShield"); 836 widget_window->SetName("OverviewModeShield");
860 837
861 ui::ScopedLayerAnimationSettings animation_settings( 838 ui::ScopedLayerAnimationSettings animation_settings(
862 widget_window->GetLayer()->GetAnimator()); 839 widget_window->GetLayer()->GetAnimator());
863 animation_settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( 840 animation_settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(
864 kOverviewSelectorTransitionMilliseconds)); 841 kOverviewSelectorTransitionMilliseconds));
865 animation_settings.SetTweenType(gfx::Tween::LINEAR_OUT_SLOW_IN); 842 animation_settings.SetTweenType(gfx::Tween::EASE_IN);
866 animation_settings.SetPreemptionStrategy( 843 animation_settings.SetPreemptionStrategy(
867 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 844 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
868 shield_widget_->SetOpacity(kShieldOpacity); 845 shield_widget_->SetOpacity(kShieldOpacity);
869 } 846 }
870 847
871 void WindowGrid::InitSelectionWidget(WindowSelector::Direction direction) { 848 void WindowGrid::InitSelectionWidget(WindowSelector::Direction direction) {
872 const bool material = ash::MaterialDesignController::IsOverviewMaterial(); 849 const bool material = ash::MaterialDesignController::IsOverviewMaterial();
873 const int border_thickness = material ? kWindowSelectionBorderThicknessMD 850 const int border_thickness = material ? kWindowSelectionBorderThicknessMD
874 : kWindowSelectionBorderThickness; 851 : kWindowSelectionBorderThickness;
875 const int border_color = 852 const int border_color =
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 if (*min_right > left) 1032 if (*min_right > left)
1056 *min_right = left; 1033 *min_right = left;
1057 if (*max_right < left) 1034 if (*max_right < left)
1058 *max_right = left; 1035 *max_right = left;
1059 } 1036 }
1060 *max_bottom = top + height; 1037 *max_bottom = top + height;
1061 } 1038 }
1062 return windows_fit; 1039 return windows_fit;
1063 } 1040 }
1064 1041
1042 void WindowGrid::PrepareForUsingMasksOrShapes(size_t windows_count) const {
1043 const int kUnlimited = -1;
1044 const base::CommandLine* command_line =
1045 base::CommandLine::ForCurrentProcess();
1046 int windows_to_use_masks = kMaxWindowsCountToHideHeaderWithMasks;
1047 if (command_line->HasSwitch(switches::kAshMaxWindowsToUseMaskInOverview) &&
1048 (!base::StringToInt(command_line->GetSwitchValueASCII(
1049 switches::kAshMaxWindowsToUseMaskInOverview),
1050 &windows_to_use_masks) ||
1051 windows_to_use_masks <= kUnlimited)) {
1052 windows_to_use_masks = kMaxWindowsCountToHideHeaderWithMasks;
1053 }
1054 int windows_to_use_shapes = kUnlimited;
1055 if (command_line->HasSwitch(switches::kAshMaxWindowsToUseShapeInOverview) &&
1056 (!base::StringToInt(command_line->GetSwitchValueASCII(
1057 switches::kAshMaxWindowsToUseShapeInOverview),
1058 &windows_to_use_shapes) ||
1059 windows_to_use_shapes <= kUnlimited)) {
1060 windows_to_use_shapes = kUnlimited;
1061 }
1062 WindowSelectorItem::set_use_mask(windows_to_use_masks <= kUnlimited ||
1063 static_cast<int>(windows_count) <=
1064 windows_to_use_masks);
1065 WindowSelectorItem::set_use_shape(windows_to_use_shapes <= kUnlimited ||
1066 static_cast<int>(windows_count) <=
1067 windows_to_use_shapes);
1068 }
1069
1065 } // namespace ash 1070 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/wm/overview/window_grid.h ('k') | ash/common/wm/overview/window_selector_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698