Commit 87a3e9e5 authored by Manu Cornet's avatar Manu Cornet Committed by Commit Bot

CrOS shelf: Don't show app list/back highlight in overflow

Split out the logic that draws this highlight out of
CalculateIdealBounds which is becoming a bit long.

Bug: 880664
Change-Id: I3b36b93e2c6030b2e25552558d6a1321e647dda9
Reviewed-on: https://chromium-review.googlesource.com/1212082Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Manu Cornet <manucornet@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589643}
parent da7560a8
...@@ -899,6 +899,7 @@ void ShelfView::LayoutToIdealBounds() { ...@@ -899,6 +899,7 @@ void ShelfView::LayoutToIdealBounds() {
views::ViewModelUtils::SetViewBoundsToIdealBounds(*view_model_); views::ViewModelUtils::SetViewBoundsToIdealBounds(*view_model_);
overflow_button_->SetBoundsRect(overflow_bounds); overflow_button_->SetBoundsRect(overflow_bounds);
UpdateBackButton(); UpdateBackButton();
LayoutAppListAndBackButtonHighlight();
} }
bool ShelfView::IsItemPinned(const ShelfItem& item) const { bool ShelfView::IsItemPinned(const ShelfItem& item) const {
...@@ -956,6 +957,29 @@ void ShelfView::UpdateAllButtonsVisibilityInOverflowMode() { ...@@ -956,6 +957,29 @@ void ShelfView::UpdateAllButtonsVisibilityInOverflowMode() {
} }
} }
void ShelfView::LayoutAppListAndBackButtonHighlight() const {
// Don't show anything if this is the overflow menu or if this is not the
// new UI.
if (is_overflow_mode() || !chromeos::switches::ShouldUseShelfNewUi()) {
back_and_app_list_background_->SetVisible(false);
return;
}
const int button_spacing = ShelfConstants::button_spacing();
// "Secondary" as in "orthogonal to the shelf primary axis".
const int control_secondary_padding =
(ShelfConstants::shelf_size() - kShelfControlSizeNewUi) / 2;
const int back_and_app_list_background_size =
kShelfControlSizeNewUi +
(IsTabletModeEnabled() ? kShelfControlSizeNewUi + button_spacing : 0);
back_and_app_list_background_->SetBounds(
shelf_->PrimaryAxisValue(button_spacing, control_secondary_padding),
shelf_->PrimaryAxisValue(control_secondary_padding, button_spacing),
shelf_->PrimaryAxisValue(back_and_app_list_background_size,
kShelfControlSizeNewUi),
shelf_->PrimaryAxisValue(kShelfControlSizeNewUi,
back_and_app_list_background_size));
}
void ShelfView::CalculateIdealBounds(gfx::Rect* overflow_bounds) const { void ShelfView::CalculateIdealBounds(gfx::Rect* overflow_bounds) const {
DCHECK(model_->item_count() == view_model_->view_size()); DCHECK(model_->item_count() == view_model_->view_size());
...@@ -1026,20 +1050,6 @@ void ShelfView::CalculateIdealBounds(gfx::Rect* overflow_bounds) const { ...@@ -1026,20 +1050,6 @@ void ShelfView::CalculateIdealBounds(gfx::Rect* overflow_bounds) const {
if (i == kAppListButtonIndex) { if (i == kAppListButtonIndex) {
app_list_button_position = shelf_->PrimaryAxisValue(x, y); app_list_button_position = shelf_->PrimaryAxisValue(x, y);
if (chromeos::switches::ShouldUseShelfNewUi()) { if (chromeos::switches::ShouldUseShelfNewUi()) {
// "Secondary" as in "orthogonal to the shelf primary axis".
const int control_secondary_padding =
(ShelfConstants::shelf_size() - kShelfControlSizeNewUi) / 2;
const int back_and_app_list_background_size =
kShelfControlSizeNewUi +
(IsTabletModeEnabled() ? kShelfControlSizeNewUi + button_spacing
: 0);
back_and_app_list_background_->SetBounds(
shelf_->PrimaryAxisValue(button_spacing, control_secondary_padding),
shelf_->PrimaryAxisValue(control_secondary_padding, button_spacing),
shelf_->PrimaryAxisValue(back_and_app_list_background_size,
kShelfControlSizeNewUi),
shelf_->PrimaryAxisValue(kShelfControlSizeNewUi,
back_and_app_list_background_size));
// In the new UI, a larger minimum padding after the app list button // In the new UI, a larger minimum padding after the app list button
// is required: increment with the necessary extra amount. // is required: increment with the necessary extra amount.
x += shelf_->PrimaryAxisValue(kAppListButtonMargin - button_spacing, 0); x += shelf_->PrimaryAxisValue(kAppListButtonMargin - button_spacing, 0);
...@@ -1146,6 +1156,7 @@ void ShelfView::AnimateToIdealBounds() { ...@@ -1146,6 +1156,7 @@ void ShelfView::AnimateToIdealBounds() {
view->SetBorder(views::NullBorder()); view->SetBorder(views::NullBorder());
} }
overflow_button_->SetBoundsRect(overflow_bounds); overflow_button_->SetBoundsRect(overflow_bounds);
LayoutAppListAndBackButtonHighlight();
} }
views::View* ShelfView::CreateViewForItem(const ShelfItem& item) { views::View* ShelfView::CreateViewForItem(const ShelfItem& item) {
......
...@@ -294,6 +294,8 @@ class ASH_EXPORT ShelfView : public views::View, ...@@ -294,6 +294,8 @@ class ASH_EXPORT ShelfView : public views::View,
// Update all button's visibility in overflow. // Update all button's visibility in overflow.
void UpdateAllButtonsVisibilityInOverflowMode(); void UpdateAllButtonsVisibilityInOverflowMode();
void LayoutAppListAndBackButtonHighlight() const;
// Calculates the ideal bounds. The bounds of each button corresponding to an // Calculates the ideal bounds. The bounds of each button corresponding to an
// item in the model is set in |view_model_|. // item in the model is set in |view_model_|.
void CalculateIdealBounds(gfx::Rect* overflow_bounds) const; void CalculateIdealBounds(gfx::Rect* overflow_bounds) const;
......
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