OLD | NEW |
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 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 } // namespace | 404 } // namespace |
405 | 405 |
406 WindowGrid::WindowGrid(WmWindow* root_window, | 406 WindowGrid::WindowGrid(WmWindow* root_window, |
407 const std::vector<WmWindow*>& windows, | 407 const std::vector<WmWindow*>& windows, |
408 WindowSelector* window_selector) | 408 WindowSelector* window_selector) |
409 : root_window_(root_window), | 409 : root_window_(root_window), |
410 window_selector_(window_selector), | 410 window_selector_(window_selector), |
411 selected_index_(0), | 411 selected_index_(0), |
412 num_columns_(0) { | 412 num_columns_(0) { |
413 std::vector<WmWindow*> windows_in_root; | 413 std::vector<WmWindow*> windows_in_root; |
414 for (auto window : windows) { | 414 for (auto* window : windows) { |
415 if (window->GetRootWindow() == root_window) | 415 if (window->GetRootWindow() == root_window) |
416 windows_in_root.push_back(window); | 416 windows_in_root.push_back(window); |
417 } | 417 } |
418 | 418 |
419 if (!ash::MaterialDesignController::IsOverviewMaterial() && | 419 if (!ash::MaterialDesignController::IsOverviewMaterial() && |
420 base::CommandLine::ForCurrentProcess()->HasSwitch( | 420 base::CommandLine::ForCurrentProcess()->HasSwitch( |
421 switches::kAshEnableStableOverviewOrder)) { | 421 switches::kAshEnableStableOverviewOrder)) { |
422 // Reorder windows to try to minimize movement to target overview positions. | 422 // Reorder windows to try to minimize movement to target overview positions. |
423 // This also creates a stable window ordering. | 423 // This also creates a stable window ordering. |
424 ReorderItemsGreedyLeastMovement(&windows_in_root, root_window_, | 424 ReorderItemsGreedyLeastMovement(&windows_in_root, root_window_, |
425 window_selector_->text_filter_bottom()); | 425 window_selector_->text_filter_bottom()); |
426 } | 426 } |
427 for (auto window : windows_in_root) { | 427 for (auto* window : windows_in_root) { |
428 window->AddObserver(this); | 428 window->AddObserver(this); |
429 observed_windows_.insert(window); | 429 observed_windows_.insert(window); |
430 window_list_.push_back(new WindowSelectorItem(window, window_selector_)); | 430 window_list_.push_back(new WindowSelectorItem(window, window_selector_)); |
431 } | 431 } |
432 } | 432 } |
433 | 433 |
434 WindowGrid::~WindowGrid() { | 434 WindowGrid::~WindowGrid() { |
435 for (WmWindow* window : observed_windows_) | 435 for (WmWindow* window : observed_windows_) |
436 window->RemoveObserver(this); | 436 window->RemoveObserver(this); |
437 } | 437 } |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
900 | 900 |
901 // Right bound of the narrowest row. | 901 // Right bound of the narrowest row. |
902 *min_right = bounds.right(); | 902 *min_right = bounds.right(); |
903 // Right bound of the widest row. | 903 // Right bound of the widest row. |
904 *max_right = bounds.x(); | 904 *max_right = bounds.x(); |
905 | 905 |
906 // With Material Design all elements are of same height and only the height is | 906 // With Material Design all elements are of same height and only the height is |
907 // necessary to determine each item's scale. | 907 // necessary to determine each item's scale. |
908 const gfx::Size item_size(0, height); | 908 const gfx::Size item_size(0, height); |
909 size_t i = 0; | 909 size_t i = 0; |
910 for (auto window : window_list_) { | 910 for (auto* window : window_list_) { |
911 const gfx::Rect target_bounds = window->GetWindow()->GetTargetBounds(); | 911 const gfx::Rect target_bounds = window->GetWindow()->GetTargetBounds(); |
912 const int width = | 912 const int width = |
913 std::max(1, gfx::ToFlooredInt(target_bounds.width() * | 913 std::max(1, gfx::ToFlooredInt(target_bounds.width() * |
914 window->GetItemScale(item_size)) + | 914 window->GetItemScale(item_size)) + |
915 2 * kWindowMarginMD); | 915 2 * kWindowMarginMD); |
916 if (left + width > bounds.right()) { | 916 if (left + width > bounds.right()) { |
917 // Move to the next row if possible. | 917 // Move to the next row if possible. |
918 if (*min_right > left) | 918 if (*min_right > left) |
919 *min_right = left; | 919 *min_right = left; |
920 if (*max_right < left) | 920 if (*max_right < left) |
(...skipping 22 matching lines...) Expand all Loading... |
943 *min_right = left; | 943 *min_right = left; |
944 if (*max_right < left) | 944 if (*max_right < left) |
945 *max_right = left; | 945 *max_right = left; |
946 } | 946 } |
947 *max_bottom = top + height; | 947 *max_bottom = top + height; |
948 } | 948 } |
949 return windows_fit; | 949 return windows_fit; |
950 } | 950 } |
951 | 951 |
952 } // namespace ash | 952 } // namespace ash |
OLD | NEW |