summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormsw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-17 04:44:54 +0000
committermsw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-17 04:44:54 +0000
commit5b7355bcdf73ef995001d0cf8fbf2385012a7a52 (patch)
tree475db8bbc8bfbbac2202646209397057ace47a1c
parent85287df27d4eaa284a441bad846057e5bee428c7 (diff)
downloadchromium_src-5b7355bcdf73ef995001d0cf8fbf2385012a7a52.zip
chromium_src-5b7355bcdf73ef995001d0cf8fbf2385012a7a52.tar.gz
chromium_src-5b7355bcdf73ef995001d0cf8fbf2385012a7a52.tar.bz2
Use the wider Bold/Normal font in LabelButton::GetPreferredSize.
Some text appears wider when rendered normally than when bold. Accommodate the widest, as buttons may show bold and shouldn't resize. See ui_strings_ja.xtb's "キャンセル" (Cancel) cut off at http://crbug.com/259156 BUG=259156 TEST=CrOS --lang=ja doesn't elide Cancel dialog button text, see the bug. R=mukai@chromium.org,kochi@chromium.org,sky@chromium.org Review URL: https://chromiumcodereview.appspot.com/18513007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@211935 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ui/views/controls/button/label_button.cc15
1 files changed, 11 insertions, 4 deletions
diff --git a/ui/views/controls/button/label_button.cc b/ui/views/controls/button/label_button.cc
index 1850afd..9fab63b0 100644
--- a/ui/views/controls/button/label_button.cc
+++ b/ui/views/controls/button/label_button.cc
@@ -156,13 +156,20 @@ void LabelButton::SetStyle(ButtonStyle style) {
}
gfx::Size LabelButton::GetPreferredSize() {
- const gfx::Font font = label_->font();
// Use a temporary label copy for sizing to avoid calculation side-effects.
- // Use bold text for STYLE_BUTTON to avoid changing size when made default.
- Label label(label_->text(), style_ == STYLE_BUTTON ?
- font.DeriveFont(0, font.GetStyle() | gfx::Font::BOLD) : font);
+ gfx::Font font = GetFont();
+ Label label(GetText(), font);
label.SetMultiLine(GetTextMultiLine());
+ if (style() == STYLE_BUTTON) {
+ // Some text appears wider when rendered normally than when rendered bold.
+ // Accommodate the widest, as buttons may show bold and shouldn't resize.
+ const int current_width = label.GetPreferredSize().width();
+ label.SetFont(font.DeriveFont(0, font.GetStyle() ^ gfx::Font::BOLD));
+ if (label.GetPreferredSize().width() < current_width)
+ label.SetFont(font);
+ }
+
// Resize multi-line labels given the current limited available width.
const gfx::Size image_size(image_->GetPreferredSize());
const int image_width = image_size.width();