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

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

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