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/controls/button/blue_button.h" |
13 #include "ui/views/painter.h" | 14 #include "ui/views/painter.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 |
(...skipping 21 matching lines...) Expand all Loading... |
44 } | 45 } |
45 | 46 |
46 // static | 47 // static |
47 LabelButton* MdTextButton::CreateSecondaryUiButton(ButtonListener* listener, | 48 LabelButton* MdTextButton::CreateSecondaryUiButton(ButtonListener* listener, |
48 const base::string16& text) { | 49 const base::string16& text) { |
49 return CreateButton(listener, text, | 50 return CreateButton(listener, text, |
50 ui::MaterialDesignController::IsSecondaryUiMaterial()); | 51 ui::MaterialDesignController::IsSecondaryUiMaterial()); |
51 } | 52 } |
52 | 53 |
53 // static | 54 // static |
| 55 LabelButton* MdTextButton::CreateSecondaryUiBlueButton( |
| 56 ButtonListener* listener, |
| 57 const base::string16& text) { |
| 58 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { |
| 59 MdTextButton* md_button = MdTextButton::CreateMdButton(listener, text); |
| 60 md_button->SetCallToAction(MdTextButton::STRONG_CALL_TO_ACTION); |
| 61 return md_button; |
| 62 } |
| 63 |
| 64 return new BlueButton(listener, text); |
| 65 } |
| 66 |
| 67 // static |
54 MdTextButton* MdTextButton::CreateMdButton(ButtonListener* listener, | 68 MdTextButton* MdTextButton::CreateMdButton(ButtonListener* listener, |
55 const base::string16& text) { | 69 const base::string16& text) { |
56 MdTextButton* button = new MdTextButton(listener); | 70 MdTextButton* button = new MdTextButton(listener); |
57 button->SetText(text); | 71 button->SetText(text); |
58 // TODO(estade): can we get rid of the platform style border hoopla if | 72 // TODO(estade): can we get rid of the platform style border hoopla if |
59 // we apply the MD treatment to all buttons, even GTK buttons? | 73 // we apply the MD treatment to all buttons, even GTK buttons? |
60 button->SetBorder( | 74 button->SetBorder( |
61 Border::CreateEmptyBorder(kVerticalPadding, kHorizontalPadding, | 75 Border::CreateEmptyBorder(kVerticalPadding, kHorizontalPadding, |
62 kVerticalPadding, kHorizontalPadding)); | 76 kVerticalPadding, kHorizontalPadding)); |
| 77 ConfigureDefaultFocus(button); |
63 return button; | 78 return button; |
64 } | 79 } |
65 | 80 |
66 void MdTextButton::SetCallToAction(CallToAction cta) { | 81 void MdTextButton::SetCallToAction(CallToAction cta) { |
67 if (cta_ == cta) | 82 if (cta_ == cta) |
68 return; | 83 return; |
69 | 84 |
70 cta_ = cta; | 85 cta_ = cta; |
71 UpdateColorsFromNativeTheme(); | 86 UpdateColorsFromNativeTheme(); |
72 } | 87 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 cta_ == STRONG_CALL_TO_ACTION | 149 cta_ == STRONG_CALL_TO_ACTION |
135 ? Background::CreateBackgroundPainter( | 150 ? Background::CreateBackgroundPainter( |
136 true, Painter::CreateSolidRoundRectPainter( | 151 true, Painter::CreateSolidRoundRectPainter( |
137 theme->GetSystemColor( | 152 theme->GetSystemColor( |
138 ui::NativeTheme::kColorId_CallToActionColor), | 153 ui::NativeTheme::kColorId_CallToActionColor), |
139 kInkDropSmallCornerRadius)) | 154 kInkDropSmallCornerRadius)) |
140 : nullptr); | 155 : nullptr); |
141 } | 156 } |
142 | 157 |
143 } // namespace views | 158 } // namespace views |
OLD | NEW |