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