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

Side by Side Diff: ash/common/wm/panels/panel_layout_manager.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_PANELS_PANEL_LAYOUT_MANAGER_H_ 5 #ifndef ASH_COMMON_WM_PANELS_PANEL_LAYOUT_MANAGER_H_
6 #define ASH_COMMON_WM_PANELS_PANEL_LAYOUT_MANAGER_H_ 6 #define ASH_COMMON_WM_PANELS_PANEL_LAYOUT_MANAGER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <memory> 9 #include <memory>
10 10
11 #include "ash/ash_export.h" 11 #include "ash/ash_export.h"
12 #include "ash/common/wm/shelf/wm_shelf_observer.h" 12 #include "ash/common/wm/shelf/wm_shelf_observer.h"
13 #include "ash/common/wm/window_state_observer.h" 13 #include "ash/common/wm/window_state_observer.h"
14 #include "ash/common/wm/wm_activation_observer.h" 14 #include "ash/common/wm_activation_observer.h"
15 #include "ash/common/wm/wm_display_observer.h" 15 #include "ash/common/wm_display_observer.h"
16 #include "ash/common/wm/wm_layout_manager.h" 16 #include "ash/common/wm_layout_manager.h"
17 #include "ash/common/wm/wm_overview_mode_observer.h" 17 #include "ash/common/wm_overview_mode_observer.h"
18 #include "ash/common/wm/wm_root_window_controller_observer.h" 18 #include "ash/common/wm_root_window_controller_observer.h"
19 #include "ash/common/wm/wm_window_observer.h" 19 #include "ash/common/wm_window_observer.h"
20 #include "ash/common/wm/wm_window_tracker.h" 20 #include "ash/common/wm_window_tracker.h"
21 #include "base/compiler_specific.h" 21 #include "base/compiler_specific.h"
22 #include "base/macros.h" 22 #include "base/macros.h"
23 #include "base/memory/weak_ptr.h" 23 #include "base/memory/weak_ptr.h"
24 #include "ui/keyboard/keyboard_controller.h" 24 #include "ui/keyboard/keyboard_controller.h"
25 #include "ui/keyboard/keyboard_controller_observer.h" 25 #include "ui/keyboard/keyboard_controller_observer.h"
26 26
27 namespace aura { 27 namespace aura {
28 class Window; 28 class Window;
29 } 29 }
30 30
(...skipping 18 matching lines...) Expand all
49 // PanelLayoutManager is responsible for organizing panels within the 49 // PanelLayoutManager is responsible for organizing panels within the
50 // workspace. It is associated with a specific container window (i.e. 50 // workspace. It is associated with a specific container window (i.e.
51 // kShellWindowId_PanelContainer) and controls the layout of any windows 51 // kShellWindowId_PanelContainer) and controls the layout of any windows
52 // added to that container. 52 // added to that container.
53 // 53 //
54 // The constructor takes a |panel_container| argument which is expected to set 54 // The constructor takes a |panel_container| argument which is expected to set
55 // its layout manager to this instance, e.g.: 55 // its layout manager to this instance, e.g.:
56 // panel_container->SetLayoutManager(new PanelLayoutManager(panel_container)); 56 // panel_container->SetLayoutManager(new PanelLayoutManager(panel_container));
57 57
58 class ASH_EXPORT PanelLayoutManager 58 class ASH_EXPORT PanelLayoutManager
59 : public wm::WmLayoutManager, 59 : public WmLayoutManager,
60 public wm::WindowStateObserver, 60 public wm::WindowStateObserver,
61 public wm::WmActivationObserver, 61 public WmActivationObserver,
62 public wm::WmDisplayObserver, 62 public WmDisplayObserver,
63 public wm::WmOverviewModeObserver, 63 public WmOverviewModeObserver,
64 public wm::WmRootWindowControllerObserver, 64 public WmRootWindowControllerObserver,
65 public wm::WmWindowObserver, 65 public WmWindowObserver,
66 public keyboard::KeyboardControllerObserver, 66 public keyboard::KeyboardControllerObserver,
67 public wm::WmShelfObserver { 67 public wm::WmShelfObserver {
68 public: 68 public:
69 explicit PanelLayoutManager(wm::WmWindow* panel_container); 69 explicit PanelLayoutManager(WmWindow* panel_container);
70 ~PanelLayoutManager() override; 70 ~PanelLayoutManager() override;
71 71
72 // Returns the PanelLayoutManager in the specified hierarchy. This searches 72 // Returns the PanelLayoutManager in the specified hierarchy. This searches
73 // from the root of |window|. 73 // from the root of |window|.
74 static PanelLayoutManager* Get(wm::WmWindow* window); 74 static PanelLayoutManager* Get(WmWindow* window);
75 75
76 // Call Shutdown() before deleting children of panel_container. 76 // Call Shutdown() before deleting children of panel_container.
77 void Shutdown(); 77 void Shutdown();
78 78
79 void StartDragging(wm::WmWindow* panel); 79 void StartDragging(WmWindow* panel);
80 void FinishDragging(); 80 void FinishDragging();
81 81
82 void ToggleMinimize(wm::WmWindow* panel); 82 void ToggleMinimize(WmWindow* panel);
83 83
84 // Hide / Show the panel callout widgets. 84 // Hide / Show the panel callout widgets.
85 void SetShowCalloutWidgets(bool show); 85 void SetShowCalloutWidgets(bool show);
86 86
87 // Returns the callout widget (arrow) for |panel|. 87 // Returns the callout widget (arrow) for |panel|.
88 views::Widget* GetCalloutWidgetForPanel(wm::WmWindow* panel); 88 views::Widget* GetCalloutWidgetForPanel(WmWindow* panel);
89 89
90 wm::WmShelf* shelf() { return shelf_; } 90 wm::WmShelf* shelf() { return shelf_; }
91 void SetShelf(wm::WmShelf* shelf); 91 void SetShelf(wm::WmShelf* shelf);
92 92
93 // Overridden from wm::WmLayoutManager 93 // Overridden from WmLayoutManager
94 void OnWindowResized() override; 94 void OnWindowResized() override;
95 void OnWindowAddedToLayout(wm::WmWindow* child) override; 95 void OnWindowAddedToLayout(WmWindow* child) override;
96 void OnWillRemoveWindowFromLayout(wm::WmWindow* child) override; 96 void OnWillRemoveWindowFromLayout(WmWindow* child) override;
97 void OnWindowRemovedFromLayout(wm::WmWindow* child) override; 97 void OnWindowRemovedFromLayout(WmWindow* child) override;
98 void OnChildWindowVisibilityChanged(wm::WmWindow* child, 98 void OnChildWindowVisibilityChanged(WmWindow* child, bool visibile) override;
99 bool visibile) override; 99 void SetChildBounds(WmWindow* child,
100 void SetChildBounds(wm::WmWindow* child,
101 const gfx::Rect& requested_bounds) override; 100 const gfx::Rect& requested_bounds) override;
102 101
103 // Overridden from wm::WmOverviewModeObserver 102 // Overridden from WmOverviewModeObserver
104 void OnOverviewModeEnded() override; 103 void OnOverviewModeEnded() override;
105 104
106 // Overridden from wm::WmRootWindowControllerObserver 105 // Overridden from WmRootWindowControllerObserver
107 void OnShelfAlignmentChanged() override; 106 void OnShelfAlignmentChanged() override;
108 107
109 // Overridden from wm::WmWindowObserver 108 // Overridden from WmWindowObserver
110 void OnWindowPropertyChanged(wm::WmWindow* window, 109 void OnWindowPropertyChanged(WmWindow* window,
111 wm::WmWindowProperty property) override; 110 WmWindowProperty property) override;
112 111
113 // Overridden from wm::WindowStateObserver 112 // Overridden from wm::WindowStateObserver
114 void OnPostWindowStateTypeChange(wm::WindowState* window_state, 113 void OnPostWindowStateTypeChange(wm::WindowState* window_state,
115 wm::WindowStateType old_type) override; 114 wm::WindowStateType old_type) override;
116 115
117 // Overridden from wm::WmActivationObserver 116 // Overridden from WmActivationObserver
118 void OnWindowActivated(wm::WmWindow* gained_active, 117 void OnWindowActivated(WmWindow* gained_active,
119 wm::WmWindow* lost_active) override; 118 WmWindow* lost_active) override;
120 119
121 // Overridden from WindowTreeHostManager::Observer 120 // Overridden from WindowTreeHostManager::Observer
122 void OnDisplayConfigurationChanged() override; 121 void OnDisplayConfigurationChanged() override;
123 122
124 // Overridden from wm::WmShelfObserver 123 // Overridden from wm::WmShelfObserver
125 void WillChangeVisibilityState(ShelfVisibilityState new_state) override; 124 void WillChangeVisibilityState(ShelfVisibilityState new_state) override;
126 void OnShelfIconPositionsChanged() override; 125 void OnShelfIconPositionsChanged() override;
127 126
128 private: 127 private:
129 friend class PanelLayoutManagerTest; 128 friend class PanelLayoutManagerTest;
130 friend class PanelWindowResizerTest; 129 friend class PanelWindowResizerTest;
131 friend class DockedWindowResizerTest; 130 friend class DockedWindowResizerTest;
132 friend class DockedWindowLayoutManagerTest; 131 friend class DockedWindowLayoutManagerTest;
133 friend class WorkspaceControllerTest; 132 friend class WorkspaceControllerTest;
134 friend class AcceleratorControllerTest; 133 friend class AcceleratorControllerTest;
135 134
136 views::Widget* CreateCalloutWidget(); 135 views::Widget* CreateCalloutWidget();
137 136
138 struct ASH_EXPORT PanelInfo { 137 struct ASH_EXPORT PanelInfo {
139 PanelInfo() : window(NULL), callout_widget(NULL), slide_in(false) {} 138 PanelInfo() : window(NULL), callout_widget(NULL), slide_in(false) {}
140 139
141 bool operator==(const wm::WmWindow* other_window) const { 140 bool operator==(const WmWindow* other_window) const {
142 return window == other_window; 141 return window == other_window;
143 } 142 }
144 143
145 // Returns |callout_widget| as a widget. Used by tests. 144 // Returns |callout_widget| as a widget. Used by tests.
146 views::Widget* CalloutWidget(); 145 views::Widget* CalloutWidget();
147 146
148 // A weak pointer to the panel window. 147 // A weak pointer to the panel window.
149 wm::WmWindow* window; 148 WmWindow* window;
150 149
151 // The callout widget for this panel. This pointer must be managed 150 // The callout widget for this panel. This pointer must be managed
152 // manually as this structure is used in a std::list. See 151 // manually as this structure is used in a std::list. See
153 // http://www.chromium.org/developers/smart-pointer-guidelines 152 // http://www.chromium.org/developers/smart-pointer-guidelines
154 PanelCalloutWidget* callout_widget; 153 PanelCalloutWidget* callout_widget;
155 154
156 // True on new and restored panel windows until the panel has been 155 // True on new and restored panel windows until the panel has been
157 // positioned. The first time Relayout is called the panel will be shown, 156 // positioned. The first time Relayout is called the panel will be shown,
158 // and slide into position and this will be set to false. 157 // and slide into position and this will be set to false.
159 bool slide_in; 158 bool slide_in;
160 }; 159 };
161 160
162 typedef std::list<PanelInfo> PanelList; 161 typedef std::list<PanelInfo> PanelList;
163 162
164 void MinimizePanel(wm::WmWindow* panel); 163 void MinimizePanel(WmWindow* panel);
165 void RestorePanel(wm::WmWindow* panel); 164 void RestorePanel(WmWindow* panel);
166 165
167 // Called whenever the panel layout might change. 166 // Called whenever the panel layout might change.
168 void Relayout(); 167 void Relayout();
169 168
170 // Called whenever the panel stacking order needs to be updated (e.g. focus 169 // Called whenever the panel stacking order needs to be updated (e.g. focus
171 // changes or a panel is moved). 170 // changes or a panel is moved).
172 void UpdateStacking(wm::WmWindow* active_panel); 171 void UpdateStacking(WmWindow* active_panel);
173 172
174 // Update the callout arrows for all managed panels. 173 // Update the callout arrows for all managed panels.
175 void UpdateCallouts(); 174 void UpdateCallouts();
176 175
177 // Overridden from keyboard::KeyboardControllerObserver: 176 // Overridden from keyboard::KeyboardControllerObserver:
178 void OnKeyboardBoundsChanging(const gfx::Rect& keyboard_bounds) override; 177 void OnKeyboardBoundsChanging(const gfx::Rect& keyboard_bounds) override;
179 178
180 // Parent window associated with this layout manager. 179 // Parent window associated with this layout manager.
181 wm::WmWindow* panel_container_; 180 WmWindow* panel_container_;
182 181
183 wm::WmRootWindowController* root_window_controller_; 182 WmRootWindowController* root_window_controller_;
184 183
185 // Protect against recursive calls to OnWindowAddedToLayout(). 184 // Protect against recursive calls to OnWindowAddedToLayout().
186 bool in_add_window_; 185 bool in_add_window_;
187 // Protect against recursive calls to Relayout(). 186 // Protect against recursive calls to Relayout().
188 bool in_layout_; 187 bool in_layout_;
189 // Indicates if the panel callout widget should be created. 188 // Indicates if the panel callout widget should be created.
190 bool show_callout_widgets_; 189 bool show_callout_widgets_;
191 // Ordered list of unowned pointers to panel windows. 190 // Ordered list of unowned pointers to panel windows.
192 PanelList panel_windows_; 191 PanelList panel_windows_;
193 // The panel being dragged. 192 // The panel being dragged.
194 wm::WmWindow* dragged_panel_; 193 WmWindow* dragged_panel_;
195 // The shelf we are observing for shelf icon changes. 194 // The shelf we are observing for shelf icon changes.
196 wm::WmShelf* shelf_; 195 wm::WmShelf* shelf_;
197 196
198 // When not NULL, the shelf is hidden (i.e. full screen) and this tracks the 197 // When not NULL, the shelf is hidden (i.e. full screen) and this tracks the
199 // set of panel windows which have been temporarily hidden and need to be 198 // set of panel windows which have been temporarily hidden and need to be
200 // restored when the shelf becomes visible again. 199 // restored when the shelf becomes visible again.
201 std::unique_ptr<wm::WmWindowTracker> restore_windows_on_shelf_visible_; 200 std::unique_ptr<WmWindowTracker> restore_windows_on_shelf_visible_;
202 201
203 // The last active panel. Used to maintain stacking order even if no panels 202 // The last active panel. Used to maintain stacking order even if no panels
204 // are currently focused. 203 // are currently focused.
205 wm::WmWindow* last_active_panel_; 204 WmWindow* last_active_panel_;
206 base::WeakPtrFactory<PanelLayoutManager> weak_factory_; 205 base::WeakPtrFactory<PanelLayoutManager> weak_factory_;
207 206
208 DISALLOW_COPY_AND_ASSIGN(PanelLayoutManager); 207 DISALLOW_COPY_AND_ASSIGN(PanelLayoutManager);
209 }; 208 };
210 209
211 } // namespace ash 210 } // namespace ash
212 211
213 #endif // ASH_COMMON_WM_PANELS_PANEL_LAYOUT_MANAGER_H_ 212 #endif // ASH_COMMON_WM_PANELS_PANEL_LAYOUT_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698