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

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

Issue 8917011: Change signature of |ui::ElideText()|. Add a truncate mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years 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/base/text/text_elider_unittest.cc ('k') | ui/views/widget/tooltip_manager.cc » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 // Hebrew or Arabic characters are displayed correctly. 478 // Hebrew or Arabic characters are displayed correctly.
479 // 479 //
480 // Note that we don't check the View's UI layout setting in order to 480 // Note that we don't check the View's UI layout setting in order to
481 // determine whether or not to insert the special Unicode formatting 481 // determine whether or not to insert the special Unicode formatting
482 // characters. We use the locale settings because an URL is always treated 482 // characters. We use the locale settings because an URL is always treated
483 // as an LTR string, even if its containing view does not use an RTL UI 483 // as an LTR string, even if its containing view does not use an RTL UI
484 // layout. 484 // layout.
485 *paint_text = base::i18n::GetDisplayStringInLTRDirectionality( 485 *paint_text = base::i18n::GetDisplayStringInLTRDirectionality(
486 *paint_text); 486 *paint_text);
487 } else if (elide_in_middle_) { 487 } else if (elide_in_middle_) {
488 *paint_text = ui::ElideText(text_, 488 *paint_text = ui::ElideText(text_, font_, GetAvailableRect().width(),
489 font_, GetAvailableRect().width(), true); 489 ui::ELIDE_IN_MIDDLE);
490 } else { 490 } else {
491 *paint_text = text_; 491 *paint_text = text_;
492 } 492 }
493 493
494 *text_bounds = GetTextBounds(); 494 *text_bounds = GetTextBounds();
495 *flags = ComputeMultiLineFlags(); 495 *flags = ComputeMultiLineFlags();
496 // If rtl_alignment_mode_ is AUTO_DETECT_ALIGNMENT (such as for text from 496 // If rtl_alignment_mode_ is AUTO_DETECT_ALIGNMENT (such as for text from
497 // webpage, not from chrome's UI), its directionality is forced to be RTL if 497 // webpage, not from chrome's UI), its directionality is forced to be RTL if
498 // it is right aligned. Otherwise, its directionality is forced to be LTR. 498 // it is right aligned. Otherwise, its directionality is forced to be LTR.
499 if (rtl_alignment_mode_ == AUTO_DETECT_ALIGNMENT) { 499 if (rtl_alignment_mode_ == AUTO_DETECT_ALIGNMENT) {
500 if (horiz_alignment_ == ALIGN_RIGHT) 500 if (horiz_alignment_ == ALIGN_RIGHT)
501 *flags |= gfx::Canvas::FORCE_RTL_DIRECTIONALITY; 501 *flags |= gfx::Canvas::FORCE_RTL_DIRECTIONALITY;
502 else 502 else
503 *flags |= gfx::Canvas::FORCE_LTR_DIRECTIONALITY; 503 *flags |= gfx::Canvas::FORCE_LTR_DIRECTIONALITY;
504 } 504 }
505 } 505 }
506 506
507 } // namespace views 507 } // namespace views
OLDNEW
« no previous file with comments | « ui/base/text/text_elider_unittest.cc ('k') | ui/views/widget/tooltip_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698