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

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

Issue 1851883002: Cleanup shelf initialization and observation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Check for shelf before setting prefs in ChromeLauncherController. Created 4 years, 8 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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_SHELF_SHELF_LAYOUT_MANAGER_H_ 5 #ifndef ASH_SHELF_SHELF_LAYOUT_MANAGER_H_
6 #define ASH_SHELF_SHELF_LAYOUT_MANAGER_H_ 6 #define ASH_SHELF_SHELF_LAYOUT_MANAGER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/ash_export.h" 10 #include "ash/ash_export.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // Size of the shelf when auto-hidden. 77 // Size of the shelf when auto-hidden.
78 static const int kAutoHideSize; 78 static const int kAutoHideSize;
79 79
80 // Inset between the inner edge of the shelf (towards centre of screen), and 80 // Inset between the inner edge of the shelf (towards centre of screen), and
81 // the shelf items, notifications, status area etc. 81 // the shelf items, notifications, status area etc.
82 static const int kShelfItemInset; 82 static const int kShelfItemInset;
83 83
84 explicit ShelfLayoutManager(ShelfWidget* shelf); 84 explicit ShelfLayoutManager(ShelfWidget* shelf);
85 ~ShelfLayoutManager() override; 85 ~ShelfLayoutManager() override;
86 86
87 // Sets the ShelfAutoHideBehavior. See enum description for details.
88 void SetAutoHideBehavior(ShelfAutoHideBehavior behavior);
89 ShelfAutoHideBehavior auto_hide_behavior() const {
90 return auto_hide_behavior_;
91 }
92
93 // Sets the alignment; changes are delayed if the screen is locked.
94 void SetAlignment(ShelfAlignment alignment);
95
96 // Returns the desired alignment for the current state, either the user's
97 // selected alignment or SHELF_ALIGNMENT_BOTTOM when the screen is locked.
98 ShelfAlignment GetAlignment() const;
99
100 void set_workspace_controller(WorkspaceController* controller) { 87 void set_workspace_controller(WorkspaceController* controller) {
101 workspace_controller_ = controller; 88 workspace_controller_ = controller;
102 } 89 }
103 90
104 bool updating_bounds() const { return updating_bounds_; } 91 bool updating_bounds() const { return updating_bounds_; }
105 92
106 // Clears internal data for shutdown process. 93 // Clears internal data for shutdown process.
107 void PrepareForShutdown(); 94 void PrepareForShutdown();
108 95
109 // Returns whether the shelf and its contents (shelf, status) are visible 96 // Returns whether the shelf and its contents (shelf, status) are visible
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 // shelf. Specifying 0 leads to use the default. 148 // shelf. Specifying 0 leads to use the default.
162 void SetAnimationDurationOverride(int duration_override_in_ms); 149 void SetAnimationDurationOverride(int duration_override_in_ms);
163 150
164 // Overridden from SnapLayoutManager: 151 // Overridden from SnapLayoutManager:
165 void OnWindowResized() override; 152 void OnWindowResized() override;
166 void SetChildBounds(aura::Window* child, 153 void SetChildBounds(aura::Window* child,
167 const gfx::Rect& requested_bounds) override; 154 const gfx::Rect& requested_bounds) override;
168 155
169 // Overridden from ash::ShellObserver: 156 // Overridden from ash::ShellObserver:
170 void OnLockStateChanged(bool locked) override; 157 void OnLockStateChanged(bool locked) override;
158 void OnShelfAlignmentChanged(aura::Window* root_window) override;
159 void OnShelfAutoHideBehaviorChanged(aura::Window* root_window) override;
171 160
172 // Overriden from aura::client::ActivationChangeObserver: 161 // Overriden from aura::client::ActivationChangeObserver:
173 void OnWindowActivated( 162 void OnWindowActivated(
174 aura::client::ActivationChangeObserver::ActivationReason reason, 163 aura::client::ActivationChangeObserver::ActivationReason reason,
175 aura::Window* gained_active, 164 aura::Window* gained_active,
176 aura::Window* lost_active) override; 165 aura::Window* lost_active) override;
177 166
178 // Overridden from ash::LockStateObserver: 167 // Overridden from ash::LockStateObserver:
179 void OnLockStateEvent(LockStateObserver::EventType event) override; 168 void OnLockStateEvent(LockStateObserver::EventType event) override;
180 169
181 // Overridden from ash::SessionStateObserver: 170 // Overridden from ash::SessionStateObserver:
182 void SessionStateChanged(SessionStateDelegate::SessionState state) override; 171 void SessionStateChanged(SessionStateDelegate::SessionState state) override;
183 172
184 // TODO(harrym|oshima): These templates will be moved to 173 // TODO(msw): Remove these accessors, kept temporarily to simplify changes.
185 // new Shelf class. 174 void SetAutoHideBehavior(ShelfAutoHideBehavior behavior) {
186 // A helper function that provides a shortcut for choosing 175 shelf_->shelf()->SetAutoHideBehavior(behavior);
187 // values specific to a shelf alignment. 176 }
177 ShelfAutoHideBehavior auto_hide_behavior() const {
178 return shelf_->shelf()->GetAutoHideBehavior();
179 }
180
181 // TODO(msw): Remove these accessors, kept temporarily to simplify changes.
182 void SetAlignment(ShelfAlignment alignment) {
183 shelf_->shelf()->SetAlignment(alignment);
184 }
185 ShelfAlignment GetAlignment() const { return shelf_->GetAlignment(); }
186
187 // TODO(harrym|oshima): These templates will be moved to a new Shelf class.
188 // A helper function for choosing values specific to a shelf alignment.
188 template <typename T> 189 template <typename T>
189 T SelectValueForShelfAlignment(T bottom, T left, T right) const { 190 T SelectValueForShelfAlignment(T bottom, T left, T right) const {
190 switch (GetAlignment()) { 191 switch (GetAlignment()) {
191 case SHELF_ALIGNMENT_BOTTOM: 192 case SHELF_ALIGNMENT_BOTTOM:
192 return bottom; 193 return bottom;
193 case SHELF_ALIGNMENT_LEFT: 194 case SHELF_ALIGNMENT_LEFT:
194 return left; 195 return left;
195 case SHELF_ALIGNMENT_RIGHT: 196 case SHELF_ALIGNMENT_RIGHT:
196 return right; 197 return right;
197 } 198 }
198 NOTREACHED(); 199 NOTREACHED();
199 return right; 200 return right;
200 } 201 }
201 202
202 template<typename T> 203 template<typename T>
203 T PrimaryAxisValue(T horizontal, T vertical) const { 204 T PrimaryAxisValue(T horizontal, T vertical) const {
204 return IsHorizontalAlignment() ? horizontal : vertical; 205 return IsHorizontalAlignment() ? horizontal : vertical;
205 } 206 }
206 207
207 // Is the shelf's alignment horizontal? 208 // Is the shelf's alignment horizontal?
208 bool IsHorizontalAlignment() const; 209 bool IsHorizontalAlignment() const;
209 210
211 // Returns true when the alignment is locked. This can be caused by the screen
212 // being locked, or when adding a user. Returns false when transitioning to a
213 // user session, and while the session is active.
214 bool IsAlignmentLocked() const;
215
210 // Set the height of the ChromeVox panel, which takes away space from the 216 // Set the height of the ChromeVox panel, which takes away space from the
211 // available work area from the top of the screen. 217 // available work area from the top of the screen.
212 void SetChromeVoxPanelHeight(int height); 218 void SetChromeVoxPanelHeight(int height);
213 219
214 private: 220 private:
215 class AutoHideEventFilter; 221 class AutoHideEventFilter;
216 class UpdateShelfObserver; 222 class UpdateShelfObserver;
217 friend class AshPopupAlignmentDelegateTest; 223 friend class AshPopupAlignmentDelegateTest;
218 friend class ash::ScreenAsh; 224 friend class ash::ScreenAsh;
219 friend class PanelLayoutManagerTest; 225 friend class PanelLayoutManagerTest;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) override; 320 void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) override;
315 321
316 // Overridden from DockedWindowLayoutManagerObserver: 322 // Overridden from DockedWindowLayoutManagerObserver:
317 void OnDockBoundsChanging( 323 void OnDockBoundsChanging(
318 const gfx::Rect& dock_bounds, 324 const gfx::Rect& dock_bounds,
319 DockedWindowLayoutManagerObserver::Reason reason) override; 325 DockedWindowLayoutManagerObserver::Reason reason) override;
320 326
321 // Called when the LoginUI changes from visible to invisible. 327 // Called when the LoginUI changes from visible to invisible.
322 void UpdateShelfVisibilityAfterLoginUIChange(); 328 void UpdateShelfVisibilityAfterLoginUIChange();
323 329
324 // Returns true when |alignment_| is locked. This can be caused by the screen
325 // being locked, or when adding a user. Returns false when transitioning to a
326 // user session, and while the session is active.
327 bool IsAlignmentLocked() const;
328
329 // The RootWindow is cached so that we don't invoke Shell::GetInstance() from 330 // The RootWindow is cached so that we don't invoke Shell::GetInstance() from
330 // our destructor. We avoid that as at the time we're deleted Shell is being 331 // our destructor. We avoid that as at the time we're deleted Shell is being
331 // deleted too. 332 // deleted too.
332 aura::Window* root_window_; 333 aura::Window* root_window_;
333 334
334 // True when inside UpdateBoundsAndOpacity() method. Used to prevent calling 335 // True when inside UpdateBoundsAndOpacity() method. Used to prevent calling
335 // UpdateBoundsAndOpacity() again from SetChildBounds(). 336 // UpdateBoundsAndOpacity() again from SetChildBounds().
336 bool updating_bounds_; 337 bool updating_bounds_;
337 338
338 // See description above setter.
339 ShelfAutoHideBehavior auto_hide_behavior_;
340
341 // See description above getter.
342 ShelfAlignment alignment_;
343
344 // Current state. 339 // Current state.
345 State state_; 340 State state_;
346 341
347 ShelfWidget* shelf_; 342 ShelfWidget* shelf_;
348 343
349 WorkspaceController* workspace_controller_; 344 WorkspaceController* workspace_controller_;
350 345
351 // Do any windows overlap the shelf? This is maintained by WorkspaceManager. 346 // Do any windows overlap the shelf? This is maintained by WorkspaceManager.
352 bool window_overlaps_shelf_; 347 bool window_overlaps_shelf_;
353 348
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 399
405 // The show hide animation duration override or 0 for default. 400 // The show hide animation duration override or 0 for default.
406 int duration_override_in_ms_; 401 int duration_override_in_ms_;
407 402
408 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManager); 403 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManager);
409 }; 404 };
410 405
411 } // namespace ash 406 } // namespace ash
412 407
413 #endif // ASH_SHELF_SHELF_LAYOUT_MANAGER_H_ 408 #endif // ASH_SHELF_SHELF_LAYOUT_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698