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/wm/shelf_layout_manager.h" | 5 #include "ash/wm/shelf_layout_manager.h" |
6 | 6 |
7 #include "ash/launcher/launcher.h" | 7 #include "ash/launcher/launcher.h" |
8 #include "ash/screen_ash.h" | 8 #include "ash/screen_ash.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/shell_delegate.h" | 10 #include "ash/shell_delegate.h" |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 LayoutShelf(); | 186 LayoutShelf(); |
187 } | 187 } |
188 | 188 |
189 void ShelfLayoutManager::SetAlignment(ShelfAlignment alignment) { | 189 void ShelfLayoutManager::SetAlignment(ShelfAlignment alignment) { |
190 if (alignment_ == alignment) | 190 if (alignment_ == alignment) |
191 return; | 191 return; |
192 | 192 |
193 alignment_ = alignment; | 193 alignment_ = alignment; |
194 if (launcher_) | 194 if (launcher_) |
195 launcher_->SetAlignment(alignment); | 195 launcher_->SetAlignment(alignment); |
| 196 if (Shell::GetInstance()->tray()) |
| 197 Shell::GetInstance()->tray()->SetShelfAlignment(alignment); |
196 LayoutShelf(); | 198 LayoutShelf(); |
197 } | 199 } |
198 | 200 |
199 gfx::Rect ShelfLayoutManager::GetIdealBounds() { | 201 gfx::Rect ShelfLayoutManager::GetIdealBounds() { |
200 // TODO: this is wrong. Figure out what monitor shelf is on and everything | 202 // TODO: this is wrong. Figure out what monitor shelf is on and everything |
201 // should be based on it. | 203 // should be based on it. |
202 gfx::Rect bounds( | 204 gfx::Rect bounds( |
203 gfx::Screen::GetMonitorNearestWindow(status_->GetNativeView()).bounds()); | 205 gfx::Screen::GetMonitorNearestWindow(status_->GetNativeView()).bounds()); |
204 int width = 0, height = 0; | 206 int width = 0, height = 0; |
205 GetShelfSize(&width, &height); | 207 GetShelfSize(&width, &height); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 if (launcher_widget()) | 390 if (launcher_widget()) |
389 GetLayer(launcher_widget())->GetAnimator()->StopAnimating(); | 391 GetLayer(launcher_widget())->GetAnimator()->StopAnimating(); |
390 GetLayer(status_)->GetAnimator()->StopAnimating(); | 392 GetLayer(status_)->GetAnimator()->StopAnimating(); |
391 } | 393 } |
392 | 394 |
393 void ShelfLayoutManager::GetShelfSize(int* width, int* height) { | 395 void ShelfLayoutManager::GetShelfSize(int* width, int* height) { |
394 *width = *height = 0; | 396 *width = *height = 0; |
395 gfx::Rect status_bounds(status_->GetWindowScreenBounds()); | 397 gfx::Rect status_bounds(status_->GetWindowScreenBounds()); |
396 gfx::Size launcher_size = launcher_ ? | 398 gfx::Size launcher_size = launcher_ ? |
397 launcher_widget()->GetContentsView()->GetPreferredSize() : gfx::Size(); | 399 launcher_widget()->GetContentsView()->GetPreferredSize() : gfx::Size(); |
398 if (alignment_ == SHELF_ALIGNMENT_BOTTOM) { | 400 if (alignment_ == SHELF_ALIGNMENT_BOTTOM) |
399 *height = std::max(launcher_size.height(), status_bounds.height()); | 401 *height = std::max(launcher_size.height(), status_bounds.height()); |
400 } else { | 402 else |
401 // TODO: include status when supports alignment. | 403 *width = std::max(launcher_size.width(), status_bounds.width()); |
402 *width = launcher_size.width(); | |
403 } | |
404 } | 404 } |
405 | 405 |
406 void ShelfLayoutManager::AdjustBoundsBasedOnAlignment(int inset, | 406 void ShelfLayoutManager::AdjustBoundsBasedOnAlignment(int inset, |
407 gfx::Rect* bounds) const { | 407 gfx::Rect* bounds) const { |
408 switch (alignment_) { | 408 switch (alignment_) { |
409 case SHELF_ALIGNMENT_BOTTOM: | 409 case SHELF_ALIGNMENT_BOTTOM: |
410 bounds->Inset(gfx::Insets(0, 0, inset, 0)); | 410 bounds->Inset(gfx::Insets(0, 0, inset, 0)); |
411 break; | 411 break; |
412 case SHELF_ALIGNMENT_LEFT: | 412 case SHELF_ALIGNMENT_LEFT: |
413 bounds->Inset(gfx::Insets(0, inset, 0, 0)); | 413 bounds->Inset(gfx::Insets(0, inset, 0, 0)); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 int ShelfLayoutManager::GetWorkAreaSize(const State& state, int size) const { | 567 int ShelfLayoutManager::GetWorkAreaSize(const State& state, int size) const { |
568 if (state.visibility_state == VISIBLE) | 568 if (state.visibility_state == VISIBLE) |
569 return size; | 569 return size; |
570 if (state.visibility_state == AUTO_HIDE) | 570 if (state.visibility_state == AUTO_HIDE) |
571 return kAutoHideSize; | 571 return kAutoHideSize; |
572 return 0; | 572 return 0; |
573 } | 573 } |
574 | 574 |
575 } // namespace internal | 575 } // namespace internal |
576 } // namespace ash | 576 } // namespace ash |
OLD | NEW |