Commit 02f471a2 authored by MinChen's avatar MinChen Committed by Commit Bot

Updates opacity of app list when dragging opened app list.

Changes,
Updates opacity of app list if dragging happened on the opened app list.
Updates opacity of start page in peeking state during dragging.
Since each page of app list can be dragged, remove the first page
restriction in UpdateOpacity.

After changes, when dragging the opened app list. The opacity of app
list will also updates during dragging.

Bug: 748620
Change-Id: Ic93edcaf28e422117bbdd3a5fa100ebcd5c9842d
Reviewed-on: https://chromium-review.googlesource.com/594682
Commit-Queue: min c <minch@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarJenny Zhang <jennyz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491554}
parent 2d0b7e1a
...@@ -490,16 +490,14 @@ void AppListView::UpdateDrag(const gfx::Point& location) { ...@@ -490,16 +490,14 @@ void AppListView::UpdateDrag(const gfx::Point& location) {
// Update the bounds of the widget while maintaining the // Update the bounds of the widget while maintaining the
// relative position of the top of the widget and the mouse/gesture. // relative position of the top of the widget and the mouse/gesture.
// Block drags north of 0 and recalculate the initial_drag_point_. // Block drags north of 0 and recalculate the initial_drag_point_.
int const new_y_position = location.y() - initial_drag_point_.y() + int new_y_position = location.y() - initial_drag_point_.y() +
fullscreen_widget_->GetWindowBoundsInScreen().y(); fullscreen_widget_->GetWindowBoundsInScreen().y();
gfx::Rect new_widget_bounds = fullscreen_widget_->GetWindowBoundsInScreen(); if (new_y_position < 0)
if (new_y_position < 0) {
new_widget_bounds.set_y(0);
initial_drag_point_ = location; initial_drag_point_ = location;
} else {
new_widget_bounds.set_y(new_y_position); UpdateYPositionAndOpacity(new_y_position,
} GetAppListBackgroundOpacityDuringDragging(),
fullscreen_widget_->SetBounds(new_widget_bounds); false /* is_end_gesture */);
} }
void AppListView::EndDrag(const gfx::Point& location) { void AppListView::EndDrag(const gfx::Point& location) {
...@@ -507,6 +505,8 @@ void AppListView::EndDrag(const gfx::Point& location) { ...@@ -507,6 +505,8 @@ void AppListView::EndDrag(const gfx::Point& location) {
if (app_list_state_ == CLOSED) if (app_list_state_ == CLOSED)
return; return;
// Restores opacity of all the items in app list if dragging ends.
UpdateOpacity(kAppListOpacity, true /* is_end_gesture */);
// Change the app list state based on where the drag ended. If fling velocity // Change the app list state based on where the drag ended. If fling velocity
// was over the threshold, snap to the next state in the direction of the // was over the threshold, snap to the next state in the direction of the
// fling. // fling.
...@@ -972,13 +972,7 @@ void AppListView::UpdateYPositionAndOpacity(int y_position_in_screen, ...@@ -972,13 +972,7 @@ void AppListView::UpdateYPositionAndOpacity(int y_position_in_screen,
new_widget_bounds.set_y(std::max(y_position_in_screen, 0)); new_widget_bounds.set_y(std::max(y_position_in_screen, 0));
fullscreen_widget_->SetBounds(new_widget_bounds); fullscreen_widget_->SetBounds(new_widget_bounds);
app_list_background_shield_->layer()->SetOpacity(background_opacity); UpdateOpacity(background_opacity, is_end_gesture);
gfx::Rect work_area_bounds = fullscreen_widget_->GetWorkAreaBoundsInScreen();
search_box_view_->UpdateOpacity(work_area_bounds.bottom(), is_end_gesture);
app_list_main_view_->contents_view()
->apps_container_view()
->apps_grid_view()
->UpdateOpacity(work_area_bounds.bottom(), is_end_gesture);
} }
PaginationModel* AppListView::GetAppsPaginationModel() { PaginationModel* AppListView::GetAppsPaginationModel() {
...@@ -1072,4 +1066,30 @@ void AppListView::OnDisplayMetricsChanged(const display::Display& display, ...@@ -1072,4 +1066,30 @@ void AppListView::OnDisplayMetricsChanged(const display::Display& display,
SetState(app_list_state_); SetState(app_list_state_);
} }
void AppListView::UpdateOpacity(float background_opacity, bool is_end_gesture) {
app_list_background_shield_->layer()->SetOpacity(background_opacity);
gfx::Rect work_area_bounds = fullscreen_widget_->GetWorkAreaBoundsInScreen();
search_box_view_->UpdateOpacity(work_area_bounds.bottom(), is_end_gesture);
app_list_main_view_->contents_view()
->apps_container_view()
->apps_grid_view()
->UpdateOpacity(work_area_bounds.bottom(), is_end_gesture);
if (app_list_state_ == PEEKING) {
app_list_main_view_->contents_view()->start_page_view()->UpdateOpacity(
work_area_bounds.bottom(), is_end_gesture);
}
}
float AppListView::GetAppListBackgroundOpacityDuringDragging() {
float top_of_applist = fullscreen_widget_->GetWindowBoundsInScreen().y();
float work_area_bottom =
fullscreen_widget_->GetWorkAreaBoundsInScreen().bottom();
float dragging_height = std::max((work_area_bottom - top_of_applist), 0.f);
float coefficient =
std::min(dragging_height / (kNumOfShelfSize * kShelfSize), 1.0f);
return coefficient * kAppListOpacity;
}
} // namespace app_list } // namespace app_list
...@@ -224,6 +224,12 @@ class APP_LIST_EXPORT AppListView : public views::BubbleDialogDelegateView, ...@@ -224,6 +224,12 @@ class APP_LIST_EXPORT AppListView : public views::BubbleDialogDelegateView,
void OnDisplayMetricsChanged(const display::Display& display, void OnDisplayMetricsChanged(const display::Display& display,
uint32_t changed_metrics) override; uint32_t changed_metrics) override;
// Updates opacity of both background and items in the app list.
void UpdateOpacity(float background_opacity, bool is_end_gesture);
// Gets app list background opacity during dragging.
float GetAppListBackgroundOpacityDuringDragging();
AppListViewDelegate* delegate_; // Weak. Owned by AppListService. AppListViewDelegate* delegate_; // Weak. Owned by AppListService.
AppListMainView* app_list_main_view_; AppListMainView* app_list_main_view_;
......
...@@ -1739,13 +1739,10 @@ void AppsGridView::UpdateOpacity(float work_area_bottom, bool is_end_gesture) { ...@@ -1739,13 +1739,10 @@ void AppsGridView::UpdateOpacity(float work_area_bottom, bool is_end_gesture) {
UpdateOpacityOfItem(all_apps_indicator_, UpdateOpacityOfItem(all_apps_indicator_,
all_apps_indicator_bounds.CenterPoint().y()); all_apps_indicator_bounds.CenterPoint().y());
// Updates the opacity of the apps in the first page. // Updates the opacity of all apps.
for (int i = 0; i < view_model_.view_size(); ++i) { for (int i = 0; i < view_model_.view_size(); ++i) {
AppListItemView* item_view = GetItemViewAt(i); AppListItemView* item_view = GetItemViewAt(i);
if (item_view != drag_view_) { if (item_view != drag_view_) {
Index index = GetIndexOfView(item_view);
if (index.page != 0)
break;
gfx::Rect view_bounds = view_model_.ideal_bounds(i); gfx::Rect view_bounds = view_model_.ideal_bounds(i);
views::View::ConvertRectToScreen(this, &view_bounds); views::View::ConvertRectToScreen(this, &view_bounds);
UpdateOpacityOfItem(item_view, view_bounds.CenterPoint().y()); UpdateOpacityOfItem(item_view, view_bounds.CenterPoint().y());
......
...@@ -40,6 +40,9 @@ ExpandArrowView::ExpandArrowView(ContentsView* contents_view, ...@@ -40,6 +40,9 @@ ExpandArrowView::ExpandArrowView(ContentsView* contents_view,
: views::CustomButton(this), : views::CustomButton(this),
contents_view_(contents_view), contents_view_(contents_view),
app_list_view_(app_list_view) { app_list_view_(app_list_view) {
SetPaintToLayer();
layer()->SetFillsBoundsOpaquely(false);
icon_ = new views::ImageView; icon_ = new views::ImageView;
icon_->SetVerticalAlignment(views::ImageView::CENTER); icon_->SetVerticalAlignment(views::ImageView::CENTER);
icon_->SetImage(gfx::CreateVectorIcon(kIcArrowUpIcon, kExpandArrowIconSize, icon_->SetImage(gfx::CreateVectorIcon(kIcArrowUpIcon, kExpandArrowIconSize,
......
...@@ -479,8 +479,39 @@ int StartPageView::GetSelectedIndexForTest() const { ...@@ -479,8 +479,39 @@ int StartPageView::GetSelectedIndexForTest() const {
return selected_index >= 0 ? selected_index : kNoSelection; return selected_index >= 0 ? selected_index : kNoSelection;
} }
void StartPageView::UpdateOpacity(float work_area_bottom, bool is_end_gesture) {
work_area_bottom_ = work_area_bottom;
is_end_gesture_ = is_end_gesture;
// Updates opacity of suggested apps indicator.
gfx::Rect indicator_bounds = indicator_->GetLabelBoundsInScreen();
UpdateOpacityOfItem(indicator_, indicator_bounds.CenterPoint().y());
// Updates opacity of suggested apps.
const std::vector<SearchResultTileItemView*>& suggested_apps =
suggestions_container_->tile_views();
gfx::Rect suggested_app_bounds;
for (auto* suggested_app : suggested_apps) {
suggested_app_bounds = suggested_app->GetBoundsInScreen();
UpdateOpacityOfItem(suggested_app, suggested_app_bounds.CenterPoint().y());
}
// Updates opacity of expand arrow.
gfx::Rect expand_arrow_bounds = expand_arrow_view_->GetBoundsInScreen();
UpdateOpacityOfItem(expand_arrow_view_,
expand_arrow_bounds.CenterPoint().y());
}
TileItemView* StartPageView::GetTileItemView(size_t index) { TileItemView* StartPageView::GetTileItemView(size_t index) {
return suggestions_container_->GetTileItemView(index); return suggestions_container_->GetTileItemView(index);
} }
void StartPageView::UpdateOpacityOfItem(views::View* view_item,
float centroid_y) {
float delta_y = std::max(work_area_bottom_ - centroid_y, 0.f);
float opacity = std::min(
delta_y / (AppListView::kNumOfShelfSize * AppListView::kShelfSize), 1.0f);
view_item->layer()->SetOpacity(is_end_gesture_ ? 1.0f : opacity);
}
} // namespace app_list } // namespace app_list
...@@ -63,6 +63,9 @@ class APP_LIST_EXPORT StartPageView : public AppListPage { ...@@ -63,6 +63,9 @@ class APP_LIST_EXPORT StartPageView : public AppListPage {
// the selected index in suggestions container view. // the selected index in suggestions container view.
int GetSelectedIndexForTest() const; int GetSelectedIndexForTest() const;
// Updates the opacity of the items in start page during dragging.
void UpdateOpacity(float work_area_bottom, bool is_end_gesture);
private: private:
void InitInstantContainer(); void InitInstantContainer();
...@@ -70,6 +73,9 @@ class APP_LIST_EXPORT StartPageView : public AppListPage { ...@@ -70,6 +73,9 @@ class APP_LIST_EXPORT StartPageView : public AppListPage {
void SetCustomLauncherPageSelected(bool selected); void SetCustomLauncherPageSelected(bool selected);
// Updates opacity of |view_item| in the start page based on |centroid_y|.
void UpdateOpacityOfItem(views::View* view_item, float centroid_y);
TileItemView* GetTileItemView(size_t index); TileItemView* GetTileItemView(size_t index);
AppListView* app_list_view_; AppListView* app_list_view_;
...@@ -94,6 +100,12 @@ class APP_LIST_EXPORT StartPageView : public AppListPage { ...@@ -94,6 +100,12 @@ class APP_LIST_EXPORT StartPageView : public AppListPage {
const bool is_fullscreen_app_list_enabled_; const bool is_fullscreen_app_list_enabled_;
// The bottom of work area.
float work_area_bottom_ = 0.f;
// True if it is the end gesture of dragging.
bool is_end_gesture_ = false;
DISALLOW_COPY_AND_ASSIGN(StartPageView); DISALLOW_COPY_AND_ASSIGN(StartPageView);
}; };
......
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