Commit d763f7e0 authored by Andrew Xu's avatar Andrew Xu Committed by Commit Bot

Fix hotseat bounds under RTL

This CL fixes two things:
(1) We use a solid-color layer to draw hotseat background. However,
Layer::SetBounds() does not mirror bounds under RTL. So we should do
it manually.
(2) View::SetBounds() mirrors bounds under RTL. So mirroring bounds
manually in ShelfView's member function is unnecessary.

Bug: 1094026
Change-Id: Iab5564b6687d7279733e5aa6d37fe41ef28cd15f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2261421Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Andrew Xu <andrewxu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#781544}
parent 59f71ba9
......@@ -389,8 +389,10 @@ void HotseatWidget::DelegateView::UpdateTranslucentBackground() {
return;
}
SetTranslucentBackground(
scrollable_shelf_view_->GetHotseatBackgroundBounds());
// Layer::SetBounds() does not mirror bounds under RTL. So set the mirrored
// bounds explicitly.
SetTranslucentBackground(scrollable_shelf_view_->GetMirroredRect(
scrollable_shelf_view_->GetHotseatBackgroundBounds()));
}
void HotseatWidget::DelegateView::SetTranslucentBackground(
......@@ -646,9 +648,8 @@ float HotseatWidget::CalculateShelfViewOpacity() const {
return (state() == HotseatState::kExtended) ? 1.0f : target_opacity;
}
void HotseatWidget::SetTranslucentBackground(
const gfx::Rect& translucent_background_bounds) {
delegate_view_->SetTranslucentBackground(translucent_background_bounds);
void HotseatWidget::UpdateTranslucentBackground() {
delegate_view_->UpdateTranslucentBackground();
}
int HotseatWidget::CalculateHotseatYInScreen(
......
......@@ -96,9 +96,9 @@ class ASH_EXPORT HotseatWidget : public ShelfComponent,
// Returns the target opacity for the shelf view given current conditions.
float CalculateShelfViewOpacity() const;
// Sets the bounds of the translucent background which functions as the
// Updates the bounds of the translucent background which functions as the
// hotseat background.
void SetTranslucentBackground(const gfx::Rect& background_bounds);
void UpdateTranslucentBackground();
// Calculates the hotseat y position for |hotseat_target_state| in screen
// coordinates.
......
......@@ -2081,10 +2081,8 @@ void ScrollableShelfView::UpdateAvailableSpace() {
// The hotseat uses |available_space_| to determine where to show its
// background, so notify it when it is recalculated.
if (HotseatWidget::ShouldShowHotseatBackground()) {
GetShelf()->hotseat_widget()->SetTranslucentBackground(
GetHotseatBackgroundBounds());
}
if (HotseatWidget::ShouldShowHotseatBackground())
GetShelf()->hotseat_widget()->UpdateTranslucentBackground();
}
gfx::Rect ScrollableShelfView::CalculateVisibleSpace(
......
......@@ -2281,14 +2281,7 @@ int ShelfView::CalculateAppIconsLayoutOffset() const {
const gfx::Insets& edge_padding_insets =
scrollable_shelf_view->edge_padding_insets();
// Paddings are within the shelf view. It makes sure that |shelf_view_|'s
// bounds are not changed by adding/removing the shelf icon under the same
// layout strategy.
const int horizontal_inset = scrollable_shelf_view->ShouldAdaptToRTL()
? edge_padding_insets.right()
: edge_padding_insets.left();
return shelf_->IsHorizontalAlignment() ? horizontal_inset
return shelf_->IsHorizontalAlignment() ? edge_padding_insets.left()
: edge_padding_insets.top();
}
......
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