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

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

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 #ifndef ASH_WM_OVERVIEW_WINDOW_GRID_H_ 5 #ifndef ASH_WM_OVERVIEW_WINDOW_GRID_H_
6 #define ASH_WM_OVERVIEW_WINDOW_GRID_H_ 6 #define ASH_WM_OVERVIEW_WINDOW_GRID_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <set> 11 #include <set>
12 #include <vector> 12 #include <vector>
13 13
14 #include "ash/common/wm/wm_window_observer.h" 14 #include "ash/common/wm_window_observer.h"
15 #include "ash/wm/overview/window_selector.h" 15 #include "ash/wm/overview/window_selector.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/scoped_vector.h" 17 #include "base/memory/scoped_vector.h"
18 18
19 namespace views { 19 namespace views {
20 class Widget; 20 class Widget;
21 } 21 }
22 22
23 namespace ash { 23 namespace ash {
24 24
(...skipping 12 matching lines...) Expand all
37 // +-------+ 37 // +-------+
38 // | 6 | 38 // | 6 |
39 // +-------+ 39 // +-------+
40 // Example sequences: 40 // Example sequences:
41 // - Going right to left 41 // - Going right to left
42 // 0, 1, 2, 3, 4, 5, 6 42 // 0, 1, 2, 3, 4, 5, 6
43 // - Going "top" to "bottom" 43 // - Going "top" to "bottom"
44 // 0, 3, 6, 1, 4, 2, 5 44 // 0, 3, 6, 1, 4, 2, 5
45 // The selector is switched to the next window grid (if available) or wrapped if 45 // The selector is switched to the next window grid (if available) or wrapped if
46 // it reaches the end of its movement sequence. 46 // it reaches the end of its movement sequence.
47 class ASH_EXPORT WindowGrid : public wm::WmWindowObserver { 47 class ASH_EXPORT WindowGrid : public WmWindowObserver {
48 public: 48 public:
49 WindowGrid(wm::WmWindow* root_window, 49 WindowGrid(WmWindow* root_window,
50 const std::vector<wm::WmWindow*>& window_list, 50 const std::vector<WmWindow*>& window_list,
51 WindowSelector* window_selector); 51 WindowSelector* window_selector);
52 ~WindowGrid() override; 52 ~WindowGrid() override;
53 53
54 // Prepares the windows in this grid for overview. This will restore all 54 // Prepares the windows in this grid for overview. This will restore all
55 // minimized windows and ensure they are visible. 55 // minimized windows and ensure they are visible.
56 void PrepareForOverview(); 56 void PrepareForOverview();
57 57
58 // Positions all the windows in the grid. 58 // Positions all the windows in the grid.
59 void PositionWindows(bool animate); 59 void PositionWindows(bool animate);
60 60
61 // Updates |selected_index_| according to the specified |direction| and calls 61 // Updates |selected_index_| according to the specified |direction| and calls
62 // MoveSelectionWidget(). Returns |true| if the new selection index is out of 62 // MoveSelectionWidget(). Returns |true| if the new selection index is out of
63 // this window grid bounds. 63 // this window grid bounds.
64 bool Move(WindowSelector::Direction direction, bool animate); 64 bool Move(WindowSelector::Direction direction, bool animate);
65 65
66 // Returns the target selected window, or NULL if there is none selected. 66 // Returns the target selected window, or NULL if there is none selected.
67 WindowSelectorItem* SelectedWindow() const; 67 WindowSelectorItem* SelectedWindow() const;
68 68
69 // Returns true if a window is contained in any of the WindowSelectorItems 69 // Returns true if a window is contained in any of the WindowSelectorItems
70 // this grid owns. 70 // this grid owns.
71 bool Contains(const wm::WmWindow* window) const; 71 bool Contains(const WmWindow* window) const;
72 72
73 // Dims the items whose titles do not contain |pattern| and prevents their 73 // Dims the items whose titles do not contain |pattern| and prevents their
74 // selection. The pattern has its accents removed and is converted to 74 // selection. The pattern has its accents removed and is converted to
75 // lowercase in a l10n sensitive context. 75 // lowercase in a l10n sensitive context.
76 // If |pattern| is empty, no item is dimmed. 76 // If |pattern| is empty, no item is dimmed.
77 void FilterItems(const base::string16& pattern); 77 void FilterItems(const base::string16& pattern);
78 78
79 // Returns true if the grid has no more windows. 79 // Returns true if the grid has no more windows.
80 bool empty() const { return window_list_.empty(); } 80 bool empty() const { return window_list_.empty(); }
81 81
82 // Returns how many window selector items are in the grid. 82 // Returns how many window selector items are in the grid.
83 size_t size() const { return window_list_.size(); } 83 size_t size() const { return window_list_.size(); }
84 84
85 // Returns true if the selection widget is active. 85 // Returns true if the selection widget is active.
86 bool is_selecting() const { return selection_widget_ != nullptr; } 86 bool is_selecting() const { return selection_widget_ != nullptr; }
87 87
88 // Returns the root window in which the grid displays the windows. 88 // Returns the root window in which the grid displays the windows.
89 const wm::WmWindow* root_window() const { return root_window_; } 89 const WmWindow* root_window() const { return root_window_; }
90 90
91 const std::vector<WindowSelectorItem*>& window_list() const { 91 const std::vector<WindowSelectorItem*>& window_list() const {
92 return window_list_.get(); 92 return window_list_.get();
93 } 93 }
94 94
95 // wm::WmWindowObserver: 95 // WmWindowObserver:
96 void OnWindowDestroying(wm::WmWindow* window) override; 96 void OnWindowDestroying(WmWindow* window) override;
97 // TODO(flackr): Handle window bounds changed in WindowSelectorItem. 97 // TODO(flackr): Handle window bounds changed in WindowSelectorItem.
98 void OnWindowBoundsChanged(wm::WmWindow* window, 98 void OnWindowBoundsChanged(WmWindow* window,
99 const gfx::Rect& old_bounds, 99 const gfx::Rect& old_bounds,
100 const gfx::Rect& new_bounds) override; 100 const gfx::Rect& new_bounds) override;
101 101
102 private: 102 private:
103 friend class WindowSelectorTest; 103 friend class WindowSelectorTest;
104 104
105 // Internal function to initialize the selection widget. 105 // Internal function to initialize the selection widget.
106 void InitSelectionWidget(WindowSelector::Direction direction); 106 void InitSelectionWidget(WindowSelector::Direction direction);
107 107
108 // Moves the selection widget to the specified |direction|. 108 // Moves the selection widget to the specified |direction|.
109 void MoveSelectionWidget(WindowSelector::Direction direction, 109 void MoveSelectionWidget(WindowSelector::Direction direction,
110 bool recreate_selection_widget, 110 bool recreate_selection_widget,
111 bool out_of_bounds, 111 bool out_of_bounds,
112 bool animate); 112 bool animate);
113 113
114 // Moves the selection widget to the targeted window. 114 // Moves the selection widget to the targeted window.
115 void MoveSelectionWidgetToTarget(bool animate); 115 void MoveSelectionWidgetToTarget(bool animate);
116 116
117 // Returns the target bounds of the currently selected item. 117 // Returns the target bounds of the currently selected item.
118 const gfx::Rect GetSelectionBounds() const; 118 const gfx::Rect GetSelectionBounds() const;
119 119
120 // Root window the grid is in. 120 // Root window the grid is in.
121 wm::WmWindow* root_window_; 121 WmWindow* root_window_;
122 122
123 // Pointer to the window selector that spawned this grid. 123 // Pointer to the window selector that spawned this grid.
124 WindowSelector* window_selector_; 124 WindowSelector* window_selector_;
125 125
126 // Vector containing all the windows in this grid. 126 // Vector containing all the windows in this grid.
127 ScopedVector<WindowSelectorItem> window_list_; 127 ScopedVector<WindowSelectorItem> window_list_;
128 128
129 // Vector containing the observed windows. 129 // Vector containing the observed windows.
130 std::set<wm::WmWindow*> observed_windows_; 130 std::set<WmWindow*> observed_windows_;
131 131
132 // Widget that indicates to the user which is the selected window. 132 // Widget that indicates to the user which is the selected window.
133 std::unique_ptr<views::Widget> selection_widget_; 133 std::unique_ptr<views::Widget> selection_widget_;
134 134
135 // Current selected window position. 135 // Current selected window position.
136 size_t selected_index_; 136 size_t selected_index_;
137 137
138 // Number of columns in the grid. 138 // Number of columns in the grid.
139 size_t num_columns_; 139 size_t num_columns_;
140 140
141 DISALLOW_COPY_AND_ASSIGN(WindowGrid); 141 DISALLOW_COPY_AND_ASSIGN(WindowGrid);
142 }; 142 };
143 143
144 } // namespace ash 144 } // namespace ash
145 145
146 #endif // ASH_WM_OVERVIEW_WINDOW_GRID_H_ 146 #endif // ASH_WM_OVERVIEW_WINDOW_GRID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698