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 | 9 |
10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 | 197 |
198 alignment_ = alignment; | 198 alignment_ = alignment; |
199 if (shelf_->launcher()) | 199 if (shelf_->launcher()) |
200 shelf_->launcher()->SetAlignment(alignment); | 200 shelf_->launcher()->SetAlignment(alignment); |
201 shelf_->status_area_widget()->SetShelfAlignment(alignment); | 201 shelf_->status_area_widget()->SetShelfAlignment(alignment); |
202 LayoutShelf(); | 202 LayoutShelf(); |
203 return true; | 203 return true; |
204 } | 204 } |
205 | 205 |
206 gfx::Rect ShelfLayoutManager::GetIdealBounds() { | 206 gfx::Rect ShelfLayoutManager::GetIdealBounds() { |
207 // TODO(oshima): this is wrong. Figure out what display shelf is on | |
208 // and everything should be based on it. | |
209 gfx::Rect bounds( | 207 gfx::Rect bounds( |
210 ScreenAsh::GetDisplayBoundsInParent(shelf_->GetNativeView())); | 208 ScreenAsh::GetDisplayBoundsInParent(shelf_->GetNativeView())); |
211 int width = 0, height = 0; | 209 int width = 0, height = 0; |
212 GetShelfSize(&width, &height); | 210 GetShelfSize(&width, &height); |
213 return SelectValueForShelfAlignment( | 211 return SelectValueForShelfAlignment( |
214 gfx::Rect(bounds.x(), bounds.bottom() - height, bounds.width(), height), | 212 gfx::Rect(bounds.x(), bounds.bottom() - height, bounds.width(), height), |
215 gfx::Rect(bounds.x(), bounds.y(), width, bounds.height()), | 213 gfx::Rect(bounds.x(), bounds.y(), width, bounds.height()), |
216 gfx::Rect(bounds.right() - width, bounds.y(), width, bounds.height()), | 214 gfx::Rect(bounds.right() - width, bounds.y(), width, bounds.height()), |
217 gfx::Rect(bounds.x(), bounds.y(), bounds.width(), height)); | 215 gfx::Rect(bounds.x(), bounds.y(), bounds.width(), height)); |
218 } | 216 } |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 return shelf ? shelf->shelf_layout_manager() : NULL; | 505 return shelf ? shelf->shelf_layout_manager() : NULL; |
508 } | 506 } |
509 | 507 |
510 //////////////////////////////////////////////////////////////////////////////// | 508 //////////////////////////////////////////////////////////////////////////////// |
511 // ShelfLayoutManager, private: | 509 // ShelfLayoutManager, private: |
512 | 510 |
513 ShelfLayoutManager::TargetBounds::TargetBounds() : opacity(0.0f) {} | 511 ShelfLayoutManager::TargetBounds::TargetBounds() : opacity(0.0f) {} |
514 ShelfLayoutManager::TargetBounds::~TargetBounds() {} | 512 ShelfLayoutManager::TargetBounds::~TargetBounds() {} |
515 | 513 |
516 void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) { | 514 void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) { |
| 515 if (!shelf_->GetNativeView()) |
| 516 return; |
| 517 |
517 State state; | 518 State state; |
518 state.visibility_state = visibility_state; | 519 state.visibility_state = visibility_state; |
519 state.auto_hide_state = CalculateAutoHideState(visibility_state); | 520 state.auto_hide_state = CalculateAutoHideState(visibility_state); |
520 state.is_screen_locked = | 521 state.is_screen_locked = |
521 Shell::GetInstance()->session_state_delegate()->IsScreenLocked(); | 522 Shell::GetInstance()->session_state_delegate()->IsScreenLocked(); |
522 | 523 |
523 // It's possible for SetState() when a window becomes maximized but the state | 524 // It's possible for SetState() when a window becomes maximized but the state |
524 // won't have changed value. Do the dimming check before the early exit. | 525 // won't have changed value. Do the dimming check before the early exit. |
525 if (workspace_controller_) { | 526 if (workspace_controller_) { |
526 shelf_->SetDimsShelf( | 527 shelf_->SetDimsShelf( |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
907 int ShelfLayoutManager::GetWorkAreaSize(const State& state, int size) const { | 908 int ShelfLayoutManager::GetWorkAreaSize(const State& state, int size) const { |
908 if (state.visibility_state == SHELF_VISIBLE) | 909 if (state.visibility_state == SHELF_VISIBLE) |
909 return size; | 910 return size; |
910 if (state.visibility_state == SHELF_AUTO_HIDE) | 911 if (state.visibility_state == SHELF_AUTO_HIDE) |
911 return kAutoHideSize; | 912 return kAutoHideSize; |
912 return 0; | 913 return 0; |
913 } | 914 } |
914 | 915 |
915 } // namespace internal | 916 } // namespace internal |
916 } // namespace ash | 917 } // namespace ash |
OLD | NEW |