Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef ASH_WM_OVERVIEW_WINDOW_GRID_H_ | |
| 6 #define ASH_WM_OVERVIEW_WINDOW_GRID_H_ | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "ash/wm/overview/window_selector.h" | |
| 11 #include "base/macros.h" | |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 | |
| 14 namespace aura { | |
| 15 class Window; | |
| 16 } | |
| 17 | |
| 18 namespace views { | |
| 19 class Widget; | |
| 20 } | |
| 21 | |
| 22 namespace ash { | |
| 23 | |
| 24 class WindowSelectorItem; | |
| 25 | |
| 26 // Represents a grid of windows in the Overview Mode in a particular root | |
| 27 // window, and manages a selection widget that can be moved with the arrow keys. | |
| 28 // The idea behind the movement strategy is that it should be possible to access | |
| 29 // any window pressing a given arrow key repeatedly. | |
| 30 // +-------+ +-------+ +-------+ | |
| 31 // | 0 | | 1 | | 2 | | |
| 32 // | | | | | | | |
|
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.
| |
| 33 // +-------+ +-------+ +-------+ | |
| 34 // +-------+ +-------+ +-------+ | |
| 35 // | 3 | | 4 | | 5 | | |
| 36 // | | | | | | | |
| 37 // +-------+ +-------+ +-------+ | |
| 38 // +-------+ | |
| 39 // | 6 | | |
| 40 // | | | |
| 41 // +-------+ | |
| 42 // Example sequences: | |
| 43 // - 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.
| |
| 44 // 0, 1, 2, 3, 4, 5, 6 | |
| 45 // - Going down->up | |
| 46 // 0, 3, 6, 1, 4, 2, 5 | |
| 47 // The selector is switched to the next window grid (if available) or wrapped if | |
| 48 // it reaches the end of its movement sequence. | |
| 49 class WindowGrid { | |
| 50 public: | |
| 51 WindowGrid(aura::Window* root_window, | |
| 52 const std::vector<WindowSelectorItem*>& window_list); | |
| 53 ~WindowGrid(); | |
| 54 | |
| 55 // Moves the selection widget to the specified |direction|. Returns true if, | |
| 56 // after moving, the widget is out of bounds. | |
| 57 bool Move(WindowSelector::Direction direction); | |
| 58 | |
| 59 // Positions all the windows in the grid. | |
| 60 void PositionWindows(bool animate); | |
| 61 | |
| 62 // Removes |window| from the grid, if present. | |
| 63 // 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.
| |
| 64 void RemoveWindow(aura::Window* window); | |
| 65 | |
| 66 // Returns the target selected window, or NULL if there is none selected. | |
| 67 WindowSelectorItem* SelectedWindow() const; | |
| 68 | |
| 69 // Returns true if the grid has no more windows. | |
| 70 bool empty() const { return window_list_.empty(); } | |
| 71 | |
| 72 // Returns true if the selection widget is active. | |
| 73 bool is_selecting() const { return selection_widget_ != NULL; } | |
| 74 | |
| 75 // Returns the root window in which the grid displays the windows. | |
| 76 const aura::Window* root_window() const { return root_window_; } | |
| 77 | |
| 78 const std::vector<WindowSelectorItem*>& window_list() const { | |
| 79 return window_list_.get(); | |
| 80 } | |
| 81 | |
| 82 private: | |
| 83 // Internal function to initialize the selection widget. | |
| 84 void InitSelectionWidget(WindowSelector::Direction direction); | |
| 85 | |
| 86 // Updates |selected_index_| according to the specified |direction|. Returns | |
| 87 // |true| if the new selection index is out of this window grid bounds. | |
| 88 bool MoveSelectedIndex(WindowSelector::Direction direction); | |
| 89 | |
| 90 // Returns the target bounds of the currently selected item. | |
| 91 const gfx::Rect GetSelectionBounds() const; | |
| 92 | |
| 93 // Root window the grid is in. | |
| 94 aura::Window* root_window_; | |
| 95 | |
| 96 // Vector containing all the windows in this grid. | |
| 97 ScopedVector<WindowSelectorItem> window_list_; | |
| 98 | |
| 99 // Widget that indicates to the user which is the selected window. | |
| 100 scoped_ptr<views::Widget> selection_widget_; | |
| 101 | |
| 102 // Current selected window position. | |
| 103 size_t selected_index_; | |
| 104 | |
| 105 // Number of columns in the grid. | |
| 106 size_t num_columns_; | |
| 107 | |
| 108 DISALLOW_COPY_AND_ASSIGN(WindowGrid); | |
| 109 }; | |
| 110 | |
| 111 } // namespace ash | |
| 112 | |
| 113 #endif // ASH_WM_OVERVIEW_WINDOW_GRID_H_ | |
| OLD | NEW |