OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/app_list/views/search_result_tile_item_view.h" | 5 #include "ui/app_list/views/search_result_tile_item_view.h" |
6 | 6 |
7 #include "base/i18n/number_formatting.h" | 7 #include "base/i18n/number_formatting.h" |
8 #include "ui/app_list/app_list_constants.h" | 8 #include "ui/app_list/app_list_constants.h" |
9 #include "ui/app_list/app_list_features.h" | 9 #include "ui/app_list/app_list_features.h" |
10 #include "ui/app_list/app_list_view_delegate.h" | 10 #include "ui/app_list/app_list_view_delegate.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 constexpr SkColor kSearchAppPriceColor = | 29 constexpr SkColor kSearchAppPriceColor = |
30 SkColorSetARGBMacro(0xFF, 0x0F, 0x9D, 0x58); | 30 SkColorSetARGBMacro(0xFF, 0x0F, 0x9D, 0x58); |
31 | 31 |
32 } // namespace | 32 } // namespace |
33 | 33 |
34 SearchResultTileItemView::SearchResultTileItemView( | 34 SearchResultTileItemView::SearchResultTileItemView( |
35 SearchResultContainerView* result_container, | 35 SearchResultContainerView* result_container, |
36 AppListViewDelegate* view_delegate) | 36 AppListViewDelegate* view_delegate) |
37 : result_container_(result_container), | 37 : result_container_(result_container), |
38 view_delegate_(view_delegate), | 38 view_delegate_(view_delegate), |
39 is_fullscreen_app_list_enabled_(features::IsFullscreenAppListEnabled()) { | 39 is_play_store_app_search_enabled_( |
| 40 features::IsPlayStoreAppSearchEnabled()) { |
40 // When |item_| is null, the tile is invisible. Calling SetSearchResult with a | 41 // When |item_| is null, the tile is invisible. Calling SetSearchResult with a |
41 // non-null item makes the tile visible. | 42 // non-null item makes the tile visible. |
42 SetVisible(false); | 43 SetVisible(false); |
43 | 44 |
44 if (is_fullscreen_app_list_enabled_) { | 45 if (is_play_store_app_search_enabled_) { |
45 const gfx::FontList& base_font = | 46 const gfx::FontList& base_font = |
46 ui::ResourceBundle::GetSharedInstance().GetFontList( | 47 ui::ResourceBundle::GetSharedInstance().GetFontList( |
47 ui::ResourceBundle::BaseFont); | 48 ui::ResourceBundle::BaseFont); |
48 | 49 |
49 rating_ = new views::Label; | 50 rating_ = new views::Label; |
50 rating_->SetEnabledColor(kSearchAppRatingColor); | 51 rating_->SetEnabledColor(kSearchAppRatingColor); |
51 rating_->SetFontList(base_font); | 52 rating_->SetFontList(base_font); |
52 rating_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 53 rating_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
53 rating_->SetVisible(false); | 54 rating_->SetVisible(false); |
54 AddChildView(rating_); | 55 AddChildView(rating_); |
(...skipping 29 matching lines...) Expand all Loading... |
84 | 85 |
85 if (!item) | 86 if (!item) |
86 return; | 87 return; |
87 | 88 |
88 item_->AddObserver(this); | 89 item_->AddObserver(this); |
89 | 90 |
90 SetTitle(item_->title()); | 91 SetTitle(item_->title()); |
91 SetRating(item_->rating()); | 92 SetRating(item_->rating()); |
92 SetPrice(item_->formatted_price()); | 93 SetPrice(item_->formatted_price()); |
93 | 94 |
94 if (is_fullscreen_app_list_enabled_) { | 95 if (is_play_store_app_search_enabled_) { |
95 const gfx::FontList& base_font = | 96 const gfx::FontList& base_font = |
96 ui::ResourceBundle::GetSharedInstance().GetFontList( | 97 ui::ResourceBundle::GetSharedInstance().GetFontList( |
97 ui::ResourceBundle::BaseFont); | 98 ui::ResourceBundle::BaseFont); |
98 | 99 |
99 // Customize title UI | 100 // Customize title UI |
100 if (item_->display_type() == SearchResult::DISPLAY_RECOMMENDATION) { | 101 if (item_->display_type() == SearchResult::DISPLAY_RECOMMENDATION) { |
101 title()->SetFontList(base_font.DeriveWithSizeDelta(1)); | 102 title()->SetFontList(base_font.DeriveWithSizeDelta(1)); |
102 title()->SetEnabledColor(kGridTitleColorFullscreen); | 103 title()->SetEnabledColor(kGridTitleColorFullscreen); |
103 } else if (item_->display_type() == SearchResult::DISPLAY_TILE) { | 104 } else if (item_->display_type() == SearchResult::DISPLAY_TILE) { |
104 title()->SetFontList(base_font.DeriveWithSizeDelta(1)); | 105 title()->SetFontList(base_font.DeriveWithSizeDelta(1)); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 context_menu_runner_->RunMenuAt(GetWidget(), nullptr, | 206 context_menu_runner_->RunMenuAt(GetWidget(), nullptr, |
206 gfx::Rect(point, gfx::Size()), | 207 gfx::Rect(point, gfx::Size()), |
207 views::MENU_ANCHOR_TOPLEFT, source_type); | 208 views::MENU_ANCHOR_TOPLEFT, source_type); |
208 } | 209 } |
209 | 210 |
210 void SearchResultTileItemView::Layout() { | 211 void SearchResultTileItemView::Layout() { |
211 gfx::Rect rect(GetContentsBounds()); | 212 gfx::Rect rect(GetContentsBounds()); |
212 if (rect.IsEmpty()) | 213 if (rect.IsEmpty()) |
213 return; | 214 return; |
214 | 215 |
215 if (!is_fullscreen_app_list_enabled_ || !item_) { | 216 if (!is_play_store_app_search_enabled_ || !item_) { |
216 TileItemView::Layout(); | 217 TileItemView::Layout(); |
217 return; | 218 return; |
218 } | 219 } |
219 | 220 |
220 if (item_->display_type() == SearchResult::DISPLAY_RECOMMENDATION) { | 221 if (item_->display_type() == SearchResult::DISPLAY_RECOMMENDATION) { |
221 rect.Inset(0, kGridIconTopPadding, 0, 0); | 222 rect.Inset(0, kGridIconTopPadding, 0, 0); |
222 icon()->SetBoundsRect(rect); | 223 icon()->SetBoundsRect(rect); |
223 | 224 |
224 rect.Inset(kGridTitleHorizontalPadding, | 225 rect.Inset(kGridTitleHorizontalPadding, |
225 kGridIconDimension + kGridTitleSpacing, | 226 kGridIconDimension + kGridTitleSpacing, |
(...skipping 29 matching lines...) Expand all Loading... |
255 price_rect.Inset(0, title()->GetPreferredSize().height(), 0, 0); | 256 price_rect.Inset(0, title()->GetPreferredSize().height(), 0, 0); |
256 price_rect.set_height(price_->GetPreferredSize().height()); | 257 price_rect.set_height(price_->GetPreferredSize().height()); |
257 price_->SetBoundsRect(price_rect); | 258 price_->SetBoundsRect(price_rect); |
258 } | 259 } |
259 } else { | 260 } else { |
260 TileItemView::Layout(); | 261 TileItemView::Layout(); |
261 } | 262 } |
262 } | 263 } |
263 | 264 |
264 gfx::Size SearchResultTileItemView::CalculatePreferredSize() const { | 265 gfx::Size SearchResultTileItemView::CalculatePreferredSize() const { |
265 if (is_fullscreen_app_list_enabled_ && item_) { | 266 if (is_play_store_app_search_enabled_ && item_) { |
266 if (item_->display_type() == SearchResult::DISPLAY_RECOMMENDATION) | 267 if (item_->display_type() == SearchResult::DISPLAY_RECOMMENDATION) |
267 return gfx::Size(kGridTileWidth, kGridTileHeight); | 268 return gfx::Size(kGridTileWidth, kGridTileHeight); |
268 if (item_->display_type() == SearchResult::DISPLAY_TILE) | 269 if (item_->display_type() == SearchResult::DISPLAY_TILE) |
269 return gfx::Size(kSearchTileWidth, kSearchTileHeight); | 270 return gfx::Size(kSearchTileWidth, kSearchTileHeight); |
270 } | 271 } |
271 | 272 |
272 return TileItemView::CalculatePreferredSize(); | 273 return TileItemView::CalculatePreferredSize(); |
273 } | 274 } |
274 | 275 |
275 } // namespace app_list | 276 } // namespace app_list |
OLD | NEW |