| 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/canvas.h" | 9 #include "ui/gfx/canvas.h" |
| 10 #include "ui/gfx/color_utils.h" | 10 #include "ui/gfx/color_utils.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 // The stroke width of the focus border in dp. | 28 // The stroke width of the focus border in dp. |
| 29 const int kFocusBorderThickness = 2; | 29 const int kFocusBorderThickness = 2; |
| 30 | 30 |
| 31 // The corner radius of the focus border roundrect. | 31 // The corner radius of the focus border roundrect. |
| 32 const int kFocusBorderCornerRadius = 3; | 32 const int kFocusBorderCornerRadius = 3; |
| 33 | 33 |
| 34 LabelButton* CreateButton(ButtonListener* listener, | 34 LabelButton* CreateButton(ButtonListener* listener, |
| 35 const base::string16& text, | 35 const base::string16& text, |
| 36 bool md) { | 36 bool md) { |
| 37 if (md) | 37 if (md) |
| 38 return MdTextButton::CreateMdButton(listener, text); | 38 return MdTextButton::Create(listener, text); |
| 39 | 39 |
| 40 LabelButton* button = new LabelButton(listener, text); | 40 LabelButton* button = new LabelButton(listener, text); |
| 41 button->SetStyle(CustomButton::STYLE_BUTTON); | 41 button->SetStyle(CustomButton::STYLE_BUTTON); |
| 42 return button; | 42 return button; |
| 43 } | 43 } |
| 44 | 44 |
| 45 const gfx::FontList& GetMdFontList() { | 45 const gfx::FontList& GetMdFontList() { |
| 46 static base::LazyInstance<gfx::FontList>::Leaky font_list = | 46 static base::LazyInstance<gfx::FontList>::Leaky font_list = |
| 47 LAZY_INSTANCE_INITIALIZER; | 47 LAZY_INSTANCE_INITIALIZER; |
| 48 const gfx::Font::Weight min_weight = gfx::Font::Weight::MEDIUM; | 48 const gfx::Font::Weight min_weight = gfx::Font::Weight::MEDIUM; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 const base::string16& text) { | 98 const base::string16& text) { |
| 99 return CreateButton(listener, text, | 99 return CreateButton(listener, text, |
| 100 ui::MaterialDesignController::IsSecondaryUiMaterial()); | 100 ui::MaterialDesignController::IsSecondaryUiMaterial()); |
| 101 } | 101 } |
| 102 | 102 |
| 103 // static | 103 // static |
| 104 LabelButton* MdTextButton::CreateSecondaryUiBlueButton( | 104 LabelButton* MdTextButton::CreateSecondaryUiBlueButton( |
| 105 ButtonListener* listener, | 105 ButtonListener* listener, |
| 106 const base::string16& text) { | 106 const base::string16& text) { |
| 107 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { | 107 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { |
| 108 MdTextButton* md_button = MdTextButton::CreateMdButton(listener, text); | 108 MdTextButton* md_button = MdTextButton::Create(listener, text); |
| 109 md_button->SetCallToAction(true); | 109 md_button->SetCallToAction(true); |
| 110 return md_button; | 110 return md_button; |
| 111 } | 111 } |
| 112 | 112 |
| 113 return new BlueButton(listener, text); | 113 return new BlueButton(listener, text); |
| 114 } | 114 } |
| 115 | 115 |
| 116 // static | 116 // static |
| 117 MdTextButton* MdTextButton::CreateMdButton(ButtonListener* listener, | 117 MdTextButton* MdTextButton::Create(ButtonListener* listener, |
| 118 const base::string16& text) { | 118 const base::string16& text) { |
| 119 MdTextButton* button = new MdTextButton(listener); | 119 MdTextButton* button = new MdTextButton(listener); |
| 120 button->SetText(text); | 120 button->SetText(text); |
| 121 button->SetFocusForPlatform(); | 121 button->SetFocusForPlatform(); |
| 122 return button; | 122 return button; |
| 123 } | 123 } |
| 124 | 124 |
| 125 void MdTextButton::SetCallToAction(bool cta) { | 125 void MdTextButton::SetCallToAction(bool cta) { |
| 126 if (is_cta_ == cta) | 126 if (is_cta_ == cta) |
| 127 return; | 127 return; |
| 128 | 128 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 SkColor stroke_color = (is_cta_ || color_utils::IsDark(text_color)) | 304 SkColor stroke_color = (is_cta_ || color_utils::IsDark(text_color)) |
| 305 ? SkColorSetA(SK_ColorBLACK, kStrokeOpacity) | 305 ? SkColorSetA(SK_ColorBLACK, kStrokeOpacity) |
| 306 : SkColorSetA(SK_ColorWHITE, 2 * kStrokeOpacity); | 306 : SkColorSetA(SK_ColorWHITE, 2 * kStrokeOpacity); |
| 307 | 307 |
| 308 set_background(Background::CreateBackgroundPainter( | 308 set_background(Background::CreateBackgroundPainter( |
| 309 true, Painter::CreateRoundRectWith1PxBorderPainter( | 309 true, Painter::CreateRoundRectWith1PxBorderPainter( |
| 310 bg_color, stroke_color, kInkDropSmallCornerRadius))); | 310 bg_color, stroke_color, kInkDropSmallCornerRadius))); |
| 311 } | 311 } |
| 312 | 312 |
| 313 } // namespace views | 313 } // namespace views |
| OLD | NEW |