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