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

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

Issue 23228004: Prepare to use gfx::RenderText in views::Label. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Revert Label implementation changes. 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
« no previous file with comments | « chrome/browser/ui/views/validation_message_bubble_delegate.cc ('k') | ui/gfx/render_text.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) 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 #ifndef UI_GFX_RENDER_TEXT_H_ 5 #ifndef UI_GFX_RENDER_TEXT_H_
6 #define UI_GFX_RENDER_TEXT_H_ 6 #define UI_GFX_RENDER_TEXT_H_
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <cstring> 9 #include <cstring>
10 #include <string> 10 #include <string>
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 bool obscured() const { return obscured_; } 234 bool obscured() const { return obscured_; }
235 void SetObscured(bool obscured); 235 void SetObscured(bool obscured);
236 236
237 // Makes a char in obscured text at |index| to be revealed. |index| should be 237 // Makes a char in obscured text at |index| to be revealed. |index| should be
238 // a UTF16 text index. If there is a previous revealed index, the previous one 238 // a UTF16 text index. If there is a previous revealed index, the previous one
239 // is cleared and only the last set index will be revealed. If |index| is -1 239 // is cleared and only the last set index will be revealed. If |index| is -1
240 // or out of range, no char will be revealed. The revealed index is also 240 // or out of range, no char will be revealed. The revealed index is also
241 // cleared when SetText or SetObscured is called. 241 // cleared when SetText or SetObscured is called.
242 void SetObscuredRevealIndex(int index); 242 void SetObscuredRevealIndex(int index);
243 243
244 // Set whether newline characters should be replaced with newline symbols.
245 void SetReplaceNewlineCharsWithSymbols(bool replace);
246
244 // TODO(ckocagil): Multiline text rendering is currently only supported on 247 // TODO(ckocagil): Multiline text rendering is currently only supported on
245 // Windows. Support other platforms. 248 // Windows. Support other platforms.
246 bool multiline() const { return multiline_; } 249 bool multiline() const { return multiline_; }
247 void SetMultiline(bool multiline); 250 void SetMultiline(bool multiline);
248 251
249 // Set the maximum length of the displayed layout text, not the actual text. 252 // Set the maximum length of the displayed layout text, not the actual text.
250 // A |length| of 0 forgoes a hard limit, but does not guarantee proper 253 // A |length| of 0 forgoes a hard limit, but does not guarantee proper
251 // functionality of very long strings. Applies to subsequent SetText calls. 254 // functionality of very long strings. Applies to subsequent SetText calls.
252 // WARNING: Only use this for system limits, it lacks complex text support. 255 // WARNING: Only use this for system limits, it lacks complex text support.
253 void set_truncate_length(size_t length) { truncate_length_ = length; } 256 void set_truncate_length(size_t length) { truncate_length_ = length; }
254 257
255 // The layout text will be elided to fit |display_rect| using this behavior. 258 // The layout text will be elided to fit |display_rect| using this behavior.
256 // The layout text may be shortened further by the truncate length. 259 // The layout text may be shortened further by the truncate length.
257 void SetElideBehavior(ElideBehavior elide_behavior); 260 void SetElideBehavior(ElideBehavior elide_behavior);
261 ElideBehavior elide_behavior() const { return elide_behavior_; }
258 262
259 const base::string16& layout_text() const { return layout_text_; } 263 const base::string16& layout_text() const { return layout_text_; }
260 264
261 const Rect& display_rect() const { return display_rect_; } 265 const Rect& display_rect() const { return display_rect_; }
262 void SetDisplayRect(const Rect& r); 266 void SetDisplayRect(const Rect& r);
263 267
264 bool background_is_transparent() const { return background_is_transparent_; } 268 bool background_is_transparent() const { return background_is_transparent_; }
265 void set_background_is_transparent(bool transparent) { 269 void set_background_is_transparent(bool transparent) {
266 background_is_transparent_ = transparent; 270 background_is_transparent_ = transparent;
267 } 271 }
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 // supplied index is already at the boundary of the string. 403 // supplied index is already at the boundary of the string.
400 size_t IndexOfAdjacentGrapheme(size_t index, 404 size_t IndexOfAdjacentGrapheme(size_t index,
401 LogicalCursorDirection direction); 405 LogicalCursorDirection direction);
402 406
403 // Return a SelectionModel with the cursor at the current selection's start. 407 // Return a SelectionModel with the cursor at the current selection's start.
404 // The returned value represents a cursor/caret position without a selection. 408 // The returned value represents a cursor/caret position without a selection.
405 SelectionModel GetSelectionModelForSelectionStart(); 409 SelectionModel GetSelectionModelForSelectionStart();
406 410
407 // Sets shadows to drawn with text. 411 // Sets shadows to drawn with text.
408 void set_shadows(const ShadowValues& shadows) { shadows_ = shadows; } 412 void set_shadows(const ShadowValues& shadows) { shadows_ = shadows; }
413 const ShadowValues& shadows() { return shadows_; }
409 414
410 typedef std::pair<Font, Range> FontSpan; 415 typedef std::pair<Font, Range> FontSpan;
411 // For testing purposes, returns which fonts were chosen for which parts of 416 // For testing purposes, returns which fonts were chosen for which parts of
412 // the text by returning a vector of Font and Range pairs, where each range 417 // the text by returning a vector of Font and Range pairs, where each range
413 // specifies the character range for which the corresponding font has been 418 // specifies the character range for which the corresponding font has been
414 // chosen. 419 // chosen.
415 virtual std::vector<FontSpan> GetFontSpansForTesting() = 0; 420 virtual std::vector<FontSpan> GetFontSpansForTesting() = 0;
416 421
417 // Gets the horizontal bounds (relative to the left of the text, not the view) 422 // Gets the horizontal bounds (relative to the left of the text, not the view)
418 // of the glyph starting at |index|. If the glyph is RTL then the returned 423 // of the glyph starting at |index|. If the glyph is RTL then the returned
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 Vector2d GetLineOffset(size_t line_number); 528 Vector2d GetLineOffset(size_t line_number);
524 529
525 // Convert points from the text space to the view space and back. Handles the 530 // Convert points from the text space to the view space and back. Handles the
526 // display area, display offset, application LTR/RTL mode and multiline. 531 // display area, display offset, application LTR/RTL mode and multiline.
527 Point ToTextPoint(const Point& point); 532 Point ToTextPoint(const Point& point);
528 Point ToViewPoint(const Point& point); 533 Point ToViewPoint(const Point& point);
529 534
530 // Convert a text space x-coordinate range to rects in view space. 535 // Convert a text space x-coordinate range to rects in view space.
531 std::vector<Rect> TextBoundsToViewBounds(const Range& x); 536 std::vector<Rect> TextBoundsToViewBounds(const Range& x);
532 537
538 // Get the alignment, resolving ALIGN_TO_HEAD with the current text direction.
539 HorizontalAlignment GetCurrentHorizontalAlignment();
540
533 // Returns the line offset from the origin, accounts for text alignment only. 541 // Returns the line offset from the origin, accounts for text alignment only.
534 Vector2d GetAlignmentOffset(size_t line_number); 542 Vector2d GetAlignmentOffset(size_t line_number);
535 543
536 // Applies fade effects to |renderer|. 544 // Applies fade effects to |renderer|.
537 void ApplyFadeEffects(internal::SkiaTextRenderer* renderer); 545 void ApplyFadeEffects(internal::SkiaTextRenderer* renderer);
538 546
539 // Applies text shadows to |renderer|. 547 // Applies text shadows to |renderer|.
540 void ApplyTextShadows(internal::SkiaTextRenderer* renderer); 548 void ApplyTextShadows(internal::SkiaTextRenderer* renderer);
541 549
542 // A convenience function to check whether the glyph attached to the caret 550 // A convenience function to check whether the glyph attached to the caret
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 667
660 // The maximum length of text to display, 0 forgoes a hard limit. 668 // The maximum length of text to display, 0 forgoes a hard limit.
661 size_t truncate_length_; 669 size_t truncate_length_;
662 670
663 // The behavior for eliding, fading, or truncating. 671 // The behavior for eliding, fading, or truncating.
664 ElideBehavior elide_behavior_; 672 ElideBehavior elide_behavior_;
665 673
666 // The obscured and/or truncated text that will be displayed. 674 // The obscured and/or truncated text that will be displayed.
667 base::string16 layout_text_; 675 base::string16 layout_text_;
668 676
677 // Whether newline characters should be replaced with newline symbols.
678 bool replace_newline_chars_with_symbols_;
679
669 // Whether the text should be broken into multiple lines. Uses the width of 680 // Whether the text should be broken into multiple lines. Uses the width of
670 // |display_rect_| as the width cap. 681 // |display_rect_| as the width cap.
671 bool multiline_; 682 bool multiline_;
672 683
673 // Is the background transparent (either partially or fully)? 684 // Is the background transparent (either partially or fully)?
674 bool background_is_transparent_; 685 bool background_is_transparent_;
675 686
676 // The local display area for rendering the text. 687 // The local display area for rendering the text.
677 Rect display_rect_; 688 Rect display_rect_;
678 689
(...skipping 25 matching lines...) Expand all
704 // Lines computed by EnsureLayout. These should be invalidated with 715 // Lines computed by EnsureLayout. These should be invalidated with
705 // ResetLayout and on |display_rect_| changes. 716 // ResetLayout and on |display_rect_| changes.
706 std::vector<internal::Line> lines_; 717 std::vector<internal::Line> lines_;
707 718
708 DISALLOW_COPY_AND_ASSIGN(RenderText); 719 DISALLOW_COPY_AND_ASSIGN(RenderText);
709 }; 720 };
710 721
711 } // namespace gfx 722 } // namespace gfx
712 723
713 #endif // UI_GFX_RENDER_TEXT_H_ 724 #endif // UI_GFX_RENDER_TEXT_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/validation_message_bubble_delegate.cc ('k') | ui/gfx/render_text.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698