Commit 335cfe34 authored by Weidong Guo's avatar Weidong Guo Committed by Commit Bot

Implement app list rounded rect background

1. Set a mask layer to create a rounded rect background.
2. Change the corner radius based on app list height.

Specs: https://screenshot.googleplex.com/xVbKhQhE9xf

Bug: 860822
Change-Id: I3db9f1ebb29978b1dd0804afbb8accf253db2751
Reviewed-on: https://chromium-review.googlesource.com/1138636Reviewed-by: default avatarYury Khmel <khmel@chromium.org>
Commit-Queue: Weidong Guo <weidongg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576248}
parent a8e48e70
...@@ -98,6 +98,13 @@ constexpr float kAppListAnimationDurationFromFullscreenMs = 250; ...@@ -98,6 +98,13 @@ constexpr float kAppListAnimationDurationFromFullscreenMs = 250;
// The app list opacity when the tablet mode is enabled. // The app list opacity when the tablet mode is enabled.
constexpr float kAppListOpacityInTabletMode = 0.1; constexpr float kAppListOpacityInTabletMode = 0.1;
// The background corner radius in peeking and fullscreen state.
constexpr int kAppListPeekingBackgroundRadius = 28;
constexpr int kAppListFullscreenBackgroundRadius = 0;
// The threshold beyond which the background radius starts transition.
constexpr int kAppListBackgroundTransitionThreshold = 156;
// Set animation durations to 0 for testing. // Set animation durations to 0 for testing.
static bool short_animations_for_testing; static bool short_animations_for_testing;
...@@ -279,6 +286,7 @@ AppListView::AppListView(AppListViewDelegate* delegate) ...@@ -279,6 +286,7 @@ AppListView::AppListView(AppListViewDelegate* delegate)
state_animation_metrics_reporter_( state_animation_metrics_reporter_(
std::make_unique<StateAnimationMetricsReporter>()), std::make_unique<StateAnimationMetricsReporter>()),
is_home_launcher_enabled_(app_list::features::IsHomeLauncherEnabled()), is_home_launcher_enabled_(app_list::features::IsHomeLauncherEnabled()),
is_new_style_launcher_enabled_(features::IsNewStyleLauncherEnabled()),
weak_ptr_factory_(this) { weak_ptr_factory_(this) {
CHECK(delegate); CHECK(delegate);
...@@ -1062,6 +1070,7 @@ void AppListView::Layout() { ...@@ -1062,6 +1070,7 @@ void AppListView::Layout() {
contents_view->Layout(); contents_view->Layout();
app_list_background_shield_->SetBoundsRect(contents_bounds); app_list_background_shield_->SetBoundsRect(contents_bounds);
UpdateBackgroundRadius();
} }
void AppListView::GetAccessibleNodeData(ui::AXNodeData* node_data) { void AppListView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
...@@ -1497,4 +1506,36 @@ bool AppListView::ShouldIgnoreScrollEvents() { ...@@ -1497,4 +1506,36 @@ bool AppListView::ShouldIgnoreScrollEvents() {
GetRootAppsGridView()->pagination_model()->has_transition(); GetRootAppsGridView()->pagination_model()->has_transition();
} }
void AppListView::UpdateBackgroundRadius() {
if (!is_new_style_launcher_enabled_)
return;
const int current_height = GetCurrentAppListHeight();
const int fullscreen_height = GetDisplayNearestView().size().height();
const int threshold_height =
fullscreen_height - kAppListBackgroundTransitionThreshold;
int background_radius = kAppListPeekingBackgroundRadius;
if (current_height > threshold_height) {
background_radius = gfx::Tween::IntValueBetween(
static_cast<double>(current_height - threshold_height) /
kAppListBackgroundTransitionThreshold,
kAppListPeekingBackgroundRadius, kAppListFullscreenBackgroundRadius);
}
// Resetting mask layer is heavy operation, so avoid doing so if radius does
// not change.
static int previous_background_radius = -1;
if (previous_background_radius == background_radius)
return;
app_list_background_mask_ = views::Painter::CreatePaintedLayer(
views::Painter::CreateSolidRoundRectPainter(SK_ColorBLACK,
background_radius));
app_list_background_mask_->layer()->SetFillsBoundsOpaquely(false);
app_list_background_mask_->layer()->SetBounds(GetContentsBounds());
app_list_background_shield_->layer()->SetMaskLayer(
app_list_background_mask_->layer());
previous_background_radius = background_radius;
}
} // namespace app_list } // namespace app_list
...@@ -324,6 +324,9 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView, ...@@ -324,6 +324,9 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView,
// Returns true if scroll events should be ignored. // Returns true if scroll events should be ignored.
bool ShouldIgnoreScrollEvents(); bool ShouldIgnoreScrollEvents();
// Updates corner radius of the app list background.
void UpdateBackgroundRadius();
AppListViewDelegate* delegate_; // Weak. Owned by AppListService. AppListViewDelegate* delegate_; // Weak. Owned by AppListService.
AppListModel* const model_; // Not Owned. AppListModel* const model_; // Not Owned.
SearchModel* const search_model_; // Not Owned. SearchModel* const search_model_; // Not Owned.
...@@ -340,6 +343,10 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView, ...@@ -340,6 +343,10 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView,
// Owned by the app list's widget. Null if the fullscreen app list is not // Owned by the app list's widget. Null if the fullscreen app list is not
// enabled. // enabled.
views::View* app_list_background_shield_ = nullptr; views::View* app_list_background_shield_ = nullptr;
// The mask layer to create rounded corner of the app list background.
std::unique_ptr<ui::LayerOwner> app_list_background_mask_ = nullptr;
// Whether tablet mode is active. // Whether tablet mode is active.
bool is_tablet_mode_ = false; bool is_tablet_mode_ = false;
// Whether the shelf is oriented on the side. // Whether the shelf is oriented on the side.
...@@ -404,6 +411,9 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView, ...@@ -404,6 +411,9 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView,
// Whether the home launcher feature is enabled. // Whether the home launcher feature is enabled.
const bool is_home_launcher_enabled_; const bool is_home_launcher_enabled_;
// True if new style launcher feature is enabled.
const bool is_new_style_launcher_enabled_;
base::WeakPtrFactory<AppListView> weak_ptr_factory_; base::WeakPtrFactory<AppListView> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(AppListView); DISALLOW_COPY_AND_ASSIGN(AppListView);
......
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