Index: ui/views/controls/button/md_text_button.cc |
diff --git a/ui/views/controls/button/md_text_button.cc b/ui/views/controls/button/md_text_button.cc |
index aaa3f2ea5ec99c3bb9dad278c72a36f4bcbbce78..460517a1e5aee96c2a7d493d5ae87da19e8810a9 100644 |
--- a/ui/views/controls/button/md_text_button.cc |
+++ b/ui/views/controls/button/md_text_button.cc |
@@ -22,6 +22,7 @@ |
#include "ui/views/layout/layout_provider.h" |
#include "ui/views/painter.h" |
#include "ui/views/style/platform_style.h" |
+#include "ui/views/style/typography.h" |
namespace views { |
@@ -31,22 +32,13 @@ LabelButton* CreateButton(ButtonListener* listener, |
const base::string16& text, |
bool md) { |
if (md) |
- return MdTextButton::Create(listener, text); |
+ return MdTextButton::Create(listener, text, style::CONTEXT_BUTTON_MD); |
- LabelButton* button = new LabelButton(listener, text); |
+ LabelButton* button = new LabelButton(listener, text, style::CONTEXT_BUTTON); |
button->SetStyleDeprecated(CustomButton::STYLE_BUTTON); |
return button; |
} |
-const gfx::FontList& GetMdFontList() { |
- static base::LazyInstance<gfx::FontList>::Leaky font_list = |
- LAZY_INSTANCE_INITIALIZER; |
- const gfx::Font::Weight min_weight = gfx::Font::Weight::MEDIUM; |
- if (font_list.Get().GetFontWeight() < min_weight) |
- font_list.Get() = font_list.Get().DeriveWithWeight(min_weight); |
- return font_list.Get(); |
-} |
- |
} // namespace |
// static |
@@ -61,7 +53,8 @@ LabelButton* MdTextButton::CreateSecondaryUiBlueButton( |
ButtonListener* listener, |
const base::string16& text) { |
if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { |
- MdTextButton* md_button = MdTextButton::Create(listener, text); |
+ MdTextButton* md_button = |
+ MdTextButton::Create(listener, text, style::CONTEXT_BUTTON_MD); |
md_button->SetProminent(true); |
return md_button; |
} |
@@ -71,8 +64,9 @@ LabelButton* MdTextButton::CreateSecondaryUiBlueButton( |
// static |
MdTextButton* MdTextButton::Create(ButtonListener* listener, |
- const base::string16& text) { |
- MdTextButton* button = new MdTextButton(listener); |
+ const base::string16& text, |
+ int button_context) { |
+ MdTextButton* button = new MdTextButton(listener, button_context); |
button->SetText(text); |
button->SetFocusForPlatform(); |
return button; |
@@ -170,23 +164,13 @@ void MdTextButton::SetText(const base::string16& text) { |
UpdatePadding(); |
} |
-void MdTextButton::AdjustFontSize(int size_delta) { |
- LabelButton::AdjustFontSize(size_delta); |
- UpdatePadding(); |
-} |
- |
void MdTextButton::UpdateStyleToIndicateDefaultStatus() { |
is_prominent_ = is_prominent_ || is_default(); |
UpdateColors(); |
} |
-void MdTextButton::SetFontList(const gfx::FontList& font_list) { |
- NOTREACHED() |
- << "Don't call MdTextButton::SetFontList (it will soon be protected)"; |
-} |
- |
-MdTextButton::MdTextButton(ButtonListener* listener) |
- : LabelButton(listener, base::string16()), |
+MdTextButton::MdTextButton(ButtonListener* listener, int button_context) |
+ : LabelButton(listener, base::string16(), button_context), |
is_prominent_(false) { |
SetInkDropMode(InkDropMode::ON); |
set_has_ink_drop_action_on_click(true); |
@@ -198,7 +182,6 @@ MdTextButton::MdTextButton(ButtonListener* listener) |
SetFocusPainter(nullptr); |
label()->SetAutoColorReadabilityEnabled(false); |
set_request_focus_on_press(false); |
- LabelButton::SetFontList(GetMdFontList()); |
set_animate_on_state_change(true); |
@@ -227,7 +210,9 @@ void MdTextButton::UpdatePadding() { |
// * Linux user sets base system font size to 17dp. For a normal button, the |
// |size_delta| will be zero, so to adjust upwards we double 17 to get 34. |
int size_delta = |
- label()->font_list().GetFontSize() - GetMdFontList().GetFontSize(); |
+ label()->font_list().GetFontSize() - |
+ style::GetFont(style::CONTEXT_BUTTON_MD, style::STYLE_PRIMARY) |
+ .GetFontSize(); |
const int kBaseHeight = 28; |
int target_height = std::max(kBaseHeight + size_delta * 2, |
label()->font_list().GetFontSize() * 2); |