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
{
43 virtual void ScheduleWrenchIconPaint() = 0;
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
);
64 FRIEND_TEST_ALL_PREFIXES(WrenchIconPainterTest
, PaintCallback
);
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;
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_