diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-20 18:28:00 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-20 18:28:00 +0000 |
commit | 68da8f78cd06ba70144c9e3fb2e1bae724208e6a (patch) | |
tree | 695907a99af87ad2c9ff646893e11588a447e41d /views/controls/label.cc | |
parent | 6658ca866d0e28950179a65179c1a4d6e8e3f8df (diff) | |
download | chromium_src-68da8f78cd06ba70144c9e3fb2e1bae724208e6a.zip chromium_src-68da8f78cd06ba70144c9e3fb2e1bae724208e6a.tar.gz chromium_src-68da8f78cd06ba70144c9e3fb2e1bae724208e6a.tar.bz2 |
Elide the EV bubble when it's extremely long. This limits it to half the location bar width, unless eliding to that would result in a width of less than 150 px.
BUG=42856
TEST=Visit https://www.barbican.org.uk/eticketing/index.asp and make the window smaller. The EV bubble should shrink, eliding in middle, until it hits a minimum size.
Review URL: http://codereview.chromium.org/2084012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47819 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls/label.cc')
-rw-r--r-- | views/controls/label.cc | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/views/controls/label.cc b/views/controls/label.cc index 9ab4e36..88a755d 100644 --- a/views/controls/label.cc +++ b/views/controls/label.cc @@ -131,30 +131,40 @@ const GURL Label::GetURL() const { return url_set_ ? url_ : GURL(WideToUTF8(text_)); } -void Label::SetHorizontalAlignment(Alignment a) { +void Label::SetHorizontalAlignment(Alignment alignment) { // If the View's UI layout is right-to-left and rtl_alignment_mode_ is // USE_UI_ALIGNMENT, we need to flip the alignment so that the alignment // settings take into account the text directionality. if (base::i18n::IsRTL() && (rtl_alignment_mode_ == USE_UI_ALIGNMENT) && - (a != ALIGN_CENTER)) - a = (a == ALIGN_LEFT) ? ALIGN_RIGHT : ALIGN_LEFT; - if (horiz_alignment_ != a) { - horiz_alignment_ = a; + (alignment != ALIGN_CENTER)) + alignment = (alignment == ALIGN_LEFT) ? ALIGN_RIGHT : ALIGN_LEFT; + if (horiz_alignment_ != alignment) { + horiz_alignment_ = alignment; SchedulePaint(); } } -void Label::SetMultiLine(bool f) { - if (f != is_multi_line_) { - is_multi_line_ = f; +void Label::SetMultiLine(bool multi_line) { + DCHECK(!multi_line || !elide_in_middle_); + if (multi_line != is_multi_line_) { + is_multi_line_ = multi_line; text_size_valid_ = false; SchedulePaint(); } } -void Label::SetAllowCharacterBreak(bool f) { - if (f != allow_character_break_) { - allow_character_break_ = f; +void Label::SetAllowCharacterBreak(bool allow_character_break) { + if (allow_character_break != allow_character_break_) { + allow_character_break_ = allow_character_break; + text_size_valid_ = false; + SchedulePaint(); + } +} + +void Label::SetElideInMiddle(bool elide_in_middle) { + DCHECK(!elide_in_middle || !is_multi_line_); + if (elide_in_middle != elide_in_middle_) { + elide_in_middle_ = elide_in_middle; text_size_valid_ = false; SchedulePaint(); } @@ -285,6 +295,7 @@ void Label::Init(const std::wstring& text, const gfx::Font& font) { horiz_alignment_ = ALIGN_CENTER; is_multi_line_ = false; allow_character_break_ = false; + elide_in_middle_ = false; collapse_when_hidden_ = false; rtl_alignment_mode_ = USE_UI_ALIGNMENT; paint_as_focused_ = false; @@ -311,6 +322,8 @@ void Label::CalculateDrawStringParams(std::wstring* paint_text, // as an LTR string, even if its containing view does not use an RTL UI // layout. base::i18n::GetDisplayStringInLTRDirectionality(paint_text); + } else if (elide_in_middle_) { + *paint_text = gfx::ElideText(text_, font_, width(), true); } else { *paint_text = text_; } |