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" |
11 #include "ui/app_list/search_result.h" | 11 #include "ui/app_list/search_result.h" |
12 #include "ui/app_list/views/search_result_container_view.h" | 12 #include "ui/app_list/views/search_result_container_view.h" |
13 #include "ui/views/controls/image_view.h" | 13 #include "ui/views/controls/image_view.h" |
14 #include "ui/views/controls/label.h" | 14 #include "ui/views/controls/label.h" |
15 #include "ui/views/controls/menu/menu_runner.h" | 15 #include "ui/views/controls/menu/menu_runner.h" |
16 | 16 |
17 namespace app_list { | 17 namespace app_list { |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 constexpr int kRecommendationTileWidth = 96; | |
22 constexpr int kRecommendationTileHeight = 99; | |
23 constexpr int kRecommendationIconTopPadding = 24; | |
24 constexpr int kRecommendationTitleSpacing = 10; | |
25 constexpr int kRecommendationTileMaxWidth = 80; | |
26 | |
27 constexpr int kSearchTileWidth = 80; | 21 constexpr int kSearchTileWidth = 80; |
28 constexpr int kSearchTileHeight = 92; | 22 constexpr int kSearchTileHeight = 92; |
29 constexpr int kSearchTileTopPadding = 4; | 23 constexpr int kSearchTileTopPadding = 4; |
30 constexpr int kSearchTitleSpacing = 6; | 24 constexpr int kSearchTitleSpacing = 6; |
31 | 25 |
32 constexpr SkColor kRecommendationTileColor = SK_ColorWHITE; | |
33 | |
34 constexpr SkColor kSearchTitleColor = | 26 constexpr SkColor kSearchTitleColor = |
35 SkColorSetARGBMacro(0xDF, 0x00, 0x00, 0x00); | 27 SkColorSetARGBMacro(0xDF, 0x00, 0x00, 0x00); |
36 constexpr SkColor kSearchAppRatingColor = | 28 constexpr SkColor kSearchAppRatingColor = |
37 SkColorSetARGBMacro(0x8F, 0x00, 0x00, 0x00); | 29 SkColorSetARGBMacro(0x8F, 0x00, 0x00, 0x00); |
38 constexpr SkColor kSearchAppPriceColor = | 30 constexpr SkColor kSearchAppPriceColor = |
39 SkColorSetARGBMacro(0xFF, 0x0F, 0x9D, 0x58); | 31 SkColorSetARGBMacro(0xFF, 0x0F, 0x9D, 0x58); |
40 | 32 |
41 } // namespace | 33 } // namespace |
42 | 34 |
43 SearchResultTileItemView::SearchResultTileItemView( | 35 SearchResultTileItemView::SearchResultTileItemView( |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
101 SetPrice(item_->formatted_price()); | 93 SetPrice(item_->formatted_price()); |
102 | 94 |
103 if (is_fullscreen_app_list_enabled_) { | 95 if (is_fullscreen_app_list_enabled_) { |
104 const gfx::FontList& base_font = | 96 const gfx::FontList& base_font = |
105 ui::ResourceBundle::GetSharedInstance().GetFontList( | 97 ui::ResourceBundle::GetSharedInstance().GetFontList( |
106 ui::ResourceBundle::BaseFont); | 98 ui::ResourceBundle::BaseFont); |
107 | 99 |
108 // Customize title UI | 100 // Customize title UI |
109 if (item_->display_type() == SearchResult::DISPLAY_RECOMMENDATION) { | 101 if (item_->display_type() == SearchResult::DISPLAY_RECOMMENDATION) { |
110 title()->SetFontList(base_font.DeriveWithSizeDelta(1)); | 102 title()->SetFontList(base_font.DeriveWithSizeDelta(1)); |
111 title()->SetEnabledColor(kRecommendationTileColor); | 103 title()->SetEnabledColor(kGridTitleColorFullscreen); |
112 } else if (item_->display_type() == SearchResult::DISPLAY_TILE) { | 104 } else if (item_->display_type() == SearchResult::DISPLAY_TILE) { |
113 title()->SetFontList(base_font.DeriveWithSizeDelta(1)); | 105 title()->SetFontList(base_font.DeriveWithSizeDelta(1)); |
114 title()->SetEnabledColor(kSearchTitleColor); | 106 title()->SetEnabledColor(kSearchTitleColor); |
115 } | 107 } |
116 } | 108 } |
117 | 109 |
118 // Only refresh the icon if it's different from the old one. This prevents | 110 // Only refresh the icon if it's different from the old one. This prevents |
119 // flickering. | 111 // flickering. |
120 if (!old_item || !item->icon().BackedBySameObjectAs(old_item->icon())) { | 112 if (!old_item || !item->icon().BackedBySameObjectAs(old_item->icon())) { |
121 OnIconChanged(); | 113 OnIconChanged(); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
214 gfx::Rect rect(GetContentsBounds()); | 206 gfx::Rect rect(GetContentsBounds()); |
215 if (rect.IsEmpty()) | 207 if (rect.IsEmpty()) |
216 return; | 208 return; |
217 | 209 |
218 if (!is_fullscreen_app_list_enabled_ || !item_) { | 210 if (!is_fullscreen_app_list_enabled_ || !item_) { |
219 TileItemView::Layout(); | 211 TileItemView::Layout(); |
220 return; | 212 return; |
221 } | 213 } |
222 | 214 |
223 if (item_->display_type() == SearchResult::DISPLAY_RECOMMENDATION) { | 215 if (item_->display_type() == SearchResult::DISPLAY_RECOMMENDATION) { |
224 rect.Inset(0, kRecommendationIconTopPadding, 0, 0); | 216 rect.Inset(0, kGridIconTopPadding, 0, 0); |
225 icon()->SetBoundsRect(rect); | 217 icon()->SetBoundsRect(rect); |
226 | 218 |
227 rect.Inset(0, kGridIconDimension + kRecommendationTitleSpacing, 0, 0); | 219 rect.Inset(kGridTitleHorizontalPadding, |
220 kGridIconDimension + kGridTitleSpacing, | |
221 kGridTitleHorizontalPadding, 0); | |
228 rect.set_height(title()->GetPreferredSize().height()); | 222 rect.set_height(title()->GetPreferredSize().height()); |
229 rect.set_width(kRecommendationTileMaxWidth); | |
230 title()->SetBoundsRect(rect); | 223 title()->SetBoundsRect(rect); |
231 } else if (item_->display_type() == SearchResult::DISPLAY_TILE) { | 224 } else if (item_->display_type() == SearchResult::DISPLAY_TILE) { |
232 rect.Inset(0, kSearchTileTopPadding, 0, 0); | 225 rect.Inset(0, kSearchTileTopPadding, 0, 0); |
233 icon()->SetBoundsRect(rect); | 226 icon()->SetBoundsRect(rect); |
234 | 227 |
235 if (badge()) { | 228 if (badge()) { |
236 gfx::Rect badge_rect(rect); | 229 gfx::Rect badge_rect(rect); |
237 gfx::Size icon_size = icon()->GetImage().size(); | 230 gfx::Size icon_size = icon()->GetImage().size(); |
238 badge_rect.Offset( | 231 badge_rect.Offset( |
239 (icon_size.width() - kAppBadgeIconSize) / 2, | 232 (icon_size.width() - kAppBadgeIconSize) / 2, |
(...skipping 19 matching lines...) Expand all Loading... | |
259 price_->SetBoundsRect(price_rect); | 252 price_->SetBoundsRect(price_rect); |
260 } | 253 } |
261 } else { | 254 } else { |
262 TileItemView::Layout(); | 255 TileItemView::Layout(); |
263 } | 256 } |
264 } | 257 } |
265 | 258 |
266 gfx::Size SearchResultTileItemView::CalculatePreferredSize() const { | 259 gfx::Size SearchResultTileItemView::CalculatePreferredSize() const { |
267 if (is_fullscreen_app_list_enabled_ && item_) { | 260 if (is_fullscreen_app_list_enabled_ && item_) { |
268 if (item_->display_type() == SearchResult::DISPLAY_RECOMMENDATION) | 261 if (item_->display_type() == SearchResult::DISPLAY_RECOMMENDATION) |
269 return gfx::Size(kRecommendationTileWidth, kRecommendationTileHeight); | 262 return gfx::Size(kGridTileWidth, kGridTileHeight); |
270 if (item_->display_type() == SearchResult::DISPLAY_TILE) | 263 else if (item_->display_type() == SearchResult::DISPLAY_TILE) |
xiyuan
2017/06/22 22:44:14
no else after return
See https://chromium.googles
Qiang(Joe) Xu
2017/06/22 22:55:38
acknowledged, done.
| |
271 return gfx::Size(kSearchTileWidth, kSearchTileHeight); | 264 return gfx::Size(kSearchTileWidth, kSearchTileHeight); |
272 } | 265 } |
273 | 266 |
274 return TileItemView::CalculatePreferredSize(); | 267 return TileItemView::CalculatePreferredSize(); |
275 } | 268 } |
276 | 269 |
277 } // namespace app_list | 270 } // namespace app_list |
OLD | NEW |