OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/app_list_folder_item.h" | 5 #include "ui/app_list/app_list_folder_item.h" |
6 | 6 |
7 #include "base/guid.h" | 7 #include "base/guid.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_list.h" | 9 #include "ui/app_list/app_list_item_list.h" |
10 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 public: | 22 public: |
23 typedef std::vector<gfx::ImageSkia> Icons; | 23 typedef std::vector<gfx::ImageSkia> Icons; |
24 | 24 |
25 FolderImageSource(const Icons& icons, const gfx::Size& size) | 25 FolderImageSource(const Icons& icons, const gfx::Size& size) |
26 : gfx::CanvasImageSource(size, false), | 26 : gfx::CanvasImageSource(size, false), |
27 icons_(icons), | 27 icons_(icons), |
28 size_(size) { | 28 size_(size) { |
29 DCHECK(icons.size() <= kNumFolderTopItems); | 29 DCHECK(icons.size() <= kNumFolderTopItems); |
30 } | 30 } |
31 | 31 |
32 virtual ~FolderImageSource() {} | 32 ~FolderImageSource() override {} |
33 | 33 |
34 private: | 34 private: |
35 void DrawIcon(gfx::Canvas* canvas, | 35 void DrawIcon(gfx::Canvas* canvas, |
36 const gfx::ImageSkia& icon, | 36 const gfx::ImageSkia& icon, |
37 const gfx::Size icon_size, | 37 const gfx::Size icon_size, |
38 int x, int y) { | 38 int x, int y) { |
39 if (icon.isNull()) | 39 if (icon.isNull()) |
40 return; | 40 return; |
41 | 41 |
42 gfx::ImageSkia resized( | 42 gfx::ImageSkia resized( |
43 gfx::ImageSkiaOperations::CreateResizedImage( | 43 gfx::ImageSkiaOperations::CreateResizedImage( |
44 icon, skia::ImageOperations::RESIZE_BEST, icon_size)); | 44 icon, skia::ImageOperations::RESIZE_BEST, icon_size)); |
45 canvas->DrawImageInt(resized, 0, 0, resized.width(), resized.height(), | 45 canvas->DrawImageInt(resized, 0, 0, resized.width(), resized.height(), |
46 x, y, resized.width(), resized.height(), true); | 46 x, y, resized.width(), resized.height(), true); |
47 } | 47 } |
48 | 48 |
49 // gfx::CanvasImageSource overrides: | 49 // gfx::CanvasImageSource overrides: |
50 virtual void Draw(gfx::Canvas* canvas) override { | 50 void Draw(gfx::Canvas* canvas) override { |
51 // Draw folder circle. | 51 // Draw folder circle. |
52 gfx::Point center = gfx::Point(size().width() / 2 , size().height() / 2); | 52 gfx::Point center = gfx::Point(size().width() / 2 , size().height() / 2); |
53 SkPaint paint; | 53 SkPaint paint; |
54 paint.setStyle(SkPaint::kFill_Style); | 54 paint.setStyle(SkPaint::kFill_Style); |
55 paint.setAntiAlias(true); | 55 paint.setAntiAlias(true); |
56 paint.setColor(kFolderBubbleColor); | 56 paint.setColor(kFolderBubbleColor); |
57 canvas->DrawCircle(center, size().width() / 2, paint); | 57 canvas->DrawCircle(center, size().width() / 2, paint); |
58 | 58 |
59 if (icons_.size() == 0) | 59 if (icons_.size() == 0) |
60 return; | 60 return; |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 for (size_t i = 0; | 237 for (size_t i = 0; |
238 i < kNumFolderTopItems && i < item_list_->item_count(); ++i) { | 238 i < kNumFolderTopItems && i < item_list_->item_count(); ++i) { |
239 AppListItem* item = item_list_->item_at(i); | 239 AppListItem* item = item_list_->item_at(i); |
240 item->AddObserver(this); | 240 item->AddObserver(this); |
241 top_items_.push_back(item); | 241 top_items_.push_back(item); |
242 } | 242 } |
243 UpdateIcon(); | 243 UpdateIcon(); |
244 } | 244 } |
245 | 245 |
246 } // namespace app_list | 246 } // namespace app_list |
OLD | NEW |