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

Side by Side Diff: ash/shelf/shelf_layout_manager.h

Issue 12313118: Refactor: Shelf Widget (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: safer shutdown (status_area_widget_) Created 7 years, 9 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
« no previous file with comments | « ash/shelf/background_animator.cc ('k') | ash/shelf/shelf_layout_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_SHELF_LAYOUT_MANAGER_H_ 5 #ifndef ASH_SHELF_SHELF_LAYOUT_MANAGER_H_
6 #define ASH_WM_SHELF_LAYOUT_MANAGER_H_ 6 #define ASH_SHELF_SHELF_LAYOUT_MANAGER_H_
7 7
8 #include "ash/ash_export.h" 8 #include "ash/ash_export.h"
9 #include "ash/launcher/launcher.h" 9 #include "ash/launcher/launcher.h"
10 #include "ash/shelf_types.h" 10 #include "ash/shelf/background_animator.h"
11 #include "ash/shelf/shelf_types.h"
11 #include "ash/shell_observer.h" 12 #include "ash/shell_observer.h"
13 #include "ash/system/status_area_widget.h"
12 #include "base/basictypes.h" 14 #include "base/basictypes.h"
13 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
14 #include "base/logging.h" 16 #include "base/logging.h"
15 #include "base/observer_list.h" 17 #include "base/observer_list.h"
16 #include "base/timer.h" 18 #include "base/timer.h"
17 #include "ui/aura/client/activation_change_observer.h" 19 #include "ui/aura/client/activation_change_observer.h"
18 #include "ui/aura/layout_manager.h" 20 #include "ui/aura/layout_manager.h"
19 #include "ui/gfx/insets.h" 21 #include "ui/gfx/insets.h"
20 #include "ui/gfx/rect.h" 22 #include "ui/gfx/rect.h"
21 23
22 namespace aura { 24 namespace aura {
23 class RootWindow; 25 class RootWindow;
24 } 26 }
25 27
26 namespace ui { 28 namespace ui {
27 class GestureEvent; 29 class GestureEvent;
28 } 30 }
29 31
30 namespace ash { 32 namespace ash {
31 class ScreenAsh; 33 class ScreenAsh;
34 class ShelfWidget;
32 namespace internal { 35 namespace internal {
33 36
34 class ShelfLayoutManagerTest; 37 class ShelfLayoutManagerTest;
35 class StatusAreaWidget; 38 class StatusAreaWidget;
36 class WorkspaceController; 39 class WorkspaceController;
37 40
38 // ShelfLayoutManager is the layout manager responsible for the launcher and 41 // ShelfLayoutManager is the layout manager responsible for the launcher and
39 // status widgets. The launcher is given the total available width and told the 42 // status widgets. The launcher is given the total available width and told the
40 // width of the status area. This allows the launcher to draw the background and 43 // width of the status area. This allows the launcher to draw the background and
41 // layout to the status area. 44 // layout to the status area.
(...skipping 16 matching lines...) Expand all
58 virtual void OnAutoHideStateChanged(ShelfAutoHideState new_state) {} 61 virtual void OnAutoHideStateChanged(ShelfAutoHideState new_state) {}
59 }; 62 };
60 63
61 // We reserve a small area at the bottom of the workspace area to ensure that 64 // We reserve a small area at the bottom of the workspace area to ensure that
62 // the bottom-of-window resize handle can be hit. 65 // the bottom-of-window resize handle can be hit.
63 static const int kWorkspaceAreaBottomInset; 66 static const int kWorkspaceAreaBottomInset;
64 67
65 // Size of the shelf when auto-hidden. 68 // Size of the shelf when auto-hidden.
66 static const int kAutoHideSize; 69 static const int kAutoHideSize;
67 70
68 explicit ShelfLayoutManager(StatusAreaWidget* status); 71 explicit ShelfLayoutManager(ShelfWidget* shelf);
69 virtual ~ShelfLayoutManager(); 72 virtual ~ShelfLayoutManager();
70 73
71 // Sets the ShelfAutoHideBehavior. See enum description for details. 74 // Sets the ShelfAutoHideBehavior. See enum description for details.
72 void SetAutoHideBehavior(ShelfAutoHideBehavior behavior); 75 void SetAutoHideBehavior(ShelfAutoHideBehavior behavior);
73 ShelfAutoHideBehavior auto_hide_behavior() const { 76 ShelfAutoHideBehavior auto_hide_behavior() const {
74 return auto_hide_behavior_; 77 return auto_hide_behavior_;
75 } 78 }
76 79
77 // Sets the alignment. Returns true if the alignment is changed. Otherwise, 80 // Sets the alignment. Returns true if the alignment is changed. Otherwise,
78 // returns false. 81 // returns false.
79 bool SetAlignment(ShelfAlignment alignment); 82 bool SetAlignment(ShelfAlignment alignment);
80 ShelfAlignment GetAlignment() const { return alignment_; } 83 ShelfAlignment GetAlignment() const { return alignment_; }
81 84
82 void set_workspace_controller(WorkspaceController* controller) { 85 void set_workspace_controller(WorkspaceController* controller) {
83 workspace_controller_ = controller; 86 workspace_controller_ = controller;
84 } 87 }
85 88
86 views::Widget* launcher_widget() {
87 return launcher_ ? launcher_->widget() : NULL;
88 }
89 const views::Widget* launcher_widget() const {
90 return launcher_ ? launcher_->widget() : NULL;
91 }
92 StatusAreaWidget* status_area_widget() { return status_area_widget_; }
93
94 bool in_layout() const { return in_layout_; } 89 bool in_layout() const { return in_layout_; }
95 90
96 // Returns whether the shelf and its contents (launcher, status) are visible 91 // Returns whether the shelf and its contents (launcher, status) are visible
97 // on the screen. 92 // on the screen.
98 bool IsVisible() const; 93 bool IsVisible() const;
99 94
100 // The launcher is typically created after the layout manager.
101 void SetLauncher(Launcher* launcher);
102 Launcher* launcher() { return launcher_; }
103
104 // Returns the ideal bounds of the shelf assuming it is visible. 95 // Returns the ideal bounds of the shelf assuming it is visible.
105 gfx::Rect GetIdealBounds(); 96 gfx::Rect GetIdealBounds();
106 97
107 // Stops any animations and sets the bounds of the launcher and status 98 // Stops any animations and sets the bounds of the launcher and status
108 // widgets. 99 // widgets.
109 void LayoutShelf(); 100 void LayoutShelf();
110 101
111 // Returns shelf visibility state based on current value of auto hide 102 // Returns shelf visibility state based on current value of auto hide
112 // behavior setting. 103 // behavior setting.
113 ShelfVisibilityState CalculateShelfVisibility(); 104 ShelfVisibilityState CalculateShelfVisibility();
114 105
115 // Returns shelf visibility state based on current value of auto hide 106 // Returns shelf visibility state based on current value of auto hide
116 // behavior setting. 107 // behavior setting.
117 ShelfVisibilityState CalculateShelfVisibilityWhileDragging(); 108 ShelfVisibilityState CalculateShelfVisibilityWhileDragging();
118 109
119 // Updates the visibility state. 110 // Updates the visibility state.
120 void UpdateVisibilityState(); 111 void UpdateVisibilityState();
121 112
122 // Invoked by the shelf/launcher when the auto-hide state may have changed. 113 // Invoked by the shelf/launcher when the auto-hide state may have changed.
123 void UpdateAutoHideState(); 114 void UpdateAutoHideState();
124 115
125 ShelfVisibilityState visibility_state() const { 116 ShelfVisibilityState visibility_state() const {
126 return state_.visibility_state; 117 return state_.visibility_state;
127 } 118 }
128 ShelfAutoHideState auto_hide_state() const { return state_.auto_hide_state; } 119 ShelfAutoHideState auto_hide_state() const { return state_.auto_hide_state; }
129 120
121 ShelfWidget* shelf_widget() { return shelf_; }
122
130 // Sets whether any windows overlap the shelf. If a window overlaps the shelf 123 // Sets whether any windows overlap the shelf. If a window overlaps the shelf
131 // the shelf renders slightly differently. 124 // the shelf renders slightly differently.
132 void SetWindowOverlapsShelf(bool value); 125 void SetWindowOverlapsShelf(bool value);
133 bool window_overlaps_shelf() const { return window_overlaps_shelf_; } 126 bool window_overlaps_shelf() const { return window_overlaps_shelf_; }
134 127
135 void AddObserver(Observer* observer); 128 void AddObserver(Observer* observer);
136 void RemoveObserver(Observer* observer); 129 void RemoveObserver(Observer* observer);
137 130
138 // Gesture dragging related functions: 131 // Gesture dragging related functions:
139 void StartGestureDrag(const ui::GestureEvent& gesture); 132 void StartGestureDrag(const ui::GestureEvent& gesture);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 static ShelfLayoutManager* ForLauncher(aura::Window* window); 191 static ShelfLayoutManager* ForLauncher(aura::Window* window);
199 192
200 private: 193 private:
201 class AutoHideEventFilter; 194 class AutoHideEventFilter;
202 class UpdateShelfObserver; 195 class UpdateShelfObserver;
203 friend class ash::ScreenAsh; 196 friend class ash::ScreenAsh;
204 friend class ShelfLayoutManagerTest; 197 friend class ShelfLayoutManagerTest;
205 198
206 struct TargetBounds { 199 struct TargetBounds {
207 TargetBounds(); 200 TargetBounds();
201 ~TargetBounds();
208 202
209 float opacity; 203 float opacity;
210 gfx::Rect launcher_bounds_in_root; 204 gfx::Rect shelf_bounds_in_root;
211 gfx::Rect status_bounds_in_root; 205 gfx::Rect launcher_bounds_in_shelf;
206 gfx::Rect status_bounds_in_shelf;
212 gfx::Insets work_area_insets; 207 gfx::Insets work_area_insets;
213 }; 208 };
214 209
215 struct State { 210 struct State {
216 State() : visibility_state(SHELF_VISIBLE), 211 State() : visibility_state(SHELF_VISIBLE),
217 auto_hide_state(SHELF_AUTO_HIDE_HIDDEN), 212 auto_hide_state(SHELF_AUTO_HIDE_HIDDEN),
218 is_screen_locked(false) {} 213 is_screen_locked(false) {}
219 214
220 // Returns true if the two states are considered equal. As 215 // Returns true if the two states are considered equal. As
221 // |auto_hide_state| only matters if |visibility_state| is 216 // |auto_hide_state| only matters if |visibility_state| is
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 bool in_layout_; 280 bool in_layout_;
286 281
287 // See description above setter. 282 // See description above setter.
288 ShelfAutoHideBehavior auto_hide_behavior_; 283 ShelfAutoHideBehavior auto_hide_behavior_;
289 284
290 ShelfAlignment alignment_; 285 ShelfAlignment alignment_;
291 286
292 // Current state. 287 // Current state.
293 State state_; 288 State state_;
294 289
295 Launcher* launcher_; 290 ShelfWidget* shelf_;
296 StatusAreaWidget* status_area_widget_;
297 291
298 WorkspaceController* workspace_controller_; 292 WorkspaceController* workspace_controller_;
299 293
300 // Do any windows overlap the shelf? This is maintained by WorkspaceManager. 294 // Do any windows overlap the shelf? This is maintained by WorkspaceManager.
301 bool window_overlaps_shelf_; 295 bool window_overlaps_shelf_;
302 296
303 base::OneShotTimer<ShelfLayoutManager> auto_hide_timer_; 297 base::OneShotTimer<ShelfLayoutManager> auto_hide_timer_;
304 298
305 // EventFilter used to detect when user moves the mouse over the launcher to 299 // EventFilter used to detect when user moves the mouse over the launcher to
306 // trigger showing the launcher. 300 // trigger showing the launcher.
(...skipping 21 matching lines...) Expand all
328 322
329 // Used to delay updating shelf background. 323 // Used to delay updating shelf background.
330 UpdateShelfObserver* update_shelf_observer_; 324 UpdateShelfObserver* update_shelf_observer_;
331 325
332 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManager); 326 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManager);
333 }; 327 };
334 328
335 } // namespace internal 329 } // namespace internal
336 } // namespace ash 330 } // namespace ash
337 331
338 #endif // ASH_WM_SHELF_LAYOUT_MANAGER_H_ 332 #endif // ASH_SHELF_SHELF_LAYOUT_MANAGER_H_
OLDNEW
« no previous file with comments | « ash/shelf/background_animator.cc ('k') | ash/shelf/shelf_layout_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698