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/gfx/canvas.h" | 14 #include "ui/gfx/canvas.h" |
15 #include "ui/gfx/color_analysis.h" | 15 #include "ui/gfx/color_analysis.h" |
16 #include "ui/gfx/color_utils.h" | 16 #include "ui/gfx/color_utils.h" |
| 17 #include "ui/views/background.h" |
17 #include "ui/views/controls/image_view.h" | 18 #include "ui/views/controls/image_view.h" |
18 #include "ui/views/controls/label.h" | 19 #include "ui/views/controls/label.h" |
19 #include "ui/views/layout/box_layout.h" | 20 #include "ui/views/layout/box_layout.h" |
20 | 21 |
21 namespace { | 22 namespace { |
22 | 23 |
23 const int kTileSize = 90; | 24 const int kTileSize = 90; |
24 const int kTileHorizontalPadding = 10; | 25 const int kTileHorizontalPadding = 10; |
25 | 26 |
26 } // namespace | 27 } // namespace |
27 | 28 |
28 namespace app_list { | 29 namespace app_list { |
29 | 30 |
30 TileItemView::TileItemView() | 31 TileItemView::TileItemView() |
31 : views::CustomButton(this), | 32 : views::CustomButton(this), |
32 item_(NULL), | 33 item_(NULL), |
33 icon_(new views::ImageView), | 34 icon_(new views::ImageView), |
34 title_(new views::Label) { | 35 title_(new views::Label) { |
35 views::BoxLayout* layout_manager = new views::BoxLayout( | 36 views::BoxLayout* layout_manager = new views::BoxLayout( |
36 views::BoxLayout::kVertical, kTileHorizontalPadding, 0, 0); | 37 views::BoxLayout::kVertical, kTileHorizontalPadding, 0, 0); |
37 layout_manager->set_main_axis_alignment( | 38 layout_manager->set_main_axis_alignment( |
38 views::BoxLayout::MAIN_AXIS_ALIGNMENT_CENTER); | 39 views::BoxLayout::MAIN_AXIS_ALIGNMENT_CENTER); |
39 SetLayoutManager(layout_manager); | 40 SetLayoutManager(layout_manager); |
40 | 41 |
41 icon_->SetImageSize(gfx::Size(kTileIconSize, kTileIconSize)); | 42 icon_->SetImageSize(gfx::Size(kTileIconSize, kTileIconSize)); |
42 | 43 |
43 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 44 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
44 title_->SetAutoColorReadabilityEnabled(false); | 45 title_->SetAutoColorReadabilityEnabled(false); |
45 title_->SetEnabledColor(kGridTitleColor); | 46 title_->SetEnabledColor(kGridTitleColor); |
| 47 title_->set_background(views::Background::CreateSolidBackground( |
| 48 app_list::kContentsBackgroundColor)); |
46 title_->SetFontList(rb.GetFontList(kItemTextFontStyle)); | 49 title_->SetFontList(rb.GetFontList(kItemTextFontStyle)); |
47 title_->SetHorizontalAlignment(gfx::ALIGN_CENTER); | 50 title_->SetHorizontalAlignment(gfx::ALIGN_CENTER); |
48 | 51 |
49 // When |item_| is NULL, the tile is invisible. Calling SetSearchResult with a | 52 // When |item_| is NULL, the tile is invisible. Calling SetSearchResult with a |
50 // non-NULL item makes the tile visible. | 53 // non-NULL item makes the tile visible. |
51 SetVisible(false); | 54 SetVisible(false); |
52 | 55 |
53 AddChildView(icon_); | 56 AddChildView(icon_); |
54 AddChildView(title_); | 57 AddChildView(title_); |
55 } | 58 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 icon_->SetImage(item_->icon()); | 99 icon_->SetImage(item_->icon()); |
97 } | 100 } |
98 | 101 |
99 void TileItemView::OnResultDestroying() { | 102 void TileItemView::OnResultDestroying() { |
100 if (item_) | 103 if (item_) |
101 item_->RemoveObserver(this); | 104 item_->RemoveObserver(this); |
102 item_ = NULL; | 105 item_ = NULL; |
103 } | 106 } |
104 | 107 |
105 } // namespace app_list | 108 } // namespace app_list |
OLD | NEW |