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