OLD | NEW |
---|---|
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 #include "ash/shelf/shelf_layout_manager.h" | 5 #include "ash/shelf/shelf_layout_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <cstring> | 9 #include <cstring> |
10 #include <string> | 10 #include <string> |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
234 | 234 |
235 bool ShelfLayoutManager::IsVisible() const { | 235 bool ShelfLayoutManager::IsVisible() const { |
236 // status_area_widget() may be NULL during the shutdown. | 236 // status_area_widget() may be NULL during the shutdown. |
237 return shelf_->status_area_widget() && | 237 return shelf_->status_area_widget() && |
238 shelf_->status_area_widget()->IsVisible() && | 238 shelf_->status_area_widget()->IsVisible() && |
239 (state_.visibility_state == SHELF_VISIBLE || | 239 (state_.visibility_state == SHELF_VISIBLE || |
240 (state_.visibility_state == SHELF_AUTO_HIDE && | 240 (state_.visibility_state == SHELF_AUTO_HIDE && |
241 state_.auto_hide_state == SHELF_AUTO_HIDE_SHOWN)); | 241 state_.auto_hide_state == SHELF_AUTO_HIDE_SHOWN)); |
242 } | 242 } |
243 | 243 |
244 bool ShelfLayoutManager::SetAlignment(ShelfAlignment alignment) { | 244 bool ShelfLayoutManager::SetAlignment(ShelfAlignment alignment) { |
tdanderson
2015/02/11 20:32:35
Does the documentation for SetAlignment() in the h
jonross
2015/02/11 22:17:44
Nope, the docs already say that the setting can be
| |
245 if (alignment_ == alignment) | 245 if (alignment_ == alignment) |
246 return false; | 246 return false; |
247 | 247 |
248 alignment_ = alignment; | 248 alignment_ = alignment; |
249 if (Shell::GetInstance()->session_state_delegate()->IsUserSessionBlocked() || | 249 // The shelf will itself move to the bottom while locked or obscured by user |
250 state_.is_adding_user_screen) { | 250 // login. If a request is sent to move while being obscured, we postpone the |
251 // The shelf will itself move to the bottom while locked. If a request is | 251 // move until the user session is resumed. |
252 // sent to move while being locked, we postpone the move until the lock | 252 if (ShouldOverrideAlignment()) |
253 // screen goes away. | |
254 return false; | 253 return false; |
255 } | |
256 | 254 |
257 // This should not be called during the lock screen transitions. | 255 // This should not be called during the lock screen transitions. |
258 shelf_->SetAlignment(alignment); | 256 shelf_->SetAlignment(alignment); |
259 LayoutShelf(); | 257 LayoutShelf(); |
260 return true; | 258 return true; |
261 } | 259 } |
262 | 260 |
263 ShelfAlignment ShelfLayoutManager::GetAlignment() const { | 261 ShelfAlignment ShelfLayoutManager::GetAlignment() const { |
264 // When the screen is locked or a user gets added, the shelf is forced into | 262 // When the screen is locked or a user gets added, the shelf is forced into |
265 // bottom alignment. Note: We cannot use state_.is_screen_locked here since | 263 // bottom alignment. |
266 // that flag gets set later than the SessionStateDelegate reports a locked | 264 if (ShouldOverrideAlignment()) |
267 // screen which leads in | |
268 if (Shell::GetInstance()->session_state_delegate()->IsUserSessionBlocked() || | |
269 state_.is_adding_user_screen) | |
270 return SHELF_ALIGNMENT_BOTTOM; | 265 return SHELF_ALIGNMENT_BOTTOM; |
271 return alignment_; | 266 return alignment_; |
272 } | 267 } |
273 | 268 |
274 gfx::Rect ShelfLayoutManager::GetIdealBounds() { | 269 gfx::Rect ShelfLayoutManager::GetIdealBounds() { |
275 gfx::Rect bounds( | 270 gfx::Rect bounds( |
276 ScreenUtil::GetDisplayBoundsInParent(shelf_->GetNativeView())); | 271 ScreenUtil::GetDisplayBoundsInParent(shelf_->GetNativeView())); |
277 int width = 0, height = 0; | 272 int width = 0, height = 0; |
278 GetShelfSize(&width, &height); | 273 GetShelfSize(&width, &height); |
279 return SelectValueForShelfAlignment( | 274 return SelectValueForShelfAlignment( |
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1152 UpdateShelfVisibilityAfterLoginUIChange(); | 1147 UpdateShelfVisibilityAfterLoginUIChange(); |
1153 return; | 1148 return; |
1154 } | 1149 } |
1155 TargetBounds target_bounds; | 1150 TargetBounds target_bounds; |
1156 CalculateTargetBounds(state_, &target_bounds); | 1151 CalculateTargetBounds(state_, &target_bounds); |
1157 UpdateBoundsAndOpacity(target_bounds, true, NULL); | 1152 UpdateBoundsAndOpacity(target_bounds, true, NULL); |
1158 UpdateVisibilityState(); | 1153 UpdateVisibilityState(); |
1159 } | 1154 } |
1160 | 1155 |
1161 void ShelfLayoutManager::UpdateShelfVisibilityAfterLoginUIChange() { | 1156 void ShelfLayoutManager::UpdateShelfVisibilityAfterLoginUIChange() { |
1162 shelf_->SetAlignment(state_.is_adding_user_screen || state_.is_screen_locked ? | 1157 shelf_->SetAlignment(GetAlignment()); |
1163 SHELF_ALIGNMENT_BOTTOM : alignment_); | |
1164 UpdateVisibilityState(); | 1158 UpdateVisibilityState(); |
1165 LayoutShelf(); | 1159 LayoutShelf(); |
1166 } | 1160 } |
1167 | 1161 |
1162 bool ShelfLayoutManager::ShouldOverrideAlignment() const { | |
tdanderson
2015/02/11 20:32:35
I suggest re-naming this method to something of th
jonross
2015/02/11 22:17:44
Done.
| |
1163 // When a user session is blocked, the shelf alignment should be forced to the | |
1164 // bottom. It can be blocked by the screen being locked, or when adding a | |
1165 // user. However the session state becomes active at the start of | |
1166 // transitioning to a user session, while the user session is considered | |
1167 // blocked until the full UI is ready. In order for proper layout we stop | |
1168 // overriding alignment during the transition. | |
tdanderson
2015/02/11 20:32:35
I love that you're adding documentation to the cod
jonross
2015/02/11 22:17:44
Done.
| |
1169 return ((Shell::GetInstance()->session_state_delegate()->GetSessionState() != | |
tdanderson
2015/02/11 20:32:35
I find this compound expression really difficult t
jonross
2015/02/11 22:17:44
Done.
| |
1170 SessionStateDelegate::SESSION_STATE_ACTIVE) && | |
1171 (Shell::GetInstance() | |
1172 ->session_state_delegate() | |
1173 ->IsUserSessionBlocked() || | |
1174 state_.is_adding_user_screen)) || | |
1175 state_.is_screen_locked; | |
1176 } | |
1177 | |
1168 } // namespace ash | 1178 } // namespace ash |
OLD | NEW |