Commit 9543c29b authored by Alex Newcomer's avatar Alex Newcomer Committed by Commit Bot

cros: Calculate hotseat position relative to display bottom

The shelf size can change, and the hotseat will jump if the bounds are
only calculated in reference to the shelf.

To fix this vertical jumping when going from in-app -> home, calculate the
hotseat y position in reference to the bottom of the display.

Bug: 1008455
Change-Id: Idd24dc17b0c53126be42d2638508e728f35f683d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1828074
Commit-Queue: Alex Newcomer <newcomer@chromium.org>
Reviewed-by: default avatarManu Cornet <manucornet@chromium.org>
Cr-Commit-Position: refs/heads/master@{#700888}
parent d7f6f0c8
......@@ -63,6 +63,9 @@ class ASH_EXPORT ShelfConfig : public TabletModeObserver,
// width when the shelf is vertical).
int shelf_size() const;
// Size of the shelf when an app is visible in tablet mode.
int in_app_shelf_size() const;
// Size of the hotseat, which contains the scrollable shelf in tablet mode.
int hotseat_size() const;
......
......@@ -135,10 +135,14 @@ int ShelfConfig::shelf_size() const {
if (!Shell::Get()->tablet_mode_controller()->InTabletMode())
return 48;
if (is_dense_)
return is_in_app() ? 36 : 48;
else
return is_in_app() ? 40 : 56;
if (is_in_app())
return in_app_shelf_size();
return is_dense_ ? 48 : 56;
}
int ShelfConfig::in_app_shelf_size() const {
return is_dense_ ? 36 : 40;
}
int ShelfConfig::hotseat_size() const {
......
......@@ -1387,28 +1387,27 @@ void ShelfLayoutManager::CalculateTargetBounds(
int hotseat_width;
int hotseat_height;
if (shelf_->IsHorizontalAlignment()) {
int hotseat_y;
const int hotseat_size = Shell::Get()->shelf_config()->hotseat_size();
int hotseat_distance_from_bottom_of_display;
const int hotseat_size = ShelfConfig::Get()->hotseat_size();
switch (state_.hotseat_state) {
case HotseatState::kShown: {
// When the hotseat state is HotseatState::kShown in tablet mode, the
// home launcher is showing. Elevate the hotseat a few px to match the
// navigation and status area.
const bool use_padding = chromeos::switches::ShouldShowShelfHotseat() &&
IsTabletModeEnabled();
hotseat_y =
use_padding
? -Shell::Get()->shelf_config()->hotseat_bottom_padding()
: 0;
const bool use_padding = IsHotseatEnabled();
hotseat_distance_from_bottom_of_display =
hotseat_size +
(use_padding ? ShelfConfig::Get()->hotseat_bottom_padding() : 0);
} break;
case HotseatState::kHidden:
// Show the hotseat offscreen.
hotseat_y = hotseat_size;
hotseat_distance_from_bottom_of_display = 0;
break;
case HotseatState::kExtended:
// Show the hotseat at its extended position.
hotseat_y = -hotseat_size -
Shell::Get()->shelf_config()->hotseat_bottom_padding();
hotseat_distance_from_bottom_of_display =
ShelfConfig::Get()->in_app_shelf_size() +
ShelfConfig::Get()->hotseat_bottom_padding() + hotseat_size;
break;
}
......@@ -1416,21 +1415,19 @@ void ShelfLayoutManager::CalculateTargetBounds(
shelf_width - target_bounds->nav_bounds_in_shelf.size().width() -
home_button_edge_spacing - ShelfConfig::Get()->app_icon_group_margin() -
status_size.width();
int hotseat_x = base::i18n::IsRTL()
? target_bounds->nav_bounds_in_shelf.x() -
home_button_edge_spacing - hotseat_width
: target_bounds->nav_bounds_in_shelf.right() +
home_button_edge_spacing;
if (state_.hotseat_state != HotseatState::kShown) {
// Give the hotseat more space if it is shown outside of the shelf.
hotseat_width = available_bounds.width();
hotseat_x = 0;
}
const int hotseat_y =
-(hotseat_distance_from_bottom_of_display - shelf_size);
hotseat_origin = gfx::Point(hotseat_x, hotseat_y);
hotseat_height = hotseat_size;
} else {
hotseat_origin = gfx::Point(0, target_bounds->nav_bounds_in_shelf.bottom() +
......
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