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() { ...@@ -389,8 +389,10 @@ void HotseatWidget::DelegateView::UpdateTranslucentBackground() {
return; return;
} }
SetTranslucentBackground( // Layer::SetBounds() does not mirror bounds under RTL. So set the mirrored
scrollable_shelf_view_->GetHotseatBackgroundBounds()); // bounds explicitly.
SetTranslucentBackground(scrollable_shelf_view_->GetMirroredRect(
scrollable_shelf_view_->GetHotseatBackgroundBounds()));
} }
void HotseatWidget::DelegateView::SetTranslucentBackground( void HotseatWidget::DelegateView::SetTranslucentBackground(
...@@ -646,9 +648,8 @@ float HotseatWidget::CalculateShelfViewOpacity() const { ...@@ -646,9 +648,8 @@ float HotseatWidget::CalculateShelfViewOpacity() const {
return (state() == HotseatState::kExtended) ? 1.0f : target_opacity; return (state() == HotseatState::kExtended) ? 1.0f : target_opacity;
} }
void HotseatWidget::SetTranslucentBackground( void HotseatWidget::UpdateTranslucentBackground() {
const gfx::Rect& translucent_background_bounds) { delegate_view_->UpdateTranslucentBackground();
delegate_view_->SetTranslucentBackground(translucent_background_bounds);
} }
int HotseatWidget::CalculateHotseatYInScreen( int HotseatWidget::CalculateHotseatYInScreen(
......
...@@ -96,9 +96,9 @@ class ASH_EXPORT HotseatWidget : public ShelfComponent, ...@@ -96,9 +96,9 @@ class ASH_EXPORT HotseatWidget : public ShelfComponent,
// Returns the target opacity for the shelf view given current conditions. // Returns the target opacity for the shelf view given current conditions.
float CalculateShelfViewOpacity() const; 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. // hotseat background.
void SetTranslucentBackground(const gfx::Rect& background_bounds); void UpdateTranslucentBackground();
// Calculates the hotseat y position for |hotseat_target_state| in screen // Calculates the hotseat y position for |hotseat_target_state| in screen
// coordinates. // coordinates.
......
...@@ -2081,10 +2081,8 @@ void ScrollableShelfView::UpdateAvailableSpace() { ...@@ -2081,10 +2081,8 @@ void ScrollableShelfView::UpdateAvailableSpace() {
// The hotseat uses |available_space_| to determine where to show its // The hotseat uses |available_space_| to determine where to show its
// background, so notify it when it is recalculated. // background, so notify it when it is recalculated.
if (HotseatWidget::ShouldShowHotseatBackground()) { if (HotseatWidget::ShouldShowHotseatBackground())
GetShelf()->hotseat_widget()->SetTranslucentBackground( GetShelf()->hotseat_widget()->UpdateTranslucentBackground();
GetHotseatBackgroundBounds());
}
} }
gfx::Rect ScrollableShelfView::CalculateVisibleSpace( gfx::Rect ScrollableShelfView::CalculateVisibleSpace(
......
...@@ -2281,14 +2281,7 @@ int ShelfView::CalculateAppIconsLayoutOffset() const { ...@@ -2281,14 +2281,7 @@ int ShelfView::CalculateAppIconsLayoutOffset() const {
const gfx::Insets& edge_padding_insets = const gfx::Insets& edge_padding_insets =
scrollable_shelf_view->edge_padding_insets(); scrollable_shelf_view->edge_padding_insets();
// Paddings are within the shelf view. It makes sure that |shelf_view_|'s return shelf_->IsHorizontalAlignment() ? edge_padding_insets.left()
// 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
: edge_padding_insets.top(); : 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