| 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/property_util.h" |
| 12 #include "base/basictypes.h" |
| 13 #include "base/compiler_specific.h" |
| 14 #include "ui/aura/client/activation_change_observer.h" |
| 15 #include "ui/aura/layout_manager.h" |
| 16 #include "ui/aura/window_observer.h" |
| 17 #include "ui/keyboard/keyboard_controller_observer.h" |
| 18 |
| 19 namespace aura { |
| 20 class Window; |
| 21 } |
| 22 |
| 23 namespace gfx { |
| 24 class Point; |
| 25 class Rect; |
| 26 } |
| 27 |
| 28 namespace ash { |
| 29 class Launcher; |
| 30 |
| 31 namespace internal { |
| 32 class ShelfLayoutManager; |
| 33 |
| 34 // DockedWindowLayoutManager is responsible for organizing windows within the |
| 35 // dock (gutter). It is associated with a specific container window (i.e. |
| 36 // kShellWindowId_DockContainer) and controls the layout of any windows |
| 37 // added to that container. |
| 38 // |
| 39 // The constructor takes a |dock_container| argument which is expected to set |
| 40 // its layout manager to this instance, e.g.: |
| 41 // dock_container->SetLayoutManager( |
| 42 // new DockedWindowLayoutManager(dock_container)); |
| 43 |
| 44 class ASH_EXPORT DockedWindowLayoutManager |
| 45 : public aura::LayoutManager, |
| 46 public ash::ShellObserver, |
| 47 public aura::WindowObserver, |
| 48 public aura::client::ActivationChangeObserver, |
| 49 public keyboard::KeyboardControllerObserver, |
| 50 public ash::ShelfLayoutManagerObserver { |
| 51 public: |
| 52 explicit DockedWindowLayoutManager(aura::Window* dock_container); |
| 53 virtual ~DockedWindowLayoutManager(); |
| 54 |
| 55 // Call Shutdown() before deleting children of dock_container. |
| 56 void Shutdown(); |
| 57 |
| 58 // Called by a DockedWindowResizer to update which window is being dragged. |
| 59 void StartDragging(aura::Window* window); |
| 60 void FinishDragging(); |
| 61 |
| 62 ash::Launcher* launcher() { return launcher_; } |
| 63 void SetLauncher(ash::Launcher* launcher); |
| 64 |
| 65 // Returns which side of the screen the window touches if any (no dock yet) or |
| 66 // DOCK_EDGE_NONE if a dock exists with a conflicting alignment. Also returns |
| 67 // DOCK_EDGE_NONE if launcher (shelf) is aligned on the same side. |
| 68 static DockedEdge FindDockEdge(aura::Window* window, |
| 69 const gfx::Point& location); |
| 70 |
| 71 // aura::LayoutManager: |
| 72 virtual void OnWindowResized() OVERRIDE; |
| 73 virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE; |
| 74 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE; |
| 75 virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE; |
| 76 virtual void OnChildWindowVisibilityChanged(aura::Window* child, |
| 77 bool visibile) OVERRIDE; |
| 78 virtual void SetChildBounds(aura::Window* child, |
| 79 const gfx::Rect& requested_bounds) OVERRIDE; |
| 80 |
| 81 // ash::ShellObserver: |
| 82 virtual void OnShelfAlignmentChanged(aura::RootWindow* root_window) OVERRIDE; |
| 83 |
| 84 // aura::WindowObserver: |
| 85 virtual void OnWindowPropertyChanged(aura::Window* window, |
| 86 const void* key, |
| 87 intptr_t old) OVERRIDE; |
| 88 virtual void OnWindowVisibilityChanged(aura::Window* window, |
| 89 bool visible) OVERRIDE; |
| 90 |
| 91 // aura::client::ActivationChangeObserver: |
| 92 virtual void OnWindowActivated(aura::Window* gained_active, |
| 93 aura::Window* lost_active) OVERRIDE; |
| 94 |
| 95 // ShelfLayoutManagerObserver: |
| 96 virtual void WillChangeVisibilityState( |
| 97 ShelfVisibilityState new_state) OVERRIDE; |
| 98 |
| 99 private: |
| 100 // Possible values of which side of the screen the dock is positioned at. |
| 101 enum DockAlignment { |
| 102 DOCK_ALIGNMENT_NONE, |
| 103 DOCK_ALIGNMENT_LEFT, |
| 104 DOCK_ALIGNMENT_RIGHT, |
| 105 }; |
| 106 |
| 107 friend class DockLayoutManagerTest; |
| 108 friend class DockWindowResizerTest; |
| 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 |