OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/md_text_button.h" | 5 #include "ui/views/controls/button/md_text_button.h" |
6 | 6 |
7 #include "base/i18n/case_conversion.h" | 7 #include "base/i18n/case_conversion.h" |
8 #include "ui/base/material_design/material_design_controller.h" | 8 #include "ui/base/material_design/material_design_controller.h" |
9 #include "ui/gfx/color_utils.h" | 9 #include "ui/gfx/color_utils.h" |
10 #include "ui/native_theme/native_theme.h" | 10 #include "ui/native_theme/native_theme.h" |
11 #include "ui/views/background.h" | 11 #include "ui/views/background.h" |
12 #include "ui/views/border.h" | 12 #include "ui/views/border.h" |
13 #include "ui/views/painter.h" | 13 #include "ui/views/painter.h" |
| 14 #include "ui/views/style/platform_style.h" |
14 | 15 |
15 namespace views { | 16 namespace views { |
16 | 17 |
17 namespace { | 18 namespace { |
18 | 19 |
19 // Inset between clickable region border and button contents (text). | 20 // Inset between clickable region border and button contents (text). |
20 const int kHorizontalPadding = 12; | 21 const int kHorizontalPadding = 12; |
21 const int kVerticalPadding = 6; | 22 const int kVerticalPadding = 6; |
22 | 23 |
23 // Minimum size to reserve for the button contents. | 24 // Minimum size to reserve for the button contents. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 LabelButton::SetText(base::i18n::ToUpper(text)); | 70 LabelButton::SetText(base::i18n::ToUpper(text)); |
70 } | 71 } |
71 | 72 |
72 MdTextButton::MdTextButton(ButtonListener* listener) | 73 MdTextButton::MdTextButton(ButtonListener* listener) |
73 : LabelButton(listener, base::string16()), | 74 : LabelButton(listener, base::string16()), |
74 ink_drop_delegate_(this, this), | 75 ink_drop_delegate_(this, this), |
75 cta_(NO_CALL_TO_ACTION) { | 76 cta_(NO_CALL_TO_ACTION) { |
76 set_ink_drop_delegate(&ink_drop_delegate_); | 77 set_ink_drop_delegate(&ink_drop_delegate_); |
77 set_has_ink_drop_action_on_click(true); | 78 set_has_ink_drop_action_on_click(true); |
78 SetHorizontalAlignment(gfx::ALIGN_CENTER); | 79 SetHorizontalAlignment(gfx::ALIGN_CENTER); |
79 SetFocusable(true); | 80 PlatformStyle::ConfigureFocus(PlatformStyle::CONTROL::BUTTON, this); |
80 SetMinSize(gfx::Size(kMinWidth, 0)); | 81 SetMinSize(gfx::Size(kMinWidth, 0)); |
81 SetFocusPainter(nullptr); | 82 SetFocusPainter(nullptr); |
82 UseMdFocusRing(); | 83 UseMdFocusRing(); |
83 label()->SetAutoColorReadabilityEnabled(false); | 84 label()->SetAutoColorReadabilityEnabled(false); |
84 } | 85 } |
85 | 86 |
86 MdTextButton::~MdTextButton() {} | 87 MdTextButton::~MdTextButton() {} |
87 | 88 |
88 void MdTextButton::UpdateColorsFromNativeTheme() { | 89 void MdTextButton::UpdateColorsFromNativeTheme() { |
89 ui::NativeTheme::ColorId fg_color_id = ui::NativeTheme::kColorId_NumColors; | 90 ui::NativeTheme::ColorId fg_color_id = ui::NativeTheme::kColorId_NumColors; |
(...skipping 15 matching lines...) Expand all Loading... |
105 cta_ == STRONG_CALL_TO_ACTION | 106 cta_ == STRONG_CALL_TO_ACTION |
106 ? Background::CreateBackgroundPainter( | 107 ? Background::CreateBackgroundPainter( |
107 true, Painter::CreateSolidRoundRectPainter( | 108 true, Painter::CreateSolidRoundRectPainter( |
108 theme->GetSystemColor( | 109 theme->GetSystemColor( |
109 ui::NativeTheme::kColorId_CallToActionColor), | 110 ui::NativeTheme::kColorId_CallToActionColor), |
110 kInkDropSmallCornerRadius)) | 111 kInkDropSmallCornerRadius)) |
111 : nullptr); | 112 : nullptr); |
112 } | 113 } |
113 | 114 |
114 } // namespace views | 115 } // namespace views |
OLD | NEW |