OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013 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_BROWSER_UI_TOOLBAR_APP_MENU_ICON_PAINTER_H_ | |
6 #define CHROME_BROWSER_UI_TOOLBAR_APP_MENU_ICON_PAINTER_H_ | |
7 | |
8 #include <memory> | |
9 | |
10 #include "base/gtest_prod_util.h" | |
11 #include "base/macros.h" | |
12 #include "ui/gfx/animation/animation_delegate.h" | |
13 #include "ui/gfx/image/image_skia.h" | |
14 | |
15 namespace gfx { | |
16 class Canvas; | |
17 class MultiAnimation; | |
18 class Rect; | |
19 } | |
20 namespace ui { | |
21 class ThemeProvider; | |
22 } | |
23 | |
24 // This class is used to draw the app menu icon. It can signify severity levels | |
25 // by changing the app menu icon to different colors. | |
26 class AppMenuIconPainter : gfx::AnimationDelegate { | |
Evan Stade
2016/09/27 20:12:43
mac still nominally relies on this class but it's
| |
27 public: | |
28 enum BezelType { | |
29 BEZEL_NONE, | |
30 BEZEL_HOVER, | |
31 BEZEL_PRESSED, | |
32 }; | |
33 | |
34 enum Severity { | |
35 SEVERITY_NONE, | |
36 SEVERITY_LOW, | |
37 SEVERITY_MEDIUM, | |
38 SEVERITY_HIGH, | |
39 }; | |
40 | |
41 class Delegate { | |
42 public: | |
43 virtual void ScheduleAppMenuIconPaint() = 0; | |
44 | |
45 protected: | |
46 virtual ~Delegate() {} | |
47 }; | |
48 | |
49 explicit AppMenuIconPainter(Delegate* delegate); | |
50 ~AppMenuIconPainter() override; | |
51 | |
52 // If |severity| is not |SEVERITY_NONE| then the app menu icon is colored to | |
53 // match the severity level. | |
54 void SetSeverity(Severity severity, bool animate); | |
55 | |
56 // A badge drawn on the top left. | |
57 void set_badge(const gfx::ImageSkia& badge) { badge_ = badge; } | |
58 | |
59 void Paint(gfx::Canvas* canvas, | |
60 const ui::ThemeProvider* theme_provider, | |
61 const gfx::Rect& rect, | |
62 BezelType bezel_type); | |
63 | |
64 private: | |
65 FRIEND_TEST_ALL_PREFIXES(AppMenuIconPainterTest, PaintCallback); | |
66 | |
67 // AnimationDelegate: | |
68 void AnimationProgressed(const gfx::Animation* animation) override; | |
69 | |
70 // Gets the image ID used to draw bars for the current severity level. | |
71 int GetCurrentSeverityImageID() const; | |
72 | |
73 Delegate* delegate_; | |
74 Severity severity_; | |
75 gfx::ImageSkia badge_; | |
76 std::unique_ptr<gfx::MultiAnimation> animation_; | |
77 | |
78 DISALLOW_COPY_AND_ASSIGN(AppMenuIconPainter); | |
79 }; | |
80 | |
81 #endif // CHROME_BROWSER_UI_TOOLBAR_APP_MENU_ICON_PAINTER_H_ | |
OLD | NEW |