Commit 55661826 authored by Yulun Wu's avatar Yulun Wu Committed by Commit Bot

Update search box view to use themed colors in default base constructor.

Bug: 1146141
Change-Id: I9d3a6dcb37f0435e29ee506bb0c7c2d678435332
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2522632Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarToni Baržić <tbarzic@chromium.org>
Reviewed-by: default avatarYulun Wu <yulunwu@chromium.org>
Commit-Queue: Yulun Wu <yulunwu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825011}
parent bf58a865
......@@ -11,6 +11,7 @@ source_set("search_box") {
]
deps = [
"//ash/public/cpp",
"//base",
"//skia",
"//ui/base",
......
......@@ -8,6 +8,7 @@
#include <memory>
#include <vector>
#include "ash/public/cpp/app_list/app_list_color_provider.h"
#include "ash/search_box/search_box_view_delegate.h"
#include "base/macros.h"
#include "third_party/skia/include/core/SkPath.h"
......@@ -233,7 +234,8 @@ SearchBoxViewBase::SearchBoxViewBase(SearchBoxViewDelegate* delegate)
AddChildView(content_container_);
content_container_->SetBackground(std::make_unique<SearchBoxBackground>(
kSearchBoxBorderCornerRadius, kSearchBoxBackgroundDefault));
kSearchBoxBorderCornerRadius,
ash::AppListColorProvider::Get()->GetSearchBoxBackgroundColor()));
box_layout_ =
content_container_->SetLayoutManager(std::make_unique<views::BoxLayout>(
......@@ -260,7 +262,8 @@ SearchBoxViewBase::SearchBoxViewBase(SearchBoxViewDelegate* delegate)
search_icon_ = new views::ImageView();
content_container_->AddChildView(search_icon_);
search_box_->set_placeholder_text_color(
kDefaultSearchboxPlaceholderTextColor);
ash::AppListColorProvider::Get()->GetSearchBoxSecondaryTextColor(
kDefaultSearchboxPlaceholderTextColor));
search_box_->set_placeholder_text_draw_flags(gfx::Canvas::TEXT_ALIGN_CENTER);
search_box_->SetFontList(search_box_->GetFontList().DeriveWithSizeDelta(2));
search_box_->SetCursorEnabled(is_search_box_active_);
......@@ -335,14 +338,16 @@ void SearchBoxViewBase::SetSearchBoxActive(bool active,
is_search_box_active_ = active;
UpdateSearchIcon();
UpdateBackgroundColor(kSearchBoxBackgroundDefault);
UpdateBackgroundColor(
ash::AppListColorProvider::Get()->GetSearchBoxBackgroundColor());
search_box_->set_placeholder_text_draw_flags(
active ? (base::i18n::IsRTL() ? gfx::Canvas::TEXT_ALIGN_RIGHT
: gfx::Canvas::TEXT_ALIGN_LEFT)
: gfx::Canvas::TEXT_ALIGN_CENTER);
search_box_->set_placeholder_text_color(
active ? kZeroQuerySearchboxColor
: kDefaultSearchboxPlaceholderTextColor);
ash::AppListColorProvider::Get()->GetSearchBoxSecondaryTextColor(
active ? kZeroQuerySearchboxColor
: kDefaultSearchboxPlaceholderTextColor));
search_box_->SetCursorEnabled(active);
if (active) {
......
......@@ -4,6 +4,7 @@
#include "ash/shortcut_viewer/views/ksv_search_box_view.h"
#include "ash/public/cpp/app_list/app_list_color_provider.h"
#include "ash/search_box/search_box_view_delegate.h"
#include "ash/shortcut_viewer/strings/grit/shortcut_viewer_strings.h"
#include "ash/shortcut_viewer/vector_icons/vector_icons.h"
......@@ -20,9 +21,6 @@ namespace keyboard_shortcut_viewer {
namespace {
constexpr SkColor kDefaultSearchBoxBackgroundColor =
SkColorSetARGB(0x28, 0x5F, 0x63, 0x68);
constexpr int kIconSize = 20;
// Border corner radius of the search box.
......@@ -33,16 +31,21 @@ constexpr int kBorderCornerRadius = 32;
KSVSearchBoxView::KSVSearchBoxView(ash::SearchBoxViewDelegate* delegate)
: ash::SearchBoxViewBase(delegate) {
SetSearchBoxBackgroundCornerRadius(kBorderCornerRadius);
UpdateBackgroundColor(kDefaultSearchBoxBackgroundColor);
UpdateBackgroundColor(
ash::AppListColorProvider::Get()->GetSearchBoxBackgroundColor());
search_box()->SetBackgroundColor(SK_ColorTRANSPARENT);
search_box()->SetColor(gfx::kGoogleGrey900);
search_box()->SetColor(
ash::AppListColorProvider::Get()->GetSearchBoxTextColor(
gfx::kGoogleGrey900));
SetPlaceholderTextAttributes();
const base::string16 search_box_name(
l10n_util::GetStringUTF16(IDS_KSV_SEARCH_BOX_ACCESSIBILITY_NAME));
search_box()->SetPlaceholderText(search_box_name);
search_box()->SetAccessibleName(search_box_name);
SetSearchIconImage(
gfx::CreateVectorIcon(kKsvSearchBarIcon, gfx::kGoogleGrey900));
SetSearchIconImage(gfx::CreateVectorIcon(
kKsvSearchBarIcon,
ash::AppListColorProvider::Get()->GetSearchBoxIconColor(
gfx::kGoogleGrey900)));
}
gfx::Size KSVSearchBoxView::CalculatePreferredSize() const {
......@@ -95,7 +98,8 @@ void KSVSearchBoxView::UpdateSearchBoxBorder() {
}
SetBorder(views::CreateRoundedRectBorder(
kBorderThichness, kBorderCornerRadius, SK_ColorTRANSPARENT));
UpdateBackgroundColor(kDefaultSearchBoxBackgroundColor);
UpdateBackgroundColor(
ash::AppListColorProvider::Get()->GetSearchBoxBackgroundColor());
}
void KSVSearchBoxView::SetupCloseButton() {
......@@ -144,7 +148,9 @@ void KSVSearchBoxView::OnSearchBoxActiveChanged(bool active) {
}
void KSVSearchBoxView::SetPlaceholderTextAttributes() {
search_box()->set_placeholder_text_color(ash::kZeroQuerySearchboxColor);
search_box()->set_placeholder_text_color(
ash::AppListColorProvider::Get()->GetSearchBoxSecondaryTextColor(
ash::kZeroQuerySearchboxColor));
search_box()->set_placeholder_text_draw_flags(
base::i18n::IsRTL() ? gfx::Canvas::TEXT_ALIGN_RIGHT
: gfx::Canvas::TEXT_ALIGN_LEFT);
......
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