Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(548)

Unified Diff: ui/views/controls/button/label_button.cc

Issue 1773893002: Make MdTextButton a LabelButton, use it in the DL shelf. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove commented out code Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/button/label_button.h ('k') | ui/views/controls/button/md_text_button.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/button/label_button.cc
diff --git a/ui/views/controls/button/label_button.cc b/ui/views/controls/button/label_button.cc
index f192e1282b258644d0a913accb63245831b2b5e4..1f023067ff0af57efa5138000c689daf5d9375bb 100644
--- a/ui/views/controls/button/label_button.cc
+++ b/ui/views/controls/button/label_button.cc
@@ -93,7 +93,7 @@ LabelButton::LabelButton(ButtonListener* listener, const base::string16& text)
image_label_spacing_(kSpacing),
horizontal_alignment_(gfx::ALIGN_LEFT) {
SetAnimationDuration(kHoverAnimationDurationMs);
- SetText(text);
+ SetTextInternal(text);
AddChildView(ink_drop_container_);
ink_drop_container_->SetPaintToLayer(true);
@@ -131,8 +131,7 @@ const base::string16& LabelButton::GetText() const {
}
void LabelButton::SetText(const base::string16& text) {
- SetAccessibleName(text);
- label_->SetText(text);
+ SetTextInternal(text);
}
void LabelButton::SetTextColor(ButtonState for_state, SkColor color) {
@@ -166,10 +165,7 @@ void LabelButton::SetFontList(const gfx::FontList& font_list) {
cached_normal_font_list_ = font_list;
cached_bold_font_list_ = font_list.DeriveWithStyle(
font_list.GetFontStyle() | gfx::Font::BOLD);
-
- // STYLE_BUTTON uses bold text to indicate default buttons.
- label_->SetFontList(
- style_ == STYLE_BUTTON && is_default_ ?
+ label_->SetFontList(is_default_ ?
cached_bold_font_list_ : cached_normal_font_list_);
}
@@ -194,18 +190,17 @@ void LabelButton::SetMaxSize(const gfx::Size& max_size) {
}
void LabelButton::SetIsDefault(bool is_default) {
+ DCHECK_EQ(STYLE_BUTTON, style_);
if (is_default == is_default_)
return;
+
is_default_ = is_default;
ui::Accelerator accel(ui::VKEY_RETURN, ui::EF_NONE);
is_default_ ? AddAccelerator(accel) : RemoveAccelerator(accel);
- // STYLE_BUTTON uses bold text to indicate default buttons.
- if (style_ == STYLE_BUTTON) {
- label_->SetFontList(
- is_default ? cached_bold_font_list_ : cached_normal_font_list_);
- InvalidateLayout();
- }
+ label_->SetFontList(
+ is_default ? cached_bold_font_list_ : cached_normal_font_list_);
+ InvalidateLayout();
}
void LabelButton::SetStyle(ButtonStyle style) {
@@ -521,6 +516,11 @@ void LabelButton::UpdateThemedBorder() {
border_is_themed_border_ = true;
}
+void LabelButton::SetTextInternal(const base::string16& text) {
+ SetAccessibleName(text);
+ label_->SetText(text);
+}
+
void LabelButton::ChildPreferredSizeChanged(View* child) {
ResetCachedPreferredSize();
PreferredSizeChanged();
« no previous file with comments | « ui/views/controls/button/label_button.h ('k') | ui/views/controls/button/md_text_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698