OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_COMMON_ICON_WITH_BADGE_IMAGE_SOURCE_H_ | 5 #ifndef CHROME_BROWSER_UI_EXTENSIONS_ICON_WITH_BADGE_IMAGE_SOURCE_H_ |
6 #define CHROME_COMMON_ICON_WITH_BADGE_IMAGE_SOURCE_H_ | 6 #define CHROME_BROWSER_UI_EXTENSIONS_ICON_WITH_BADGE_IMAGE_SOURCE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
| 10 #include "base/macros.h" |
10 #include "third_party/skia/include/core/SkColor.h" | 11 #include "third_party/skia/include/core/SkColor.h" |
11 #include "ui/gfx/image/canvas_image_source.h" | 12 #include "ui/gfx/image/canvas_image_source.h" |
12 #include "ui/gfx/image/image.h" | 13 #include "ui/gfx/image/image.h" |
13 | 14 |
14 namespace gfx { | 15 namespace gfx { |
15 class Size; | 16 class Size; |
16 } | 17 } |
17 | 18 |
18 // CanvasImageSource for creating extension icon with a badge. | 19 // CanvasImageSource for creating extension icon with a badge. |
19 // TODO(devlin): This class and its buddy badge_util don't really belong in | |
20 // chrome/common/. | |
21 class IconWithBadgeImageSource : public gfx::CanvasImageSource { | 20 class IconWithBadgeImageSource : public gfx::CanvasImageSource { |
22 public: | 21 public: |
23 // The data representing a badge to be painted over the base image. | 22 // The data representing a badge to be painted over the base image. |
24 struct Badge { | 23 struct Badge { |
25 Badge(const std::string& text, | 24 Badge(const std::string& text, |
26 SkColor text_color, | 25 SkColor text_color, |
27 SkColor background_color); | 26 SkColor background_color); |
28 ~Badge(); | 27 ~Badge(); |
29 | 28 |
30 std::string text; | 29 std::string text; |
(...skipping 14 matching lines...) Expand all Loading... |
45 paint_decoration_ = paint_decoration; | 44 paint_decoration_ = paint_decoration; |
46 } | 45 } |
47 | 46 |
48 bool grayscale() const { return grayscale_; } | 47 bool grayscale() const { return grayscale_; } |
49 bool paint_decoration() const { return paint_decoration_; } | 48 bool paint_decoration() const { return paint_decoration_; } |
50 | 49 |
51 private: | 50 private: |
52 // gfx::CanvasImageSource: | 51 // gfx::CanvasImageSource: |
53 void Draw(gfx::Canvas* canvas) override; | 52 void Draw(gfx::Canvas* canvas) override; |
54 | 53 |
| 54 // Paints |badge_|, if any, on |canvas|. |
| 55 void PaintBadge(gfx::Canvas* canvas); |
| 56 |
55 // Paints a decoration over the base icon to indicate that the action wants to | 57 // Paints a decoration over the base icon to indicate that the action wants to |
56 // run. | 58 // run. |
57 void PaintDecoration(gfx::Canvas* canvas); | 59 void PaintDecoration(gfx::Canvas* canvas); |
58 | 60 |
59 // The base icon to draw. | 61 // The base icon to draw. |
60 gfx::Image icon_; | 62 gfx::Image icon_; |
61 | 63 |
62 // An optional badge to draw over the base icon. | 64 // An optional badge to draw over the base icon. |
63 scoped_ptr<Badge> badge_; | 65 scoped_ptr<Badge> badge_; |
64 | 66 |
65 // Whether or not the icon should be grayscaled (e.g., to show it is | 67 // Whether or not the icon should be grayscaled (e.g., to show it is |
66 // disabled). | 68 // disabled). |
67 bool grayscale_; | 69 bool grayscale_; |
68 | 70 |
69 // Whether or not to paint a decoration over the base icon to indicate the | 71 // Whether or not to paint a decoration over the base icon to indicate the |
70 // represented action wants to run. | 72 // represented action wants to run. |
71 bool paint_decoration_; | 73 bool paint_decoration_; |
72 | 74 |
73 DISALLOW_COPY_AND_ASSIGN(IconWithBadgeImageSource); | 75 DISALLOW_COPY_AND_ASSIGN(IconWithBadgeImageSource); |
74 }; | 76 }; |
75 | 77 |
76 #endif // CHROME_COMMON_ICON_WITH_BADGE_IMAGE_SOURCE_H_ | 78 #endif // CHROME_BROWSER_UI_EXTENSIONS_ICON_WITH_BADGE_IMAGE_SOURCE_H_ |
OLD | NEW |