Commit a53cb4c0 authored by Manu Cornet's avatar Manu Cornet Committed by Commit Bot

CrOS Shelf: Ensure a minimum margin around the overflow bubble

See some before/after screenshots here:

    https://bugs.chromium.org/p/chromium/issues/detail?id=881043#c8

Note that this also introduces the same margin in the "old" UI, but
this is a desired side effect.

Bug: 881043, 876474
Change-Id: Iddd8dd701076d3a2e230e841eba5eec467a94882
Reviewed-on: https://chromium-review.googlesource.com/1212092Reviewed-by: default avatarSammie Quon <sammiequon@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Manu Cornet <manucornet@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589545}
parent dd1ecc52
...@@ -30,6 +30,9 @@ constexpr int kEndPadding = 16; ...@@ -30,6 +30,9 @@ constexpr int kEndPadding = 16;
// Distance between overflow bubble and the main shelf. // Distance between overflow bubble and the main shelf.
constexpr int kDistanceToMainShelf = 4; constexpr int kDistanceToMainShelf = 4;
// Minimum margin around the bubble so that it doesn't hug the screen edges.
constexpr int kMinimumMargin = 8;
} // namespace } // namespace
OverflowBubbleView::OverflowBubbleView(Shelf* shelf) OverflowBubbleView::OverflowBubbleView(Shelf* shelf)
...@@ -188,6 +191,8 @@ gfx::Rect OverflowBubbleView::GetBubbleBounds() { ...@@ -188,6 +191,8 @@ gfx::Rect OverflowBubbleView::GetBubbleBounds() {
display::Screen::GetScreen() display::Screen::GetScreen()
->GetDisplayNearestPoint(anchor_rect.CenterPoint()) ->GetDisplayNearestPoint(anchor_rect.CenterPoint())
.work_area(); .work_area();
// Make sure no part of the bubble touches a screen edge.
monitor_rect.Inset(gfx::Insets(kMinimumMargin));
if (shelf_->IsHorizontalAlignment()) { if (shelf_->IsHorizontalAlignment()) {
gfx::Rect bounds( gfx::Rect bounds(
...@@ -198,8 +203,8 @@ gfx::Rect OverflowBubbleView::GetBubbleBounds() { ...@@ -198,8 +203,8 @@ gfx::Rect OverflowBubbleView::GetBubbleBounds() {
content_size.width() + 2 * kEndPadding, content_size.height()); content_size.width() + 2 * kEndPadding, content_size.height());
if (bounds.x() < monitor_rect.x()) if (bounds.x() < monitor_rect.x())
bounds.Offset(monitor_rect.x() - bounds.x(), 0); bounds.Offset(monitor_rect.x() - bounds.x(), 0);
else if (bounds.right() > monitor_rect.right()) if (bounds.right() > monitor_rect.right())
bounds.Offset(monitor_rect.right() - bounds.right(), 0); bounds.set_width(monitor_rect.right() - bounds.x());
return bounds; return bounds;
} }
gfx::Rect bounds( gfx::Rect bounds(
...@@ -211,8 +216,8 @@ gfx::Rect OverflowBubbleView::GetBubbleBounds() { ...@@ -211,8 +216,8 @@ gfx::Rect OverflowBubbleView::GetBubbleBounds() {
bounds.set_x(anchor_rect.x() - kDistanceToMainShelf - content_size.width()); bounds.set_x(anchor_rect.x() - kDistanceToMainShelf - content_size.width());
if (bounds.y() < monitor_rect.y()) if (bounds.y() < monitor_rect.y())
bounds.Offset(0, monitor_rect.y() - bounds.y()); bounds.Offset(0, monitor_rect.y() - bounds.y());
else if (bounds.bottom() > monitor_rect.bottom()) if (bounds.bottom() > monitor_rect.bottom())
bounds.Offset(monitor_rect.bottom() - bounds.bottom(), 0); bounds.set_height(monitor_rect.bottom() - bounds.y());
return bounds; return bounds;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment