OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/label_button.h" | 5 #include "ui/views/controls/button/label_button.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 | 230 |
231 void LabelButton::SetFocusPainter(std::unique_ptr<Painter> focus_painter) { | 231 void LabelButton::SetFocusPainter(std::unique_ptr<Painter> focus_painter) { |
232 focus_painter_ = std::move(focus_painter); | 232 focus_painter_ = std::move(focus_painter); |
233 } | 233 } |
234 | 234 |
235 gfx::Size LabelButton::GetPreferredSize() const { | 235 gfx::Size LabelButton::GetPreferredSize() const { |
236 if (cached_preferred_size_valid_) | 236 if (cached_preferred_size_valid_) |
237 return cached_preferred_size_; | 237 return cached_preferred_size_; |
238 | 238 |
239 // Use a temporary label copy for sizing to avoid calculation side-effects. | 239 // Use a temporary label copy for sizing to avoid calculation side-effects. |
240 Label label(GetText(), label_->font_list()); | 240 Label label(GetText(), {label_->font_list()}); |
241 label.SetShadows(label_->shadows()); | 241 label.SetShadows(label_->shadows()); |
242 | 242 |
243 if (style_ == STYLE_BUTTON && PlatformStyle::kDefaultLabelButtonHasBoldFont) { | 243 if (style_ == STYLE_BUTTON && PlatformStyle::kDefaultLabelButtonHasBoldFont) { |
244 // Some text appears wider when rendered normally than when rendered bold. | 244 // Some text appears wider when rendered normally than when rendered bold. |
245 // Accommodate the widest, as buttons may show bold and shouldn't resize. | 245 // Accommodate the widest, as buttons may show bold and shouldn't resize. |
246 const int current_width = label.GetPreferredSize().width(); | 246 const int current_width = label.GetPreferredSize().width(); |
247 label.SetFontList(cached_bold_font_list_); | 247 label.SetFontList(cached_bold_font_list_); |
248 if (label.GetPreferredSize().width() < current_width) | 248 if (label.GetPreferredSize().width() < current_width) |
249 label.SetFontList(label_->font_list()); | 249 label.SetFontList(label_->font_list()); |
250 } | 250 } |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 : PlatformStyle::TextColorForButton(button_state_colors_, *this); | 604 : PlatformStyle::TextColorForButton(button_state_colors_, *this); |
605 if (state() != STATE_DISABLED && label_->enabled_color() != color) | 605 if (state() != STATE_DISABLED && label_->enabled_color() != color) |
606 label_->SetEnabledColor(color); | 606 label_->SetEnabledColor(color); |
607 } | 607 } |
608 | 608 |
609 bool LabelButton::UseFloodFillInkDrop() const { | 609 bool LabelButton::UseFloodFillInkDrop() const { |
610 return !GetText().empty(); | 610 return !GetText().empty(); |
611 } | 611 } |
612 | 612 |
613 } // namespace views | 613 } // namespace views |
OLD | NEW |