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"
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
{
42 virtual void ScheduleWrenchIconPaint() = 0;
44 virtual ~Delegate() {}
47 explicit WrenchIconPainter(Delegate
* delegate
);
48 ~WrenchIconPainter() override
;
50 // If |severity| is not |SEVERITY_NONE| then the wrench icon is colored to
51 // match the severity level.
52 void SetSeverity(Severity severity
, bool animate
);
54 // A badge drawn on the top left.
55 void set_badge(const gfx::ImageSkia
& badge
) { badge_
= badge
; }
57 void Paint(gfx::Canvas
* canvas
,
58 ui::ThemeProvider
* theme_provider
,
59 const gfx::Rect
& rect
,
60 BezelType bezel_type
);
63 FRIEND_TEST_ALL_PREFIXES(WrenchIconPainterTest
, PaintCallback
);
66 void AnimationProgressed(const gfx::Animation
* animation
) override
;
68 // Gets the image ID used to draw bars for the current severity level.
69 int GetCurrentSeverityImageID() const;
73 gfx::ImageSkia badge_
;
74 scoped_ptr
<gfx::MultiAnimation
> animation_
;
76 DISALLOW_COPY_AND_ASSIGN(WrenchIconPainter
);
79 #endif // CHROME_BROWSER_UI_TOOLBAR_WRENCH_ICON_PAINTER_H_