Commit 69b0b1f6 authored by Qiang Xu's avatar Qiang Xu Committed by Commit Bot

app_list: update selection highlight for opened search box

changes:
(1) no hover state highlight
(2) update search result tile selection highlight
(3) update search result simple row selection highlight
(4) another opened search box background color change: when search box
is opened (state is STATE_SEARCH_RESULTS), the background color should
be #FAFAFC 100%.

specs: https://screenshot.googleplex.com/thXHXNn3Vmt
screenshot: https://screenshot.googleplex.com/UXtpfwpqHJY

Test: test with and without fullscreen app list flag
Bug: 750690
Change-Id: I090462bf36305393a55fcc1083c1c48fb5ae7a5a
Reviewed-on: https://chromium-review.googlesource.com/600729
Commit-Queue: Qiang(Joe) Xu <warx@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491813}
parent 65f74381
......@@ -599,7 +599,7 @@ int SearchBoxView::GetSearchBoxBorderCornerRadiusForState(
SkColor SearchBoxView::GetBackgroundColorForState(
AppListModel::State state) const {
if (state == AppListModel::STATE_SEARCH_RESULTS)
return kSearchBoxBackgroundDefault;
return kCardBackgroundColorFullscreen;
return background_color_;
}
......
......@@ -115,7 +115,7 @@ void SearchResultTileItemView::SetSearchResult(SearchResult* item) {
ui::ResourceBundle::BaseFont);
if (item_->display_type() == SearchResult::DISPLAY_RECOMMENDATION) {
EnableWhiteSelectedColor(true);
set_is_recommendation(true);
title()->SetFontList(base_font.DeriveWithSizeDelta(1));
title()->SetEnabledColor(kGridTitleColorFullscreen);
......
......@@ -48,6 +48,9 @@ constexpr SkColor kDefaultTextColor =
SkColorSetARGBMacro(0x8A, 0x00, 0x00, 0x00);
// URL color.
constexpr SkColor kUrlColor = SkColorSetARGBMacro(0xFF, 0x33, 0x67, 0xD6);
// Row selected color, #000 8%.
constexpr SkColor kRowSelectedColor =
SkColorSetARGBMacro(0x14, 0x00, 0x00, 0x00);
int GetIconViewWidth() {
if (!features::IsFullscreenAppListEnabled())
......@@ -331,10 +334,13 @@ void SearchResultView::PaintButtonContents(gfx::Canvas* canvas) {
// Possibly call FillRect a second time (these colours are partially
// transparent, so the previous FillRect is not redundant).
if (selected)
canvas->FillRect(content_rect, kSelectedColor);
else if (hover)
if (selected) {
canvas->FillRect(content_rect, is_fullscreen_app_list_enabled_
? kRowSelectedColor
: kSelectedColor);
} else if (!is_fullscreen_app_list_enabled_ && hover) {
canvas->FillRect(content_rect, kHighlightedColor);
}
if (!is_fullscreen_app_list_enabled_ && !is_last_result_) {
gfx::Rect line_rect = content_rect;
......
......@@ -23,6 +23,11 @@ constexpr int kTopPadding = 5;
constexpr int kTileSize = 90;
constexpr int kIconTitleSpacing = 6;
constexpr int kIconSelectedSize = 56;
constexpr int kIconSelectedCornerRadius = 4;
// Icon selected color, #000 8%.
constexpr int kIconSelectedColor = SkColorSetARGBMacro(0x14, 0x00, 0x00, 0x00);
// The background image source for badge.
class BadgeBackgroundImageSource : public gfx::CanvasImageSource {
public:
......@@ -55,7 +60,8 @@ TileItemView::TileItemView()
parent_background_color_(SK_ColorTRANSPARENT),
icon_(new views::ImageView),
badge_(nullptr),
title_(new views::Label) {
title_(new views::Label),
is_fullscreen_app_list_enabled_(features::IsFullscreenAppListEnabled()) {
// Prevent the icon view from interfering with our mouse events.
icon_->set_can_process_events_within_subtree(false);
icon_->SetVerticalAlignment(views::ImageView::LEADING);
......@@ -148,26 +154,30 @@ void TileItemView::SetTitle(const base::string16& title) {
SetAccessibleName(title);
}
void TileItemView::EnableWhiteSelectedColor(bool enabled) {
white_selected_color_enabled_ = enabled;
}
void TileItemView::StateChanged(ButtonState old_state) {
UpdateBackgroundColor();
}
void TileItemView::PaintButtonContents(gfx::Canvas* canvas) {
if (!white_selected_color_enabled_ || !selected_)
if (!is_fullscreen_app_list_enabled_ || !selected_)
return;
gfx::Rect rect(GetContentsBounds());
rect.Inset((rect.width() - kGridSelectedSize) / 2,
(rect.height() - kGridSelectedSize) / 2);
cc::PaintFlags flags;
flags.setAntiAlias(true);
flags.setColor(kGridSelectedColor);
flags.setStyle(cc::PaintFlags::kFill_Style);
canvas->DrawRoundRect(gfx::RectF(rect), kGridSelectedCornerRadius, flags);
if (is_recommendation_) {
rect.Inset((rect.width() - kGridSelectedSize) / 2,
(rect.height() - kGridSelectedSize) / 2);
flags.setColor(kGridSelectedColor);
canvas->DrawRoundRect(gfx::RectF(rect), kGridSelectedCornerRadius, flags);
} else {
const int kLeftRightPadding = (rect.width() - kIconSelectedSize) / 2;
rect.Inset(kLeftRightPadding, 0);
rect.set_height(kIconSelectedSize);
flags.setColor(kIconSelectedColor);
canvas->DrawRoundRect(gfx::RectF(rect), kIconSelectedCornerRadius, flags);
}
}
void TileItemView::Layout() {
......@@ -207,15 +217,20 @@ bool TileItemView::GetTooltipText(const gfx::Point& p,
}
void TileItemView::UpdateBackgroundColor() {
if (white_selected_color_enabled_) {
SkColor background_color = parent_background_color_;
// Tell the label what color it will be drawn onto. It will use whether the
// background color is opaque or transparent to decide whether to use subpixel
// rendering. Does not actually set the label's background color.
title_->SetBackgroundColor(background_color);
if (is_fullscreen_app_list_enabled_) {
SetBackground(nullptr);
SchedulePaint();
return;
}
std::unique_ptr<views::Background> background;
SkColor background_color = parent_background_color_;
if (selected_) {
background_color = kSelectedColor;
background = views::CreateSolidBackground(background_color);
......@@ -229,11 +244,6 @@ void TileItemView::UpdateBackgroundColor() {
background = views::CreateSolidBackground(background_color);
}
// Tell the label what color it will be drawn onto. It will use whether the
// background color is opaque or transparent to decide whether to use subpixel
// rendering. Does not actually set the label's background color.
title_->SetBackgroundColor(background_color);
SetBackground(std::move(background));
SchedulePaint();
}
......
......@@ -27,6 +27,8 @@ class Label;
namespace app_list {
// The view for a tile in the app list on the start/search page.
// TODO(warx): Merge this class to its subclass SearchResultTileItemView once
// bubble launcher deprecates.
class APP_LIST_EXPORT TileItemView : public views::CustomButton,
public views::ButtonListener,
public ImageShadowAnimator::Delegate {
......@@ -76,7 +78,9 @@ class APP_LIST_EXPORT TileItemView : public views::CustomButton,
views::Label* title() const { return title_; }
void SetTitle(const base::string16& title);
void EnableWhiteSelectedColor(bool enabled);
void set_is_recommendation(bool is_recommendation) {
is_recommendation_ = is_recommendation;
}
private:
void UpdateBackgroundColor();
......@@ -90,10 +94,13 @@ class APP_LIST_EXPORT TileItemView : public views::CustomButton,
bool selected_ = false;
// Indicates whether the white color background selected color should be used
// for this TileItemView. It is enabled for suggested apps only for new
// design.
bool white_selected_color_enabled_ = false;
// Indicates whether this view is the base class for recommendation display
// type SearchResultTileItemView.
// TODO(warx): It is not needed once TileItemView class is merged to
// SearchResultTileItemVIew.
bool is_recommendation_ = false;
const bool is_fullscreen_app_list_enabled_;
DISALLOW_COPY_AND_ASSIGN(TileItemView);
};
......
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