| 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 #ifndef ASH_COMMON_WM_OVERVIEW_WINDOW_GRID_H_ | 5 #ifndef ASH_COMMON_WM_OVERVIEW_WINDOW_GRID_H_ |
| 6 #define ASH_COMMON_WM_OVERVIEW_WINDOW_GRID_H_ | 6 #define ASH_COMMON_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/overview/window_selector.h" | 14 #include "ash/common/wm/overview/window_selector.h" |
| 15 #include "ash/common/wm/window_state_observer.h" |
| 15 #include "ash/common/wm_window_observer.h" | 16 #include "ash/common/wm_window_observer.h" |
| 16 #include "base/macros.h" | 17 #include "base/macros.h" |
| 17 #include "base/memory/scoped_vector.h" | 18 #include "base/memory/scoped_vector.h" |
| 18 #include "base/scoped_observer.h" | 19 #include "base/scoped_observer.h" |
| 19 | 20 |
| 20 namespace views { | 21 namespace views { |
| 21 class Widget; | 22 class Widget; |
| 22 } | 23 } |
| 23 | 24 |
| 24 namespace wm { | 25 namespace wm { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 38 // +-------+ +-------+ +-------+ | 39 // +-------+ +-------+ +-------+ |
| 39 // +-------+ +-------+ +-------+ | 40 // +-------+ +-------+ +-------+ |
| 40 // | 3 | | 4 | | 5 | | 41 // | 3 | | 4 | | 5 | |
| 41 // +-------+ +-------+ +-------+ | 42 // +-------+ +-------+ +-------+ |
| 42 // +-------+ | 43 // +-------+ |
| 43 // | 6 | | 44 // | 6 | |
| 44 // +-------+ | 45 // +-------+ |
| 45 // Example sequences: | 46 // Example sequences: |
| 46 // - Going right to left | 47 // - Going right to left |
| 47 // 0, 1, 2, 3, 4, 5, 6 | 48 // 0, 1, 2, 3, 4, 5, 6 |
| 48 // - Going "top" to "bottom" | |
| 49 // 0, 3, 6, 1, 4, 2, 5 | |
| 50 // The selector is switched to the next window grid (if available) or wrapped if | 49 // The selector is switched to the next window grid (if available) or wrapped if |
| 51 // it reaches the end of its movement sequence. | 50 // it reaches the end of its movement sequence. |
| 52 class ASH_EXPORT WindowGrid : public WmWindowObserver { | 51 class ASH_EXPORT WindowGrid : public WmWindowObserver, |
| 52 public wm::WindowStateObserver { |
| 53 public: | 53 public: |
| 54 WindowGrid(WmWindow* root_window, | 54 WindowGrid(WmWindow* root_window, |
| 55 const std::vector<WmWindow*>& window_list, | 55 const std::vector<WmWindow*>& window_list, |
| 56 WindowSelector* window_selector); | 56 WindowSelector* window_selector); |
| 57 ~WindowGrid() override; | 57 ~WindowGrid() override; |
| 58 | 58 |
| 59 // Exits overview mode, fading out the |shield_widget_| if necessary. | 59 // Exits overview mode, fading out the |shield_widget_| if necessary. |
| 60 void Shutdown(); | 60 void Shutdown(); |
| 61 | 61 |
| 62 // Prepares the windows in this grid for overview. This will restore all | 62 // Prepares the windows in this grid for overview. This will restore all |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 return window_list_.get(); | 116 return window_list_.get(); |
| 117 } | 117 } |
| 118 | 118 |
| 119 // WmWindowObserver: | 119 // WmWindowObserver: |
| 120 void OnWindowDestroying(WmWindow* window) override; | 120 void OnWindowDestroying(WmWindow* window) override; |
| 121 // TODO(flackr): Handle window bounds changed in WindowSelectorItem. | 121 // TODO(flackr): Handle window bounds changed in WindowSelectorItem. |
| 122 void OnWindowBoundsChanged(WmWindow* window, | 122 void OnWindowBoundsChanged(WmWindow* window, |
| 123 const gfx::Rect& old_bounds, | 123 const gfx::Rect& old_bounds, |
| 124 const gfx::Rect& new_bounds) override; | 124 const gfx::Rect& new_bounds) override; |
| 125 | 125 |
| 126 // wm::WindowStateObserver: |
| 127 void OnPostWindowStateTypeChange(wm::WindowState* window_state, |
| 128 wm::WindowStateType old_type) override; |
| 129 |
| 126 private: | 130 private: |
| 127 friend class WindowSelectorTest; | 131 friend class WindowSelectorTest; |
| 128 | 132 |
| 129 // Initializes the screen shield widget. | 133 // Initializes the screen shield widget. |
| 130 void InitShieldWidget(); | 134 void InitShieldWidget(); |
| 131 | 135 |
| 132 // Internal function to initialize the selection widget. | 136 // Internal function to initialize the selection widget. |
| 133 void InitSelectionWidget(WindowSelector::Direction direction); | 137 void InitSelectionWidget(WindowSelector::Direction direction); |
| 134 | 138 |
| 135 // Moves the selection widget to the specified |direction|. | 139 // Moves the selection widget to the specified |direction|. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 160 // Root window the grid is in. | 164 // Root window the grid is in. |
| 161 WmWindow* root_window_; | 165 WmWindow* root_window_; |
| 162 | 166 |
| 163 // Pointer to the window selector that spawned this grid. | 167 // Pointer to the window selector that spawned this grid. |
| 164 WindowSelector* window_selector_; | 168 WindowSelector* window_selector_; |
| 165 | 169 |
| 166 // Vector containing all the windows in this grid. | 170 // Vector containing all the windows in this grid. |
| 167 ScopedVector<WindowSelectorItem> window_list_; | 171 ScopedVector<WindowSelectorItem> window_list_; |
| 168 | 172 |
| 169 ScopedObserver<WmWindow, WindowGrid> window_observer_; | 173 ScopedObserver<WmWindow, WindowGrid> window_observer_; |
| 174 ScopedObserver<wm::WindowState, WindowGrid> window_state_observer_; |
| 170 | 175 |
| 171 // Widget that darkens the screen background. | 176 // Widget that darkens the screen background. |
| 172 std::unique_ptr<views::Widget> shield_widget_; | 177 std::unique_ptr<views::Widget> shield_widget_; |
| 173 | 178 |
| 174 // Widget that indicates to the user which is the selected window. | 179 // Widget that indicates to the user which is the selected window. |
| 175 std::unique_ptr<views::Widget> selection_widget_; | 180 std::unique_ptr<views::Widget> selection_widget_; |
| 176 | 181 |
| 177 // Shadow around the selector. | 182 // Shadow around the selector. |
| 178 std::unique_ptr<::wm::Shadow> selector_shadow_; | 183 std::unique_ptr<::wm::Shadow> selector_shadow_; |
| 179 | 184 |
| 180 // Current selected window position. | 185 // Current selected window position. |
| 181 size_t selected_index_; | 186 size_t selected_index_; |
| 182 | 187 |
| 183 // Number of columns in the grid. | 188 // Number of columns in the grid. |
| 184 size_t num_columns_; | 189 size_t num_columns_; |
| 185 | 190 |
| 186 // True only after all windows have been prepared for overview. | 191 // True only after all windows have been prepared for overview. |
| 187 bool prepared_for_overview_; | 192 bool prepared_for_overview_; |
| 188 | 193 |
| 189 DISALLOW_COPY_AND_ASSIGN(WindowGrid); | 194 DISALLOW_COPY_AND_ASSIGN(WindowGrid); |
| 190 }; | 195 }; |
| 191 | 196 |
| 192 } // namespace ash | 197 } // namespace ash |
| 193 | 198 |
| 194 #endif // ASH_COMMON_WM_OVERVIEW_WINDOW_GRID_H_ | 199 #endif // ASH_COMMON_WM_OVERVIEW_WINDOW_GRID_H_ |
| OLD | NEW |