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

Side by Side Diff: ash/wm/dock/dock_layout_manager.h

Issue 13896026: Stick windows to sides of workspaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Dock on left or right edge Created 7 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_WM_PANELS_PANEL_LAYOUT_MANAGER_H_ 5 #ifndef ASH_WM_DOCK_DOCK_LAYOUT_MANAGER_H_
6 #define ASH_WM_PANELS_PANEL_LAYOUT_MANAGER_H_ 6 #define ASH_WM_DOCK_DOCK_LAYOUT_MANAGER_H_
7 7
8 #include <list> 8 #include <list>
9 9
10 #include "ash/ash_export.h" 10 #include "ash/ash_export.h"
11 #include "ash/launcher/launcher_icon_observer.h" 11 #include "ash/launcher/launcher_icon_observer.h"
12 #include "ash/shelf/shelf_layout_manager_observer.h" 12 #include "ash/shelf/shelf_layout_manager_observer.h"
13 #include "ash/shell_observer.h" 13 #include "ash/shell_observer.h"
14 #include "ash/wm/dock/dock_observer.h"
14 #include "base/basictypes.h" 15 #include "base/basictypes.h"
15 #include "base/compiler_specific.h" 16 #include "base/compiler_specific.h"
16 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
17 #include "base/memory/weak_ptr.h" 18 #include "base/memory/weak_ptr.h"
19 #include "base/observer_list.h"
18 #include "ui/aura/client/activation_change_observer.h" 20 #include "ui/aura/client/activation_change_observer.h"
19 #include "ui/aura/layout_manager.h" 21 #include "ui/aura/layout_manager.h"
20 #include "ui/aura/window_observer.h" 22 #include "ui/aura/window_observer.h"
21 #include "ui/keyboard/keyboard_controller.h" 23 #include "ui/keyboard/keyboard_controller.h"
22 #include "ui/keyboard/keyboard_controller_observer.h" 24 #include "ui/keyboard/keyboard_controller_observer.h"
23 25
24 namespace aura { 26 namespace aura {
25 class Window; 27 class Window;
26 } 28 }
27 29
28 namespace gfx { 30 namespace gfx {
29 class Rect; 31 class Rect;
30 } 32 }
31 33
32 namespace views { 34 namespace views {
33 class Widget; 35 class Widget;
34 } 36 }
35 37
36 namespace ash { 38 namespace ash {
37 class Launcher; 39 class Launcher;
38 40
39 namespace internal { 41 namespace internal {
40 class PanelCalloutWidget;
41 class ShelfLayoutManager; 42 class ShelfLayoutManager;
43 class WorkspaceController;
42 44
43 // PanelLayoutManager is responsible for organizing panels within the 45 // DockLayoutManager is responsible for organizing windows within the
44 // workspace. It is associated with a specific container window (i.e. 46 // dock (gutter). It is associated with a specific container window (i.e.
45 // kShellWindowId_PanelContainer) and controls the layout of any windows 47 // kShellWindowId_DockContainer) and controls the layout of any windows
46 // added to that container. 48 // added to that container.
47 // 49 //
48 // The constructor takes a |panel_container| argument which is expected to set 50 // The constructor takes a |dock_container| argument which is expected to set
49 // its layout manager to this instance, e.g.: 51 // its layout manager to this instance, e.g.:
50 // panel_container->SetLayoutManager(new PanelLayoutManager(panel_container)); 52 // dock_container->SetLayoutManager(new DockLayoutManager(dock_container));
51 53
52 class ASH_EXPORT PanelLayoutManager 54 class ASH_EXPORT DockLayoutManager
53 : public aura::LayoutManager, 55 : public aura::LayoutManager,
54 public ash::LauncherIconObserver, 56 public ash::LauncherIconObserver,
55 public ash::ShellObserver, 57 public ash::ShellObserver,
56 public aura::WindowObserver, 58 public aura::WindowObserver,
57 public aura::client::ActivationChangeObserver, 59 public aura::client::ActivationChangeObserver,
58 public keyboard::KeyboardControllerObserver, 60 public keyboard::KeyboardControllerObserver,
59 public ShelfLayoutManagerObserver { 61 public ShelfLayoutManagerObserver {
60 public: 62 public:
61 explicit PanelLayoutManager(aura::Window* panel_container); 63 explicit DockLayoutManager(aura::Window* dock_container);
62 virtual ~PanelLayoutManager(); 64 virtual ~DockLayoutManager();
63 65
64 // Call Shutdown() before deleting children of panel_container. 66 // Call Shutdown() before deleting children of dock_container.
65 void Shutdown(); 67 void Shutdown();
66 68
67 void StartDragging(aura::Window* panel); 69 // Management of the observer list.
70 virtual void AddObserver(DockObserver* observer);
71 virtual void RemoveObserver(DockObserver* observer);
72
73 void StartDragging(aura::Window* window);
68 void FinishDragging(); 74 void FinishDragging();
69 75
70 void ToggleMinimize(aura::Window* panel); 76 void ToggleMinimize(aura::Window* window);
71 77
72 ash::Launcher* launcher() { return launcher_; } 78 ash::Launcher* launcher() { return launcher_; }
73 void SetLauncher(ash::Launcher* launcher); 79 void SetLauncher(ash::Launcher* launcher);
74 80
81 int CalculateDockEdges(const gfx::Rect& bounds) const;
82
75 // Overridden from aura::LayoutManager: 83 // Overridden from aura::LayoutManager:
76 virtual void OnWindowResized() OVERRIDE; 84 virtual void OnWindowResized() OVERRIDE;
77 virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE; 85 virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE;
78 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE; 86 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE;
79 virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE; 87 virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE;
80 virtual void OnChildWindowVisibilityChanged(aura::Window* child, 88 virtual void OnChildWindowVisibilityChanged(aura::Window* child,
81 bool visibile) OVERRIDE; 89 bool visibile) OVERRIDE;
82 virtual void SetChildBounds(aura::Window* child, 90 virtual void SetChildBounds(aura::Window* child,
83 const gfx::Rect& requested_bounds) OVERRIDE; 91 const gfx::Rect& requested_bounds) OVERRIDE;
84 92
(...skipping 12 matching lines...) Expand all
97 105
98 // Overridden from aura::client::ActivationChangeObserver 106 // Overridden from aura::client::ActivationChangeObserver
99 virtual void OnWindowActivated(aura::Window* gained_active, 107 virtual void OnWindowActivated(aura::Window* gained_active,
100 aura::Window* lost_active) OVERRIDE; 108 aura::Window* lost_active) OVERRIDE;
101 109
102 // Overridden from ShelfLayoutManagerObserver 110 // Overridden from ShelfLayoutManagerObserver
103 virtual void WillChangeVisibilityState( 111 virtual void WillChangeVisibilityState(
104 ShelfVisibilityState new_state) OVERRIDE; 112 ShelfVisibilityState new_state) OVERRIDE;
105 113
106 private: 114 private:
107 friend class PanelLayoutManagerTest; 115 friend class DockLayoutManagerTest;
108 friend class PanelWindowResizerTest;
109 116
110 views::Widget* CreateCalloutWidget(); 117 views::Widget* CreateCalloutWidget();
111 118
112 struct PanelInfo{ 119 struct DockInfo{
113 PanelInfo() : window(NULL), callout_widget(NULL), slide_in(false) {} 120 DockInfo() : window(NULL), slide_in(false) {}
114 121
115 bool operator==(const aura::Window* other_window) const { 122 bool operator==(const aura::Window* other_window) const {
116 return window == other_window; 123 return window == other_window;
117 } 124 }
118 125
119 // A weak pointer to the panel window. 126 // A weak pointer to the docked window.
120 aura::Window* window; 127 aura::Window* window;
121 // The callout widget for this panel. This pointer must be managed
122 // manually as this structure is used in a std::list. See
123 // http://www.chromium.org/developers/smart-pointer-guidelines
124 PanelCalloutWidget* callout_widget;
125 128
126 // True on new and restored panel windows until the panel has been 129 // True on new and restored docked windows until the window has been
127 // positioned. The first time Relayout is called the panel will slide into 130 // positioned. The first time Relayout is called the window will slide into
128 // position and this will be set to false. 131 // position and this will be set to false.
129 bool slide_in; 132 bool slide_in;
130 }; 133 };
131 134
132 typedef std::list<PanelInfo> PanelList; 135 typedef std::list<DockInfo> DockList;
133 136
134 void MinimizePanel(aura::Window* panel); 137 void MinimizeWindow(aura::Window* window);
135 void RestorePanel(aura::Window* panel); 138 void RestoreWindow(aura::Window* window);
136 139
137 // Called whenever the panel layout might change. 140 // Called whenever the window layout might change.
138 void Relayout(); 141 void Relayout();
139 142
140 // Called whenever the panel stacking order needs to be updated (e.g. focus 143 // Called whenever the window stacking order needs to be updated (e.g. focus
141 // changes or a panel is moved). 144 // changes or a window is moved).
142 void UpdateStacking(aura::Window* active_panel); 145 void UpdateStacking(aura::Window* active_window);
143
144 // Update the callout arrows for all managed panels.
145 void UpdateCallouts();
146 146
147 // Overridden from keyboard::KeyboardControllerObserver: 147 // Overridden from keyboard::KeyboardControllerObserver:
148 virtual void OnKeyboardBoundsChanging( 148 virtual void OnKeyboardBoundsChanging(
149 const gfx::Rect& keyboard_bounds) OVERRIDE; 149 const gfx::Rect& keyboard_bounds) OVERRIDE;
150 150
151 // Parent window associated with this layout manager. 151 // Parent window associated with this layout manager.
152 aura::Window* panel_container_; 152 aura::Window* dock_container_;
153 // Protect against recursive calls to Relayout(). 153 // Protect against recursive calls to Relayout().
154 bool in_layout_; 154 bool in_layout_;
155 // Ordered list of unowned pointers to panel windows. 155 // Ordered list of unowned pointers to docked windows.
156 PanelList panel_windows_; 156 DockList dock_windows_;
flackr 2013/05/31 14:23:45 I don't think you need to maintain a separate list
varkha 2013/05/31 23:33:42 Done.
157 // The panel being dragged. 157 // The docked window being dragged.
158 aura::Window* dragged_panel_; 158 aura::Window* dragged_window_;
159 // The launcher we are observing for launcher icon changes. 159 // The launcher we are observing for launcher icon changes.
160 Launcher* launcher_; 160 Launcher* launcher_;
161 // The shelf layout manager being observed for visibility changes. 161 // The shelf layout manager being observed for visibility changes.
162 ShelfLayoutManager* shelf_layout_manager_; 162 ShelfLayoutManager* shelf_layout_manager_;
163 // Tracks the visibility of the shelf. Defaults to false when there is no 163 // Tracks the visibility of the shelf. Defaults to false when there is no
164 // shelf. 164 // shelf.
165 bool shelf_hidden_; 165 bool shelf_hidden_;
166 // The last active panel. Used to maintain stacking even if no panels are 166 // The last active window. Used to maintain stacking even if no windows are
167 // currently focused. 167 // currently focused.
168 aura::Window* last_active_panel_; 168 aura::Window* last_active_window_;
169 base::WeakPtrFactory<PanelLayoutManager> weak_factory_; 169 // current width of the dock
170 int dock_width_;
170 171
171 DISALLOW_COPY_AND_ASSIGN(PanelLayoutManager); 172 // side of the screen the dock is positioned at
173 enum DockAlignment {
174 DOCK_ALIGNMENT_NONE,
175 DOCK_ALIGNMENT_LEFT,
176 DOCK_ALIGNMENT_RIGHT,
177 };
178 DockAlignment alignment_;
179
180 ObserverList<DockObserver> observer_list_;
181
182 DISALLOW_COPY_AND_ASSIGN(DockLayoutManager);
172 }; 183 };
173 184
174 } // namespace internal 185 } // namespace internal
175 } // namespace ash 186 } // namespace ash
176 187
177 #endif // ASH_WM_PANELS_PANEL_LAYOUT_MANAGER_H_ 188 #endif // ASH_WM_DOCK_DOCK_LAYOUT_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698