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

Unified Diff: ui/views/controls/label.cc

Issue 14322007: Add line height setting to views::Label & use it for notifications. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 7 years, 8 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/label.h ('k') | ui/views/controls/tree/tree_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/label.cc
diff --git a/ui/views/controls/label.cc b/ui/views/controls/label.cc
index 351c4e865f576a13659324c3687e1916d141f49c..e2b2f5d42cc9713206870f087ac5214cd3154936 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());
+ const int flags = ComputeDrawStringFlags();
+ 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;
}
@@ -338,6 +348,7 @@ void Label::Init(const string16& text, const gfx::Font& font) {
auto_color_readability_ = true;
UpdateColorsFromTheme(ui::NativeTheme::instance());
horizontal_alignment_ = gfx::ALIGN_CENTER;
+ line_height_ = 0;
is_multi_line_ = false;
allow_character_break_ = false;
elide_behavior_ = NO_ELIDE;
« no previous file with comments | « ui/views/controls/label.h ('k') | ui/views/controls/tree/tree_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698