Add testing/scripts/OWNERS
[chromium-blink-merge.git] / ui / app_list / folder_image_source.h
blob6bfba4c28e53f87109350cdc36b40f85fd6786bc
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
3 // found in the LICENSE file.
5 #ifndef UI_APP_LIST_APP_LIST_FOLDER_IMAGE_SOURCE_H_
6 #define UI_APP_LIST_APP_LIST_FOLDER_IMAGE_SOURCE_H_
8 #include <vector>
10 #include "ui/gfx/image/canvas_image_source.h"
12 namespace gfx {
13 class Canvas;
14 class ImageSkia;
15 class Rect;
16 class Size;
19 namespace app_list {
21 // Generates the folder icon with the top 4 child item icons laid in 2x2 tile.
22 class FolderImageSource : public gfx::CanvasImageSource {
23 public:
24 typedef std::vector<gfx::ImageSkia> Icons;
26 FolderImageSource(const Icons& icons, const gfx::Size& size);
27 ~FolderImageSource() override;
29 // Gets the size of a small app icon inside the folder icon.
30 static gfx::Size ItemIconSize();
32 // Calculates the top item icons' bounds inside |folder_icon_bounds|.
33 // Returns the bounds of top item icons in sequence of top left, top right,
34 // bottom left, bottom right.
35 static std::vector<gfx::Rect> GetTopIconsBounds(
36 const gfx::Rect& folder_icon_bounds);
38 private:
39 void DrawIcon(gfx::Canvas* canvas,
40 const gfx::ImageSkia& icon,
41 const gfx::Size icon_size,
42 int x,
43 int y);
45 // gfx::CanvasImageSource overrides:
46 void Draw(gfx::Canvas* canvas) override;
48 Icons icons_;
49 gfx::Size size_;
51 DISALLOW_COPY_AND_ASSIGN(FolderImageSource);
54 } // namespace app_list
56 #endif // UI_APP_LIST_APP_LIST_FOLDER_ITEM_H_