| 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/views/app_list_main_view.h" | 12 #include "ui/app_list/views/app_list_main_view.h" |
| 13 #include "ui/gfx/canvas.h" | 13 #include "ui/gfx/canvas.h" |
| 14 #include "ui/gfx/color_analysis.h" | 14 #include "ui/gfx/color_analysis.h" |
| 15 #include "ui/gfx/color_utils.h" | 15 #include "ui/gfx/color_utils.h" |
| 16 #include "ui/views/background.h" | 16 #include "ui/views/background.h" |
| 17 #include "ui/views/controls/image_view.h" | 17 #include "ui/views/controls/image_view.h" |
| 18 #include "ui/views/controls/label.h" | 18 #include "ui/views/controls/label.h" |
| 19 #include "ui/views/layout/box_layout.h" | 19 #include "ui/views/layout/box_layout.h" |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 const int kTileSize = 90; | 23 const int kTileSize = 90; |
| 24 const int kTileHorizontalPadding = 10; | 24 const int kTileHorizontalPadding = 10; |
| 25 const int kTileImageSize = 48; | |
| 26 | 25 |
| 27 const SkColor kTileBackgroundColor = SK_ColorWHITE; | 26 const SkColor kTileBackgroundColor = SK_ColorWHITE; |
| 28 const int kTileColorStripHeight = 2; | 27 const int kTileColorStripHeight = 2; |
| 29 const SkAlpha kTileColorStripOpacity = 0X5F; | 28 const SkAlpha kTileColorStripOpacity = 0X5F; |
| 30 const int kTileCornerRadius = 2; | 29 const int kTileCornerRadius = 2; |
| 31 | 30 |
| 32 } // namespace | 31 } // namespace |
| 33 | 32 |
| 34 namespace app_list { | 33 namespace app_list { |
| 35 | 34 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 title_(new views::Label), | 77 title_(new views::Label), |
| 79 background_(new TileItemBackground()) { | 78 background_(new TileItemBackground()) { |
| 80 set_background(background_); | 79 set_background(background_); |
| 81 | 80 |
| 82 views::BoxLayout* layout_manager = new views::BoxLayout( | 81 views::BoxLayout* layout_manager = new views::BoxLayout( |
| 83 views::BoxLayout::kVertical, kTileHorizontalPadding, 0, 0); | 82 views::BoxLayout::kVertical, kTileHorizontalPadding, 0, 0); |
| 84 layout_manager->set_main_axis_alignment( | 83 layout_manager->set_main_axis_alignment( |
| 85 views::BoxLayout::MAIN_AXIS_ALIGNMENT_CENTER); | 84 views::BoxLayout::MAIN_AXIS_ALIGNMENT_CENTER); |
| 86 SetLayoutManager(layout_manager); | 85 SetLayoutManager(layout_manager); |
| 87 | 86 |
| 88 icon_->SetImageSize(gfx::Size(kTileImageSize, kTileImageSize)); | 87 icon_->SetImageSize(gfx::Size(kTileIconSize, kTileIconSize)); |
| 89 | 88 |
| 90 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 89 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 91 title_->SetAutoColorReadabilityEnabled(false); | 90 title_->SetAutoColorReadabilityEnabled(false); |
| 92 title_->SetEnabledColor(kGridTitleColor); | 91 title_->SetEnabledColor(kGridTitleColor); |
| 93 title_->SetFontList(rb.GetFontList(kItemTextFontStyle)); | 92 title_->SetFontList(rb.GetFontList(kItemTextFontStyle)); |
| 94 title_->SetHorizontalAlignment(gfx::ALIGN_CENTER); | 93 title_->SetHorizontalAlignment(gfx::ALIGN_CENTER); |
| 95 | 94 |
| 96 // When |item_| is NULL, the tile is invisible. Calling SetAppListItem with a | 95 // When |item_| is NULL, the tile is invisible. Calling SetAppListItem with a |
| 97 // non-NULL item makes the tile visible. | 96 // non-NULL item makes the tile visible. |
| 98 SetVisible(false); | 97 SetVisible(false); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 gfx::Size TileItemView::GetPreferredSize() const { | 129 gfx::Size TileItemView::GetPreferredSize() const { |
| 131 return gfx::Size(kTileSize, kTileSize); | 130 return gfx::Size(kTileSize, kTileSize); |
| 132 } | 131 } |
| 133 | 132 |
| 134 void TileItemView::ButtonPressed(views::Button* sender, | 133 void TileItemView::ButtonPressed(views::Button* sender, |
| 135 const ui::Event& event) { | 134 const ui::Event& event) { |
| 136 item_->Activate(event.flags()); | 135 item_->Activate(event.flags()); |
| 137 } | 136 } |
| 138 | 137 |
| 139 } // namespace app_list | 138 } // namespace app_list |
| OLD | NEW |