Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2404)

Unified Diff: ash/system/tray/tray_background_view.cc

Issue 23928004: ash:Shelf - Update position and hit box of status area. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ash/system/tray/tray_background_view.cc
diff --git a/ash/system/tray/tray_background_view.cc b/ash/system/tray/tray_background_view.cc
index d979b1ad4f98a80ef37c47fd7c20874dd080d4d2..b045f016e9f62901c66882c28389bdf4175b60f1 100644
--- a/ash/system/tray/tray_background_view.cc
+++ b/ash/system/tray/tray_background_view.cc
@@ -443,16 +443,29 @@ void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) {
void TrayBackgroundView::SetBorder() {
views::View* parent = status_area_widget_->status_area_widget_delegate();
-
+ // Tray views are laid out right-to-left or bottom-to-top
+ int on_edge = (this == parent->child_at(0));
James Cook 2013/09/18 01:36:07 int -> bool?
if (ash::switches::UseAlternateShelfLayout()) {
- set_border(views::Border::CreateEmptyBorder(
- 0,
- 0,
- ShelfLayoutManager::kAutoHideSize,
- 0));
+ int inner_edge = ShelfLayoutManager::kShelfItemInset;
+ int outer_edge =
+ ShelfLayoutManager::GetPreferredShelfSize() - inner_edge -
+ GetShelfItemHeight();
+ int leading_edge = 0;
+ int trailing_edge = on_edge ? kPaddingFromShelf : 0;
+ if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) {
+ set_border(views::Border::CreateEmptyBorder(
+ inner_edge, leading_edge, outer_edge, trailing_edge);
+ } else if (shelf_alignment() == SHELF_ALIGNMENT_LEFT) {
+ set_border(views::Border::CreateEmptyBorder(
+ leading_edge, outer_edge, trailing_edge, inner_edge));
+ } else { // SHELF_ALIGNMENT_RIGHT
+ set_border(views::Border::CreateEmptyBorder(
+ leading_edge,
+ inner_edge,
+ trailing_edge,
+ outer_edge));
+ }
} else {
- // Tray views are laid out right-to-left or bottom-to-top
- int on_edge = (this == parent->child_at(0));
// Change the border padding for different shelf alignment.
if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) {
set_border(views::Border::CreateEmptyBorder(
@@ -509,31 +522,50 @@ gfx::Rect TrayBackgroundView::GetBubbleAnchorRect(
if (anchor_type == TrayBubbleView::ANCHOR_TYPE_TRAY) {
if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM) {
bool rtl = base::i18n::IsRTL();
- rect.Inset(
- rtl ? kPaddingFromRightEdgeOfScreenBottomAlignment : 0,
- kTrayBubbleAnchorTopInsetBottomAnchor,
- rtl ? 0 : kPaddingFromRightEdgeOfScreenBottomAlignment,
- kPaddingFromBottomOfScreenBottomAlignment);
+ if (!ash::switches::UseAlternateShelfLayout()) {
+ rect.Inset(
+ rtl ? kPaddingFromRightEdgeOfScreenBottomAlignment : 0,
+ kTrayBubbleAnchorTopInsetBottomAnchor,
+ rtl ? 0 : kPaddingFromRightEdgeOfScreenBottomAlignment,
+ kPaddingFromBottomOfScreenBottomAlignment);
+ } else {
+ rect.Inset(
+ rtl ? kAlternateLayoutBubblePaddingHorizontalSide : 0,
+ kAlternateLayoutBubblePaddingHorizontalBottom,
+ rtl ? 0 : kAlternateLayoutBubblePaddingHorizontalSide,
+ 0);
+ }
} else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_LEFT) {
- rect.Inset(0, 0, kPaddingFromInnerEdgeOfLauncherVerticalAlignment + 5,
- kPaddingFromBottomOfScreenVerticalAlignment);
+ if (!ash::switches::UseAlternateShelfLayout()) {
+ rect.Inset(0, 0, kPaddingFromInnerEdgeOfLauncherVerticalAlignment + 5,
+ kPaddingFromBottomOfScreenVerticalAlignment);
+ } else {
+ rect.Inset(0, 0, kAlternateLayoutBubblePaddingVerticalSide + 4,
+ kAlternateLayoutBubblePaddingVerticalBottom);
+ }
} else {
- rect.Inset(kPaddingFromInnerEdgeOfLauncherVerticalAlignment + 1,
- 0, 0, kPaddingFromBottomOfScreenVerticalAlignment);
+ if (!ash::switches::UseAlternateShelfLayout()) {
+ rect.Inset(kPaddingFromInnerEdgeOfLauncherVerticalAlignment + 1,
+ 0, 0, kPaddingFromBottomOfScreenVerticalAlignment);
+ } else {
+ rect.Inset(kAlternateLayoutBubblePaddingVerticalSide, 0, 0,
+ kAlternateLayoutBubblePaddingVerticalBottom);
+ }
}
} else if (anchor_type == TrayBubbleView::ANCHOR_TYPE_BUBBLE) {
// Invert the offsets to align with the bubble below.
// Note that with the alternate shelf layout the tips are not shown and
// the offsets for left and right alignment do not need to be applied.
int vertical_alignment = ash::switches::UseAlternateShelfLayout() ?
- 0 : kPaddingFromInnerEdgeOfLauncherVerticalAlignment;
- if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_LEFT) {
- rect.Inset(vertical_alignment,
- 0, 0, kPaddingFromBottomOfScreenVerticalAlignment);
- } else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT) {
- rect.Inset(0, 0, vertical_alignment,
- kPaddingFromBottomOfScreenVerticalAlignment);
- }
+ 0 :
+ kPaddingFromInnerEdgeOfLauncherVerticalAlignment;
+ int horizontal_alignment = ash::switches::UseAlternateShelfLayout() ?
+ kAlternateLayoutBubblePaddingVerticalBottom :
+ kPaddingFromBottomOfScreenVerticalAlignment;
+ if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_LEFT)
+ rect.Inset(vertical_alignment, 0, 0, horizontal_alignment);
+ else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT)
+ rect.Inset(0, 0, vertical_alignment, horizontal_alignment);
}
}

Powered by Google App Engine
This is Rietveld 408576698