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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 title()->SetFontList(base_font.DeriveWithSizeDelta(1)); | 105 title()->SetFontList(base_font.DeriveWithSizeDelta(1)); |
106 title()->SetEnabledColor(kSearchTitleColor); | 106 title()->SetEnabledColor(kSearchTitleColor); |
107 } | 107 } |
108 } | 108 } |
109 | 109 |
110 // 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 |
111 // flickering. | 111 // flickering. |
112 if (!old_item || !item->icon().BackedBySameObjectAs(old_item->icon())) { | 112 if (!old_item || !item->icon().BackedBySameObjectAs(old_item->icon())) { |
113 OnIconChanged(); | 113 OnIconChanged(); |
114 } | 114 } |
| 115 if (!old_item || |
| 116 !item->badge_icon().BackedBySameObjectAs(old_item->badge_icon())) { |
| 117 OnBadgeIconChanged(); |
| 118 } |
115 } | 119 } |
116 | 120 |
117 void SearchResultTileItemView::SetRating(float rating) { | 121 void SearchResultTileItemView::SetRating(float rating) { |
118 if (!rating_) | 122 if (!rating_) |
119 return; | 123 return; |
120 | 124 |
121 if (rating < 0) { | 125 if (rating < 0) { |
122 rating_->SetVisible(false); | 126 rating_->SetVisible(false); |
123 return; | 127 return; |
124 } | 128 } |
(...skipping 24 matching lines...) Expand all Loading... |
149 if (event.key_code() == ui::VKEY_RETURN) { | 153 if (event.key_code() == ui::VKEY_RETURN) { |
150 view_delegate_->OpenSearchResult(item_, false, event.flags()); | 154 view_delegate_->OpenSearchResult(item_, false, event.flags()); |
151 return true; | 155 return true; |
152 } | 156 } |
153 | 157 |
154 return false; | 158 return false; |
155 } | 159 } |
156 | 160 |
157 void SearchResultTileItemView::OnIconChanged() { | 161 void SearchResultTileItemView::OnIconChanged() { |
158 SetIcon(item_->icon()); | 162 SetIcon(item_->icon()); |
| 163 Layout(); |
159 } | 164 } |
160 | 165 |
161 void SearchResultTileItemView::OnBadgeIconChanged() { | 166 void SearchResultTileItemView::OnBadgeIconChanged() { |
162 SetBadgeIcon(item_->badge_icon()); | 167 SetBadgeIcon(item_->badge_icon()); |
| 168 Layout(); |
163 } | 169 } |
164 | 170 |
165 void SearchResultTileItemView::OnRatingChanged() { | 171 void SearchResultTileItemView::OnRatingChanged() { |
166 SetRating(item_->rating()); | 172 SetRating(item_->rating()); |
167 } | 173 } |
168 | 174 |
169 void SearchResultTileItemView::OnFormattedPriceChanged() { | 175 void SearchResultTileItemView::OnFormattedPriceChanged() { |
170 SetPrice(item_->formatted_price()); | 176 SetPrice(item_->formatted_price()); |
171 } | 177 } |
172 | 178 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 if (item_->display_type() == SearchResult::DISPLAY_RECOMMENDATION) | 267 if (item_->display_type() == SearchResult::DISPLAY_RECOMMENDATION) |
262 return gfx::Size(kGridTileWidth, kGridTileHeight); | 268 return gfx::Size(kGridTileWidth, kGridTileHeight); |
263 if (item_->display_type() == SearchResult::DISPLAY_TILE) | 269 if (item_->display_type() == SearchResult::DISPLAY_TILE) |
264 return gfx::Size(kSearchTileWidth, kSearchTileHeight); | 270 return gfx::Size(kSearchTileWidth, kSearchTileHeight); |
265 } | 271 } |
266 | 272 |
267 return TileItemView::CalculatePreferredSize(); | 273 return TileItemView::CalculatePreferredSize(); |
268 } | 274 } |
269 | 275 |
270 } // namespace app_list | 276 } // namespace app_list |
OLD | NEW |