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

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

Issue 2111643004: [ash-md] Adjusts animation of the selector after closing an overview item (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: [ash-md] Adjusts animation of the selector after closing an overview item (more 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
« no previous file with comments | « ash/common/wm/overview/window_grid.h ('k') | ash/common/wm/overview/window_selector.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>
11 #include <vector> 11 #include <vector>
12 12
13 #include "ash/common/ash_switches.h" 13 #include "ash/common/ash_switches.h"
14 #include "ash/common/material_design/material_design_controller.h" 14 #include "ash/common/material_design/material_design_controller.h"
15 #include "ash/common/shell_window_ids.h" 15 #include "ash/common/shell_window_ids.h"
16 #include "ash/common/wm/overview/scoped_overview_animation_settings.h"
17 #include "ash/common/wm/overview/scoped_overview_animation_settings_factory.h"
16 #include "ash/common/wm/overview/scoped_transform_overview_window.h" 18 #include "ash/common/wm/overview/scoped_transform_overview_window.h"
17 #include "ash/common/wm/overview/window_selector.h" 19 #include "ash/common/wm/overview/window_selector.h"
18 #include "ash/common/wm/overview/window_selector_item.h" 20 #include "ash/common/wm/overview/window_selector_item.h"
19 #include "ash/common/wm/window_state.h" 21 #include "ash/common/wm/window_state.h"
20 #include "ash/common/wm/wm_screen_util.h" 22 #include "ash/common/wm/wm_screen_util.h"
21 #include "ash/common/wm_lookup.h" 23 #include "ash/common/wm_lookup.h"
22 #include "ash/common/wm_root_window_controller.h" 24 #include "ash/common/wm_root_window_controller.h"
23 #include "ash/common/wm_window.h" 25 #include "ash/common/wm_window.h"
24 #include "base/command_line.h" 26 #include "base/command_line.h"
25 #include "base/i18n/string_search.h" 27 #include "base/i18n/string_search.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 89
88 // Conceptually the window overview is a table or grid of cells having this 90 // Conceptually the window overview is a table or grid of cells having this
89 // fixed aspect ratio. The number of columns is determined by maximizing the 91 // fixed aspect ratio. The number of columns is determined by maximizing the
90 // area of them based on the number of window_list. 92 // area of them based on the number of window_list.
91 const float kCardAspectRatio = 4.0f / 3.0f; 93 const float kCardAspectRatio = 4.0f / 3.0f;
92 94
93 // The minimum number of cards along the major axis (i.e. horizontally on a 95 // The minimum number of cards along the major axis (i.e. horizontally on a
94 // landscape orientation). 96 // landscape orientation).
95 const int kMinCardsMajor = 3; 97 const int kMinCardsMajor = 3;
96 98
97 const int kOverviewSelectorTransitionMilliseconds = 200; 99 const int kOverviewSelectorTransitionMilliseconds = 250;
98 100
99 // The color and opacity of the screen shield in overview. 101 // The color and opacity of the screen shield in overview.
100 const SkColor kShieldColor = SkColorSetARGB(178, 0, 0, 0); 102 const SkColor kShieldColor = SkColorSetARGB(178, 0, 0, 0);
101 103
102 // The color and opacity of the overview selector. 104 // The color and opacity of the overview selector.
103 const SkColor kWindowSelectionColor = SkColorSetARGB(128, 0, 0, 0); 105 const SkColor kWindowSelectionColor = SkColorSetARGB(128, 0, 0, 0);
104 const SkColor kWindowSelectionColorMD = SkColorSetARGB(51, 255, 255, 255); 106 const SkColor kWindowSelectionColorMD = SkColorSetARGB(51, 255, 255, 255);
105 const SkColor kWindowSelectionBorderColor = SkColorSetARGB(38, 255, 255, 255); 107 const SkColor kWindowSelectionBorderColor = SkColorSetARGB(38, 255, 255, 255);
106 const SkColor kWindowSelectionBorderColorMD = SkColorSetARGB(76, 255, 255, 255); 108 const SkColor kWindowSelectionBorderColorMD = SkColorSetARGB(76, 255, 255, 255);
107 109
108 // Border thickness of overview selector. 110 // Border thickness of overview selector.
109 const int kWindowSelectionBorderThickness = 2; 111 const int kWindowSelectionBorderThickness = 2;
110 const int kWindowSelectionBorderThicknessMD = 1; 112 const int kWindowSelectionBorderThicknessMD = 1;
111 113
112 // Corner radius of the overview selector border. 114 // Corner radius of the overview selector border.
113 const int kWindowSelectionRadius = 0; 115 const int kWindowSelectionRadius = 0;
114 const int kWindowSelectionRadiusMD = 4; 116 const int kWindowSelectionRadiusMD = 4;
115 117
116 // The minimum amount of spacing between the bottom of the text filtering 118 // The minimum amount of spacing between the bottom of the text filtering
117 // text field and the top of the selection widget on the first row of items. 119 // text field and the top of the selection widget on the first row of items.
118 const int kTextFilterBottomMargin = 5; 120 const int kTextFilterBottomMargin = 5;
119 121
120 // In the conceptual overview table, the window margin is the space reserved 122 // In the conceptual overview table, the window margin is the space reserved
121 // around the window within the cell. This margin does not overlap so the 123 // around the window within the cell. This margin does not overlap so the
122 // closest distance between adjacent windows will be twice this amount. 124 // closest distance between adjacent windows will be twice this amount.
123 const int kWindowMarginMD = 5; 125 const int kWindowMarginMD = 5;
124 126
125 // Additional inset of overview selector (4 is the visible selector thickness).
126 const int kSelectionInset = kWindowMarginMD - 5;
127
128 // Windows are not allowed to get taller than this. 127 // Windows are not allowed to get taller than this.
129 const int kMaxHeight = 512; 128 const int kMaxHeight = 512;
130 129
131 // Margins reserved in the overview mode. 130 // Margins reserved in the overview mode.
132 const float kOverviewInsetRatio = 0.05f; 131 const float kOverviewInsetRatio = 0.05f;
133 132
134 // Additional vertical inset reserved for windows in overview mode. 133 // Additional vertical inset reserved for windows in overview mode.
135 const float kOverviewVerticalInset = 0.1f; 134 const float kOverviewVerticalInset = 0.1f;
136 135
137 // A View having rounded corners and a specified background color which is 136 // A View having rounded corners and a specified background color which is
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 } else { 721 } else {
723 (*iter)->SetDimmed(true); 722 (*iter)->SetDimmed(true);
724 if (selection_widget_ && SelectedWindow() == *iter) { 723 if (selection_widget_ && SelectedWindow() == *iter) {
725 SelectedWindow()->SetSelected(false); 724 SelectedWindow()->SetSelected(false);
726 selection_widget_.reset(); 725 selection_widget_.reset();
727 } 726 }
728 } 727 }
729 } 728 }
730 } 729 }
731 730
731 void WindowGrid::WindowClosing(WindowSelectorItem* window) {
732 if (!selection_widget_ || SelectedWindow() != window)
733 return;
734 WmWindow* selection_widget_window =
735 WmLookup::Get()->GetWindowForWidget(selection_widget_.get());
736 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings_label =
737 ScopedOverviewAnimationSettingsFactory::Get()
738 ->CreateOverviewAnimationSettings(
739 OverviewAnimationType::OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM,
740 selection_widget_window);
741 selection_widget_->SetOpacity(0.f);
742 }
743
732 void WindowGrid::OnWindowDestroying(WmWindow* window) { 744 void WindowGrid::OnWindowDestroying(WmWindow* window) {
733 window->RemoveObserver(this); 745 window->RemoveObserver(this);
734 observed_windows_.erase(window); 746 observed_windows_.erase(window);
735 ScopedVector<WindowSelectorItem>::iterator iter = 747 ScopedVector<WindowSelectorItem>::iterator iter =
736 std::find_if(window_list_.begin(), window_list_.end(), 748 std::find_if(window_list_.begin(), window_list_.end(),
737 WindowSelectorItemComparator(window)); 749 WindowSelectorItemComparator(window));
738 750
739 DCHECK(iter != window_list_.end()); 751 DCHECK(iter != window_list_.end());
740 752
741 size_t removed_index = iter - window_list_.begin(); 753 size_t removed_index = iter - window_list_.begin();
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 // read. 868 // read.
857 SelectedWindow()->SendAccessibleSelectionEvent(); 869 SelectedWindow()->SendAccessibleSelectionEvent();
858 // The selection widget is moved to the newly selected item in the same 870 // The selection widget is moved to the newly selected item in the same
859 // grid. 871 // grid.
860 MoveSelectionWidgetToTarget(animate); 872 MoveSelectionWidgetToTarget(animate);
861 } 873 }
862 874
863 void WindowGrid::MoveSelectionWidgetToTarget(bool animate) { 875 void WindowGrid::MoveSelectionWidgetToTarget(bool animate) {
864 gfx::Rect bounds = 876 gfx::Rect bounds =
865 root_window_->ConvertRectFromScreen(SelectedWindow()->target_bounds()); 877 root_window_->ConvertRectFromScreen(SelectedWindow()->target_bounds());
866 if (ash::MaterialDesignController::IsOverviewMaterial())
867 bounds.Inset(kSelectionInset, kSelectionInset);
868 if (animate) { 878 if (animate) {
869 WmWindow* selection_widget_window = 879 WmWindow* selection_widget_window =
870 WmLookup::Get()->GetWindowForWidget(selection_widget_.get()); 880 WmLookup::Get()->GetWindowForWidget(selection_widget_.get());
871 ui::ScopedLayerAnimationSettings animation_settings( 881 ui::ScopedLayerAnimationSettings animation_settings(
872 selection_widget_window->GetLayer()->GetAnimator()); 882 selection_widget_window->GetLayer()->GetAnimator());
873 animation_settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( 883 animation_settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(
874 kOverviewSelectorTransitionMilliseconds)); 884 kOverviewSelectorTransitionMilliseconds));
875 animation_settings.SetTweenType(gfx::Tween::LINEAR_OUT_SLOW_IN); 885 animation_settings.SetTweenType(
886 ash::MaterialDesignController::IsOverviewMaterial()
887 ? gfx::Tween::EASE_IN_OUT
888 : gfx::Tween::LINEAR_OUT_SLOW_IN);
876 animation_settings.SetPreemptionStrategy( 889 animation_settings.SetPreemptionStrategy(
877 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 890 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
878 selection_widget_->SetBounds(bounds); 891 selection_widget_->SetBounds(bounds);
879 selection_widget_->SetOpacity(1.f); 892 selection_widget_->SetOpacity(1.f);
880 return; 893 return;
881 } 894 }
882 selection_widget_->SetBounds(bounds); 895 selection_widget_->SetBounds(bounds);
883 selection_widget_->SetOpacity(1.f); 896 selection_widget_->SetOpacity(1.f);
884 } 897 }
885 898
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 *min_right = left; 957 *min_right = left;
945 if (*max_right < left) 958 if (*max_right < left)
946 *max_right = left; 959 *max_right = left;
947 } 960 }
948 *max_bottom = top + height; 961 *max_bottom = top + height;
949 } 962 }
950 return windows_fit; 963 return windows_fit;
951 } 964 }
952 965
953 } // namespace ash 966 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/wm/overview/window_grid.h ('k') | ash/common/wm/overview/window_selector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698