Commit b14537df authored by Ana Salazar's avatar Ana Salazar Committed by Commit Bot

Cros: Add minor UI improvements to app paging

This cl is intended to implement some of the recommendations extended by
UX for the Launcher app paging.
- Fix vertical spacing between pages, should be 12px
- Border radius for background cards should be 12px
- Peeking pages on top and bottom should have the same height
- Focused page's background card should be Grey100 @ 20%
- Non focused pages' background card should be Grey100 @ 10%
- Add gradient mask in cardified state

Bug: 996822
Change-Id: I602952f5776cdb6d28521546f2479d709240105a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2250713
Commit-Queue: Ana Salazar <anasalazar@chromium.org>
Reviewed-by: default avatarToni Baržić <tbarzic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#779917}
parent a3c5e1a5
...@@ -91,11 +91,14 @@ constexpr float kDragAndDropProxyScale = 1.2f; ...@@ -91,11 +91,14 @@ constexpr float kDragAndDropProxyScale = 1.2f;
// The apps grid should be scaled down by this factor. // The apps grid should be scaled down by this factor.
constexpr float kCardifiedScale = 0.84f; constexpr float kCardifiedScale = 0.84f;
// Horizontal padding of the apps grid page when it is in cardified state. // Vertical padding between the apps grid pages in cardified state.
constexpr int kCardifiedPaddingBetweenPages = 12;
// Horizontal padding of the apps grid page in cardified state.
constexpr int kCardifiedHorizontalPadding = 16; constexpr int kCardifiedHorizontalPadding = 16;
// The radius of the corner of the background cards in the apps grid. // The radius of the corner of the background cards in the apps grid.
constexpr int kBackgroundCardCornerRadius = 16; constexpr int kBackgroundCardCornerRadius = 12;
// Delays in milliseconds to show re-order preview. // Delays in milliseconds to show re-order preview.
constexpr int kReorderDelay = 120; constexpr int kReorderDelay = 120;
...@@ -113,8 +116,13 @@ constexpr int kDefaultAnimationDuration = 200; ...@@ -113,8 +116,13 @@ constexpr int kDefaultAnimationDuration = 200;
// apps grid view. // apps grid view.
constexpr int kEndCardifiedAnimationDuration = 350; constexpr int kEndCardifiedAnimationDuration = 350;
// The opacity for the background cards when shown. // The background card opacity of the active apps grid page, when background
constexpr float kBackgroundCardOpacityShow = 0.2f; // cards are shown.
constexpr float kBackgroundCardOpacityActivePage = 0.2f;
// The background card opacity of inactive apps grid pages, when background
// cards are shown.
constexpr float kBackgroundCardOpacityInactivePage = 0.1f;
// The opacity for the background cards when hidden. // The opacity for the background cards when hidden.
constexpr float kBackgroundCardOpacityHide = 0.0f; constexpr float kBackgroundCardOpacityHide = 0.0f;
...@@ -543,8 +551,11 @@ gfx::Size AppsGridView::GetMaximumTileGridSize(int cols, ...@@ -543,8 +551,11 @@ gfx::Size AppsGridView::GetMaximumTileGridSize(int cols,
} }
int AppsGridView::GetPaddingBetweenPages() const { int AppsGridView::GetPaddingBetweenPages() const {
return std::round(GetAppListConfig().page_spacing() * // In cardified state, padding between pages should be fixed and it should
(cardified_state_ ? kCardifiedScale : 1.0)); // include background card padding.
return cardified_state_
? kCardifiedPaddingBetweenPages + 2 * vertical_tile_padding_
: GetAppListConfig().page_spacing();
} }
void AppsGridView::ResetForShowApps() { void AppsGridView::ResetForShowApps() {
...@@ -1125,6 +1136,7 @@ void AppsGridView::Layout() { ...@@ -1125,6 +1136,7 @@ void AppsGridView::Layout() {
} }
} }
if (cardified_state_) { if (cardified_state_) {
MaybeCreateGradientMask();
// Make sure that the background cards render behind everything // Make sure that the background cards render behind everything
// else in the items container. // else in the items container.
for (auto& background_card : background_cards_) for (auto& background_card : background_cards_)
...@@ -2274,6 +2286,7 @@ void AppsGridView::StartAppsGridCardifiedView() { ...@@ -2274,6 +2286,7 @@ void AppsGridView::StartAppsGridCardifiedView() {
UpdateTilePadding(); UpdateTilePadding();
for (int i = 0; i < pagination_model_.total_pages(); i++) for (int i = 0; i < pagination_model_.total_pages(); i++)
AppendBackgroundCard(kBackgroundCardOpacityHide); AppendBackgroundCard(kBackgroundCardOpacityHide);
MaybeCreateGradientMask();
AnimateCardifiedState(); AnimateCardifiedState();
} }
...@@ -2353,8 +2366,16 @@ void AppsGridView::AnimateCardifiedState() { ...@@ -2353,8 +2366,16 @@ void AppsGridView::AnimateCardifiedState() {
background_card->GetAnimator(), background_card->GetAnimator(),
metrics_util::ForSmoothness( metrics_util::ForSmoothness(
base::BindRepeating(&ReportCardifiedSmoothness, cardified_state_))); base::BindRepeating(&ReportCardifiedSmoothness, cardified_state_)));
background_card->SetOpacity(cardified_state_ ? kBackgroundCardOpacityShow if (cardified_state_) {
: kBackgroundCardOpacityHide); const bool is_active_page =
background_cards_[pagination_model_.selected_page()] ==
background_card;
background_card->SetOpacity(is_active_page
? kBackgroundCardOpacityActivePage
: kBackgroundCardOpacityInactivePage);
} else {
background_card->SetOpacity(kBackgroundCardOpacityHide);
}
} }
} }
...@@ -2964,7 +2985,7 @@ void AppsGridView::AppendBackgroundCard(float opacity) { ...@@ -2964,7 +2985,7 @@ void AppsGridView::AppendBackgroundCard(float opacity) {
background_cards_.push_back( background_cards_.push_back(
std::make_unique<ui::Layer>(ui::LAYER_SOLID_COLOR)); std::make_unique<ui::Layer>(ui::LAYER_SOLID_COLOR));
ui::Layer* current_layer = background_cards_.back().get(); ui::Layer* current_layer = background_cards_.back().get();
current_layer->SetColor(SK_ColorGRAY); current_layer->SetColor(gfx::kGoogleGrey100);
// The size of the grid excluding the outer padding. // The size of the grid excluding the outer padding.
const gfx::Size grid_size = GetTileGridSize(); const gfx::Size grid_size = GetTileGridSize();
// The size for the background card that will be displayed. The outer padding // The size for the background card that will be displayed. The outer padding
...@@ -2983,10 +3004,10 @@ void AppsGridView::AppendBackgroundCard(float opacity) { ...@@ -2983,10 +3004,10 @@ void AppsGridView::AppendBackgroundCard(float opacity) {
const int horizontal_padding = const int horizontal_padding =
(GetContentsBounds().width() - background_card_size.width()) / 2 + (GetContentsBounds().width() - background_card_size.width()) / 2 +
kCardifiedHorizontalPadding; kCardifiedHorizontalPadding;
// The vertical padding should account for the fadeout mask.
const int vertical_padding = const int vertical_padding =
(GetContentsBounds().height() - background_card_size.height() + (GetContentsBounds().height() - background_card_size.height()) / 2 +
padding_between_pages) / GetAppListConfig().grid_fadeout_mask_height();
2;
current_layer->SetBounds(gfx::Rect( current_layer->SetBounds(gfx::Rect(
horizontal_padding, vertical_padding + vertical_page_start_offset, horizontal_padding, vertical_padding + vertical_page_start_offset,
background_card_size.width() - 2 * kCardifiedHorizontalPadding, background_card_size.width() - 2 * kCardifiedHorizontalPadding,
...@@ -3029,7 +3050,7 @@ void AppsGridView::TotalPagesChanged(int previous_page_count, ...@@ -3029,7 +3050,7 @@ void AppsGridView::TotalPagesChanged(int previous_page_count,
const int page_difference = new_page_count - previous_page_count; const int page_difference = new_page_count - previous_page_count;
if (page_difference > 0) { if (page_difference > 0) {
for (int i = previous_page_count; i < new_page_count; ++i) for (int i = previous_page_count; i < new_page_count; ++i)
AppendBackgroundCard(kBackgroundCardOpacityShow); AppendBackgroundCard(kBackgroundCardOpacityHide);
} else { } else {
for (int i = 0; i < page_difference; ++i) for (int i = 0; i < page_difference; ++i)
RemoveBackgroundCard(); RemoveBackgroundCard();
...@@ -3072,6 +3093,12 @@ void AppsGridView::SelectedPageChanged(int old_selected, int new_selected) { ...@@ -3072,6 +3093,12 @@ void AppsGridView::SelectedPageChanged(int old_selected, int new_selected) {
} }
Layout(); Layout();
} }
if (cardified_state_) {
background_cards_[old_selected]->SetOpacity(
kBackgroundCardOpacityInactivePage);
background_cards_[new_selected]->SetOpacity(
kBackgroundCardOpacityActivePage);
}
} }
void AppsGridView::TransitionStarting() { void AppsGridView::TransitionStarting() {
......
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