| 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/label.h" | 5 #include "ui/views/controls/label.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 gfx::Insets insets = GetInsets(); | 209 gfx::Insets insets = GetInsets(); |
| 210 size.Enlarge(insets.width(), insets.height()); | 210 size.Enlarge(insets.width(), insets.height()); |
| 211 return size; | 211 return size; |
| 212 } | 212 } |
| 213 | 213 |
| 214 gfx::Size Label::GetMinimumSize() { | 214 gfx::Size Label::GetMinimumSize() { |
| 215 gfx::Size text_size(GetTextSize()); | 215 gfx::Size text_size(GetTextSize()); |
| 216 if ((!visible() && collapse_when_hidden_) || text_size.IsEmpty()) | 216 if ((!visible() && collapse_when_hidden_) || text_size.IsEmpty()) |
| 217 return gfx::Size(); | 217 return gfx::Size(); |
| 218 | 218 |
| 219 gfx::Size size(font_list_.GetStringWidth(base::string16(gfx::kEllipsisUTF16)), | 219 gfx::Size size(gfx::GetStringWidth(base::string16(gfx::kEllipsisUTF16), |
| 220 font_list_), |
| 220 font_list_.GetHeight()); | 221 font_list_.GetHeight()); |
| 221 size.SetToMin(text_size); // The actual text may be shorter than an ellipsis. | 222 size.SetToMin(text_size); // The actual text may be shorter than an ellipsis. |
| 222 gfx::Insets insets = GetInsets(); | 223 gfx::Insets insets = GetInsets(); |
| 223 size.Enlarge(insets.width(), insets.height()); | 224 size.Enlarge(insets.width(), insets.height()); |
| 224 return size; | 225 return size; |
| 225 } | 226 } |
| 226 | 227 |
| 227 int Label::GetHeightForWidth(int w) { | 228 int Label::GetHeightForWidth(int w) { |
| 228 if (!is_multi_line_) | 229 if (!is_multi_line_) |
| 229 return View::GetHeightForWidth(w); | 230 return View::GetHeightForWidth(w); |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 for (int i = 0; i < kCachedSizeLimit; ++i) | 521 for (int i = 0; i < kCachedSizeLimit; ++i) |
| 521 cached_heights_[i] = gfx::Size(); | 522 cached_heights_[i] = gfx::Size(); |
| 522 } | 523 } |
| 523 | 524 |
| 524 bool Label::ShouldShowDefaultTooltip() const { | 525 bool Label::ShouldShowDefaultTooltip() const { |
| 525 return !is_multi_line_ && | 526 return !is_multi_line_ && |
| 526 gfx::GetStringWidth(text_, font_list_) > GetAvailableRect().width(); | 527 gfx::GetStringWidth(text_, font_list_) > GetAvailableRect().width(); |
| 527 } | 528 } |
| 528 | 529 |
| 529 } // namespace views | 530 } // namespace views |
| OLD | NEW |