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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 (state_.visibility_state == SHELF_VISIBLE || | 245 (state_.visibility_state == SHELF_VISIBLE || |
246 (state_.visibility_state == SHELF_AUTO_HIDE && | 246 (state_.visibility_state == SHELF_AUTO_HIDE && |
247 state_.auto_hide_state == SHELF_AUTO_HIDE_SHOWN)); | 247 state_.auto_hide_state == SHELF_AUTO_HIDE_SHOWN)); |
248 } | 248 } |
249 | 249 |
250 bool ShelfLayoutManager::SetAlignment(ShelfAlignment alignment) { | 250 bool ShelfLayoutManager::SetAlignment(ShelfAlignment alignment) { |
251 if (alignment_ == alignment) | 251 if (alignment_ == alignment) |
252 return false; | 252 return false; |
253 | 253 |
254 alignment_ = alignment; | 254 alignment_ = alignment; |
255 if (Shell::GetInstance()->session_state_delegate()->IsUserSessionBlocked() || | 255 if (state_.is_screen_locked || state_.is_adding_user_screen) { |
256 state_.is_adding_user_screen) { | |
257 // The shelf will itself move to the bottom while locked. If a request is | 256 // The shelf will itself move to the bottom while locked. If a request is |
258 // sent to move while being locked, we postpone the move until the lock | 257 // sent to move while being locked, we postpone the move until the lock |
259 // screen goes away. | 258 // screen goes away. |
260 return false; | 259 return false; |
261 } | 260 } |
262 | 261 |
263 // This should not be called during the lock screen transitions. | 262 // This should not be called during the lock screen transitions. |
264 shelf_->SetAlignment(alignment); | 263 shelf_->SetAlignment(alignment); |
265 LayoutShelf(); | 264 LayoutShelf(); |
266 return true; | 265 return true; |
267 } | 266 } |
268 | 267 |
269 ShelfAlignment ShelfLayoutManager::GetAlignment() const { | 268 ShelfAlignment ShelfLayoutManager::GetAlignment() const { |
270 // When the screen is locked or a user gets added, the shelf is forced into | 269 // When the screen is locked or a user gets added, the shelf is forced into |
271 // bottom alignment. Note: We cannot use state_.is_screen_locked here since | 270 // bottom alignment. Note: We cannot use state_.is_screen_locked here since |
272 // that flag gets set later than the SessionStateDelegate reports a locked | 271 // that flag gets set later than the SessionStateDelegate reports a locked |
273 // screen which leads in | 272 // screen which leads in |
274 if (Shell::GetInstance()->session_state_delegate()->IsUserSessionBlocked() || | 273 if (state_.is_screen_locked || state_.is_adding_user_screen) |
275 state_.is_adding_user_screen) | |
276 return SHELF_ALIGNMENT_BOTTOM; | 274 return SHELF_ALIGNMENT_BOTTOM; |
277 return alignment_; | 275 return alignment_; |
278 } | 276 } |
279 | 277 |
280 gfx::Rect ShelfLayoutManager::GetIdealBounds() { | 278 gfx::Rect ShelfLayoutManager::GetIdealBounds() { |
281 gfx::Rect bounds( | 279 gfx::Rect bounds( |
282 ScreenUtil::GetDisplayBoundsInParent(shelf_->GetNativeView())); | 280 ScreenUtil::GetDisplayBoundsInParent(shelf_->GetNativeView())); |
283 int width = 0, height = 0; | 281 int width = 0, height = 0; |
284 GetShelfSize(&width, &height); | 282 GetShelfSize(&width, &height); |
285 return SelectValueForShelfAlignment( | 283 return SelectValueForShelfAlignment( |
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1182 } | 1180 } |
1183 | 1181 |
1184 void ShelfLayoutManager::UpdateShelfVisibilityAfterLoginUIChange() { | 1182 void ShelfLayoutManager::UpdateShelfVisibilityAfterLoginUIChange() { |
1185 shelf_->SetAlignment(state_.is_adding_user_screen || state_.is_screen_locked ? | 1183 shelf_->SetAlignment(state_.is_adding_user_screen || state_.is_screen_locked ? |
1186 SHELF_ALIGNMENT_BOTTOM : alignment_); | 1184 SHELF_ALIGNMENT_BOTTOM : alignment_); |
1187 UpdateVisibilityState(); | 1185 UpdateVisibilityState(); |
1188 LayoutShelf(); | 1186 LayoutShelf(); |
1189 } | 1187 } |
1190 | 1188 |
1191 } // namespace ash | 1189 } // namespace ash |
OLD | NEW |