Chromium Code Reviews| Index: ash/wm/overview/window_grid.cc |
| diff --git a/ash/wm/overview/window_grid.cc b/ash/wm/overview/window_grid.cc |
| index 99ea37c2d1e54056e20674b2f1366eb468a595f8..e56022f81d06d8774052e0bbf6995b3a5d93d3a3 100644 |
| --- a/ash/wm/overview/window_grid.cc |
| +++ b/ash/wm/overview/window_grid.cc |
| @@ -13,6 +13,7 @@ |
| #include "ash/wm/overview/window_selector_panels.h" |
| #include "ash/wm/overview/window_selector_window.h" |
| #include "ash/wm/window_state.h" |
| +#include "base/i18n/string_search.cc" |
| #include "base/memory/scoped_vector.h" |
| #include "third_party/skia/include/core/SkColor.h" |
| #include "ui/aura/window.h" |
| @@ -128,7 +129,8 @@ WindowGrid::WindowGrid(aura::Window* root_window, |
| const std::vector<aura::Window*>& windows, |
| WindowSelector* window_selector) |
| : root_window_(root_window), |
| - window_selector_(window_selector) { |
| + window_selector_(window_selector), |
| + has_active_item_(true) { |
| WindowSelectorPanels* panels_item = NULL; |
| for (aura::Window::Windows::const_iterator iter = windows.begin(); |
| iter != windows.end(); ++iter) { |
| @@ -197,6 +199,7 @@ void WindowGrid::PositionWindows(bool animate) { |
| (total_bounds.width() - num_columns_ * window_size.width())) / 2; |
| int y_offset = total_bounds.y() + (total_bounds.height() - |
| num_rows * window_size.height()) / 2; |
| + |
| for (size_t i = 0; i < window_list_.size(); ++i) { |
| gfx::Transform transform; |
| int column = i % num_columns_; |
| @@ -218,7 +221,10 @@ void WindowGrid::PositionWindows(bool animate) { |
| MoveSelectionWidgetToTarget(animate); |
| } |
| -bool WindowGrid::Move(WindowSelector::Direction direction) { |
| +bool WindowGrid::Move(WindowSelector::Direction direction, bool animate) { |
| + if (!has_active_item_) |
|
flackr
2014/06/27 20:00:06
This is the only place where has_active_item_ is u
Nina
2014/06/27 22:42:01
Done.
|
| + return true; |
| + |
| bool recreate_selection_widget = false; |
| bool out_of_bounds = false; |
| if (!selection_widget_) { |
| @@ -235,7 +241,8 @@ bool WindowGrid::Move(WindowSelector::Direction direction) { |
| selected_index_ = 0; |
| break; |
| } |
| - } else { |
| + } |
| + while (SelectedWindow()->dimmed() || selection_widget_) { |
| switch (direction) { |
| case WindowSelector::RIGHT: |
| if (selected_index_ >= window_list_.size() - 1) |
| @@ -272,9 +279,13 @@ bool WindowGrid::Move(WindowSelector::Direction direction) { |
| } |
| break; |
| } |
| + // Exit the loop if we broke free from the grid or found an active item. |
| + if (out_of_bounds || !SelectedWindow()->dimmed()) |
| + break; |
| } |
| - MoveSelectionWidget(direction, recreate_selection_widget, out_of_bounds); |
| + MoveSelectionWidget(direction, recreate_selection_widget, |
| + out_of_bounds, animate); |
| return out_of_bounds; |
| } |
| @@ -289,6 +300,22 @@ bool WindowGrid::Contains(const aura::Window* window) const { |
| window_list_.end(); |
| } |
| +void WindowGrid::FilterItems(const base::string16& pattern) { |
| + has_active_item_ = false; |
| + base::i18n::FixedPatternStringSearchIgnoringCaseAndAccents finder(pattern); |
| + for (ScopedVector<WindowSelectorItem>::iterator iter = window_list_.begin(); |
| + iter != window_list_.end(); iter++) { |
| + if (finder.Search((*iter)->SelectionWindow()->title(), NULL, NULL)) { |
| + (*iter)->SetDimmed(false); |
| + has_active_item_ = true; |
| + } else { |
| + (*iter)->SetDimmed(true); |
| + if (selection_widget_ && SelectedWindow() == *iter) |
| + selection_widget_.reset(); |
| + } |
| + } |
| +} |
| + |
| void WindowGrid::OnWindowDestroying(aura::Window* window) { |
| window->RemoveObserver(this); |
| observed_windows_.erase(window); |
| @@ -383,7 +410,8 @@ void WindowGrid::InitSelectionWidget(WindowSelector::Direction direction) { |
| void WindowGrid::MoveSelectionWidget(WindowSelector::Direction direction, |
| bool recreate_selection_widget, |
| - bool out_of_bounds) { |
| + bool out_of_bounds, |
| + bool animate) { |
| // If the selection widget is already active, fade it out in the selection |
| // direction. |
| if (selection_widget_ && (recreate_selection_widget || out_of_bounds)) { |
| @@ -420,7 +448,7 @@ void WindowGrid::MoveSelectionWidget(WindowSelector::Direction direction, |
| SelectedWindow()->SendFocusAlert(); |
| // The selection widget is moved to the newly selected item in the same |
| // grid. |
| - MoveSelectionWidgetToTarget(true); |
| + MoveSelectionWidgetToTarget(animate); |
| } |
| void WindowGrid::MoveSelectionWidgetToTarget(bool animate) { |