blob: 86954e0c90b5fcdaeb5b30fa9b7b0cee93ed7708 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/views/toolbar/wrench_toolbar_button.h"
#include "grit/theme_resources.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/theme_provider.h"
WrenchToolbarButton::WrenchToolbarButton(views::MenuButtonListener* listener)
: views::MenuButton(NULL, string16(), listener, false) {
wrench_icon_painter_.reset(new WrenchIconPainter(this));
// Used for sizing only.
ui::ResourceBundle& rb = ResourceBundle::GetSharedInstance();
SetIcon(*rb.GetImageSkiaNamed(IDR_TOOLBAR_BEZEL_HOVER));
}
WrenchToolbarButton::~WrenchToolbarButton() {
}
void WrenchToolbarButton::SetSeverity(WrenchIconPainter::Severity severity,
bool animate) {
wrench_icon_painter_->SetSeverity(severity, animate);
}
void WrenchToolbarButton::OnPaint(gfx::Canvas* canvas) {
// Badge linux aura builds so they're quickly identifiable.
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
wrench_icon_painter_->set_badge(
*GetThemeProvider()->GetImageSkiaNamed(IDR_TOOLS_BADGE_AURA));
#endif
wrench_icon_painter_->Paint(
canvas, GetThemeProvider(), gfx::Rect(size()), GetCurrentBezelType());
OnPaintFocusBorder(canvas);
}
void WrenchToolbarButton::ScheduleWrenchIconPaint() {
SchedulePaint();
}
WrenchIconPainter::BezelType WrenchToolbarButton::GetCurrentBezelType() const {
switch (state()) {
case STATE_HOVERED:
return WrenchIconPainter::BEZEL_HOVER;
case STATE_PRESSED:
return WrenchIconPainter::BEZEL_PRESSED;
default:
return WrenchIconPainter::BEZEL_NONE;
}
}
|