| 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/tile_item_view.h" | 5 #include "ui/app_list/views/tile_item_view.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.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_item.h" | 9 #include "ui/app_list/app_list_item.h" |
| 10 #include "ui/app_list/app_list_model.h" | 10 #include "ui/app_list/app_list_model.h" |
| 11 #include "ui/app_list/app_list_view_delegate.h" | 11 #include "ui/app_list/app_list_view_delegate.h" |
| 12 #include "ui/app_list/search_result.h" | 12 #include "ui/app_list/search_result.h" |
| 13 #include "ui/app_list/views/app_list_main_view.h" | 13 #include "ui/app_list/views/app_list_main_view.h" |
| 14 #include "ui/base/resource/resource_bundle.h" |
| 14 #include "ui/gfx/canvas.h" | 15 #include "ui/gfx/canvas.h" |
| 15 #include "ui/gfx/color_analysis.h" | 16 #include "ui/gfx/color_analysis.h" |
| 16 #include "ui/gfx/color_utils.h" | 17 #include "ui/gfx/color_utils.h" |
| 17 #include "ui/views/background.h" | 18 #include "ui/views/background.h" |
| 18 #include "ui/views/controls/image_view.h" | 19 #include "ui/views/controls/image_view.h" |
| 19 #include "ui/views/controls/label.h" | 20 #include "ui/views/controls/label.h" |
| 20 #include "ui/views/layout/box_layout.h" | 21 #include "ui/views/layout/box_layout.h" |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| 24 const int kTileSize = 90; | 25 const int kTileSize = 90; |
| 25 const int kTileHorizontalPadding = 10; | 26 const int kTileHorizontalPadding = 10; |
| 26 | 27 |
| 28 // In Windows, transparent background color will cause ugly text rendering, |
| 29 // therefore kContentsBackgroundColor should be used. See crbug.com/406989 |
| 30 #if defined(OS_CHROMEOS) |
| 31 const SkColor kTitleBackgroundColor = SK_ColorTRANSPARENT; |
| 32 #else |
| 33 const SkColor kTitleBackgroundColor = app_list::kContentsBackgroundColor; |
| 34 #endif |
| 35 |
| 27 } // namespace | 36 } // namespace |
| 28 | 37 |
| 29 namespace app_list { | 38 namespace app_list { |
| 30 | 39 |
| 31 TileItemView::TileItemView() | 40 TileItemView::TileItemView() |
| 32 : views::CustomButton(this), | 41 : views::CustomButton(this), |
| 33 item_(NULL), | 42 item_(NULL), |
| 34 icon_(new views::ImageView), | 43 icon_(new views::ImageView), |
| 35 title_(new views::Label) { | 44 title_(new views::Label) { |
| 36 views::BoxLayout* layout_manager = new views::BoxLayout( | 45 views::BoxLayout* layout_manager = new views::BoxLayout( |
| 37 views::BoxLayout::kVertical, kTileHorizontalPadding, 0, 0); | 46 views::BoxLayout::kVertical, kTileHorizontalPadding, 0, 0); |
| 38 layout_manager->set_main_axis_alignment( | 47 layout_manager->set_main_axis_alignment( |
| 39 views::BoxLayout::MAIN_AXIS_ALIGNMENT_CENTER); | 48 views::BoxLayout::MAIN_AXIS_ALIGNMENT_CENTER); |
| 40 SetLayoutManager(layout_manager); | 49 SetLayoutManager(layout_manager); |
| 41 | 50 |
| 42 icon_->SetImageSize(gfx::Size(kTileIconSize, kTileIconSize)); | 51 icon_->SetImageSize(gfx::Size(kTileIconSize, kTileIconSize)); |
| 43 | 52 |
| 44 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 53 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 45 title_->SetAutoColorReadabilityEnabled(false); | 54 title_->SetAutoColorReadabilityEnabled(false); |
| 46 title_->SetEnabledColor(kGridTitleColor); | 55 title_->SetEnabledColor(kGridTitleColor); |
| 47 title_->set_background(views::Background::CreateSolidBackground( | 56 title_->set_background(views::Background::CreateSolidBackground( |
| 48 app_list::kContentsBackgroundColor)); | 57 kTitleBackgroundColor)); |
| 49 title_->SetFontList(rb.GetFontList(kItemTextFontStyle)); | 58 title_->SetFontList(rb.GetFontList(kItemTextFontStyle)); |
| 50 title_->SetHorizontalAlignment(gfx::ALIGN_CENTER); | 59 title_->SetHorizontalAlignment(gfx::ALIGN_CENTER); |
| 51 | 60 |
| 52 // When |item_| is NULL, the tile is invisible. Calling SetSearchResult with a | 61 // When |item_| is NULL, the tile is invisible. Calling SetSearchResult with a |
| 53 // non-NULL item makes the tile visible. | 62 // non-NULL item makes the tile visible. |
| 54 SetVisible(false); | 63 SetVisible(false); |
| 55 | 64 |
| 56 AddChildView(icon_); | 65 AddChildView(icon_); |
| 57 AddChildView(title_); | 66 AddChildView(title_); |
| 58 } | 67 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 icon_->SetImage(item_->icon()); | 108 icon_->SetImage(item_->icon()); |
| 100 } | 109 } |
| 101 | 110 |
| 102 void TileItemView::OnResultDestroying() { | 111 void TileItemView::OnResultDestroying() { |
| 103 if (item_) | 112 if (item_) |
| 104 item_->RemoveObserver(this); | 113 item_->RemoveObserver(this); |
| 105 item_ = NULL; | 114 item_ = NULL; |
| 106 } | 115 } |
| 107 | 116 |
| 108 } // namespace app_list | 117 } // namespace app_list |
| OLD | NEW |