Commit f3dcdf90 authored by MinChen's avatar MinChen Committed by Commit Bot

Update the work area bottom when shelf is auto-hide.

This is reland of https://chromium-review.googlesource.com/c/chromium/src/+/721801

Bug: 774617
Change-Id: I047740cedf056198743eb439b183ecb3b0ce3158
Reviewed-on: https://chromium-review.googlesource.com/723671Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarAlex Newcomer <newcomer@chromium.org>
Commit-Queue: min c <minch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#509552}
parent 9e7a747d
......@@ -1348,8 +1348,8 @@ void AppListView::SetIsInDrag(bool is_in_drag) {
->UpdateControlVisibility(app_list_state_, is_in_drag_);
}
int AppListView::GetWorkAreaBottom() {
return fullscreen_widget_->GetWorkAreaBoundsInScreen().bottom();
int AppListView::GetScreenBottom() {
return GetDisplayNearestView().bounds().bottom();
}
void AppListView::DraggingLayout() {
......@@ -1453,7 +1453,8 @@ void AppListView::OnDisplayMetricsChanged(const display::Display& display,
float AppListView::GetAppListBackgroundOpacityDuringDragging() {
float top_of_applist = fullscreen_widget_->GetWindowBoundsInScreen().y();
float dragging_height = std::max((GetWorkAreaBottom() - top_of_applist), 0.f);
float dragging_height =
std::max((GetScreenBottom() - kShelfSize - top_of_applist), 0.f);
float coefficient =
std::min(dragging_height / (kNumOfShelfSize * kShelfSize), 1.0f);
float shield_opacity =
......
......@@ -198,8 +198,8 @@ class APP_LIST_EXPORT AppListView : public views::BubbleDialogDelegateView,
// screen coordinates.
gfx::Rect GetAppInfoDialogBounds() const;
// Gets current work area bottom.
int GetWorkAreaBottom();
// Gets current screen bottom.
int GetScreenBottom();
views::Widget* get_fullscreen_widget_for_test() const {
return fullscreen_widget_;
......
......@@ -215,10 +215,9 @@ gfx::Rect AppsContainerView::GetPageBoundsDuringDragging(
AppListModel::State state) const {
float app_list_y_position_in_screen =
contents_view()->app_list_view()->app_list_y_position_in_screen();
float work_area_bottom =
contents_view()->app_list_view()->GetWorkAreaBottom();
float drag_amount =
std::max(0.f, work_area_bottom - app_list_y_position_in_screen);
std::max(0.f, contents_view()->app_list_view()->GetScreenBottom() -
kShelfSize - app_list_y_position_in_screen);
float y = 0;
float peeking_final_y =
......@@ -381,7 +380,7 @@ int AppsContainerView::GetSearchBoxTopPaddingDuringDragging() const {
float peeking_to_fullscreen_height =
contents_view()->GetDisplayHeight() - kPeekingAppListHeight;
float drag_amount = std::max(
0, contents_view()->app_list_view()->GetWorkAreaBottom() -
0, contents_view()->app_list_view()->GetScreenBottom() - kShelfSize -
contents_view()->app_list_view()->app_list_y_position_in_screen());
if (drag_amount <= (kPeekingAppListHeight - kShelfSize)) {
......
......@@ -1968,7 +1968,7 @@ void AppsGridView::UpdateOpacity() {
int app_list_y_position_in_screen =
contents_view_->app_list_view()->app_list_y_position_in_screen();
AppListView* app_list_view = contents_view_->app_list_view();
int work_area_bottom = app_list_view->GetWorkAreaBottom();
int screen_bottom = app_list_view->GetScreenBottom();
bool should_restore_opacity =
!app_list_view->is_in_drag() &&
(app_list_view->app_list_state() != AppListView::AppListState::CLOSED);
......@@ -1979,7 +1979,8 @@ void AppsGridView::UpdateOpacity() {
// |kSuggestedAppsOpacityEndFraction|, the opacity of suggested apps changes
// from 0.f to 1.0f.
float fraction =
std::max<float>(work_area_bottom - app_list_y_position_in_screen, 0) /
std::max<float>(
screen_bottom - kShelfSize - app_list_y_position_in_screen, 0) /
(kPeekingAppListHeight - kShelfSize);
float opacity =
std::min(std::max((fraction - kSuggestedAppsOpacityStartFraction) /
......@@ -2011,8 +2012,8 @@ void AppsGridView::UpdateOpacity() {
// changes from 0.f to 1.0f.
float peeking_to_fullscreen_height =
contents_view_->GetDisplayHeight() - kPeekingAppListHeight;
float drag_amount = (work_area_bottom + kShelfSize) -
app_list_y_position_in_screen - kPeekingAppListHeight;
float drag_amount =
screen_bottom - app_list_y_position_in_screen - kPeekingAppListHeight;
fraction = std::max(drag_amount / peeking_to_fullscreen_height, 0.f);
opacity = std::min(std::max((fraction + kAllAppsIndicatorOpacityEndFraction -
kAllAppsIndicatorOpacityStartFraction - 1.0f) /
......@@ -2037,7 +2038,7 @@ void AppsGridView::UpdateOpacity() {
1.0f);
if (expand_arrow_view_) {
if (app_list_y_position_in_screen <
(work_area_bottom + kShelfSize - kPeekingAppListHeight)) {
(screen_bottom - kPeekingAppListHeight)) {
expand_arrow_view_->layer()->SetOpacity(
should_restore_opacity ? 1.0f : arrow_fullscreen_opacity);
} else {
......@@ -2051,9 +2052,8 @@ void AppsGridView::UpdateOpacity() {
// of work area and transitioning to 1.0f by the time the centerline reaches
// |kAllAppsOpacityEndPx| above the work area bottom.
float centerline_above_work_area = 0.f;
const float drag_amount_above_peeking = work_area_bottom + kShelfSize -
app_list_y_position_in_screen -
kPeekingAppListHeight;
const float drag_amount_above_peeking =
screen_bottom - app_list_y_position_in_screen - kPeekingAppListHeight;
const float opacity_factor = drag_amount_above_peeking / kShelfSize;
for (int i = 0; i < view_model_.view_size(); ++i) {
AppListItemView* item_view = GetItemViewAt(i);
......@@ -2062,8 +2062,8 @@ void AppsGridView::UpdateOpacity() {
gfx::Rect view_bounds = view_model_.ideal_bounds(i);
views::View::ConvertRectToScreen(this, &view_bounds);
centerline_above_work_area = std::max<float>(
work_area_bottom + kShelfSize - view_bounds.CenterPoint().y(), 0.f);
centerline_above_work_area =
std::max<float>(screen_bottom - view_bounds.CenterPoint().y(), 0.f);
opacity = std::min(
std::max((centerline_above_work_area - kAllAppsOpacityStartPx) /
(kAllAppsOpacityEndPx - kAllAppsOpacityStartPx),
......@@ -2089,8 +2089,8 @@ void AppsGridView::UpdateOpacity() {
// Updates the opacity of page switcher buttons. The same rule as all apps.
if (page_switcher_view_) {
gfx::Rect switcher_bounds = page_switcher_view_->GetBoundsInScreen();
centerline_above_work_area = std::max<float>(
work_area_bottom + kShelfSize - switcher_bounds.CenterPoint().y(), 0.f);
centerline_above_work_area =
std::max<float>(screen_bottom - switcher_bounds.CenterPoint().y(), 0.f);
opacity = std::min(
std::max((centerline_above_work_area - kAllAppsOpacityStartPx) /
(kAllAppsOpacityEndPx - kAllAppsOpacityStartPx),
......
......@@ -747,8 +747,8 @@ void SearchBoxView::UpdateOpacity() {
int app_list_y_position_in_screen =
contents_view->app_list_view()->app_list_y_position_in_screen();
float fraction =
std::max<float>(0, contents_view->app_list_view()->GetWorkAreaBottom() -
app_list_y_position_in_screen) /
std::max<float>(0, contents_view->app_list_view()->GetScreenBottom() -
kShelfSize - app_list_y_position_in_screen) /
(kPeekingAppListHeight - kShelfSize);
float opacity =
......
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