Skip to content

Commit

Permalink
CrOS: Ensure that SearchBoxView rounded corners are 24 when reshown
Browse files Browse the repository at this point in the history
Make sure the SBV corners are correct. Add a function to reset the
state of the view before it is reshown.

Bug: 976988
Change-Id: Ia726cc1244ba7a2cd47481a5dd67ed95734737ad
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1677558
Commit-Queue: Alex Newcomer <newcomer@chromium.org>
Reviewed-by: Sammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#672645}
  • Loading branch information
Alex Newcomer authored and Commit Bot committed Jun 26, 2019
1 parent 2c6508e commit 022ad25
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ash/app_list/views/app_list_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1894,7 +1894,7 @@ void AppListView::OnBoundsAnimationCompleted() {

// Reset the search box to be shown again. This is done after the animation
// is complete in order to minimize work during the animation.
search_box_view_->SetSearchBoxActive(false /*active*/, ui::ET_LAST);
search_box_view_->ClearSearchAndDeactivateSearchBox();
}

// Layout if the animation was completed.
Expand Down
7 changes: 2 additions & 5 deletions ash/app_list/views/contents_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,13 @@ void ContentsView::Init(AppListModel* model) {
void ContentsView::ResetForShow() {
SetActiveState(ash::AppListState::kStateApps);
GetAppsContainerView()->ResetForShowApps();
// We clear the search when hiding so when app list appears it is not showing
// search results.
GetSearchBoxView()->ClearSearch();

GetSearchBoxView()->ResetForShow();
// In side shelf, the opacity of the contents is not animated so set it to the
// final state. In tablet mode, opacity of the elements is controlled by the
// HomeLauncherGestureHandler which expects these elements to be opaque.
// Otherwise the contents animate from 0 to 1 so set the initial opacity to 0.
const float initial_opacity =
app_list_view_->is_side_shelf() || app_list_view()->is_tablet_mode()
app_list_view_->is_side_shelf() || app_list_view_->is_tablet_mode()
? 1.0f
: 0.0f;
GetSearchBoxView()->layer()->SetOpacity(initial_opacity);
Expand Down
6 changes: 6 additions & 0 deletions ash/app_list/views/search_box_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ void SearchBoxView::Init(bool is_tablet_mode) {
SearchBoxViewBase::Init();
}

void SearchBoxView::ResetForShow() {
ClearSearch();
SetSearchBoxBackgroundCornerRadius(
GetSearchBoxBorderCornerRadiusForState(contents_view_->GetActiveState()));
}

void SearchBoxView::ClearSearch() {
search_box::SearchBoxViewBase::ClearSearch();
app_list_view_->SetStateFromSearchBoxView(
Expand Down
3 changes: 3 additions & 0 deletions ash/app_list/views/search_box_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ class APP_LIST_EXPORT SearchBoxView : public search_box::SearchBoxViewBase,

void Init(bool is_tablet_mode);

// Resets state of SearchBoxView so it can be reshown.
void ResetForShow();

// Returns the total focus ring spacing for use in folders.
static int GetFocusRingSpacing();

Expand Down

0 comments on commit 022ad25

Please sign in to comment.