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

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 with zero width (comments) 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.
sky 2013/06/11 00:03:13 Dates are wrong in all new files.
varkha 2013/06/11 02:34:24 Done.
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
8 #include <list>
9 7
10 #include "ash/ash_export.h" 8 #include "ash/ash_export.h"
11 #include "ash/launcher/launcher_icon_observer.h"
12 #include "ash/shelf/shelf_layout_manager_observer.h" 9 #include "ash/shelf/shelf_layout_manager_observer.h"
13 #include "ash/shell_observer.h" 10 #include "ash/shell_observer.h"
11 #include "ash/wm/property_util.h"
14 #include "base/basictypes.h" 12 #include "base/basictypes.h"
15 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
16 #include "base/memory/scoped_ptr.h"
17 #include "base/memory/weak_ptr.h"
18 #include "ui/aura/client/activation_change_observer.h" 14 #include "ui/aura/client/activation_change_observer.h"
19 #include "ui/aura/layout_manager.h" 15 #include "ui/aura/layout_manager.h"
20 #include "ui/aura/window_observer.h" 16 #include "ui/aura/window_observer.h"
21 #include "ui/keyboard/keyboard_controller.h"
22 #include "ui/keyboard/keyboard_controller_observer.h" 17 #include "ui/keyboard/keyboard_controller_observer.h"
23 18
24 namespace aura { 19 namespace aura {
25 class Window; 20 class Window;
26 } 21 }
27 22
28 namespace gfx { 23 namespace gfx {
29 class Rect; 24 class Rect;
30 } 25 }
31 26
32 namespace views {
33 class Widget;
34 }
35
36 namespace ash { 27 namespace ash {
37 class Launcher; 28 class Launcher;
38 29
39 namespace internal { 30 namespace internal {
40 class PanelCalloutWidget;
41 class ShelfLayoutManager; 31 class ShelfLayoutManager;
42 32
43 // PanelLayoutManager is responsible for organizing panels within the 33 // DockLayoutManager is responsible for organizing windows within the
sky 2013/06/11 00:03:13 IMO dock is an overloaded term and the use of it h
varkha 2013/06/11 02:34:24 I like DockedWindowLayoutManager better. I checked
sky 2013/06/11 16:15:26 I think many people use the term 'dock' to mean 'l
varkha 2013/06/12 04:52:13 I now try to avoid using "dock" as a term for the
44 // workspace. It is associated with a specific container window (i.e. 34 // dock (gutter). It is associated with a specific container window (i.e.
45 // kShellWindowId_PanelContainer) and controls the layout of any windows 35 // kShellWindowId_DockContainer) and controls the layout of any windows
46 // added to that container. 36 // added to that container.
47 // 37 //
48 // The constructor takes a |panel_container| argument which is expected to set 38 // The constructor takes a |dock_container| argument which is expected to set
49 // its layout manager to this instance, e.g.: 39 // its layout manager to this instance, e.g.:
50 // panel_container->SetLayoutManager(new PanelLayoutManager(panel_container)); 40 // dock_container->SetLayoutManager(new DockLayoutManager(dock_container));
51 41
52 class ASH_EXPORT PanelLayoutManager 42 class ASH_EXPORT DockLayoutManager
53 : public aura::LayoutManager, 43 : public aura::LayoutManager,
54 public ash::LauncherIconObserver,
55 public ash::ShellObserver, 44 public ash::ShellObserver,
56 public aura::WindowObserver, 45 public aura::WindowObserver,
57 public aura::client::ActivationChangeObserver, 46 public aura::client::ActivationChangeObserver,
58 public keyboard::KeyboardControllerObserver, 47 public keyboard::KeyboardControllerObserver,
59 public ShelfLayoutManagerObserver { 48 public ash::ShelfLayoutManagerObserver {
60 public: 49 public:
61 explicit PanelLayoutManager(aura::Window* panel_container); 50 explicit DockLayoutManager(aura::Window* dock_container);
62 virtual ~PanelLayoutManager(); 51 virtual ~DockLayoutManager();
63 52
64 // Call Shutdown() before deleting children of panel_container. 53 // Call Shutdown() before deleting children of dock_container.
65 void Shutdown(); 54 void Shutdown();
66 55
67 void StartDragging(aura::Window* panel); 56 void StartDragging(aura::Window* window);
68 void FinishDragging(); 57 void FinishDragging();
69 58
70 void ToggleMinimize(aura::Window* panel); 59 void ToggleMinimize(aura::Window* window);
sky 2013/06/11 00:03:13 Description?
varkha 2013/06/11 02:34:24 This one is removed.
71 60
72 ash::Launcher* launcher() { return launcher_; } 61 ash::Launcher* launcher() { return launcher_; }
73 void SetLauncher(ash::Launcher* launcher); 62 void SetLauncher(ash::Launcher* launcher);
74 63
64 // checks if the window touches the screen edge (no dock yet) or has entered
sky 2013/06/11 00:03:13 Start with cap and end with appropriate punctuatio
varkha 2013/06/11 02:34:24 Done.
65 // existing dock area
66 static DockEdge FindDockEdge(aura::Window* window);
67
75 // Overridden from aura::LayoutManager: 68 // Overridden from aura::LayoutManager:
76 virtual void OnWindowResized() OVERRIDE; 69 virtual void OnWindowResized() OVERRIDE;
77 virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE; 70 virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE;
78 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE; 71 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE;
79 virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE; 72 virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE;
80 virtual void OnChildWindowVisibilityChanged(aura::Window* child, 73 virtual void OnChildWindowVisibilityChanged(aura::Window* child,
81 bool visibile) OVERRIDE; 74 bool visibile) OVERRIDE;
82 virtual void SetChildBounds(aura::Window* child, 75 virtual void SetChildBounds(aura::Window* child,
83 const gfx::Rect& requested_bounds) OVERRIDE; 76 const gfx::Rect& requested_bounds) OVERRIDE;
84 77
85 // Overridden from ash::LauncherIconObserver
86 virtual void OnLauncherIconPositionsChanged() OVERRIDE;
87
88 // Overridden from ash::ShellObserver 78 // Overridden from ash::ShellObserver
89 virtual void OnShelfAlignmentChanged(aura::RootWindow* root_window) OVERRIDE; 79 virtual void OnShelfAlignmentChanged(aura::RootWindow* root_window) OVERRIDE;
90 80
91 // Overridden from aura::WindowObserver 81 // Overridden from aura::WindowObserver
92 virtual void OnWindowPropertyChanged(aura::Window* window, 82 virtual void OnWindowPropertyChanged(aura::Window* window,
93 const void* key, 83 const void* key,
94 intptr_t old) OVERRIDE; 84 intptr_t old) OVERRIDE;
95 virtual void OnWindowVisibilityChanged(aura::Window* window, 85 virtual void OnWindowVisibilityChanged(aura::Window* window,
96 bool visible) OVERRIDE; 86 bool visible) OVERRIDE;
97 87
98 // Overridden from aura::client::ActivationChangeObserver 88 // Overridden from aura::client::ActivationChangeObserver
99 virtual void OnWindowActivated(aura::Window* gained_active, 89 virtual void OnWindowActivated(aura::Window* gained_active,
100 aura::Window* lost_active) OVERRIDE; 90 aura::Window* lost_active) OVERRIDE;
101 91
102 // Overridden from ShelfLayoutManagerObserver 92 // Overridden from ShelfLayoutManagerObserver
103 virtual void WillChangeVisibilityState( 93 virtual void WillChangeVisibilityState(
104 ShelfVisibilityState new_state) OVERRIDE; 94 ShelfVisibilityState new_state) OVERRIDE;
105 95
106 private: 96 private:
107 friend class PanelLayoutManagerTest; 97 friend class DockLayoutManagerTest;
108 friend class PanelWindowResizerTest; 98 friend class DockWindowResizerTest;
109 99
110 views::Widget* CreateCalloutWidget(); 100 // minimize / restore window and relayout
101 void MinimizeWindow(aura::Window* window);
102 void RestoreWindow(aura::Window* window);
111 103
112 struct PanelInfo{ 104 // Called whenever the window layout might change.
113 PanelInfo() : window(NULL), callout_widget(NULL), slide_in(false) {}
114
115 bool operator==(const aura::Window* other_window) const {
116 return window == other_window;
117 }
118
119 // A weak pointer to the panel window.
120 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
126 // True on new and restored panel windows until the panel has been
127 // positioned. The first time Relayout is called the panel will slide into
128 // position and this will be set to false.
129 bool slide_in;
130 };
131
132 typedef std::list<PanelInfo> PanelList;
133
134 void MinimizePanel(aura::Window* panel);
135 void RestorePanel(aura::Window* panel);
136
137 // Called whenever the panel layout might change.
138 void Relayout(); 105 void Relayout();
139 106
140 // Called whenever the panel stacking order needs to be updated (e.g. focus 107 // Called whenever the window stacking order needs to be updated (e.g. focus
141 // changes or a panel is moved). 108 // changes or a window is moved).
142 void UpdateStacking(aura::Window* active_panel); 109 void UpdateStacking(aura::Window* active_window);
143
144 // Update the callout arrows for all managed panels.
145 void UpdateCallouts();
146 110
147 // Overridden from keyboard::KeyboardControllerObserver: 111 // Overridden from keyboard::KeyboardControllerObserver:
148 virtual void OnKeyboardBoundsChanging( 112 virtual void OnKeyboardBoundsChanging(
149 const gfx::Rect& keyboard_bounds) OVERRIDE; 113 const gfx::Rect& keyboard_bounds) OVERRIDE;
150 114
151 // Parent window associated with this layout manager. 115 // Parent window associated with this layout manager.
152 aura::Window* panel_container_; 116 aura::Window* dock_container_;
153 // Protect against recursive calls to Relayout(). 117 // Protect against recursive calls to Relayout().
154 bool in_layout_; 118 bool in_layout_;
155 // Ordered list of unowned pointers to panel windows. 119 // The docked window being dragged.
156 PanelList panel_windows_; 120 aura::Window* dragged_window_;
157 // The panel being dragged.
158 aura::Window* dragged_panel_;
159 // The launcher we are observing for launcher icon changes. 121 // The launcher we are observing for launcher icon changes.
160 Launcher* launcher_; 122 Launcher* launcher_;
161 // The shelf layout manager being observed for visibility changes. 123 // The shelf layout manager being observed for visibility changes.
162 ShelfLayoutManager* shelf_layout_manager_; 124 ShelfLayoutManager* shelf_layout_manager_;
163 // Tracks the visibility of the shelf. Defaults to false when there is no 125 // Tracks the visibility of the shelf. Defaults to false when there is no
164 // shelf. 126 // shelf.
165 bool shelf_hidden_; 127 bool shelf_hidden_;
166 // The last active panel. Used to maintain stacking even if no panels are
167 // currently focused.
168 aura::Window* last_active_panel_;
169 base::WeakPtrFactory<PanelLayoutManager> weak_factory_;
170 128
171 DISALLOW_COPY_AND_ASSIGN(PanelLayoutManager); 129 // side of the screen the dock is positioned at
130 enum DockAlignment {
sky 2013/06/11 00:03:13 enums should be near the top of a section (see sty
varkha 2013/06/11 02:34:24 Done.
131 DOCK_ALIGNMENT_NONE,
132 DOCK_ALIGNMENT_LEFT,
133 DOCK_ALIGNMENT_RIGHT,
134 };
135 DockAlignment alignment_;
136
137 DISALLOW_COPY_AND_ASSIGN(DockLayoutManager);
172 }; 138 };
173 139
174 } // namespace internal 140 } // namespace internal
175 } // namespace ash 141 } // namespace ash
176 142
177 #endif // ASH_WM_PANELS_PANEL_LAYOUT_MANAGER_H_ 143 #endif // ASH_WM_DOCK_DOCK_LAYOUT_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698