OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 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 #include "ui/views/controls/button/blue_button.h" | |
6 | |
7 #include "grit/ui_resources.h" | |
8 #include "ui/base/accessibility/accessible_view_state.h" | |
9 #include "ui/base/resource/resource_bundle.h" | |
10 #include "ui/views/controls/button/label_button_border.h" | |
11 | |
12 namespace { | |
13 | |
14 const int kBlueNormalImages[] = IMAGE_GRID(IDR_BLUE_BUTTON_NORMAL); | |
15 const int kBlueHoveredImages[] = IMAGE_GRID(IDR_BLUE_BUTTON_HOVER); | |
16 const int kBluePressedImages[] = IMAGE_GRID(IDR_BLUE_BUTTON_PRESSED); | |
17 const int kBlueFocusedNormalImages[] = IMAGE_GRID( | |
18 IDR_BLUE_BUTTON_FOCUSED_NORMAL); | |
19 const int kBlueFocusedHoveredImages[] = IMAGE_GRID( | |
20 IDR_BLUE_BUTTON_FOCUSED_HOVER); | |
21 const int kBlueFocusedPressedImages[] = IMAGE_GRID( | |
22 IDR_BLUE_BUTTON_FOCUSED_PRESSED); | |
23 | |
24 // Blue button style default font color. | |
25 const SkColor kBlueButtonTextColor = SK_ColorWHITE; | |
26 | |
27 // Blue button style shadow color. | |
28 const SkColor kBlueButtonShadowColor = SkColorSetRGB(0x53, 0x8C, 0xEA); | |
29 | |
30 } // namespace | |
31 | |
32 namespace views { | |
33 | |
34 // static | |
35 const char BlueButton::kViewClassName[] = "views/BlueButton"; | |
36 | |
37 BlueButton::BlueButton(ButtonListener* listener, const string16& text) | |
38 : LabelButton(listener, text) { | |
39 LabelButtonBorder* button_border = static_cast<LabelButtonBorder*>(border()); | |
40 | |
41 button_border->set_insets(gfx::Insets(9, 13, 9, 13)); | |
42 | |
43 button_border->SetPainter(false, Button::STATE_NORMAL, | |
msw
2013/05/24 16:14:28
nit: i suppose you don't need to specify Button::
benwells
2013/05/27 06:53:59
Done.
| |
44 Painter::CreateImageGridPainter(kBlueNormalImages)); | |
45 button_border->SetPainter( | |
msw
2013/05/24 16:14:28
nit: match the arg placement across all these call
benwells
2013/05/27 06:53:59
Done.
| |
46 false, Button::STATE_HOVERED, | |
47 Painter::CreateImageGridPainter(kBlueHoveredImages)); | |
48 button_border->SetPainter( | |
49 false, Button::STATE_PRESSED, | |
50 Painter::CreateImageGridPainter(kBluePressedImages)); | |
51 button_border->SetPainter(false, Button::STATE_DISABLED, | |
52 Painter::CreateImageGridPainter(kBlueNormalImages)); | |
53 button_border->SetPainter( | |
54 true, Button::STATE_NORMAL, | |
55 Painter::CreateImageGridPainter(kBlueFocusedNormalImages)); | |
56 button_border->SetPainter( | |
57 true, Button::STATE_HOVERED, | |
58 Painter::CreateImageGridPainter(kBlueFocusedHoveredImages)); | |
59 button_border->SetPainter( | |
60 true, Button::STATE_PRESSED, | |
61 Painter::CreateImageGridPainter(kBlueFocusedPressedImages)); | |
62 button_border->SetPainter( | |
63 true, Button::STATE_DISABLED, | |
64 Painter::CreateImageGridPainter(kBlueNormalImages)); | |
65 | |
66 for (size_t state = STATE_NORMAL; state < STATE_COUNT; ++state) | |
67 SetTextColor(static_cast<ButtonState>(state), kBlueButtonTextColor); | |
68 label()->SetShadowColors(kBlueButtonShadowColor, kBlueButtonShadowColor); | |
69 label()->SetShadowOffset(0, 1); | |
70 } | |
71 | |
72 BlueButton::~BlueButton() {} | |
73 | |
74 const char* BlueButton::GetClassName() const { | |
75 return BlueButton::kViewClassName; | |
76 } | |
77 | |
78 // TODO(msw): Re-enable animations for blue buttons. It's disabled now due | |
79 // to crbug.com/239121. | |
80 const ui::Animation* BlueButton::GetThemeAnimation() const { | |
81 return NULL; | |
82 } | |
83 | |
84 } // namespace views | |
OLD | NEW |