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_util.h" | 9 #include "ash/screen_util.h" |
10 #include "ash/shelf/shelf_layout_manager.h" | 10 #include "ash/shelf/shelf_layout_manager.h" |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
541 if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM) { | 541 if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM) { |
542 bool rtl = base::i18n::IsRTL(); | 542 bool rtl = base::i18n::IsRTL(); |
543 rect.Inset( | 543 rect.Inset( |
544 rtl ? kBubblePaddingHorizontalSide : 0, | 544 rtl ? kBubblePaddingHorizontalSide : 0, |
545 kBubblePaddingHorizontalBottom, | 545 kBubblePaddingHorizontalBottom, |
546 rtl ? 0 : kBubblePaddingHorizontalSide, | 546 rtl ? 0 : kBubblePaddingHorizontalSide, |
547 0); | 547 0); |
548 } else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_LEFT) { | 548 } else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_LEFT) { |
549 rect.Inset(0, 0, kBubblePaddingVerticalSide + 4, | 549 rect.Inset(0, 0, kBubblePaddingVerticalSide + 4, |
550 kBubblePaddingVerticalBottom); | 550 kBubblePaddingVerticalBottom); |
551 } else { | 551 } else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT) { |
552 rect.Inset(kBubblePaddingVerticalSide, 0, 0, | 552 rect.Inset(kBubblePaddingVerticalSide, 0, 0, |
553 kBubblePaddingVerticalBottom); | 553 kBubblePaddingVerticalBottom); |
554 } else { | |
555 // TODO(bruthig) May need to handle other ANCHOR_ALIGNMENT_ values. | |
556 // ie. ANCHOR_ALIGNMENT_TOP | |
557 DCHECK(false) << "Unhandled anchor alignment."; | |
554 } | 558 } |
555 } else if (anchor_type == TrayBubbleView::ANCHOR_TYPE_BUBBLE) { | 559 } else if (anchor_type == TrayBubbleView::ANCHOR_TYPE_BUBBLE) { |
556 // Invert the offsets to align with the bubble below. | 560 // Invert the offsets to align with the bubble below. |
557 // 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 |
558 // 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. |
559 int vertical_alignment = 0; | 563 int vertical_alignment = 0; |
560 int horizontal_alignment = kBubblePaddingVerticalBottom; | 564 int horizontal_alignment = kBubblePaddingVerticalBottom; |
561 if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_LEFT) | 565 if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_LEFT) |
562 rect.Inset(vertical_alignment, 0, 0, horizontal_alignment); | 566 rect.Inset(vertical_alignment, 0, 0, horizontal_alignment); |
563 else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT) | 567 else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT) |
564 rect.Inset(0, 0, vertical_alignment, horizontal_alignment); | 568 rect.Inset(0, 0, vertical_alignment, horizontal_alignment); |
569 } else { | |
570 DCHECK(false) << "Unhandled anchor type."; | |
565 } | 571 } |
566 } | 572 } else { |
567 | |
568 // TODO(jennyz): May need to add left/right alignment in the following code. | |
569 if (rect.IsEmpty()) { | |
570 aura::Window* target_root = anchor_widget ? | 573 aura::Window* target_root = anchor_widget ? |
571 anchor_widget->GetNativeView()->GetRootWindow() : | 574 anchor_widget->GetNativeView()->GetRootWindow() : |
572 Shell::GetPrimaryRootWindow(); | 575 Shell::GetPrimaryRootWindow(); |
573 rect = target_root->bounds(); | 576 rect = target_root->bounds(); |
574 rect = gfx::Rect( | 577 if (anchor_type == TrayBubbleView::ANCHOR_TYPE_TRAY) { |
575 base::i18n::IsRTL() ? kPaddingFromRightEdgeOfScreenBottomAlignment : | 578 if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM) { |
576 rect.width() - kPaddingFromRightEdgeOfScreenBottomAlignment, | 579 rect = gfx::Rect( |
577 rect.height() - kPaddingFromBottomOfScreenBottomAlignment, | 580 base::i18n::IsRTL() ? |
578 0, 0); | 581 kPaddingFromRightEdgeOfScreenBottomAlignment : |
579 rect = ScreenUtil::ConvertRectToScreen(target_root, rect); | 582 rect.width() - kPaddingFromRightEdgeOfScreenBottomAlignment, |
583 rect.height() - kPaddingFromBottomOfScreenBottomAlignment, | |
584 0, 0); | |
585 rect = ScreenUtil::ConvertRectToScreen(target_root, rect); | |
586 } else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_LEFT) { | |
587 rect = gfx::Rect( | |
588 kPaddingFromRightEdgeOfScreenBottomAlignment, | |
589 rect.height() - kPaddingFromBottomOfScreenBottomAlignment, | |
590 1, 1); | |
591 rect = ScreenUtil::ConvertRectToScreen(target_root, rect); | |
592 } else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT) { | |
593 rect = gfx::Rect( | |
594 rect.width() - kPaddingFromRightEdgeOfScreenBottomAlignment, | |
595 rect.height() - kPaddingFromBottomOfScreenBottomAlignment, | |
596 1, 1); | |
597 rect = ScreenUtil::ConvertRectToScreen(target_root, rect); | |
598 } else { | |
599 // TODO(bruthig) May need to handle other ANCHOR_ALIGNMENT_ values. | |
600 // ie. ANCHOR_ALIGNMENT_TOP | |
601 DCHECK(false) << "Unhandled anchor alignment."; | |
602 } | |
603 } else { | |
604 DCHECK(false) << "Unhandled anchor type."; | |
bruthig
2014/07/15 21:00:45
The WebNotificationTrayTest.PopupAndAutoHideShelf
| |
605 } | |
580 } | 606 } |
581 return rect; | 607 return rect; |
582 } | 608 } |
583 | 609 |
584 TrayBubbleView::AnchorAlignment TrayBackgroundView::GetAnchorAlignment() const { | 610 TrayBubbleView::AnchorAlignment TrayBackgroundView::GetAnchorAlignment() const { |
585 switch (shelf_alignment_) { | 611 switch (shelf_alignment_) { |
586 case SHELF_ALIGNMENT_BOTTOM: | 612 case SHELF_ALIGNMENT_BOTTOM: |
587 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; | 613 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; |
588 case SHELF_ALIGNMENT_LEFT: | 614 case SHELF_ALIGNMENT_LEFT: |
589 return TrayBubbleView::ANCHOR_ALIGNMENT_LEFT; | 615 return TrayBubbleView::ANCHOR_ALIGNMENT_LEFT; |
(...skipping 20 matching lines...) Expand all Loading... | |
610 background_->set_alpha(kTrayBackgroundAlpha); | 636 background_->set_alpha(kTrayBackgroundAlpha); |
611 SchedulePaint(); | 637 SchedulePaint(); |
612 } | 638 } |
613 | 639 |
614 void TrayBackgroundView::UpdateBubbleViewArrow( | 640 void TrayBackgroundView::UpdateBubbleViewArrow( |
615 views::TrayBubbleView* bubble_view) { | 641 views::TrayBubbleView* bubble_view) { |
616 // Nothing to do here. | 642 // Nothing to do here. |
617 } | 643 } |
618 | 644 |
619 } // namespace ash | 645 } // namespace ash |
OLD | NEW |