| 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; | 25 const int kTileImageSize = 48; |
| 26 | 26 |
| 27 const SkColor kTileBackgroundColor = SK_ColorWHITE; | 27 const SkColor kTileBackgroundColor = SK_ColorWHITE; |
| 28 const SkColor kTileBorderColor = SkColorSetARGB(0x30, 0xD0, 0xD0, 0xD0); | |
| 29 const int kTileColorStripHeight = 2; | 28 const int kTileColorStripHeight = 2; |
| 30 const SkAlpha kTileColorStripOpacity = 0X5F; | 29 const SkAlpha kTileColorStripOpacity = 0X5F; |
| 31 const int kTileCornerRadius = 2; | 30 const int kTileCornerRadius = 2; |
| 32 | 31 |
| 33 } // namespace | 32 } // namespace |
| 34 | 33 |
| 35 namespace app_list { | 34 namespace app_list { |
| 36 | 35 |
| 37 // A background for the start page item view which consists of a rounded rect | 36 // A background for the start page item view which consists of a rounded rect |
| 38 // with a dominant color strip at the bottom. | 37 // with a dominant color strip at the bottom. |
| 39 class TileItemView::TileItemBackground : public views::Background { | 38 class TileItemView::TileItemBackground : public views::Background { |
| 40 public: | 39 public: |
| 41 TileItemBackground() : strip_color_(SK_ColorBLACK) {} | 40 TileItemBackground() : strip_color_(SK_ColorBLACK) {} |
| 42 virtual ~TileItemBackground() {} | 41 virtual ~TileItemBackground() {} |
| 43 | 42 |
| 44 void set_strip_color(SkColor strip_color) { strip_color_ = strip_color; } | 43 void set_strip_color(SkColor strip_color) { strip_color_ = strip_color; } |
| 45 | 44 |
| 46 // Overridden from views::Background: | 45 // Overridden from views::Background: |
| 47 virtual void Paint(gfx::Canvas* canvas, views::View* view) const OVERRIDE { | 46 virtual void Paint(gfx::Canvas* canvas, views::View* view) const OVERRIDE { |
| 48 SkPaint paint; | 47 SkPaint paint; |
| 49 paint.setFlags(SkPaint::kAntiAlias_Flag); | 48 paint.setFlags(SkPaint::kAntiAlias_Flag); |
| 50 | 49 |
| 51 // Paint the border. | 50 // Paint the border. |
| 52 paint.setColor(kTileBorderColor); | 51 paint.setColor(kStartPageBorderColor); |
| 53 canvas->DrawRoundRect(view->GetContentsBounds(), kTileCornerRadius, paint); | 52 canvas->DrawRoundRect(view->GetContentsBounds(), kTileCornerRadius, paint); |
| 54 | 53 |
| 55 // Paint a rectangle for the color strip. | 54 // Paint a rectangle for the color strip. |
| 56 gfx::Rect color_strip_rect(view->GetContentsBounds()); | 55 gfx::Rect color_strip_rect(view->GetContentsBounds()); |
| 57 color_strip_rect.Inset(1, 1, 1, 1); | 56 color_strip_rect.Inset(1, 1, 1, 1); |
| 58 paint.setColor(SkColorSetA(strip_color_, kTileColorStripOpacity)); | 57 paint.setColor(SkColorSetA(strip_color_, kTileColorStripOpacity)); |
| 59 canvas->DrawRoundRect(color_strip_rect, kTileCornerRadius, paint); | 58 canvas->DrawRoundRect(color_strip_rect, kTileCornerRadius, paint); |
| 60 | 59 |
| 61 // Paint the main background rectangle, leaving part of the color strip | 60 // Paint the main background rectangle, leaving part of the color strip |
| 62 // unobscured. | 61 // unobscured. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 gfx::Size TileItemView::GetPreferredSize() const { | 120 gfx::Size TileItemView::GetPreferredSize() const { |
| 122 return gfx::Size(kTileSize, kTileSize); | 121 return gfx::Size(kTileSize, kTileSize); |
| 123 } | 122 } |
| 124 | 123 |
| 125 void TileItemView::ButtonPressed(views::Button* sender, | 124 void TileItemView::ButtonPressed(views::Button* sender, |
| 126 const ui::Event& event) { | 125 const ui::Event& event) { |
| 127 item_->Activate(event.flags()); | 126 item_->Activate(event.flags()); |
| 128 } | 127 } |
| 129 | 128 |
| 130 } // namespace app_list | 129 } // namespace app_list |
| OLD | NEW |