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

Side by Side Diff: ui/views/controls/label.cc

Issue 10834207: aura: Long launcher tooltips should elide at end. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/label.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 if (base::i18n::IsRTL() && (directionality_mode_ == USE_UI_DIRECTIONALITY) && 107 if (base::i18n::IsRTL() && (directionality_mode_ == USE_UI_DIRECTIONALITY) &&
108 (alignment != ALIGN_CENTER)) 108 (alignment != ALIGN_CENTER))
109 alignment = (alignment == ALIGN_LEFT) ? ALIGN_RIGHT : ALIGN_LEFT; 109 alignment = (alignment == ALIGN_LEFT) ? ALIGN_RIGHT : ALIGN_LEFT;
110 if (horiz_alignment_ != alignment) { 110 if (horiz_alignment_ != alignment) {
111 horiz_alignment_ = alignment; 111 horiz_alignment_ = alignment;
112 SchedulePaint(); 112 SchedulePaint();
113 } 113 }
114 } 114 }
115 115
116 void Label::SetMultiLine(bool multi_line) { 116 void Label::SetMultiLine(bool multi_line) {
117 DCHECK(!multi_line || !elide_in_middle_); 117 DCHECK(!multi_line || elide_behavior_ != ELIDE_IN_MIDDLE);
118 if (multi_line != is_multi_line_) { 118 if (multi_line != is_multi_line_) {
119 is_multi_line_ = multi_line; 119 is_multi_line_ = multi_line;
120 text_size_valid_ = false; 120 text_size_valid_ = false;
121 PreferredSizeChanged(); 121 PreferredSizeChanged();
122 SchedulePaint(); 122 SchedulePaint();
123 } 123 }
124 } 124 }
125 125
126 void Label::SetAllowCharacterBreak(bool allow_character_break) { 126 void Label::SetAllowCharacterBreak(bool allow_character_break) {
127 if (allow_character_break != allow_character_break_) { 127 if (allow_character_break != allow_character_break_) {
128 allow_character_break_ = allow_character_break; 128 allow_character_break_ = allow_character_break;
129 text_size_valid_ = false; 129 text_size_valid_ = false;
130 PreferredSizeChanged(); 130 PreferredSizeChanged();
131 SchedulePaint(); 131 SchedulePaint();
132 } 132 }
133 } 133 }
134 134
135 void Label::SetElideInMiddle(bool elide_in_middle) { 135 void Label::SetElideBehavior(ElideBehavior elide_behavior) {
136 DCHECK(!elide_in_middle || !is_multi_line_); 136 DCHECK(elide_behavior != ELIDE_IN_MIDDLE || !is_multi_line_);
137 if (elide_in_middle != elide_in_middle_) { 137 if (elide_behavior != elide_behavior_) {
138 elide_in_middle_ = elide_in_middle; 138 elide_behavior_ = elide_behavior;
139 text_size_valid_ = false; 139 text_size_valid_ = false;
140 is_email_ = false; 140 is_email_ = false;
141 PreferredSizeChanged(); 141 PreferredSizeChanged();
142 SchedulePaint(); 142 SchedulePaint();
143 } 143 }
144 } 144 }
145 145
146 void Label::SetTooltipText(const string16& tooltip_text) { 146 void Label::SetTooltipText(const string16& tooltip_text) {
147 tooltip_text_ = tooltip_text; 147 tooltip_text_ = tooltip_text;
148 } 148 }
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 ui::NativeTheme::kColorId_LabelEnabledColor); 352 ui::NativeTheme::kColorId_LabelEnabledColor);
353 requested_disabled_color_ = ui::NativeTheme::instance()->GetSystemColor( 353 requested_disabled_color_ = ui::NativeTheme::instance()->GetSystemColor(
354 ui::NativeTheme::kColorId_LabelDisabledColor); 354 ui::NativeTheme::kColorId_LabelDisabledColor);
355 background_color_ = ui::NativeTheme::instance()->GetSystemColor( 355 background_color_ = ui::NativeTheme::instance()->GetSystemColor(
356 ui::NativeTheme::kColorId_LabelBackgroundColor); 356 ui::NativeTheme::kColorId_LabelBackgroundColor);
357 auto_color_readability_ = true; 357 auto_color_readability_ = true;
358 RecalculateColors(); 358 RecalculateColors();
359 horiz_alignment_ = ALIGN_CENTER; 359 horiz_alignment_ = ALIGN_CENTER;
360 is_multi_line_ = false; 360 is_multi_line_ = false;
361 allow_character_break_ = false; 361 allow_character_break_ = false;
362 elide_in_middle_ = false; 362 elide_behavior_ = NO_ELIDE;
363 is_email_ = false; 363 is_email_ = false;
364 collapse_when_hidden_ = false; 364 collapse_when_hidden_ = false;
365 directionality_mode_ = USE_UI_DIRECTIONALITY; 365 directionality_mode_ = USE_UI_DIRECTIONALITY;
366 paint_as_focused_ = false; 366 paint_as_focused_ = false;
367 has_focus_border_ = false; 367 has_focus_border_ = false;
368 enabled_shadow_color_ = 0; 368 enabled_shadow_color_ = 0;
369 disabled_shadow_color_ = 0; 369 disabled_shadow_color_ = 0;
370 shadow_offset_.SetPoint(1, 1); 370 shadow_offset_.SetPoint(1, 1);
371 has_shadow_ = false; 371 has_shadow_ = false;
372 372
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 return bounds; 478 return bounds;
479 } 479 }
480 480
481 void Label::CalculateDrawStringParams(string16* paint_text, 481 void Label::CalculateDrawStringParams(string16* paint_text,
482 gfx::Rect* text_bounds, 482 gfx::Rect* text_bounds,
483 int* flags) const { 483 int* flags) const {
484 DCHECK(paint_text && text_bounds && flags); 484 DCHECK(paint_text && text_bounds && flags);
485 485
486 if (is_email_) { 486 if (is_email_) {
487 *paint_text = ui::ElideEmail(text_, font_, GetAvailableRect().width()); 487 *paint_text = ui::ElideEmail(text_, font_, GetAvailableRect().width());
488 } else if (elide_in_middle_) { 488 } else if (elide_behavior_ == ELIDE_IN_MIDDLE) {
489 *paint_text = ui::ElideText(text_, font_, GetAvailableRect().width(), 489 *paint_text = ui::ElideText(text_, font_, GetAvailableRect().width(),
490 ui::ELIDE_IN_MIDDLE); 490 ui::ELIDE_IN_MIDDLE);
491 } else if (elide_behavior_ == ELIDE_AT_END) {
492 *paint_text = ui::ElideText(text_, font_, GetAvailableRect().width(),
493 ui::ELIDE_AT_END);
491 } else { 494 } else {
492 *paint_text = text_; 495 *paint_text = text_;
493 } 496 }
494 497
495 *text_bounds = GetTextBounds(); 498 *text_bounds = GetTextBounds();
496 *flags = ComputeDrawStringFlags(); 499 *flags = ComputeDrawStringFlags();
497 } 500 }
498 501
499 } // namespace views 502 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/label.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698