Chromium Code Reviews| 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/system/tray/tray_background_view.h" | 5 #include "ash/system/tray/tray_background_view.h" |
| 6 | 6 |
| 7 #include "ash/material_design/material_design_controller.h" | |
| 7 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
| 8 #include "ash/screen_util.h" | 9 #include "ash/screen_util.h" |
| 9 #include "ash/shelf/shelf_layout_manager.h" | 10 #include "ash/shelf/shelf_layout_manager.h" |
| 10 #include "ash/shelf/shelf_util.h" | 11 #include "ash/shelf/shelf_util.h" |
| 11 #include "ash/shelf/shelf_widget.h" | 12 #include "ash/shelf/shelf_widget.h" |
| 12 #include "ash/shell.h" | 13 #include "ash/shell.h" |
| 13 #include "ash/shell_window_ids.h" | 14 #include "ash/shell_window_ids.h" |
| 14 #include "ash/system/status_area_widget.h" | 15 #include "ash/system/status_area_widget.h" |
| 15 #include "ash/system/status_area_widget_delegate.h" | 16 #include "ash/system/status_area_widget_delegate.h" |
| 16 #include "ash/system/tray/system_tray.h" | 17 #include "ash/system/tray/system_tray.h" |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 void TrayBackgroundView::TrayContainer::ViewHierarchyChanged( | 189 void TrayBackgroundView::TrayContainer::ViewHierarchyChanged( |
| 189 const ViewHierarchyChangedDetails& details) { | 190 const ViewHierarchyChangedDetails& details) { |
| 190 if (details.parent == this) | 191 if (details.parent == this) |
| 191 PreferredSizeChanged(); | 192 PreferredSizeChanged(); |
| 192 } | 193 } |
| 193 | 194 |
| 194 void TrayBackgroundView::TrayContainer::UpdateLayout() { | 195 void TrayBackgroundView::TrayContainer::UpdateLayout() { |
| 195 // Adjust the size of status tray dark background by adding additional | 196 // Adjust the size of status tray dark background by adding additional |
| 196 // empty border. | 197 // empty border. |
| 197 if (wm::IsHorizontalAlignment(alignment_)) { | 198 if (wm::IsHorizontalAlignment(alignment_)) { |
| 198 SetBorder(views::Border::CreateEmptyBorder( | 199 SetBorder(views::Border::CreateEmptyBorder( |
|
bruthig
2016/05/25 20:24:52
There appears to be quite a bit of duplicated code
yiyix
2016/06/02 03:54:53
Done.
| |
| 199 kPaddingFromEdgeOfShelf, | 200 kEmptyBoarderPadding, kEmptyBoarderPadding, kEmptyBoarderPadding, |
| 200 kPaddingFromEdgeOfShelf, | 201 kEmptyBoarderPadding)); |
| 201 kPaddingFromEdgeOfShelf, | |
| 202 kPaddingFromEdgeOfShelf)); | |
| 203 | 202 |
| 204 views::BoxLayout* layout = | 203 views::BoxLayout* layout = |
| 205 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); | 204 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); |
| 206 layout->SetDefaultFlex(1); | 205 layout->SetDefaultFlex(1); |
| 207 views::View::SetLayoutManager(layout); | 206 views::View::SetLayoutManager(layout); |
| 208 } else { | 207 } else { |
| 209 SetBorder(views::Border::CreateEmptyBorder( | 208 SetBorder(views::Border::CreateEmptyBorder( |
| 210 kPaddingFromEdgeOfShelf, | 209 kEmptyBoarderPadding, kEmptyBoarderPadding, kEmptyBoarderPadding, |
| 211 kPaddingFromEdgeOfShelf, | 210 kEmptyBoarderPadding)); |
| 212 kPaddingFromEdgeOfShelf, | |
| 213 kPaddingFromEdgeOfShelf)); | |
| 214 | 211 |
| 215 views::BoxLayout* layout = | 212 views::BoxLayout* layout = |
| 216 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0); | 213 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0); |
| 217 layout->SetDefaultFlex(1); | 214 layout->SetDefaultFlex(1); |
| 218 views::View::SetLayoutManager(layout); | 215 views::View::SetLayoutManager(layout); |
| 219 } | 216 } |
| 220 PreferredSizeChanged(); | 217 PreferredSizeChanged(); |
| 221 } | 218 } |
| 222 | 219 |
| 223 //////////////////////////////////////////////////////////////////////////////// | 220 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 409 shelf_alignment_ = alignment; | 406 shelf_alignment_ = alignment; |
| 410 SetTrayBorder(); | 407 SetTrayBorder(); |
| 411 tray_container_->SetAlignment(alignment); | 408 tray_container_->SetAlignment(alignment); |
| 412 } | 409 } |
| 413 | 410 |
| 414 void TrayBackgroundView::SetTrayBorder() { | 411 void TrayBackgroundView::SetTrayBorder() { |
| 415 views::View* parent = status_area_widget_->status_area_widget_delegate(); | 412 views::View* parent = status_area_widget_->status_area_widget_delegate(); |
| 416 // Tray views are laid out right-to-left or bottom-to-top | 413 // Tray views are laid out right-to-left or bottom-to-top |
| 417 bool on_edge = (this == parent->child_at(0)); | 414 bool on_edge = (this == parent->child_at(0)); |
| 418 int left_edge, top_edge, right_edge, bottom_edge; | 415 int left_edge, top_edge, right_edge, bottom_edge; |
| 419 if (wm::IsHorizontalAlignment(shelf_alignment())) { | 416 |
| 420 top_edge = ShelfLayoutManager::kShelfItemInset; | 417 if (MaterialDesignController::IsShelfMaterial()) { |
| 421 left_edge = 0; | 418 if (wm::IsHorizontalAlignment(shelf_alignment())) { |
| 422 bottom_edge = kShelfSize - | 419 top_edge = (GetShelfLayoutConstant(SHELF_SIZE) - kShelfItemHeight) / 2; |
| 423 ShelfLayoutManager::kShelfItemInset - kShelfItemHeight; | 420 left_edge = 0; |
| 424 right_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; | 421 bottom_edge = (GetShelfLayoutConstant(SHELF_SIZE) - kShelfItemHeight) / 2; |
| 425 } else if (shelf_alignment() == wm::SHELF_ALIGNMENT_LEFT) { | 422 right_edge = |
| 426 top_edge = 0; | 423 on_edge |
| 427 left_edge = kShelfSize - | 424 ? GetShelfStatusAreaInset(PADDING_FROM_EDGE_TO_OVERVIEW_BUTTON) |
|
tdanderson
2016/05/26 22:55:56
I think I have a better idea of what's happening h
yiyix
2016/06/02 03:54:53
We have discussed it in person earlier this week.
| |
| 428 ShelfLayoutManager::kShelfItemInset - kShelfItemHeight; | 425 : 0; |
| 429 bottom_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; | 426 } else { // SHELF_ALIGNMENT_LEFT || SHELF_ALIGNMENT_RIGHT |
| 430 right_edge = ShelfLayoutManager::kShelfItemInset; | 427 top_edge = 0; |
| 431 } else { // SHELF_ALIGNMENT_RIGHT | 428 left_edge = (GetShelfLayoutConstant(SHELF_SIZE) - kShelfItemHeight) / 2; |
| 432 top_edge = 0; | 429 bottom_edge = |
| 433 left_edge = ShelfLayoutManager::kShelfItemInset; | 430 on_edge |
| 434 bottom_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; | 431 ? GetShelfStatusAreaInset(PADDING_FROM_EDGE_TO_OVERVIEW_BUTTON) |
| 435 right_edge = kShelfSize - | 432 : 0; |
| 436 ShelfLayoutManager::kShelfItemInset - kShelfItemHeight; | 433 right_edge = (GetShelfLayoutConstant(SHELF_SIZE) - kShelfItemHeight) / 2; |
| 434 } | |
| 435 } else { | |
| 436 if (wm::IsHorizontalAlignment(shelf_alignment())) { | |
| 437 top_edge = ShelfLayoutManager::GetShelfItemInset( | |
| 438 ShelfLayoutManager::SHELF_ITEM_INSET); | |
| 439 left_edge = 0; | |
| 440 bottom_edge = GetShelfLayoutConstant(SHELF_SIZE) - | |
| 441 ShelfLayoutManager::GetShelfItemInset( | |
| 442 ShelfLayoutManager::SHELF_ITEM_INSET) - | |
| 443 kShelfItemHeight; | |
| 444 right_edge = | |
| 445 on_edge | |
| 446 ? GetShelfStatusAreaInset(PADDING_FROM_EDGE_TO_OVERVIEW_BUTTON) | |
| 447 : 0; | |
| 448 } else if (shelf_alignment() == wm::SHELF_ALIGNMENT_LEFT) { | |
| 449 top_edge = 0; | |
| 450 left_edge = GetShelfLayoutConstant(SHELF_SIZE) - | |
| 451 ShelfLayoutManager::GetShelfItemInset( | |
| 452 ShelfLayoutManager::SHELF_ITEM_INSET) - | |
| 453 kShelfItemHeight; | |
| 454 bottom_edge = | |
| 455 on_edge | |
| 456 ? GetShelfStatusAreaInset(PADDING_FROM_EDGE_TO_OVERVIEW_BUTTON) | |
| 457 : 0; | |
| 458 right_edge = ShelfLayoutManager::GetShelfItemInset( | |
| 459 ShelfLayoutManager::SHELF_ITEM_INSET); | |
| 460 } else { // SHELF_ALIGNMENT_RIGHT | |
| 461 top_edge = 0; | |
| 462 left_edge = ShelfLayoutManager::GetShelfItemInset( | |
| 463 ShelfLayoutManager::SHELF_ITEM_INSET); | |
| 464 bottom_edge = | |
| 465 on_edge | |
| 466 ? GetShelfStatusAreaInset(PADDING_FROM_EDGE_TO_OVERVIEW_BUTTON) | |
| 467 : 0; | |
| 468 right_edge = GetShelfLayoutConstant(SHELF_SIZE) - | |
| 469 ShelfLayoutManager::GetShelfItemInset( | |
| 470 ShelfLayoutManager::SHELF_ITEM_INSET) - | |
| 471 kShelfItemHeight; | |
| 472 } | |
| 437 } | 473 } |
| 438 SetBorder(views::Border::CreateEmptyBorder( | 474 SetBorder(views::Border::CreateEmptyBorder( |
| 439 top_edge, left_edge, bottom_edge, right_edge)); | 475 top_edge, left_edge, bottom_edge, right_edge)); |
| 440 } | 476 } |
| 441 | 477 |
| 442 void TrayBackgroundView::OnImplicitAnimationsCompleted() { | 478 void TrayBackgroundView::OnImplicitAnimationsCompleted() { |
| 443 // If there is another animation in the queue, the reverse animation was | 479 // If there is another animation in the queue, the reverse animation was |
| 444 // triggered before the completion of animating to invisible. Do not turn off | 480 // triggered before the completion of animating to invisible. Do not turn off |
| 445 // the visibility so that the next animation may render. The value of | 481 // the visibility so that the next animation may render. The value of |
| 446 // layer()->GetTargetVisibility() can be incorrect if the hide animation was | 482 // layer()->GetTargetVisibility() can be incorrect if the hide animation was |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 582 background_->set_alpha(kTrayBackgroundAlpha); | 618 background_->set_alpha(kTrayBackgroundAlpha); |
| 583 SchedulePaint(); | 619 SchedulePaint(); |
| 584 } | 620 } |
| 585 | 621 |
| 586 void TrayBackgroundView::UpdateBubbleViewArrow( | 622 void TrayBackgroundView::UpdateBubbleViewArrow( |
| 587 views::TrayBubbleView* bubble_view) { | 623 views::TrayBubbleView* bubble_view) { |
| 588 // Nothing to do here. | 624 // Nothing to do here. |
| 589 } | 625 } |
| 590 | 626 |
| 591 } // namespace ash | 627 } // namespace ash |
| OLD | NEW |