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

Side by Side Diff: ui/gfx/text_elider.h

Issue 381953002: New avatar button: Consolidate text elision between Mac and Win/Linux (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 6 years, 5 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
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 // This file defines utility functions for eliding and formatting UI text. 5 // This file defines utility functions for eliding and formatting UI text.
6 6
7 #ifndef UI_GFX_TEXT_ELIDER_H_ 7 #ifndef UI_GFX_TEXT_ELIDER_H_
8 #define UI_GFX_TEXT_ELIDER_H_ 8 #define UI_GFX_TEXT_ELIDER_H_
9 9
10 #include <string> 10 #include <string>
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 INSUFFICIENT_SPACE_HORIZONTAL = 1 << 0, 136 INSUFFICIENT_SPACE_HORIZONTAL = 1 << 0,
137 INSUFFICIENT_SPACE_VERTICAL = 1 << 1, 137 INSUFFICIENT_SPACE_VERTICAL = 1 << 1,
138 }; 138 };
139 139
140 // Reformats |text| into output vector |lines| so that the resulting text fits 140 // Reformats |text| into output vector |lines| so that the resulting text fits
141 // into an |available_pixel_width| by |available_pixel_height| rectangle with 141 // into an |available_pixel_width| by |available_pixel_height| rectangle with
142 // the specified |font_list|. Input newlines are respected, but lines that are 142 // the specified |font_list|. Input newlines are respected, but lines that are
143 // too long are broken into pieces. For words that are too wide to fit on a 143 // too long are broken into pieces. For words that are too wide to fit on a
144 // single line, the wrapping behavior can be specified with the |wrap_behavior| 144 // single line, the wrapping behavior can be specified with the |wrap_behavior|
145 // param. Returns a combination of |ReformattingResultFlags| that indicate 145 // param. Returns a combination of |ReformattingResultFlags| that indicate
146 // whether the given rectangle had insufficient space to accommodate |texŧ|, 146 // whether the given rectangle had insufficient space to accommodate |text|,
147 // leading to elision or truncation (and not just reformatting). 147 // leading to elision or truncation (and not just reformatting).
148 GFX_EXPORT int ElideRectangleText(const base::string16& text, 148 GFX_EXPORT int ElideRectangleText(const base::string16& text,
149 const gfx::FontList& font_list, 149 const gfx::FontList& font_list,
150 float available_pixel_width, 150 float available_pixel_width,
151 int available_pixel_height, 151 int available_pixel_height,
152 WordWrapBehavior wrap_behavior, 152 WordWrapBehavior wrap_behavior,
153 std::vector<base::string16>* lines); 153 std::vector<base::string16>* lines);
154 154
155 // Truncates the string to length characters. This breaks the string at 155 // Truncates |string| to |length| characters. This breaks the string according
156 // the first word break before length, adding the horizontal ellipsis 156 // to the specified |break_type|, which must be either WORD_BREAK or
157 // character (unicode character 0x2026) to render ... 157 // CHARACTER_BREAK, and adds the horizontal ellipsis character (unicode
158 // The supplied string is returned if the string has length characters or 158 // character 0x2026) to render "...". The supplied string is returned if the
159 // less. 159 // string has |length| characters or less.
160 GFX_EXPORT base::string16 TruncateString(const base::string16& string, 160 GFX_EXPORT base::string16 TruncateString(const base::string16& string,
161 size_t length); 161 size_t length,
162 BreakType break_type);
162 163
163 } // namespace gfx 164 } // namespace gfx
164 165
165 #endif // UI_GFX_TEXT_ELIDER_H_ 166 #endif // UI_GFX_TEXT_ELIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698