Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / chrome / browser / ui / toolbar / wrench_icon_painter.h
blobcf4f7f114a2ec98fbab33a14bb707c7622933117
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.
5 #ifndef CHROME_BROWSER_UI_TOOLBAR_WRENCH_ICON_PAINTER_H_
6 #define CHROME_BROWSER_UI_TOOLBAR_WRENCH_ICON_PAINTER_H_
8 #include "base/compiler_specific.h"
9 #include "base/gtest_prod_util.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "ui/gfx/animation/animation_delegate.h"
12 #include "ui/gfx/image/image_skia.h"
14 namespace gfx {
15 class Canvas;
16 class MultiAnimation;
17 class Rect;
19 namespace ui {
20 class ThemeProvider;
23 // This class is used to draw the wrench icon. It can signify severity levels
24 // by changing the wrench icon to different colors.
25 class WrenchIconPainter : gfx::AnimationDelegate {
26 public:
27 enum BezelType {
28 BEZEL_NONE,
29 BEZEL_HOVER,
30 BEZEL_PRESSED,
33 enum Severity {
34 SEVERITY_NONE,
35 SEVERITY_INFO,
36 SEVERITY_LOW,
37 SEVERITY_MEDIUM,
38 SEVERITY_HIGH,
41 class Delegate {
42 public:
43 virtual void ScheduleWrenchIconPaint() = 0;
44 protected:
45 virtual ~Delegate() {}
48 explicit WrenchIconPainter(Delegate* delegate);
49 ~WrenchIconPainter() override;
51 // If |severity| is not |SEVERITY_NONE| then the wrench icon is colored to
52 // match the severity level.
53 void SetSeverity(Severity severity, bool animate);
55 // A badge drawn on the top left.
56 void set_badge(const gfx::ImageSkia& badge) { badge_ = badge; }
58 void Paint(gfx::Canvas* canvas,
59 ui::ThemeProvider* theme_provider,
60 const gfx::Rect& rect,
61 BezelType bezel_type);
63 private:
64 FRIEND_TEST_ALL_PREFIXES(WrenchIconPainterTest, PaintCallback);
66 // AnimationDelegate:
67 void AnimationProgressed(const gfx::Animation* animation) override;
69 // Gets the image ID used to draw bars for the current severity level.
70 int GetCurrentSeverityImageID() const;
72 Delegate* delegate_;
73 Severity severity_;
74 gfx::ImageSkia badge_;
75 scoped_ptr<gfx::MultiAnimation> animation_;
77 DISALLOW_COPY_AND_ASSIGN(WrenchIconPainter);
80 #endif // CHROME_BROWSER_UI_TOOLBAR_WRENCH_ICON_PAINTER_H_