Skip to content

Commit

Permalink
CrOS shelf: extend background to handle overdrag in any condition
Browse files Browse the repository at this point in the history
Before this CL, we already extend the shelf's opaque background a
bit off screen, so that "over-drag" events don't appear to be tearing
off the shelf from the screen edge.

This CL extends this behavior to "fullscreen" mode (shelf is a little
darker, and has square corners) so that there too we prevent a tearing
effect.

Bug: 911880
Change-Id: I0e91c83824417027060c75ccdd8fdcf1bdb3ffb5
Reviewed-on: https://chromium-review.googlesource.com/c/1382446
Reviewed-by: Xiyuan Xia <[email protected]>
Commit-Queue: Manu Cornet <[email protected]>
Cr-Commit-Position: refs/heads/master@{#617514}
  • Loading branch information
Manu Cornet authored and Commit Bot committed Dec 18, 2018
1 parent e9d8df7 commit d38df25
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions ash/shelf/shelf_widget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -223,23 +223,27 @@ void ShelfWidget::DelegateView::UpdateOpaqueBackground() {
if (!opaque_background_.visible())
opaque_background_.SetVisible(true);

// Extend the opaque layer a little bit to handle "overshoot" gestures
// gracefully (the user drags the shelf further than it can actually go).
// That way:
// 1) When the shelf has rounded corners, only two of them are visible,
// 2) Even when the shelf is squared, it doesn't tear off the screen edge
// when dragged away.
// To achieve this, we extend the layer in the same direction where the shelf
// is aligned (downwards for a bottom shelf, etc.).
const int radius = kShelfRoundedCornerRadius;
const int safety_margin = 3 * radius;
opaque_background_bounds.Inset(
-shelf->SelectValueForShelfAlignment(0, safety_margin, 0), 0,
-shelf->SelectValueForShelfAlignment(0, 0, safety_margin),
-shelf->SelectValueForShelfAlignment(safety_margin, 0, 0));

// Show rounded corners except in maximized and split modes.
if (background_type == SHELF_BACKGROUND_MAXIMIZED ||
background_type == SHELF_BACKGROUND_SPLIT_VIEW) {
mask_ = nullptr;
opaque_background_.SetMaskLayer(nullptr);
} else {
const int radius = kShelfRoundedCornerRadius;
// Extend the opaque layer a little bit so that only two rounded
// corners are visible, even when gestures to show the shelf "overshoot"
// the standard shelf size a little bit. Extend the layer in the same
// direction where the shelf is aligned (downwards for a bottom
// shelf, etc.).
const int safety_margin = 3 * radius;
opaque_background_bounds.Inset(
-shelf->SelectValueForShelfAlignment(0, safety_margin, 0), 0,
-shelf->SelectValueForShelfAlignment(0, 0, safety_margin),
-shelf->SelectValueForShelfAlignment(safety_margin, 0, 0));
if (!mask_) {
mask_ = views::Painter::CreatePaintedLayer(
views::Painter::CreateSolidRoundRectPainter(SK_ColorBLACK, radius));
Expand Down

0 comments on commit d38df25

Please sign in to comment.