Commit 3b3b962b authored by Weidong Guo's avatar Weidong Guo Committed by Commit Bot

applist-focus: Focus ring on search box update

Changes:
The gray ring is shown only when search box is selected and it is not
active.

BUG=779693

Change-Id: I10fdd7238361ea8320c4a74697a7d7015863d36e
Reviewed-on: https://chromium-review.googlesource.com/748310Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Weidong Guo <weidongg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#513193}
parent cb94ab16
......@@ -236,9 +236,7 @@ SearchBoxView::SearchBoxView(SearchBoxViewDelegate* delegate,
? kPreferredWidthFullscreen
: kPreferredWidth,
kSearchBoxPreferredHeight));
// Creates an empty border as a placeholder for colored border which indicates
// that the search box is selected.
SetDefaultBorder();
UpdateSearchBoxBorder();
AddChildView(content_container_);
SetShadow(GetShadowForZHeight(2));
......@@ -513,6 +511,12 @@ bool SearchBoxView::MoveTabFocus(bool move_backwards) {
}
void SearchBoxView::ResetTabFocus(bool on_contents) {
if (is_app_list_focus_enabled_) {
// TODO(weidongg/766807) Remove this function when the flag is enabled by
// default.
return;
}
if (back_button_)
back_button_->SetSelected(false);
if (speech_button_)
......@@ -569,6 +573,7 @@ void SearchBoxView::SetSearchBoxActive(bool active) {
search_box_right_space_->SetVisible(!active);
UpdateSearchBoxBorder();
UpdateKeyboardVisibility();
if (focused_view_ != FOCUS_CONTENTS_VIEW)
......@@ -806,23 +811,14 @@ void SearchBoxView::SetSelected(bool selected) {
if (selected) {
// Set the ChromeVox focus to the search box.
search_box_->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true);
if (IsSearchBoxTrimmedQueryEmpty()) {
// This includes two situations: query is empty or query is a string of
// spaces. In both situations, opened search box is hidden and we need to
// show a ring around search box to indicate that it is selected.
SetBorder(views::CreateRoundedRectBorder(
kSearchBoxBorderWidth, kSearchBoxFocusBorderCornerRadius,
kSearchBoxBorderColor));
}
if (!is_app_list_focus_enabled_ && !search_box_->text().empty()) {
// If query is not empty (including a string of spaces), we need to select
// the entire text range. When app list focus flag is enabled, query is
// automatically selected all when search box is focused.
search_box_->SelectAll(false);
}
} else {
SetDefaultBorder();
}
UpdateSearchBoxBorder();
Layout();
SchedulePaint();
}
......@@ -1132,9 +1128,22 @@ bool SearchBoxView::IsSearchBoxTrimmedQueryEmpty() const {
return trimmed_query.empty();
}
void SearchBoxView::SetDefaultBorder() {
void SearchBoxView::UpdateSearchBoxBorder() {
if (!is_fullscreen_app_list_enabled_)
return;
if (selected() && !is_search_box_active()) {
// Show a gray ring around search box to indicate that the search box is
// selected. Do not show it when search box is active, because blinking
// cursor already indicates that.
SetBorder(views::CreateRoundedRectBorder(kSearchBoxBorderWidth,
kSearchBoxFocusBorderCornerRadius,
kSearchBoxBorderColor));
return;
}
// Creates an empty border as a placeholder for colored border so that
// re-layout won't move views below the search box.
SetBorder(
views::CreateEmptyBorder(kSearchBoxBorderWidth, kSearchBoxBorderWidth,
kSearchBoxBorderWidth, kSearchBoxBorderWidth));
......
......@@ -224,7 +224,8 @@ class APP_LIST_EXPORT SearchBoxView : public views::WidgetDelegateView,
// Overridden from AppListViewDelegateObserver:
void OnWallpaperColorsChanged() override;
void SetDefaultBorder();
// Update search box border based on whether the search box is activated.
void UpdateSearchBoxBorder();
SearchBoxViewDelegate* delegate_; // Not owned.
AppListViewDelegate* view_delegate_; // Not owned.
......
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