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/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
9 #include "ash/screen_ash.h" | 9 #include "ash/screen_ash.h" |
10 #include "ash/shelf/shelf_layout_manager.h" | 10 #include "ash/shelf/shelf_layout_manager.h" |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
436 } | 436 } |
437 | 437 |
438 void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) { | 438 void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) { |
439 shelf_alignment_ = alignment; | 439 shelf_alignment_ = alignment; |
440 SetBorder(); | 440 SetBorder(); |
441 tray_container_->SetAlignment(alignment); | 441 tray_container_->SetAlignment(alignment); |
442 } | 442 } |
443 | 443 |
444 void TrayBackgroundView::SetBorder() { | 444 void TrayBackgroundView::SetBorder() { |
445 views::View* parent = status_area_widget_->status_area_widget_delegate(); | 445 views::View* parent = status_area_widget_->status_area_widget_delegate(); |
446 | 446 // Tray views are laid out right-to-left or bottom-to-top |
447 int on_edge = (this == parent->child_at(0)); | |
447 if (ash::switches::UseAlternateShelfLayout()) { | 448 if (ash::switches::UseAlternateShelfLayout()) { |
448 set_border(views::Border::CreateEmptyBorder( | 449 int inner_edge = ShelfLayoutManager::kShelfItemInset; |
449 0, | 450 int outer_edge = |
450 0, | 451 ShelfLayoutManager::GetPreferredShelfSize() - inner_edge - |
451 ShelfLayoutManager::kAutoHideSize, | 452 GetShelfItemHeight(); |
452 0)); | 453 if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { |
454 set_border(views::Border::CreateEmptyBorder( | |
455 inner_edge, | |
456 0, | |
457 outer_edge, | |
458 on_edge ? kPaddingFromEdgeOfShelf : 0)); | |
459 } else if (shelf_alignment() == SHELF_ALIGNMENT_LEFT) { | |
460 set_border(views::Border::CreateEmptyBorder( | |
461 0, | |
462 outer_edge, | |
463 on_edge ? kPaddingFromEdgeOfShelf : 0, | |
464 inner_edge)); | |
465 } else { // SHELF_ALIGNMENT_RIGHT | |
466 set_border(views::Border::CreateEmptyBorder( | |
467 0, | |
468 inner_edge, | |
469 on_edge ? kPaddingFromEdgeOfShelf : 0, | |
470 outer_edge)); | |
471 } | |
Mr4D (OOO till 08-26)
2013/09/18 00:07:49
Looking at this function I wonder if it is not bet
Harry McCleave
2013/09/18 01:34:56
Done.
| |
453 } else { | 472 } else { |
454 // Tray views are laid out right-to-left or bottom-to-top | |
455 int on_edge = (this == parent->child_at(0)); | |
456 // Change the border padding for different shelf alignment. | 473 // Change the border padding for different shelf alignment. |
457 if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { | 474 if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { |
458 set_border(views::Border::CreateEmptyBorder( | 475 set_border(views::Border::CreateEmptyBorder( |
459 0, 0, | 476 0, 0, |
460 on_edge ? kPaddingFromBottomOfScreenBottomAlignment : | 477 on_edge ? kPaddingFromBottomOfScreenBottomAlignment : |
461 kPaddingFromBottomOfScreenBottomAlignment - 1, | 478 kPaddingFromBottomOfScreenBottomAlignment - 1, |
462 on_edge ? kPaddingFromRightEdgeOfScreenBottomAlignment : 0)); | 479 on_edge ? kPaddingFromRightEdgeOfScreenBottomAlignment : 0)); |
463 } else if (shelf_alignment() == SHELF_ALIGNMENT_TOP) { | 480 } else if (shelf_alignment() == SHELF_ALIGNMENT_TOP) { |
464 set_border(views::Border::CreateEmptyBorder( | 481 set_border(views::Border::CreateEmptyBorder( |
465 on_edge ? kPaddingFromBottomOfScreenBottomAlignment : | 482 on_edge ? kPaddingFromBottomOfScreenBottomAlignment : |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
502 gfx::Rect TrayBackgroundView::GetBubbleAnchorRect( | 519 gfx::Rect TrayBackgroundView::GetBubbleAnchorRect( |
503 views::Widget* anchor_widget, | 520 views::Widget* anchor_widget, |
504 TrayBubbleView::AnchorType anchor_type, | 521 TrayBubbleView::AnchorType anchor_type, |
505 TrayBubbleView::AnchorAlignment anchor_alignment) const { | 522 TrayBubbleView::AnchorAlignment anchor_alignment) const { |
506 gfx::Rect rect; | 523 gfx::Rect rect; |
507 if (anchor_widget && anchor_widget->IsVisible()) { | 524 if (anchor_widget && anchor_widget->IsVisible()) { |
508 rect = anchor_widget->GetWindowBoundsInScreen(); | 525 rect = anchor_widget->GetWindowBoundsInScreen(); |
509 if (anchor_type == TrayBubbleView::ANCHOR_TYPE_TRAY) { | 526 if (anchor_type == TrayBubbleView::ANCHOR_TYPE_TRAY) { |
510 if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM) { | 527 if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM) { |
511 bool rtl = base::i18n::IsRTL(); | 528 bool rtl = base::i18n::IsRTL(); |
512 rect.Inset( | 529 if (!ash::switches::UseAlternateShelfLayout()) { |
513 rtl ? kPaddingFromRightEdgeOfScreenBottomAlignment : 0, | 530 rect.Inset( |
514 kTrayBubbleAnchorTopInsetBottomAnchor, | 531 rtl ? kPaddingFromRightEdgeOfScreenBottomAlignment : 0, |
515 rtl ? 0 : kPaddingFromRightEdgeOfScreenBottomAlignment, | 532 kTrayBubbleAnchorTopInsetBottomAnchor, |
516 kPaddingFromBottomOfScreenBottomAlignment); | 533 rtl ? 0 : kPaddingFromRightEdgeOfScreenBottomAlignment, |
534 kPaddingFromBottomOfScreenBottomAlignment); | |
535 } else { | |
536 rect.Inset( | |
537 rtl ? kAlternateLayoutBubblePaddingHorizontalSide : 0, | |
538 kAlternateLayoutBubblePaddingHorizontalBottom, | |
539 rtl ? 0 : kAlternateLayoutBubblePaddingHorizontalSide, | |
540 0);//kAlternateLayoutBubblePaddingHorizontalBottom); | |
Mr4D (OOO till 08-26)
2013/09/18 00:07:49
I think you can remove the comment here?
Harry McCleave
2013/09/18 01:34:56
Done.
Harry McCleave
2013/09/18 01:34:56
Done.
| |
541 } | |
517 } else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_LEFT) { | 542 } else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_LEFT) { |
518 rect.Inset(0, 0, kPaddingFromInnerEdgeOfLauncherVerticalAlignment + 5, | 543 if (!ash::switches::UseAlternateShelfLayout()) { |
519 kPaddingFromBottomOfScreenVerticalAlignment); | 544 rect.Inset(0, 0, kPaddingFromInnerEdgeOfLauncherVerticalAlignment + 5, |
545 kPaddingFromBottomOfScreenVerticalAlignment); | |
546 } else { | |
547 rect.Inset(0, 0, kAlternateLayoutBubblePaddingVerticalSide + 4, | |
548 kAlternateLayoutBubblePaddingVerticalBottom); | |
549 } | |
520 } else { | 550 } else { |
521 rect.Inset(kPaddingFromInnerEdgeOfLauncherVerticalAlignment + 1, | 551 if (!ash::switches::UseAlternateShelfLayout()) { |
522 0, 0, kPaddingFromBottomOfScreenVerticalAlignment); | 552 rect.Inset(kPaddingFromInnerEdgeOfLauncherVerticalAlignment + 1, |
553 0, 0, kPaddingFromBottomOfScreenVerticalAlignment); | |
554 } else { | |
555 rect.Inset(kAlternateLayoutBubblePaddingVerticalSide, 0, 0, | |
556 kAlternateLayoutBubblePaddingVerticalBottom); | |
557 } | |
523 } | 558 } |
524 } else if (anchor_type == TrayBubbleView::ANCHOR_TYPE_BUBBLE) { | 559 } else if (anchor_type == TrayBubbleView::ANCHOR_TYPE_BUBBLE) { |
525 // Invert the offsets to align with the bubble below. | 560 // Invert the offsets to align with the bubble below. |
526 // Note that with the alternate shelf layout the tips are not shown and | 561 // Note that with the alternate shelf layout the tips are not shown and |
527 // the offsets for left and right alignment do not need to be applied. | 562 // the offsets for left and right alignment do not need to be applied. |
528 int vertical_alignment = ash::switches::UseAlternateShelfLayout() ? | 563 int vertical_alignment = ash::switches::UseAlternateShelfLayout() ? |
529 0 : kPaddingFromInnerEdgeOfLauncherVerticalAlignment; | 564 0 : |
530 if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_LEFT) { | 565 kPaddingFromInnerEdgeOfLauncherVerticalAlignment; |
531 rect.Inset(vertical_alignment, | 566 int horizontal_alignment = ash::switches::UseAlternateShelfLayout() ? |
532 0, 0, kPaddingFromBottomOfScreenVerticalAlignment); | 567 kAlternateLayoutBubblePaddingVerticalBottom : |
533 } else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT) { | 568 kPaddingFromBottomOfScreenVerticalAlignment; |
534 rect.Inset(0, 0, vertical_alignment, | 569 if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_LEFT) |
535 kPaddingFromBottomOfScreenVerticalAlignment); | 570 rect.Inset(vertical_alignment, 0, 0, horizontal_alignment); |
536 } | 571 else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT) |
572 rect.Inset(0, 0, vertical_alignment, horizontal_alignment); | |
537 } | 573 } |
538 } | 574 } |
539 | 575 |
540 // TODO(jennyz): May need to add left/right alignment in the following code. | 576 // TODO(jennyz): May need to add left/right alignment in the following code. |
541 if (rect.IsEmpty()) { | 577 if (rect.IsEmpty()) { |
542 aura::RootWindow* target_root = anchor_widget ? | 578 aura::RootWindow* target_root = anchor_widget ? |
543 anchor_widget->GetNativeView()->GetRootWindow() : | 579 anchor_widget->GetNativeView()->GetRootWindow() : |
544 Shell::GetPrimaryRootWindow(); | 580 Shell::GetPrimaryRootWindow(); |
545 rect = target_root->bounds(); | 581 rect = target_root->bounds(); |
546 rect = gfx::Rect( | 582 rect = gfx::Rect( |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
593 ash::internal::ShelfLayoutManager* shelf = | 629 ash::internal::ShelfLayoutManager* shelf = |
594 ShelfLayoutManager::ForLauncher(root_window); | 630 ShelfLayoutManager::ForLauncher(root_window); |
595 bubble_view->SetArrowPaintType( | 631 bubble_view->SetArrowPaintType( |
596 (shelf && shelf->IsVisible()) ? | 632 (shelf && shelf->IsVisible()) ? |
597 views::BubbleBorder::PAINT_NORMAL : | 633 views::BubbleBorder::PAINT_NORMAL : |
598 views::BubbleBorder::PAINT_TRANSPARENT); | 634 views::BubbleBorder::PAINT_TRANSPARENT); |
599 } | 635 } |
600 | 636 |
601 } // namespace internal | 637 } // namespace internal |
602 } // namespace ash | 638 } // namespace ash |
OLD | NEW |