Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(821)

Unified Diff: ui/app_list/views/search_box_view.cc

Issue 2941573002: cros: add google/mic icons to searchbox (Closed)
Patch Set: rebase Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/app_list/views/search_box_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/app_list/views/search_box_view.cc
diff --git a/ui/app_list/views/search_box_view.cc b/ui/app_list/views/search_box_view.cc
index db92a679a2d3684f292444dcc5bba84efc3ba3e7..47799720dce75b2d0011e9c3e569ca1ff621d7e4 100644
--- a/ui/app_list/views/search_box_view.cc
+++ b/ui/app_list/views/search_box_view.cc
@@ -17,6 +17,7 @@
#include "ui/app_list/resources/grit/app_list_resources.h"
#include "ui/app_list/search_box_model.h"
#include "ui/app_list/speech_ui_model.h"
+#include "ui/app_list/vector_icons.h"
#include "ui/app_list/views/app_list_view.h"
#include "ui/app_list/views/contents_view.h"
#include "ui/app_list/views/search_box_view_delegate.h"
@@ -26,6 +27,7 @@
#include "ui/events/event.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/insets.h"
+#include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/shadow_value.h"
#include "ui/strings/grit/ui_strings.h"
#include "ui/views/background.h"
@@ -53,6 +55,20 @@ const SkColor kHintTextColor = SkColorSetRGB(0xA0, 0xA0, 0xA0);
const int kBackgroundBorderCornerRadius = 2;
const int kBackgroundBorderCornerRadiusFullscreen = 20;
+constexpr int kGoogleIconSize = 24;
+constexpr int kMicIconSize = 24;
+
+// Default color used when wallpaper customized color is not available for
+// searchbox, #000 at 87% opacity.
+constexpr SkColor kDefaultSearchboxColor =
+ SkColorSetA(SK_ColorTRANSPARENT, 0xDE);
xiyuan 2017/06/13 20:10:41 nit: SK_ColorTRANSPARENT -> SK_ColorBLACK. Techniq
xiyuan 2017/06/13 20:10:41 Prefer to use SkColorSetARGBMacro instead of SkCol
Qiang(Joe) Xu 2017/06/13 20:50:53 Done.
+
+bool IsFullscreenAppListEnabled() {
xiyuan 2017/06/13 20:10:41 Get rid of this. Alex has a CL (https://codereview
Qiang(Joe) Xu 2017/06/13 20:50:53 Done.
+ // Cache this value to avoid repeated lookup.
+ static bool cached_value = features::IsFullscreenAppListEnabled();
+ return cached_value;
+}
+
// A background that paints a solid white rounded rect with a thin grey border.
class SearchBoxBackground : public views::Background {
public:
@@ -70,7 +86,7 @@ class SearchBoxBackground : public views::Background {
cc::PaintFlags flags;
flags.setAntiAlias(true);
- flags.setColor(kSearchBoxBackground);
+ flags.setColor(kSearchBoxBackgroundDefault);
canvas->DrawRoundRect(bounds, background_border_corner_radius_, flags);
}
@@ -131,6 +147,7 @@ SearchBoxView::SearchBoxView(SearchBoxViewDelegate* delegate,
view_delegate_(view_delegate),
model_(NULL),
content_container_(new views::View),
+ google_icon_(new views::ImageView),
xiyuan 2017/06/13 20:10:41 This leaks for the old behavior since |google_icon
Qiang(Joe) Xu 2017/06/13 20:50:53 Done.
back_button_(NULL),
speech_button_(NULL),
search_box_(new views::Textfield),
@@ -146,14 +163,6 @@ SearchBoxView::SearchBoxView(SearchBoxViewDelegate* delegate,
AddChildView(content_container_);
SetShadow(GetShadowForZHeight(2));
- back_button_ = new SearchBoxImageButton(this);
- ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- back_button_->SetImage(views::ImageButton::STATE_NORMAL,
- rb.GetImageSkiaNamed(IDR_APP_LIST_FOLDER_BACK_NORMAL));
- back_button_->SetImageAlignment(views::ImageButton::ALIGN_CENTER,
- views::ImageButton::ALIGN_MIDDLE);
- SetBackButtonLabel(false);
- content_container_->AddChildView(back_button_);
content_container_->SetBackground(base::MakeUnique<SearchBoxBackground>());
views::BoxLayout* layout = new views::BoxLayout(
@@ -166,11 +175,29 @@ SearchBoxView::SearchBoxView(SearchBoxViewDelegate* delegate,
search_box_->SetBorder(views::NullBorder());
search_box_->SetTextColor(kSearchTextColor);
- search_box_->SetBackgroundColor(kSearchBoxBackground);
- search_box_->set_placeholder_text_color(kHintTextColor);
+ search_box_->SetBackgroundColor(kSearchBoxBackgroundDefault);
search_box_->set_controller(this);
search_box_->SetTextInputType(ui::TEXT_INPUT_TYPE_SEARCH);
search_box_->SetTextInputFlags(ui::TEXT_INPUT_FLAG_AUTOCORRECT_OFF);
+ if (features::IsFullscreenAppListEnabled()) {
+ google_icon_->SetImage(gfx::CreateVectorIcon(
+ kIcGoogleBlackIcon, kGoogleIconSize, kDefaultSearchboxColor));
+ content_container_->AddChildView(google_icon_);
+
+ search_box_->set_placeholder_text_color(kDefaultSearchboxColor);
+ } else {
+ back_button_ = new SearchBoxImageButton(this);
+ ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
+ back_button_->SetImage(
+ views::ImageButton::STATE_NORMAL,
+ rb.GetImageSkiaNamed(IDR_APP_LIST_FOLDER_BACK_NORMAL));
+ back_button_->SetImageAlignment(views::ImageButton::ALIGN_CENTER,
+ views::ImageButton::ALIGN_MIDDLE);
+ SetBackButtonLabel(false);
+ content_container_->AddChildView(back_button_);
+
+ search_box_->set_placeholder_text_color(kHintTextColor);
+ }
content_container_->AddChildView(search_box_);
layout->SetFlexForView(search_box_, 1);
@@ -418,14 +445,24 @@ void SearchBoxView::SpeechRecognitionButtonPropChanged() {
}
speech_button_->SetAccessibleName(speech_button_prop->accessible_name);
+ if (IsFullscreenAppListEnabled()) {
+ speech_button_->SetImage(
+ views::Button::STATE_NORMAL,
+ gfx::CreateVectorIcon(kIcMicBlackIcon, kMicIconSize,
+ kDefaultSearchboxColor));
xiyuan 2017/06/13 20:10:41 So we will show the mic icon regardless of the spe
Qiang(Joe) Xu 2017/06/13 20:50:53 Specification doesn't mention this. I think we can
xiyuan 2017/06/13 21:09:27 Acknowledged.
+ }
if (view_delegate_->GetSpeechUI()->state() ==
SPEECH_RECOGNITION_HOTWORD_LISTENING) {
- speech_button_->SetImage(
- views::Button::STATE_NORMAL, &speech_button_prop->on_icon);
+ if (!IsFullscreenAppListEnabled()) {
+ speech_button_->SetImage(views::Button::STATE_NORMAL,
+ &speech_button_prop->on_icon);
+ }
speech_button_->SetTooltipText(speech_button_prop->on_tooltip);
xiyuan 2017/06/13 20:10:41 It is a bit strange that we change the image optio
Qiang(Joe) Xu 2017/06/13 20:50:53 The tooltip is changed based on whether OK google
xiyuan 2017/06/13 21:09:27 Thanks for the clarification.
} else {
- speech_button_->SetImage(
- views::Button::STATE_NORMAL, &speech_button_prop->off_icon);
+ if (!IsFullscreenAppListEnabled()) {
+ speech_button_->SetImage(views::Button::STATE_NORMAL,
+ &speech_button_prop->off_icon);
+ }
speech_button_->SetTooltipText(speech_button_prop->off_tooltip);
}
} else {
« no previous file with comments | « ui/app_list/views/search_box_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698