summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-26 05:04:23 +0000
committervandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-26 05:04:23 +0000
commitba76b0341a80b98b0381f9f3715409cada4a93cb (patch)
tree20f98e11fa2d3eda5123754bb3a763dbd99c9105
parentb82273d99ef45b18ce12abb425b2400f149933d9 (diff)
downloadchromium_src-ba76b0341a80b98b0381f9f3715409cada4a93cb.zip
chromium_src-ba76b0341a80b98b0381f9f3715409cada4a93cb.tar.gz
chromium_src-ba76b0341a80b98b0381f9f3715409cada4a93cb.tar.bz2
Add ELIDE_AT_BEGINNING to views::Label
BUG=NONE Review URL: https://codereview.chromium.org/177843007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@253354 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ui/views/controls/label.cc6
-rw-r--r--ui/views/controls/label.h10
2 files changed, 11 insertions, 5 deletions
diff --git a/ui/views/controls/label.cc b/ui/views/controls/label.cc
index 7729835..f35d119 100644
--- a/ui/views/controls/label.cc
+++ b/ui/views/controls/label.cc
@@ -130,7 +130,8 @@ void Label::SetLineHeight(int height) {
}
void Label::SetMultiLine(bool multi_line) {
- DCHECK(!multi_line || elide_behavior_ != ELIDE_IN_MIDDLE);
+ DCHECK(!multi_line || (elide_behavior_ != ELIDE_IN_MIDDLE &&
+ elide_behavior_ != ELIDE_AT_BEGINNING));
if (multi_line != is_multi_line_) {
is_multi_line_ = multi_line;
ResetCachedSize();
@@ -481,6 +482,9 @@ void Label::CalculateDrawStringParams(base::string16* paint_text,
// this is done, we can set NO_ELLIPSIS unconditionally at the bottom.
if (is_multi_line_ || (elide_behavior_ == NO_ELIDE)) {
*paint_text = text_;
+ } else if (elide_behavior_ == ELIDE_AT_BEGINNING) {
+ *paint_text = gfx::ElideText(text_, font_list_, GetAvailableRect().width(),
+ gfx::ELIDE_AT_BEGINNING);
} else if (elide_behavior_ == ELIDE_IN_MIDDLE) {
*paint_text = gfx::ElideText(text_, font_list_, GetAvailableRect().width(),
gfx::ELIDE_IN_MIDDLE);
diff --git a/ui/views/controls/label.h b/ui/views/controls/label.h
index 77b18e0..463afac 100644
--- a/ui/views/controls/label.h
+++ b/ui/views/controls/label.h
@@ -43,10 +43,12 @@ class VIEWS_EXPORT Label : public View {
};
enum ElideBehavior {
- NO_ELIDE, // Do not elide the label text; truncate as needed.
- ELIDE_IN_MIDDLE, // Add ellipsis in the middle of the string as needed.
- ELIDE_AT_END, // Add ellipsis at the end of the string as needed.
- ELIDE_AS_EMAIL, // Elide while retaining username/domain chars as needed.
+ NO_ELIDE, // Do not elide the label text; truncate as needed.
+ ELIDE_AT_BEGINNING, // Add ellipsis at the start of the string as needed.
+ ELIDE_IN_MIDDLE, // Add ellipsis in the middle of the string as needed.
+ ELIDE_AT_END, // Add ellipsis at the end of the string as needed.
+ ELIDE_AS_EMAIL, // Elide while retaining username/domain chars
+ // as needed.
};
// Internal class name.