OLD | NEW |
---|---|
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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 ui::Range range; | 88 ui::Range range; |
89 }; | 89 }; |
90 | 90 |
91 typedef std::vector<StyleRange> StyleRanges; | 91 typedef std::vector<StyleRange> StyleRanges; |
92 | 92 |
93 // TODO(msw): Distinguish between logical character stops and glyph stops? | 93 // TODO(msw): Distinguish between logical character stops and glyph stops? |
94 // CHARACTER_BREAK cursor movements should stop at neighboring characters. | 94 // CHARACTER_BREAK cursor movements should stop at neighboring characters. |
95 // WORD_BREAK cursor movements should stop at the nearest word boundaries. | 95 // WORD_BREAK cursor movements should stop at the nearest word boundaries. |
96 // LINE_BREAK cursor movements should stop at the text ends as shown on screen. | 96 // LINE_BREAK cursor movements should stop at the text ends as shown on screen. |
97 enum BreakType { | 97 enum BreakType { |
98 CHARACTER_BREAK, | 98 CHARACTER_BREAK = 0, |
Alexei Svitkine (slow)
2012/07/27 11:40:36
Does our style guide require this?
msw
2012/07/28 01:17:11
Not explicitly, but the Google C++ style guide sho
| |
99 WORD_BREAK, | 99 WORD_BREAK, |
100 LINE_BREAK, | 100 LINE_BREAK, |
101 }; | 101 }; |
102 | 102 |
103 // Horizontal text alignment styles. | 103 // Horizontal text alignment styles. |
104 enum HorizontalAlignment { | 104 enum HorizontalAlignment { |
105 ALIGN_LEFT, | 105 ALIGN_LEFT = 0, |
106 ALIGN_CENTER, | 106 ALIGN_CENTER, |
107 ALIGN_RIGHT, | 107 ALIGN_RIGHT, |
108 }; | 108 }; |
109 | 109 |
110 // The directionality modes used to determine the base text direction. | |
111 enum DirectionalityMode { | |
112 DERIVE_FROM_TEXT = 0, // Use the first strong character's direction. | |
Alexei Svitkine (slow)
2012/07/27 11:40:36
This is not a good name for an enum entry in the g
msw
2012/07/28 01:17:11
Done (ui/gfx/text_constants.h and "DIRECTIONALITY_
| |
113 DERIVE_FROM_UI, // Use the UI's language/locale direction. | |
114 FORCE_LTR, // Use LTR regardless of the text content or UI locale. | |
115 FORCE_RTL, // Use RTL regardless of the text content or UI locale. | |
116 }; | |
117 | |
110 // RenderText represents an abstract model of styled text and its corresponding | 118 // RenderText represents an abstract model of styled text and its corresponding |
111 // visual layout. Support is built in for a cursor, a selection, simple styling, | 119 // visual layout. Support is built in for a cursor, a selection, simple styling, |
112 // complex scripts, and bi-directional text. Implementations provide mechanisms | 120 // complex scripts, and bi-directional text. Implementations provide mechanisms |
113 // for rendering and translation between logical and visual data. | 121 // for rendering and translation between logical and visual data. |
114 class UI_EXPORT RenderText { | 122 class UI_EXPORT RenderText { |
115 public: | 123 public: |
116 virtual ~RenderText(); | 124 virtual ~RenderText(); |
117 | 125 |
118 // Creates a platform-specific RenderText instance. | 126 // Creates a platform-specific RenderText instance. |
119 static RenderText* CreateInstance(); | 127 static RenderText* CreateInstance(); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
239 | 247 |
240 const ui::Range& GetCompositionRange() const; | 248 const ui::Range& GetCompositionRange() const; |
241 void SetCompositionRange(const ui::Range& composition_range); | 249 void SetCompositionRange(const ui::Range& composition_range); |
242 | 250 |
243 // Apply |style_range| to the internal style model. | 251 // Apply |style_range| to the internal style model. |
244 void ApplyStyleRange(const StyleRange& style_range); | 252 void ApplyStyleRange(const StyleRange& style_range); |
245 | 253 |
246 // Apply |default_style_| over the entire text range. | 254 // Apply |default_style_| over the entire text range. |
247 void ApplyDefaultStyle(); | 255 void ApplyDefaultStyle(); |
248 | 256 |
249 // Returns the dominant direction of the current text. | 257 // Set the text directionality mode and get the text direction yielded. |
250 virtual base::i18n::TextDirection GetTextDirection() = 0; | 258 void SetDirectionalityMode(DirectionalityMode mode); |
259 base::i18n::TextDirection GetTextDirection(); | |
251 | 260 |
252 // Returns the visual movement direction corresponding to the logical end | 261 // Returns the visual movement direction corresponding to the logical end |
253 // of the text, considering only the dominant direction returned by | 262 // of the text, considering only the dominant direction returned by |
254 // |GetTextDirection()|, not the direction of a particular run. | 263 // |GetTextDirection()|, not the direction of a particular run. |
255 VisualCursorDirection GetVisualDirectionOfLogicalEnd(); | 264 VisualCursorDirection GetVisualDirectionOfLogicalEnd(); |
256 | 265 |
257 // Returns the size in pixels of the entire string. For the height, this will | 266 // Returns the size in pixels of the entire string. For the height, this will |
258 // return the maximum height among the different fonts in the text runs. | 267 // return the maximum height among the different fonts in the text runs. |
259 // Note that this returns the raw size of the string, which does not include | 268 // Note that this returns the raw size of the string, which does not include |
260 // the margin area of text shadows. | 269 // the margin area of text shadows. |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
432 // Draw the selection and cursor. | 441 // Draw the selection and cursor. |
433 void DrawSelection(Canvas* canvas); | 442 void DrawSelection(Canvas* canvas); |
434 void DrawCursor(Canvas* canvas); | 443 void DrawCursor(Canvas* canvas); |
435 | 444 |
436 // Logical UTF-16 string data to be drawn. | 445 // Logical UTF-16 string data to be drawn. |
437 string16 text_; | 446 string16 text_; |
438 | 447 |
439 // Horizontal alignment of the text with respect to |display_rect_|. | 448 // Horizontal alignment of the text with respect to |display_rect_|. |
440 HorizontalAlignment horizontal_alignment_; | 449 HorizontalAlignment horizontal_alignment_; |
441 | 450 |
451 // The text directionality mode, defaults to DERIVE_FROM_TEXT. | |
452 DirectionalityMode directionality_mode_; | |
453 | |
454 // The cached text direction, potentially computed from the text or UI locale. | |
455 base::i18n::TextDirection text_direction_; | |
456 | |
442 // A list of fonts used to render |text_|. | 457 // A list of fonts used to render |text_|. |
443 FontList font_list_; | 458 FontList font_list_; |
444 | 459 |
445 // Logical selection range and visual cursor position. | 460 // Logical selection range and visual cursor position. |
446 SelectionModel selection_model_; | 461 SelectionModel selection_model_; |
447 | 462 |
448 // The cached cursor bounds; get these bounds with GetUpdatedCursorBounds. | 463 // The cached cursor bounds; get these bounds with GetUpdatedCursorBounds. |
449 Rect cursor_bounds_; | 464 Rect cursor_bounds_; |
450 | 465 |
451 // Specifies whether the cursor is enabled. If disabled, no space is reserved | 466 // Specifies whether the cursor is enabled. If disabled, no space is reserved |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
508 | 523 |
509 // Text shadows to be drawn. | 524 // Text shadows to be drawn. |
510 ShadowValues text_shadows_; | 525 ShadowValues text_shadows_; |
511 | 526 |
512 DISALLOW_COPY_AND_ASSIGN(RenderText); | 527 DISALLOW_COPY_AND_ASSIGN(RenderText); |
513 }; | 528 }; |
514 | 529 |
515 } // namespace gfx | 530 } // namespace gfx |
516 | 531 |
517 #endif // UI_GFX_RENDER_TEXT_H_ | 532 #endif // UI_GFX_RENDER_TEXT_H_ |
OLD | NEW |