Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 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_DOCK_DOCKED_WINDOW_LAYOUT_MANAGER_H_ | |
| 6 #define ASH_WM_DOCK_DOCKED_WINDOW_LAYOUT_MANAGER_H_ | |
| 7 | |
| 8 #include "ash/ash_export.h" | |
| 9 #include "ash/shelf/shelf_layout_manager_observer.h" | |
| 10 #include "ash/shell_observer.h" | |
| 11 #include "ash/wm/dock/dock_types.h" | |
| 12 #include "ash/wm/property_util.h" | |
| 13 #include "base/basictypes.h" | |
| 14 #include "base/compiler_specific.h" | |
| 15 #include "ui/aura/client/activation_change_observer.h" | |
| 16 #include "ui/aura/layout_manager.h" | |
| 17 #include "ui/aura/window_observer.h" | |
| 18 #include "ui/keyboard/keyboard_controller_observer.h" | |
| 19 | |
| 20 namespace aura { | |
| 21 class Window; | |
| 22 } | |
| 23 | |
| 24 namespace gfx { | |
| 25 class Point; | |
| 26 class Rect; | |
| 27 } | |
| 28 | |
| 29 namespace ash { | |
| 30 class Launcher; | |
| 31 | |
| 32 namespace internal { | |
| 33 class ShelfLayoutManager; | |
| 34 | |
| 35 // DockedWindowLayoutManager is responsible for organizing windows when they are | |
| 36 // docked to the side of a screen. It is associated with a specific container | |
| 37 // window (i.e. kShellWindowId_DockContainer) and controls the layout of any | |
| 38 // windows added to that container. | |
| 39 // | |
| 40 // The constructor takes a |dock_container| argument which is expected to set | |
| 41 // its layout manager to this instance, e.g.: | |
| 42 // dock_container->SetLayoutManager( | |
| 43 // new DockedWindowLayoutManager(dock_container)); | |
| 44 | |
| 45 class ASH_EXPORT DockedWindowLayoutManager | |
| 46 : public aura::LayoutManager, | |
|
sky
2013/06/12 21:50:17
BaseLayoutManager provides default implementation
varkha
2013/06/13 05:02:11
Looking at the BaseLayoutManager it deals with man
| |
| 47 public ash::ShellObserver, | |
| 48 public aura::WindowObserver, | |
| 49 public aura::client::ActivationChangeObserver, | |
| 50 public keyboard::KeyboardControllerObserver, | |
| 51 public ash::ShelfLayoutManagerObserver { | |
| 52 public: | |
| 53 explicit DockedWindowLayoutManager(aura::Window* dock_container); | |
| 54 virtual ~DockedWindowLayoutManager(); | |
| 55 | |
| 56 // Call Shutdown() before deleting children of dock_container. | |
|
sky
2013/06/12 21:50:17
This comment is misleading. AFAICT Shutdown() isn'
varkha
2013/06/13 05:02:11
I checked the logic and it seems that normal termi
| |
| 57 void Shutdown(); | |
| 58 | |
| 59 // Called by a DockedWindowResizer to update which window is being dragged. | |
| 60 void StartDragging(aura::Window* window); | |
| 61 void FinishDragging(); | |
| 62 | |
| 63 // Returns true if a window is touching the side of the screen | |
| 64 // unless when other windows are already docked on the other side or | |
| 65 // unless launcher (shelf) is aligned on the same side. | |
| 66 static bool ShouldWindowDock(aura::Window* window, | |
| 67 const gfx::Point& location); | |
| 68 | |
| 69 ash::Launcher* launcher() { return launcher_; } | |
| 70 void SetLauncher(ash::Launcher* launcher); | |
| 71 | |
| 72 // Used to snap docked windows to the side of screen during drag. | |
| 73 DockAlignment alignment() const { return alignment_; } | |
| 74 | |
| 75 // Currently dragged window should be able to dock on another screen | |
| 76 aura::Window* dragged_window() const { return dragged_window_;} | |
| 77 | |
| 78 // aura::LayoutManager: | |
| 79 virtual void OnWindowResized() OVERRIDE; | |
| 80 virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE; | |
| 81 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE; | |
| 82 virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE; | |
| 83 virtual void OnChildWindowVisibilityChanged(aura::Window* child, | |
| 84 bool visibile) OVERRIDE; | |
| 85 virtual void SetChildBounds(aura::Window* child, | |
| 86 const gfx::Rect& requested_bounds) OVERRIDE; | |
| 87 | |
| 88 // ash::ShellObserver: | |
| 89 virtual void OnShelfAlignmentChanged(aura::RootWindow* root_window) OVERRIDE; | |
| 90 | |
| 91 // aura::WindowObserver: | |
| 92 virtual void OnWindowPropertyChanged(aura::Window* window, | |
| 93 const void* key, | |
| 94 intptr_t old) OVERRIDE; | |
| 95 virtual void OnWindowVisibilityChanged(aura::Window* window, | |
| 96 bool visible) OVERRIDE; | |
| 97 | |
| 98 // aura::client::ActivationChangeObserver: | |
| 99 virtual void OnWindowActivated(aura::Window* gained_active, | |
| 100 aura::Window* lost_active) OVERRIDE; | |
| 101 | |
| 102 // ShelfLayoutManagerObserver: | |
| 103 virtual void WillChangeVisibilityState( | |
| 104 ShelfVisibilityState new_state) OVERRIDE; | |
| 105 | |
| 106 private: | |
| 107 friend class DockedWindowLayoutManagerTest; | |
| 108 friend class DockedWindowResizerTest; | |
| 109 | |
| 110 // Minimize / restore window and relayout. | |
| 111 void MinimizeWindow(aura::Window* window); | |
| 112 void RestoreWindow(aura::Window* window); | |
| 113 | |
| 114 // Called whenever the window layout might change. | |
| 115 void Relayout(); | |
| 116 | |
| 117 // Called whenever the window stacking order needs to be updated (e.g. focus | |
| 118 // changes or a window is moved). | |
| 119 void UpdateStacking(aura::Window* active_window); | |
| 120 | |
| 121 // keyboard::KeyboardControllerObserver: | |
| 122 virtual void OnKeyboardBoundsChanging( | |
| 123 const gfx::Rect& keyboard_bounds) OVERRIDE; | |
| 124 | |
| 125 // Parent window associated with this layout manager. | |
| 126 aura::Window* dock_container_; | |
| 127 // Protect against recursive calls to Relayout(). | |
| 128 bool in_layout_; | |
| 129 // The docked window being dragged. | |
| 130 aura::Window* dragged_window_; | |
| 131 // The launcher we are observing for launcher icon changes. | |
| 132 Launcher* launcher_; | |
| 133 // The shelf layout manager being observed for visibility changes. | |
| 134 ShelfLayoutManager* shelf_layout_manager_; | |
| 135 // Tracks the visibility of the shelf. Defaults to false when there is no | |
| 136 // shelf. | |
| 137 bool shelf_hidden_; | |
| 138 | |
| 139 // Side of the screen that the dock is positioned at. | |
| 140 DockAlignment alignment_; | |
| 141 | |
| 142 DISALLOW_COPY_AND_ASSIGN(DockedWindowLayoutManager); | |
| 143 }; | |
| 144 | |
| 145 } // namespace internal | |
| 146 } // namespace ash | |
| 147 | |
| 148 #endif // ASH_WM_DOCK_DOCKED_WINDOW_LAYOUT_MANAGER_H_ | |
| OLD | NEW |