Chromium Code Reviews| Index: ui/app_list/views/tile_item_view.cc |
| diff --git a/ui/app_list/views/tile_item_view.cc b/ui/app_list/views/tile_item_view.cc |
| index 5e6543b1db78547f906ed50596031e3d17554e69..d0c2e68b3d208e9ba7fc0dc2c3bea9e02c4f53ba 100644 |
| --- a/ui/app_list/views/tile_item_view.cc |
| +++ b/ui/app_list/views/tile_item_view.cc |
| @@ -8,6 +8,7 @@ |
| #include "ui/app_list/app_list_features.h" |
| #include "ui/app_list/views/app_list_main_view.h" |
| #include "ui/gfx/canvas.h" |
| +#include "ui/gfx/font_list.h" |
| #include "ui/gfx/image/canvas_image_source.h" |
| #include "ui/gfx/image/image_skia_operations.h" |
| #include "ui/views/background.h" |
| @@ -23,6 +24,11 @@ constexpr int kIconTitleSpacing = 6; |
| constexpr int kBadgeBackgroundRadius = 10; |
| +// Layout constants used when fullscreen app list feature is enabled. |
| +constexpr int kItemTopPadding = 4; |
| +constexpr int kItemWidth = 80; |
| +constexpr int kItemHeight = 90; |
| + |
| // The background image source for badge. |
| class BadgeBackgroundImageSource : public gfx::CanvasImageSource { |
| public: |
| @@ -55,7 +61,10 @@ TileItemView::TileItemView() |
| parent_background_color_(SK_ColorTRANSPARENT), |
| icon_(new views::ImageView), |
| badge_(nullptr), |
| - title_(new views::Label) { |
| + title_(new views::Label), |
| + price_(nullptr), |
| + rating_(nullptr), |
| + 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); |
| @@ -68,13 +77,26 @@ TileItemView::TileItemView() |
| title_->SetHandlesTooltips(false); |
| AddChildView(icon_); |
| - if (features::IsFullscreenAppListEnabled()) { |
| + AddChildView(title_); |
| + |
| + if (is_fullscreen_app_list_enabled_) { |
| badge_ = new views::ImageView(); |
| badge_->set_can_process_events_within_subtree(false); |
| badge_->SetVerticalAlignment(views::ImageView::LEADING); |
| AddChildView(badge_); |
| + |
| + price_ = new views::Label; |
| + price_->SetEnabledColor(kAppPriceColor); |
| + price_->SetFontList(gfx::FontList(kAppPriceFontList)); |
|
xiyuan
2017/06/20 22:19:23
Roboto is the current default UI font. Let's try n
weidongg
2017/06/22 00:59:16
Good to know, thanks. Done.
|
| + price_->SetHorizontalAlignment(gfx::ALIGN_RIGHT); |
| + AddChildView(price_); |
| + |
| + rating_ = new views::Label; |
| + rating_->SetEnabledColor(kAppRatingColor); |
| + rating_->SetFontList(gfx::FontList(kAppRatingFontList)); |
| + rating_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| + AddChildView(rating_); |
| } |
| - AddChildView(title_); |
| } |
| TileItemView::~TileItemView() = default; |
| @@ -148,6 +170,18 @@ void TileItemView::SetTitle(const base::string16& title) { |
| SetAccessibleName(title); |
| } |
| +void TileItemView::SetPrice(const base::string16& price) { |
| + if (!price_) |
| + return; |
| + price_->SetText(price); |
| +} |
| + |
| +void TileItemView::SetRating(const base::string16& rating) { |
| + if (!rating_) |
| + return; |
| + rating_->SetText(rating); |
| +} |
| + |
| void TileItemView::StateChanged(ButtonState old_state) { |
| UpdateBackgroundColor(); |
| } |
| @@ -157,7 +191,8 @@ void TileItemView::Layout() { |
| if (rect.IsEmpty()) |
| return; |
| - rect.Inset(0, kTopPadding, 0, 0); |
| + rect.Inset(0, is_fullscreen_app_list_enabled_ ? kItemTopPadding : kTopPadding, |
| + 0, 0); |
| icon_->SetBoundsRect(rect); |
| if (badge_) { |
| @@ -172,6 +207,20 @@ void TileItemView::Layout() { |
| rect.Inset(0, kGridIconDimension + kIconTitleSpacing, 0, 0); |
| rect.set_height(title_->GetPreferredSize().height()); |
| title_->SetBoundsRect(rect); |
| + |
| + if (price_) { |
| + gfx::Rect price_rect(rect); |
| + price_rect.Inset(0, title_->GetPreferredSize().height(), 0, 0); |
| + price_rect.set_height(price_->GetPreferredSize().height()); |
| + price_->SetBoundsRect(price_rect); |
| + } |
| + |
| + if (rating_) { |
| + gfx::Rect rating_rect(rect); |
| + rating_rect.Inset(0, title_->GetPreferredSize().height(), 0, 0); |
| + rating_rect.set_height(rating_->GetPreferredSize().height()); |
| + rating_->SetBoundsRect(rating_rect); |
| + } |
| } |
| const char* TileItemView::GetClassName() const { |
| @@ -210,7 +259,10 @@ void TileItemView::UpdateBackgroundColor() { |
| } |
| gfx::Size TileItemView::CalculatePreferredSize() const { |
| - return gfx::Size(kTileSize, kTileSize); |
| + if (is_fullscreen_app_list_enabled_) |
| + return gfx::Size(kItemWidth, kItemHeight); |
| + else |
|
xiyuan
2017/06/20 22:19:23
Don't use else after return.
See https://chromium
weidongg
2017/06/22 00:59:16
Done.
|
| + return gfx::Size(kTileSize, kTileSize); |
| } |
| bool TileItemView::GetTooltipText(const gfx::Point& p, |