Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: chrome/common/icon_with_badge_image_source.h

Issue 1472863004: [MD] re-skin extension browser action badges (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: undo file move Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/common/badge_util.cc ('k') | chrome/common/icon_with_badge_image_source.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_COMMON_ICON_WITH_BADGE_IMAGE_SOURCE_H_
6 #define CHROME_COMMON_ICON_WITH_BADGE_IMAGE_SOURCE_H_
7
8 #include <string>
9
10 #include "third_party/skia/include/core/SkColor.h"
11 #include "ui/gfx/image/canvas_image_source.h"
12 #include "ui/gfx/image/image.h"
13
14 namespace gfx {
15 class Size;
16 }
17
18 // 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 {
22 public:
23 // The data representing a badge to be painted over the base image.
24 struct Badge {
25 Badge(const std::string& text,
26 SkColor text_color,
27 SkColor background_color);
28 ~Badge();
29
30 std::string text;
31 SkColor text_color;
32 SkColor background_color;
33
34 private:
35 DISALLOW_COPY_AND_ASSIGN(Badge);
36 };
37
38 explicit IconWithBadgeImageSource(const gfx::Size& size);
39 ~IconWithBadgeImageSource() override;
40
41 void SetIcon(const gfx::Image& icon);
42 void SetBadge(scoped_ptr<Badge> badge);
43 void set_grayscale(bool grayscale) { grayscale_ = grayscale; }
44 void set_paint_decoration(bool paint_decoration) {
45 paint_decoration_ = paint_decoration;
46 }
47
48 bool grayscale() const { return grayscale_; }
49 bool paint_decoration() const { return paint_decoration_; }
50
51 private:
52 // gfx::CanvasImageSource:
53 void Draw(gfx::Canvas* canvas) override;
54
55 // Paints a decoration over the base icon to indicate that the action wants to
56 // run.
57 void PaintDecoration(gfx::Canvas* canvas);
58
59 // The base icon to draw.
60 gfx::Image icon_;
61
62 // An optional badge to draw over the base icon.
63 scoped_ptr<Badge> badge_;
64
65 // Whether or not the icon should be grayscaled (e.g., to show it is
66 // disabled).
67 bool grayscale_;
68
69 // Whether or not to paint a decoration over the base icon to indicate the
70 // represented action wants to run.
71 bool paint_decoration_;
72
73 DISALLOW_COPY_AND_ASSIGN(IconWithBadgeImageSource);
74 };
75
76 #endif // CHROME_COMMON_ICON_WITH_BADGE_IMAGE_SOURCE_H_
OLDNEW
« no previous file with comments | « chrome/common/badge_util.cc ('k') | chrome/common/icon_with_badge_image_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698