Chromium Code Reviews| Index: ash/wm/overview/window_grid.h |
| diff --git a/ash/wm/overview/window_grid.h b/ash/wm/overview/window_grid.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0513c50e90bba39cf42919bbd469063cad391a38 |
| --- /dev/null |
| +++ b/ash/wm/overview/window_grid.h |
| @@ -0,0 +1,113 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef ASH_WM_OVERVIEW_WINDOW_GRID_H_ |
| +#define ASH_WM_OVERVIEW_WINDOW_GRID_H_ |
| + |
| +#include <vector> |
| + |
| +#include "ash/wm/overview/window_selector.h" |
| +#include "base/macros.h" |
| +#include "base/memory/scoped_ptr.h" |
| + |
| +namespace aura { |
| +class Window; |
| +} |
| + |
| +namespace views { |
| +class Widget; |
| +} |
| + |
| +namespace ash { |
| + |
| +class WindowSelectorItem; |
| + |
| +// Represents a grid of windows in the Overview Mode in a particular root |
| +// window, and manages a selection widget that can be moved with the arrow keys. |
| +// The idea behind the movement strategy is that it should be possible to access |
| +// any window pressing a given arrow key repeatedly. |
| +// +-------+ +-------+ +-------+ |
| +// | 0 | | 1 | | 2 | |
| +// | | | | | | |
|
flackr
2014/06/03 17:12:07
nit: These boxes probably don't need the extra emp
Nina
2014/06/04 20:21:13
Done.
flackr
2014/06/04 22:25:06
Sorry, to be specific, I meant you could remove li
Nina
2014/06/05 18:04:34
Done.
|
| +// +-------+ +-------+ +-------+ |
| +// +-------+ +-------+ +-------+ |
| +// | 3 | | 4 | | 5 | |
| +// | | | | | | |
| +// +-------+ +-------+ +-------+ |
| +// +-------+ |
| +// | 6 | |
| +// | | |
| +// +-------+ |
| +// Example sequences: |
| +// - Going right->left |
|
flackr
2014/06/03 17:12:07
nit: "Going left to right:" and "Going "top" to "b
Nina
2014/06/04 20:21:13
Done.
|
| +// 0, 1, 2, 3, 4, 5, 6 |
| +// - Going down->up |
| +// 0, 3, 6, 1, 4, 2, 5 |
| +// The selector is switched to the next window grid (if available) or wrapped if |
| +// it reaches the end of its movement sequence. |
| +class WindowGrid { |
| + public: |
| + WindowGrid(aura::Window* root_window, |
| + const std::vector<WindowSelectorItem*>& window_list); |
| + ~WindowGrid(); |
| + |
| + // Moves the selection widget to the specified |direction|. Returns true if, |
| + // after moving, the widget is out of bounds. |
| + bool Move(WindowSelector::Direction direction); |
| + |
| + // Positions all the windows in the grid. |
| + void PositionWindows(bool animate); |
| + |
| + // Removes |window| from the grid, if present. |
| + // RemoveWindow() repositions the items in the grid if necessary. |
|
flackr
2014/06/03 17:12:07
No need to mention method name since it's the comm
Nina
2014/06/04 20:21:13
Comment noted, this code has been removed.
|
| + void RemoveWindow(aura::Window* window); |
| + |
| + // Returns the target selected window, or NULL if there is none selected. |
| + WindowSelectorItem* SelectedWindow() const; |
| + |
| + // Returns true if the grid has no more windows. |
| + bool empty() const { return window_list_.empty(); } |
| + |
| + // Returns true if the selection widget is active. |
| + bool is_selecting() const { return selection_widget_ != NULL; } |
| + |
| + // Returns the root window in which the grid displays the windows. |
| + const aura::Window* root_window() const { return root_window_; } |
| + |
| + const std::vector<WindowSelectorItem*>& window_list() const { |
| + return window_list_.get(); |
| + } |
| + |
| + private: |
| + // Internal function to initialize the selection widget. |
| + void InitSelectionWidget(WindowSelector::Direction direction); |
| + |
| + // Updates |selected_index_| according to the specified |direction|. Returns |
| + // |true| if the new selection index is out of this window grid bounds. |
| + bool MoveSelectedIndex(WindowSelector::Direction direction); |
| + |
| + // Returns the target bounds of the currently selected item. |
| + const gfx::Rect GetSelectionBounds() const; |
| + |
| + // Root window the grid is in. |
| + aura::Window* root_window_; |
| + |
| + // Vector containing all the windows in this grid. |
| + ScopedVector<WindowSelectorItem> window_list_; |
| + |
| + // Widget that indicates to the user which is the selected window. |
| + scoped_ptr<views::Widget> selection_widget_; |
| + |
| + // Current selected window position. |
| + size_t selected_index_; |
| + |
| + // Number of columns in the grid. |
| + size_t num_columns_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(WindowGrid); |
| +}; |
| + |
| +} // namespace ash |
| + |
| +#endif // ASH_WM_OVERVIEW_WINDOW_GRID_H_ |