Index: ui/views/controls/label.cc |
diff --git a/ui/views/controls/label.cc b/ui/views/controls/label.cc |
index 351c4e865f576a13659324c3687e1916d141f49c..ca5a82f9c3806e85290d68747cdaa6b57c715fdd 100644 |
--- a/ui/views/controls/label.cc |
+++ b/ui/views/controls/label.cc |
@@ -121,6 +121,15 @@ void Label::SetHorizontalAlignment(gfx::HorizontalAlignment alignment) { |
} |
} |
+void Label::SetLineHeight(int height) { |
+ if (height != line_height_) { |
+ line_height_ = height; |
+ ResetCachedSize(); |
+ PreferredSizeChanged(); |
+ SchedulePaint(); |
+ } |
+} |
+ |
void Label::SetMultiLine(bool multi_line) { |
DCHECK(!multi_line || elide_behavior_ != ELIDE_IN_MIDDLE); |
if (multi_line != is_multi_line_) { |
@@ -226,7 +235,8 @@ int Label::GetHeightForWidth(int w) { |
int cache_width = w; |
int h = font_.GetHeight(); |
- gfx::Canvas::SizeStringInt(text_, font_, &w, &h, ComputeDrawStringFlags()); |
+ int flags = ComputeDrawStringFlags(); |
msw
2013/04/17 20:12:59
nit: const
dharcourt
2013/04/17 23:29:40
Done.
|
+ gfx::Canvas::SizeStringInt(text_, font_, &w, &h, line_height_, flags); |
cached_heights_[cached_heights_cursor_] = gfx::Size(cache_width, h); |
cached_heights_cursor_ = (cached_heights_cursor_ + 1) % kCachedSizeLimit; |
return h + GetInsets().height(); |
@@ -274,7 +284,7 @@ void Label::PaintText(gfx::Canvas* canvas, |
enabled() ? enabled_shadow_color_ : disabled_shadow_color_)); |
canvas->DrawStringWithShadows(text, font_, |
enabled() ? actual_enabled_color_ : actual_disabled_color_, |
- text_bounds, flags, shadows); |
+ text_bounds, line_height_, flags, shadows); |
if (HasFocus()) { |
gfx::Rect focus_bounds = text_bounds; |
@@ -297,7 +307,7 @@ gfx::Size Label::GetTextSize() const { |
int flags = ComputeDrawStringFlags(); |
if (!is_multi_line_) |
flags |= gfx::Canvas::NO_ELLIPSIS; |
- gfx::Canvas::SizeStringInt(text_, font_, &w, &h, flags); |
+ gfx::Canvas::SizeStringInt(text_, font_, &w, &h, line_height_, flags); |
text_size_.SetSize(w, h); |
text_size_valid_ = true; |
} |