| 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 4453f2a2aa72f428b0e7519f9061938bcb93d4fb..688cbd28b133d3e7b76fa06deb1c6a3c614b9177 100644
|
| --- a/ui/views/controls/button/md_text_button.cc
|
| +++ b/ui/views/controls/button/md_text_button.cc
|
| @@ -21,6 +21,7 @@
|
| #include "ui/views/controls/focus_ring.h"
|
| #include "ui/views/painter.h"
|
| #include "ui/views/style/platform_style.h"
|
| +#include "ui/views/style/typography.h"
|
| #include "ui/views/views_delegate.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->SetStyle(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(PlatformStyle::kUseRipples ? InkDropMode::ON
|
| : InkDropMode::OFF);
|
| @@ -199,7 +183,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);
|
|
|
| @@ -228,7 +211,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);
|
|
|