OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/views/controls/button/label_button.h" | 5 #include "ui/views/controls/button/label_button.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "grit/ui_resources.h" | 8 #include "grit/ui_resources.h" |
9 #include "ui/base/animation/throb_animation.h" | 9 #include "ui/base/animation/throb_animation.h" |
10 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
11 #include "ui/views/controls/button/label_button_border.h" | 11 #include "ui/views/controls/button/label_button_border.h" |
12 #include "ui/views/focus_border.h" | 12 #include "ui/views/focus_border.h" |
13 | 13 |
14 #if defined(OS_WIN) | 14 #if defined(OS_WIN) |
15 #include "ui/gfx/color_utils.h" | 15 #include "ui/gfx/color_utils.h" |
16 #include "ui/base/native_theme/native_theme_win.h" | 16 #include "ui/base/native_theme/native_theme_win.h" |
17 #endif | 17 #endif |
18 | 18 |
19 namespace views { | |
20 | |
21 namespace { | 19 namespace { |
22 | 20 |
23 // The spacing between the icon and text. | 21 // The spacing between the icon and text. |
24 static const int kSpacing = 5; | 22 const int kSpacing = 5; |
25 | 23 |
26 // The length of the hover fade animation. | 24 // The length of the hover fade animation. |
27 static const int kHoverAnimationDurationMs = 170; | 25 const int kHoverAnimationDurationMs = 170; |
28 | 26 |
29 } // namespace | 27 } // namespace |
30 | 28 |
| 29 namespace views { |
| 30 |
31 LabelButton::LabelButton(ButtonListener* listener, const string16& text) | 31 LabelButton::LabelButton(ButtonListener* listener, const string16& text) |
32 : CustomButton(listener), | 32 : CustomButton(listener), |
33 image_(new ImageView()), | 33 image_(new ImageView()), |
34 label_(new Label(text)), | 34 label_(new Label(text)), |
35 default_button_(false), | 35 default_button_(false), |
36 native_theme_(false) { | 36 native_theme_(false) { |
37 set_border(new LabelButtonBorder(this)); | 37 set_border(new LabelButtonBorder()); |
38 // Inset the button focus rect from the actual border; roughly match Windows. | 38 // Inset the button focus rect from the actual border; roughly match Windows. |
39 set_focus_border(FocusBorder::CreateDashedFocusBorder(3, 3, 3, 3)); | 39 set_focus_border(FocusBorder::CreateDashedFocusBorder(3, 3, 3, 3)); |
40 SetAnimationDuration(kHoverAnimationDurationMs); | 40 SetAnimationDuration(kHoverAnimationDurationMs); |
41 | 41 |
42 AddChildView(image_); | 42 AddChildView(image_); |
43 image_->set_interactive(false); | 43 image_->set_interactive(false); |
44 | 44 |
45 AddChildView(label_); | 45 AddChildView(label_); |
46 label_->SetAutoColorReadabilityEnabled(false); | 46 label_->SetAutoColorReadabilityEnabled(false); |
47 label_->SetHorizontalAlignment(Label::ALIGN_LEFT); | 47 label_->SetHorizontalAlignment(Label::ALIGN_LEFT); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 params->button.indeterminate = false; | 253 params->button.indeterminate = false; |
254 params->button.is_default = default_button(); | 254 params->button.is_default = default_button(); |
255 params->button.is_focused = HasFocus() && IsAccessibilityFocusable(); | 255 params->button.is_focused = HasFocus() && IsAccessibilityFocusable(); |
256 params->button.has_border = native_theme(); | 256 params->button.has_border = native_theme(); |
257 params->button.classic_state = 0; | 257 params->button.classic_state = 0; |
258 params->button.background_color = ui::NativeTheme::instance()->GetSystemColor( | 258 params->button.background_color = ui::NativeTheme::instance()->GetSystemColor( |
259 ui::NativeTheme::kColorId_TextButtonBackgroundColor); | 259 ui::NativeTheme::kColorId_TextButtonBackgroundColor); |
260 } | 260 } |
261 | 261 |
262 } // namespace views | 262 } // namespace views |
OLD | NEW |