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, STATE_NORMAL, |
| 44 Painter::CreateImageGridPainter(kBlueNormalImages)); |
| 45 button_border->SetPainter(false, STATE_HOVERED, |
| 46 Painter::CreateImageGridPainter(kBlueHoveredImages)); |
| 47 button_border->SetPainter(false, STATE_PRESSED, |
| 48 Painter::CreateImageGridPainter(kBluePressedImages)); |
| 49 button_border->SetPainter(false, STATE_DISABLED, |
| 50 Painter::CreateImageGridPainter(kBlueNormalImages)); |
| 51 button_border->SetPainter(true, STATE_NORMAL, |
| 52 Painter::CreateImageGridPainter(kBlueFocusedNormalImages)); |
| 53 button_border->SetPainter(true, STATE_HOVERED, |
| 54 Painter::CreateImageGridPainter(kBlueFocusedHoveredImages)); |
| 55 button_border->SetPainter(true, STATE_PRESSED, |
| 56 Painter::CreateImageGridPainter(kBlueFocusedPressedImages)); |
| 57 button_border->SetPainter(true, STATE_DISABLED, |
| 58 Painter::CreateImageGridPainter(kBlueNormalImages)); |
| 59 |
| 60 for (size_t state = STATE_NORMAL; state < STATE_COUNT; ++state) |
| 61 SetTextColor(static_cast<ButtonState>(state), kBlueButtonTextColor); |
| 62 label()->SetShadowColors(kBlueButtonShadowColor, kBlueButtonShadowColor); |
| 63 label()->SetShadowOffset(0, 1); |
| 64 } |
| 65 |
| 66 BlueButton::~BlueButton() {} |
| 67 |
| 68 const char* BlueButton::GetClassName() const { |
| 69 return BlueButton::kViewClassName; |
| 70 } |
| 71 |
| 72 // TODO(msw): Re-enable animations for blue buttons. It's disabled now due |
| 73 // to crbug.com/239121. |
| 74 const ui::Animation* BlueButton::GetThemeAnimation() const { |
| 75 return NULL; |
| 76 } |
| 77 |
| 78 } // namespace views |
OLD | NEW |