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

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

Issue 2035543004: Shuffles and renames ash/common/wm classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: random changes for chrome tests Created 4 years, 6 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 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/wm/overview/window_grid.h" 5 #include "ash/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/ash_switches.h" 13 #include "ash/ash_switches.h"
14 #include "ash/common/shell_window_ids.h" 14 #include "ash/common/shell_window_ids.h"
15 #include "ash/common/wm/window_state.h" 15 #include "ash/common/wm/window_state.h"
16 #include "ash/common/wm/wm_lookup.h"
17 #include "ash/common/wm/wm_root_window_controller.h"
18 #include "ash/common/wm/wm_screen_util.h" 16 #include "ash/common/wm/wm_screen_util.h"
19 #include "ash/common/wm/wm_window.h" 17 #include "ash/common/wm_lookup.h"
18 #include "ash/common/wm_root_window_controller.h"
19 #include "ash/common/wm_window.h"
20 #include "ash/wm/overview/scoped_transform_overview_window.h" 20 #include "ash/wm/overview/scoped_transform_overview_window.h"
21 #include "ash/wm/overview/window_selector.h" 21 #include "ash/wm/overview/window_selector.h"
22 #include "ash/wm/overview/window_selector_item.h" 22 #include "ash/wm/overview/window_selector_item.h"
23 #include "base/command_line.h" 23 #include "base/command_line.h"
24 #include "base/i18n/string_search.h" 24 #include "base/i18n/string_search.h"
25 #include "base/memory/scoped_vector.h" 25 #include "base/memory/scoped_vector.h"
26 #include "third_party/skia/include/core/SkColor.h" 26 #include "third_party/skia/include/core/SkColor.h"
27 #include "ui/compositor/layer_animation_observer.h" 27 #include "ui/compositor/layer_animation_observer.h"
28 #include "ui/compositor/scoped_layer_animation_settings.h" 28 #include "ui/compositor/scoped_layer_animation_settings.h"
29 #include "ui/display/display.h" 29 #include "ui/display/display.h"
30 #include "ui/display/screen.h" 30 #include "ui/display/screen.h"
31 #include "ui/gfx/animation/tween.h" 31 #include "ui/gfx/animation/tween.h"
32 #include "ui/gfx/geometry/vector2d.h" 32 #include "ui/gfx/geometry/vector2d.h"
33 #include "ui/views/background.h" 33 #include "ui/views/background.h"
34 #include "ui/views/border.h" 34 #include "ui/views/border.h"
35 #include "ui/views/view.h" 35 #include "ui/views/view.h"
36 #include "ui/views/widget/widget.h" 36 #include "ui/views/widget/widget.h"
37 #include "ui/wm/core/window_animations.h" 37 #include "ui/wm/core/window_animations.h"
38 38
39 namespace ash { 39 namespace ash {
40 namespace { 40 namespace {
41 41
42 using Windows = std::vector<wm::WmWindow*>; 42 using Windows = std::vector<WmWindow*>;
43 43
44 // An observer which holds onto the passed widget until the animation is 44 // An observer which holds onto the passed widget until the animation is
45 // complete. 45 // complete.
46 class CleanupWidgetAfterAnimationObserver 46 class CleanupWidgetAfterAnimationObserver
47 : public ui::ImplicitAnimationObserver { 47 : public ui::ImplicitAnimationObserver {
48 public: 48 public:
49 explicit CleanupWidgetAfterAnimationObserver( 49 explicit CleanupWidgetAfterAnimationObserver(
50 std::unique_ptr<views::Widget> widget); 50 std::unique_ptr<views::Widget> widget);
51 ~CleanupWidgetAfterAnimationObserver() override; 51 ~CleanupWidgetAfterAnimationObserver() override;
52 52
(...skipping 12 matching lines...) Expand all
65 65
66 CleanupWidgetAfterAnimationObserver::~CleanupWidgetAfterAnimationObserver() { 66 CleanupWidgetAfterAnimationObserver::~CleanupWidgetAfterAnimationObserver() {
67 } 67 }
68 68
69 void CleanupWidgetAfterAnimationObserver::OnImplicitAnimationsCompleted() { 69 void CleanupWidgetAfterAnimationObserver::OnImplicitAnimationsCompleted() {
70 delete this; 70 delete this;
71 } 71 }
72 72
73 // A comparator for locating a given target window. 73 // A comparator for locating a given target window.
74 struct WindowSelectorItemComparator { 74 struct WindowSelectorItemComparator {
75 explicit WindowSelectorItemComparator(const wm::WmWindow* target_window) 75 explicit WindowSelectorItemComparator(const WmWindow* target_window)
76 : target(target_window) {} 76 : target(target_window) {}
77 77
78 bool operator()(WindowSelectorItem* window) const { 78 bool operator()(WindowSelectorItem* window) const {
79 return window->GetWindow() == target; 79 return window->GetWindow() == target;
80 } 80 }
81 81
82 const wm::WmWindow* target; 82 const WmWindow* target;
83 }; 83 };
84 84
85 // Conceptually the window overview is a table or grid of cells having this 85 // Conceptually the window overview is a table or grid of cells having this
86 // fixed aspect ratio. The number of columns is determined by maximizing the 86 // fixed aspect ratio. The number of columns is determined by maximizing the
87 // area of them based on the number of window_list. 87 // area of them based on the number of window_list.
88 const float kCardAspectRatio = 4.0f / 3.0f; 88 const float kCardAspectRatio = 4.0f / 3.0f;
89 89
90 // The minimum number of cards along the major axis (i.e. horizontally on a 90 // The minimum number of cards along the major axis (i.e. horizontally on a
91 // landscape orientation). 91 // landscape orientation).
92 const int kMinCardsMajor = 3; 92 const int kMinCardsMajor = 3;
(...skipping 27 matching lines...) Expand all
120 vector.set_x(-bounds.height()); 120 vector.set_x(-bounds.height());
121 break; 121 break;
122 } 122 }
123 return vector; 123 return vector;
124 } 124 }
125 125
126 // Given |root_window|, calculates the item size necessary to fit |items| 126 // Given |root_window|, calculates the item size necessary to fit |items|
127 // items in the window selection. |bounding_rect| is set to the centered 127 // items in the window selection. |bounding_rect| is set to the centered
128 // rectangle containing the grid and |item_size| is set to the size of each 128 // rectangle containing the grid and |item_size| is set to the size of each
129 // individual item. 129 // individual item.
130 void CalculateOverviewSizes(wm::WmWindow* root_window, 130 void CalculateOverviewSizes(WmWindow* root_window,
131 size_t items, 131 size_t items,
132 gfx::Rect* bounding_rect, 132 gfx::Rect* bounding_rect,
133 gfx::Size* item_size) { 133 gfx::Size* item_size) {
134 gfx::Rect total_bounds = root_window->ConvertRectToScreen( 134 gfx::Rect total_bounds = root_window->ConvertRectToScreen(
135 wm::GetDisplayWorkAreaBoundsInParent(root_window->GetChildByShellWindowId( 135 wm::GetDisplayWorkAreaBoundsInParent(root_window->GetChildByShellWindowId(
136 kShellWindowId_DefaultContainer))); 136 kShellWindowId_DefaultContainer)));
137 137
138 // Reserve space at the top for the text filtering textbox to appear. 138 // Reserve space at the top for the text filtering textbox to appear.
139 total_bounds.Inset( 139 total_bounds.Inset(
140 0, WindowSelector::kTextFilterBottomEdge + kTextFilterBottomMargin, 0, 0); 140 0, WindowSelector::kTextFilterBottomEdge + kTextFilterBottomMargin, 0, 0);
(...skipping 19 matching lines...) Expand all
160 bounding_rect->set_x(total_bounds.x() + 160 bounding_rect->set_x(total_bounds.x() +
161 (total_bounds.width() - bounding_rect->width()) / 2); 161 (total_bounds.width() - bounding_rect->width()) / 2);
162 bounding_rect->set_y(total_bounds.y() + 162 bounding_rect->set_y(total_bounds.y() +
163 (total_bounds.height() - bounding_rect->height()) / 2); 163 (total_bounds.height() - bounding_rect->height()) / 2);
164 } 164 }
165 165
166 // Reorders the list of windows |items| in |root_window| in an attempt to 166 // Reorders the list of windows |items| in |root_window| in an attempt to
167 // minimize the distance each window will travel to enter overview. For 167 // minimize the distance each window will travel to enter overview. For
168 // equidistant windows preserves a stable order between overview sessions 168 // equidistant windows preserves a stable order between overview sessions
169 // by comparing window pointers. 169 // by comparing window pointers.
170 void ReorderItemsGreedyLeastMovement(std::vector<wm::WmWindow*>* items, 170 void ReorderItemsGreedyLeastMovement(std::vector<WmWindow*>* items,
171 wm::WmWindow* root_window) { 171 WmWindow* root_window) {
172 if (items->empty()) 172 if (items->empty())
173 return; 173 return;
174 gfx::Rect bounding_rect; 174 gfx::Rect bounding_rect;
175 gfx::Size item_size; 175 gfx::Size item_size;
176 CalculateOverviewSizes(root_window, items->size(), &bounding_rect, 176 CalculateOverviewSizes(root_window, items->size(), &bounding_rect,
177 &item_size); 177 &item_size);
178 int num_columns = std::min(static_cast<int>(items->size()), 178 int num_columns = std::min(static_cast<int>(items->size()),
179 bounding_rect.width() / item_size.width()); 179 bounding_rect.width() / item_size.width());
180 for (size_t i = 0; i < items->size(); ++i) { 180 for (size_t i = 0; i < items->size(); ++i) {
181 int column = i % num_columns; 181 int column = i % num_columns;
182 int row = i / num_columns; 182 int row = i / num_columns;
183 gfx::Point overview_item_center( 183 gfx::Point overview_item_center(
184 bounding_rect.x() + column * item_size.width() + item_size.width() / 2, 184 bounding_rect.x() + column * item_size.width() + item_size.width() / 2,
185 bounding_rect.y() + row * item_size.height() + item_size.height() / 2); 185 bounding_rect.y() + row * item_size.height() + item_size.height() / 2);
186 // Find the nearest window for this position. 186 // Find the nearest window for this position.
187 size_t swap_index = i; 187 size_t swap_index = i;
188 int64_t shortest_distance = std::numeric_limits<int64_t>::max(); 188 int64_t shortest_distance = std::numeric_limits<int64_t>::max();
189 for (size_t j = i; j < items->size(); ++j) { 189 for (size_t j = i; j < items->size(); ++j) {
190 wm::WmWindow* window = (*items)[j]; 190 WmWindow* window = (*items)[j];
191 const gfx::Rect screen_target_bounds = 191 const gfx::Rect screen_target_bounds =
192 window->ConvertRectToScreen(window->GetTargetBounds()); 192 window->ConvertRectToScreen(window->GetTargetBounds());
193 int64_t distance = 193 int64_t distance =
194 (screen_target_bounds.CenterPoint() - overview_item_center) 194 (screen_target_bounds.CenterPoint() - overview_item_center)
195 .LengthSquared(); 195 .LengthSquared();
196 // We compare raw pointers to create a stable ordering given two windows 196 // We compare raw pointers to create a stable ordering given two windows
197 // with the same center point. 197 // with the same center point.
198 if (distance < shortest_distance || 198 if (distance < shortest_distance ||
199 (distance == shortest_distance && window < (*items)[swap_index])) { 199 (distance == shortest_distance && window < (*items)[swap_index])) {
200 shortest_distance = distance; 200 shortest_distance = distance;
201 swap_index = j; 201 swap_index = j;
202 } 202 }
203 } 203 }
204 if (swap_index > i) 204 if (swap_index > i)
205 std::swap((*items)[i], (*items)[swap_index]); 205 std::swap((*items)[i], (*items)[swap_index]);
206 } 206 }
207 } 207 }
208 208
209 } // namespace 209 } // namespace
210 210
211 WindowGrid::WindowGrid(wm::WmWindow* root_window, 211 WindowGrid::WindowGrid(WmWindow* root_window,
212 const std::vector<wm::WmWindow*>& windows, 212 const std::vector<WmWindow*>& windows,
213 WindowSelector* window_selector) 213 WindowSelector* window_selector)
214 : root_window_(root_window), window_selector_(window_selector) { 214 : root_window_(root_window), window_selector_(window_selector) {
215 std::vector<wm::WmWindow*> windows_in_root; 215 std::vector<WmWindow*> windows_in_root;
216 for (auto window : windows) { 216 for (auto window : windows) {
217 if (window->GetRootWindow() == root_window) 217 if (window->GetRootWindow() == root_window)
218 windows_in_root.push_back(window); 218 windows_in_root.push_back(window);
219 } 219 }
220 220
221 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 221 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
222 switches::kAshEnableStableOverviewOrder)) { 222 switches::kAshEnableStableOverviewOrder)) {
223 // Reorder windows to try to minimize movement to target overview positions. 223 // Reorder windows to try to minimize movement to target overview positions.
224 // This also creates a stable window ordering. 224 // This also creates a stable window ordering.
225 ReorderItemsGreedyLeastMovement(&windows_in_root, root_window_); 225 ReorderItemsGreedyLeastMovement(&windows_in_root, root_window_);
226 } 226 }
227 for (auto window : windows_in_root) { 227 for (auto window : windows_in_root) {
228 window->AddObserver(this); 228 window->AddObserver(this);
229 observed_windows_.insert(window); 229 observed_windows_.insert(window);
230 window_list_.push_back(new WindowSelectorItem(window, window_selector_)); 230 window_list_.push_back(new WindowSelectorItem(window, window_selector_));
231 } 231 }
232 } 232 }
233 233
234 WindowGrid::~WindowGrid() { 234 WindowGrid::~WindowGrid() {
235 for (wm::WmWindow* window : observed_windows_) 235 for (WmWindow* window : observed_windows_)
236 window->RemoveObserver(this); 236 window->RemoveObserver(this);
237 } 237 }
238 238
239 void WindowGrid::PrepareForOverview() { 239 void WindowGrid::PrepareForOverview() {
240 for (auto iter = window_list_.begin(); iter != window_list_.end(); ++iter) 240 for (auto iter = window_list_.begin(); iter != window_list_.end(); ++iter)
241 (*iter)->PrepareForOverview(); 241 (*iter)->PrepareForOverview();
242 } 242 }
243 243
244 void WindowGrid::PositionWindows(bool animate) { 244 void WindowGrid::PositionWindows(bool animate) {
245 CHECK(!window_list_.empty()); 245 CHECK(!window_list_.empty());
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 return out_of_bounds; 332 return out_of_bounds;
333 } 333 }
334 334
335 WindowSelectorItem* WindowGrid::SelectedWindow() const { 335 WindowSelectorItem* WindowGrid::SelectedWindow() const {
336 if (!selection_widget_) 336 if (!selection_widget_)
337 return nullptr; 337 return nullptr;
338 CHECK(selected_index_ < window_list_.size()); 338 CHECK(selected_index_ < window_list_.size());
339 return window_list_[selected_index_]; 339 return window_list_[selected_index_];
340 } 340 }
341 341
342 bool WindowGrid::Contains(const wm::WmWindow* window) const { 342 bool WindowGrid::Contains(const WmWindow* window) const {
343 for (const WindowSelectorItem* window_item : window_list_) { 343 for (const WindowSelectorItem* window_item : window_list_) {
344 if (window_item->Contains(window)) 344 if (window_item->Contains(window))
345 return true; 345 return true;
346 } 346 }
347 return false; 347 return false;
348 } 348 }
349 349
350 void WindowGrid::FilterItems(const base::string16& pattern) { 350 void WindowGrid::FilterItems(const base::string16& pattern) {
351 base::i18n::FixedPatternStringSearchIgnoringCaseAndAccents finder(pattern); 351 base::i18n::FixedPatternStringSearchIgnoringCaseAndAccents finder(pattern);
352 for (auto iter = window_list_.begin(); iter != window_list_.end(); iter++) { 352 for (auto iter = window_list_.begin(); iter != window_list_.end(); iter++) {
353 if (finder.Search((*iter)->GetWindow()->GetTitle(), nullptr, nullptr)) { 353 if (finder.Search((*iter)->GetWindow()->GetTitle(), nullptr, nullptr)) {
354 (*iter)->SetDimmed(false); 354 (*iter)->SetDimmed(false);
355 } else { 355 } else {
356 (*iter)->SetDimmed(true); 356 (*iter)->SetDimmed(true);
357 if (selection_widget_ && SelectedWindow() == *iter) 357 if (selection_widget_ && SelectedWindow() == *iter)
358 selection_widget_.reset(); 358 selection_widget_.reset();
359 } 359 }
360 } 360 }
361 } 361 }
362 362
363 void WindowGrid::OnWindowDestroying(wm::WmWindow* window) { 363 void WindowGrid::OnWindowDestroying(WmWindow* window) {
364 window->RemoveObserver(this); 364 window->RemoveObserver(this);
365 observed_windows_.erase(window); 365 observed_windows_.erase(window);
366 ScopedVector<WindowSelectorItem>::iterator iter = 366 ScopedVector<WindowSelectorItem>::iterator iter =
367 std::find_if(window_list_.begin(), window_list_.end(), 367 std::find_if(window_list_.begin(), window_list_.end(),
368 WindowSelectorItemComparator(window)); 368 WindowSelectorItemComparator(window));
369 369
370 DCHECK(iter != window_list_.end()); 370 DCHECK(iter != window_list_.end());
371 371
372 size_t removed_index = iter - window_list_.begin(); 372 size_t removed_index = iter - window_list_.begin();
373 window_list_.erase(iter); 373 window_list_.erase(iter);
(...skipping 10 matching lines...) Expand all
384 bool send_focus_alert = selected_index_ == removed_index; 384 bool send_focus_alert = selected_index_ == removed_index;
385 if (selected_index_ >= removed_index && selected_index_ != 0) 385 if (selected_index_ >= removed_index && selected_index_ != 0)
386 selected_index_--; 386 selected_index_--;
387 if (send_focus_alert) 387 if (send_focus_alert)
388 SelectedWindow()->SendAccessibleSelectionEvent(); 388 SelectedWindow()->SendAccessibleSelectionEvent();
389 } 389 }
390 390
391 PositionWindows(true); 391 PositionWindows(true);
392 } 392 }
393 393
394 void WindowGrid::OnWindowBoundsChanged(wm::WmWindow* window, 394 void WindowGrid::OnWindowBoundsChanged(WmWindow* window,
395 const gfx::Rect& old_bounds, 395 const gfx::Rect& old_bounds,
396 const gfx::Rect& new_bounds) { 396 const gfx::Rect& new_bounds) {
397 auto iter = std::find_if(window_list_.begin(), window_list_.end(), 397 auto iter = std::find_if(window_list_.begin(), window_list_.end(),
398 WindowSelectorItemComparator(window)); 398 WindowSelectorItemComparator(window));
399 DCHECK(iter != window_list_.end()); 399 DCHECK(iter != window_list_.end());
400 400
401 // Immediately finish any active bounds animation. 401 // Immediately finish any active bounds animation.
402 window->StopAnimatingProperty(ui::LayerAnimationElement::BOUNDS); 402 window->StopAnimatingProperty(ui::LayerAnimationElement::BOUNDS);
403 403
404 // Recompute the transform for the window. 404 // Recompute the transform for the window.
405 (*iter)->RecomputeWindowTransforms(); 405 (*iter)->RecomputeWindowTransforms();
406 } 406 }
407 407
408 void WindowGrid::InitSelectionWidget(WindowSelector::Direction direction) { 408 void WindowGrid::InitSelectionWidget(WindowSelector::Direction direction) {
409 selection_widget_.reset(new views::Widget); 409 selection_widget_.reset(new views::Widget);
410 views::Widget::InitParams params; 410 views::Widget::InitParams params;
411 params.type = views::Widget::InitParams::TYPE_POPUP; 411 params.type = views::Widget::InitParams::TYPE_POPUP;
412 params.keep_on_top = false; 412 params.keep_on_top = false;
413 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 413 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
414 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; 414 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
415 params.accept_events = false; 415 params.accept_events = false;
416 selection_widget_->set_focus_on_creation(false); 416 selection_widget_->set_focus_on_creation(false);
417 root_window_->GetRootWindowController() 417 root_window_->GetRootWindowController()
418 ->ConfigureWidgetInitParamsForContainer( 418 ->ConfigureWidgetInitParamsForContainer(
419 selection_widget_.get(), kShellWindowId_DefaultContainer, &params); 419 selection_widget_.get(), kShellWindowId_DefaultContainer, &params);
420 selection_widget_->Init(params); 420 selection_widget_->Init(params);
421 wm::WmWindow* selection_widget_window = 421 WmWindow* selection_widget_window =
422 wm::WmLookup::Get()->GetWindowForWidget(selection_widget_.get()); 422 WmLookup::Get()->GetWindowForWidget(selection_widget_.get());
423 // Disable the "bounce in" animation when showing the window. 423 // Disable the "bounce in" animation when showing the window.
424 selection_widget_window->SetVisibilityAnimationTransition(::wm::ANIMATE_NONE); 424 selection_widget_window->SetVisibilityAnimationTransition(::wm::ANIMATE_NONE);
425 // The selection widget should not activate the shelf when passing under it. 425 // The selection widget should not activate the shelf when passing under it.
426 selection_widget_window->GetWindowState()->set_ignored_by_shelf(true); 426 selection_widget_window->GetWindowState()->set_ignored_by_shelf(true);
427 427
428 views::View* content_view = new views::View; 428 views::View* content_view = new views::View;
429 content_view->set_background( 429 content_view->set_background(
430 views::Background::CreateSolidBackground(kWindowSelectionColor)); 430 views::Background::CreateSolidBackground(kWindowSelectionColor));
431 content_view->SetBorder(views::Border::CreateSolidBorder( 431 content_view->SetBorder(views::Border::CreateSolidBorder(
432 kWindowSelectionBorderThickness, kWindowSelectionBorderColor)); 432 kWindowSelectionBorderThickness, kWindowSelectionBorderColor));
(...skipping 15 matching lines...) Expand all
448 448
449 void WindowGrid::MoveSelectionWidget(WindowSelector::Direction direction, 449 void WindowGrid::MoveSelectionWidget(WindowSelector::Direction direction,
450 bool recreate_selection_widget, 450 bool recreate_selection_widget,
451 bool out_of_bounds, 451 bool out_of_bounds,
452 bool animate) { 452 bool animate) {
453 // If the selection widget is already active, fade it out in the selection 453 // If the selection widget is already active, fade it out in the selection
454 // direction. 454 // direction.
455 if (selection_widget_ && (recreate_selection_widget || out_of_bounds)) { 455 if (selection_widget_ && (recreate_selection_widget || out_of_bounds)) {
456 // Animate the old selection widget and then destroy it. 456 // Animate the old selection widget and then destroy it.
457 views::Widget* old_selection = selection_widget_.get(); 457 views::Widget* old_selection = selection_widget_.get();
458 wm::WmWindow* old_selection_window = 458 WmWindow* old_selection_window =
459 wm::WmLookup::Get()->GetWindowForWidget(old_selection); 459 WmLookup::Get()->GetWindowForWidget(old_selection);
460 gfx::Vector2d fade_out_direction = 460 gfx::Vector2d fade_out_direction =
461 GetSlideVectorForFadeIn(direction, old_selection_window->GetBounds()); 461 GetSlideVectorForFadeIn(direction, old_selection_window->GetBounds());
462 462
463 ui::ScopedLayerAnimationSettings animation_settings( 463 ui::ScopedLayerAnimationSettings animation_settings(
464 old_selection_window->GetLayer()->GetAnimator()); 464 old_selection_window->GetLayer()->GetAnimator());
465 animation_settings.SetTransitionDuration( 465 animation_settings.SetTransitionDuration(
466 base::TimeDelta::FromMilliseconds( 466 base::TimeDelta::FromMilliseconds(
467 kOverviewSelectorTransitionMilliseconds)); 467 kOverviewSelectorTransitionMilliseconds));
468 animation_settings.SetPreemptionStrategy( 468 animation_settings.SetPreemptionStrategy(
469 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 469 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
(...skipping 15 matching lines...) Expand all
485 // Send an a11y alert so that if ChromeVox is enabled, the item label is 485 // Send an a11y alert so that if ChromeVox is enabled, the item label is
486 // read. 486 // read.
487 SelectedWindow()->SendAccessibleSelectionEvent(); 487 SelectedWindow()->SendAccessibleSelectionEvent();
488 // The selection widget is moved to the newly selected item in the same 488 // The selection widget is moved to the newly selected item in the same
489 // grid. 489 // grid.
490 MoveSelectionWidgetToTarget(animate); 490 MoveSelectionWidgetToTarget(animate);
491 } 491 }
492 492
493 void WindowGrid::MoveSelectionWidgetToTarget(bool animate) { 493 void WindowGrid::MoveSelectionWidgetToTarget(bool animate) {
494 if (animate) { 494 if (animate) {
495 wm::WmWindow* selection_widget_window = 495 WmWindow* selection_widget_window =
496 wm::WmLookup::Get()->GetWindowForWidget(selection_widget_.get()); 496 WmLookup::Get()->GetWindowForWidget(selection_widget_.get());
497 ui::ScopedLayerAnimationSettings animation_settings( 497 ui::ScopedLayerAnimationSettings animation_settings(
498 selection_widget_window->GetLayer()->GetAnimator()); 498 selection_widget_window->GetLayer()->GetAnimator());
499 animation_settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( 499 animation_settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(
500 kOverviewSelectorTransitionMilliseconds)); 500 kOverviewSelectorTransitionMilliseconds));
501 animation_settings.SetTweenType(gfx::Tween::LINEAR_OUT_SLOW_IN); 501 animation_settings.SetTweenType(gfx::Tween::LINEAR_OUT_SLOW_IN);
502 animation_settings.SetPreemptionStrategy( 502 animation_settings.SetPreemptionStrategy(
503 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 503 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
504 selection_widget_->SetBounds(SelectedWindow()->target_bounds()); 504 selection_widget_->SetBounds(SelectedWindow()->target_bounds());
505 selection_widget_->SetOpacity(1.f); 505 selection_widget_->SetOpacity(1.f);
506 return; 506 return;
507 } 507 }
508 selection_widget_->SetBounds(SelectedWindow()->target_bounds()); 508 selection_widget_->SetBounds(SelectedWindow()->target_bounds());
509 selection_widget_->SetOpacity(1.f); 509 selection_widget_->SetOpacity(1.f);
510 } 510 }
511 511
512 } // namespace ash 512 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698