| OLD | NEW |
| 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_WM_PANELS_PANEL_LAYOUT_MANAGER_H_ | 5 #ifndef ASH_WM_PANELS_PANEL_LAYOUT_MANAGER_H_ |
| 6 #define ASH_WM_PANELS_PANEL_LAYOUT_MANAGER_H_ | 6 #define ASH_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/root_window_controller.h" | 12 #include "ash/root_window_controller.h" |
| 13 #include "ash/shelf/wm_shelf_observer.h" | 13 #include "ash/shelf/shelf_observer.h" |
| 14 #include "ash/shell_observer.h" | 14 #include "ash/shell_observer.h" |
| 15 #include "ash/wm/window_state_observer.h" | 15 #include "ash/wm/window_state_observer.h" |
| 16 #include "ash/wm_display_observer.h" | 16 #include "ash/wm_display_observer.h" |
| 17 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
| 18 #include "base/macros.h" | 18 #include "base/macros.h" |
| 19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
| 20 #include "base/scoped_observer.h" | 20 #include "base/scoped_observer.h" |
| 21 #include "ui/aura/layout_manager.h" | 21 #include "ui/aura/layout_manager.h" |
| 22 #include "ui/aura/window_observer.h" | 22 #include "ui/aura/window_observer.h" |
| 23 #include "ui/aura/window_tracker.h" | 23 #include "ui/aura/window_tracker.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 #include "ui/wm/public/activation_change_observer.h" | 26 #include "ui/wm/public/activation_change_observer.h" |
| 27 | 27 |
| 28 namespace gfx { | 28 namespace gfx { |
| 29 class Rect; | 29 class Rect; |
| 30 } | 30 } |
| 31 | 31 |
| 32 namespace views { | 32 namespace views { |
| 33 class Widget; | 33 class Widget; |
| 34 } | 34 } |
| 35 | 35 |
| 36 namespace ash { | 36 namespace ash { |
| 37 class PanelCalloutWidget; | 37 class PanelCalloutWidget; |
| 38 class WmShelf; | 38 class Shelf; |
| 39 | 39 |
| 40 namespace wm { | 40 namespace wm { |
| 41 class RootWindowController; | 41 class RootWindowController; |
| 42 } | 42 } |
| 43 | 43 |
| 44 // PanelLayoutManager is responsible for organizing panels within the | 44 // PanelLayoutManager is responsible for organizing panels within the |
| 45 // workspace. It is associated with a specific container window (i.e. | 45 // workspace. It is associated with a specific container window (i.e. |
| 46 // kShellWindowId_PanelContainer) and controls the layout of any windows | 46 // kShellWindowId_PanelContainer) and controls the layout of any windows |
| 47 // added to that container. | 47 // added to that container. |
| 48 // | 48 // |
| 49 // The constructor takes a |panel_container| argument which is expected to set | 49 // The constructor takes a |panel_container| argument which is expected to set |
| 50 // its layout manager to this instance, e.g.: | 50 // its layout manager to this instance, e.g.: |
| 51 // panel_container->SetLayoutManager(new PanelLayoutManager(panel_container)); | 51 // panel_container->SetLayoutManager(new PanelLayoutManager(panel_container)); |
| 52 | 52 |
| 53 class ASH_EXPORT PanelLayoutManager | 53 class ASH_EXPORT PanelLayoutManager |
| 54 : public aura::LayoutManager, | 54 : public aura::LayoutManager, |
| 55 public wm::WindowStateObserver, | 55 public wm::WindowStateObserver, |
| 56 public aura::client::ActivationChangeObserver, | 56 public aura::client::ActivationChangeObserver, |
| 57 public WmDisplayObserver, | 57 public WmDisplayObserver, |
| 58 public ShellObserver, | 58 public ShellObserver, |
| 59 public aura::WindowObserver, | 59 public aura::WindowObserver, |
| 60 public keyboard::KeyboardControllerObserver, | 60 public keyboard::KeyboardControllerObserver, |
| 61 public WmShelfObserver { | 61 public ShelfObserver { |
| 62 public: | 62 public: |
| 63 explicit PanelLayoutManager(WmWindow* panel_container); | 63 explicit PanelLayoutManager(WmWindow* panel_container); |
| 64 ~PanelLayoutManager() override; | 64 ~PanelLayoutManager() override; |
| 65 | 65 |
| 66 // Returns the PanelLayoutManager in the specified hierarchy. This searches | 66 // Returns the PanelLayoutManager in the specified hierarchy. This searches |
| 67 // from the root of |window|. | 67 // from the root of |window|. |
| 68 static PanelLayoutManager* Get(WmWindow* window); | 68 static PanelLayoutManager* Get(WmWindow* window); |
| 69 | 69 |
| 70 // Call Shutdown() before deleting children of panel_container. | 70 // Call Shutdown() before deleting children of panel_container. |
| 71 void Shutdown(); | 71 void Shutdown(); |
| 72 | 72 |
| 73 void StartDragging(WmWindow* panel); | 73 void StartDragging(WmWindow* panel); |
| 74 void FinishDragging(); | 74 void FinishDragging(); |
| 75 | 75 |
| 76 void ToggleMinimize(WmWindow* panel); | 76 void ToggleMinimize(WmWindow* panel); |
| 77 | 77 |
| 78 // Hide / Show the panel callout widgets. | 78 // Hide / Show the panel callout widgets. |
| 79 void SetShowCalloutWidgets(bool show); | 79 void SetShowCalloutWidgets(bool show); |
| 80 | 80 |
| 81 // Returns the callout widget (arrow) for |panel|. | 81 // Returns the callout widget (arrow) for |panel|. |
| 82 views::Widget* GetCalloutWidgetForPanel(WmWindow* panel); | 82 views::Widget* GetCalloutWidgetForPanel(WmWindow* panel); |
| 83 | 83 |
| 84 WmShelf* shelf() { return shelf_; } | 84 Shelf* shelf() { return shelf_; } |
| 85 void SetShelf(WmShelf* shelf); | 85 void SetShelf(Shelf* shelf); |
| 86 | 86 |
| 87 // aura::LayoutManager: | 87 // aura::LayoutManager: |
| 88 void OnWindowResized() override; | 88 void OnWindowResized() override; |
| 89 void OnWindowAddedToLayout(aura::Window* child) override; | 89 void OnWindowAddedToLayout(aura::Window* child) override; |
| 90 void OnWillRemoveWindowFromLayout(aura::Window* child) override; | 90 void OnWillRemoveWindowFromLayout(aura::Window* child) override; |
| 91 void OnWindowRemovedFromLayout(aura::Window* child) override; | 91 void OnWindowRemovedFromLayout(aura::Window* child) override; |
| 92 void OnChildWindowVisibilityChanged(aura::Window* child, | 92 void OnChildWindowVisibilityChanged(aura::Window* child, |
| 93 bool visible) override; | 93 bool visible) override; |
| 94 void SetChildBounds(aura::Window* child, | 94 void SetChildBounds(aura::Window* child, |
| 95 const gfx::Rect& requested_bounds) override; | 95 const gfx::Rect& requested_bounds) override; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 110 wm::WindowStateType old_type) override; | 110 wm::WindowStateType old_type) override; |
| 111 | 111 |
| 112 // aura::client::ActivationChangeObserver: | 112 // aura::client::ActivationChangeObserver: |
| 113 void OnWindowActivated(ActivationReason reason, | 113 void OnWindowActivated(ActivationReason reason, |
| 114 aura::Window* gained_active, | 114 aura::Window* gained_active, |
| 115 aura::Window* lost_active) override; | 115 aura::Window* lost_active) override; |
| 116 | 116 |
| 117 // WindowTreeHostManager::Observer: | 117 // WindowTreeHostManager::Observer: |
| 118 void OnDisplayConfigurationChanged() override; | 118 void OnDisplayConfigurationChanged() override; |
| 119 | 119 |
| 120 // WmShelfObserver: | 120 // ShelfObserver: |
| 121 void WillChangeVisibilityState(ShelfVisibilityState new_state) override; | 121 void WillChangeVisibilityState(ShelfVisibilityState new_state) override; |
| 122 void OnShelfIconPositionsChanged() override; | 122 void OnShelfIconPositionsChanged() override; |
| 123 | 123 |
| 124 private: | 124 private: |
| 125 friend class PanelLayoutManagerTest; | 125 friend class PanelLayoutManagerTest; |
| 126 friend class PanelWindowResizerTest; | 126 friend class PanelWindowResizerTest; |
| 127 friend class WorkspaceControllerTest; | 127 friend class WorkspaceControllerTest; |
| 128 friend class AcceleratorControllerTest; | 128 friend class AcceleratorControllerTest; |
| 129 | 129 |
| 130 views::Widget* CreateCalloutWidget(); | 130 views::Widget* CreateCalloutWidget(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 bool in_add_window_; | 181 bool in_add_window_; |
| 182 // Protect against recursive calls to Relayout(). | 182 // Protect against recursive calls to Relayout(). |
| 183 bool in_layout_; | 183 bool in_layout_; |
| 184 // Indicates if the panel callout widget should be created. | 184 // Indicates if the panel callout widget should be created. |
| 185 bool show_callout_widgets_; | 185 bool show_callout_widgets_; |
| 186 // Ordered list of unowned pointers to panel windows. | 186 // Ordered list of unowned pointers to panel windows. |
| 187 PanelList panel_windows_; | 187 PanelList panel_windows_; |
| 188 // The panel being dragged. | 188 // The panel being dragged. |
| 189 WmWindow* dragged_panel_; | 189 WmWindow* dragged_panel_; |
| 190 // The shelf we are observing for shelf icon changes. | 190 // The shelf we are observing for shelf icon changes. |
| 191 WmShelf* shelf_; | 191 Shelf* shelf_; |
| 192 | 192 |
| 193 // When not NULL, the shelf is hidden (i.e. full screen) and this tracks the | 193 // When not NULL, the shelf is hidden (i.e. full screen) and this tracks the |
| 194 // set of panel windows which have been temporarily hidden and need to be | 194 // set of panel windows which have been temporarily hidden and need to be |
| 195 // restored when the shelf becomes visible again. | 195 // restored when the shelf becomes visible again. |
| 196 std::unique_ptr<aura::WindowTracker> restore_windows_on_shelf_visible_; | 196 std::unique_ptr<aura::WindowTracker> restore_windows_on_shelf_visible_; |
| 197 | 197 |
| 198 // The last active panel. Used to maintain stacking order even if no panels | 198 // The last active panel. Used to maintain stacking order even if no panels |
| 199 // are currently focused. | 199 // are currently focused. |
| 200 WmWindow* last_active_panel_; | 200 WmWindow* last_active_panel_; |
| 201 | 201 |
| 202 ScopedObserver<keyboard::KeyboardController, | 202 ScopedObserver<keyboard::KeyboardController, |
| 203 keyboard::KeyboardControllerObserver> | 203 keyboard::KeyboardControllerObserver> |
| 204 keyboard_observer_; | 204 keyboard_observer_; |
| 205 | 205 |
| 206 base::WeakPtrFactory<PanelLayoutManager> weak_factory_; | 206 base::WeakPtrFactory<PanelLayoutManager> weak_factory_; |
| 207 | 207 |
| 208 DISALLOW_COPY_AND_ASSIGN(PanelLayoutManager); | 208 DISALLOW_COPY_AND_ASSIGN(PanelLayoutManager); |
| 209 }; | 209 }; |
| 210 | 210 |
| 211 } // namespace ash | 211 } // namespace ash |
| 212 | 212 |
| 213 #endif // ASH_WM_PANELS_PANEL_LAYOUT_MANAGER_H_ | 213 #endif // ASH_WM_PANELS_PANEL_LAYOUT_MANAGER_H_ |
| OLD | NEW |