|
psychic-ui 0.0.0
|
#include <TextLayout.hpp>
Public Member Functions | |
| void | setText (const icu::UnicodeString &text) |
| bool | setStyle (const TextLayoutStyle &style) |
| const TextLayoutStyle & | style () const |
| void | setMultiline (bool multiline) |
| float | maxContentWidth () |
| size_t | lineCountAt (float width) |
| void | layout (float width) |
| void | paint (SkCanvas *canvas, float x, float y, SkColor color) |
| void | paintSelection (SkCanvas *canvas, float x, float y, unsigned int begin, unsigned int end, SkColor background, SkColor foreground) |
| SkRect | caretRect (unsigned int index) |
| unsigned int | indexAt (float x, float y) |
| float | fittingWidth (float width) |
Static Public Member Functions | |
| static std::size_t | paragraphsBuilt () |
Lays out text with SkParagraph: shaping, font fallback, line breaking and alignment, and the geometry editing needs (caret rectangles and hit testing; TextEditing has the rest). Every index is in UTF-16 code units, like icu::UnicodeString's.
Every line is lineHeight tall, its glyphs centred in it (CSS's half-leading). One-line layouts never wrap: their text overflows the width instead, or ends in an ellipsis that fits (TextOverflow::Ellipsis), and line returns lay out as spaces.
Colors are given when painting, so a color change (a transition) never builds or lays out the paragraph again.
| SkRect psychic_ui::TextLayout::caretRect | ( | unsigned int | index | ) |
The caret before the character at the index: a zero-width rectangle across its line
| float psychic_ui::TextLayout::fittingWidth | ( | float | width | ) |
The x where the visible text ends when it's cut at the width: the end of the last glyph cluster that fits whole
| unsigned int psychic_ui::TextLayout::indexAt | ( | float | x, |
| float | y ) |
The caret index closest to a point
| void psychic_ui::TextLayout::layout | ( | float | width | ) |
Lay the text out at the width of its box
| size_t psychic_ui::TextLayout::lineCountAt | ( | float | width | ) |
How many lines the text takes at that width, without changing the layout used for painting and the queries below
| float psychic_ui::TextLayout::maxContentWidth | ( | ) |
The width of the widest line when nothing wraps
| void psychic_ui::TextLayout::paint | ( | SkCanvas * | canvas, |
| float | x, | ||
| float | y, | ||
| SkColor | color ) |
Paint the text in a color with its top left at (x, y)
| void psychic_ui::TextLayout::paintSelection | ( | SkCanvas * | canvas, |
| float | x, | ||
| float | y, | ||
| unsigned int | begin, | ||
| unsigned int | end, | ||
| SkColor | background, | ||
| SkColor | foreground ) |
Paint the selection from begin to end over the text painted at (x, y): its rectangles (a line's height each, in visual order, so bidirectional text gets several) in background, and the text inside them again in foreground
|
static |
How many paragraphs every TextLayout has built so far, for tests of what rebuilds them
| void psychic_ui::TextLayout::setMultiline | ( | bool | multiline | ) |
Whether the text wraps at the width (or stays on one line, past it)
| bool psychic_ui::TextLayout::setStyle | ( | const TextLayoutStyle & | style | ) |
Set what the text is laid out with
| void psychic_ui::TextLayout::setText | ( | const icu::UnicodeString & | text | ) |
Set the text, copied (call again after changing it)