|
guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
|
A run of text: its content, its font metrics and the position of the editing cursor. More...
#include <headers/guillaume/components/text.hpp>


Public Member Functions | |
| Text (void)=default | |
| Default constructor for the Text component. | |
| ~Text (void)=default | |
| Default destructor for the Text component. | |
| const std::string & | getContent (void) const |
| Get the text. | |
| Text & | setContent (const std::string &content) |
| Replace the text. | |
| float | getFontSize (void) const |
| Get the font size. | |
| Text & | setFontSize (float fontSize) |
| Set the font size. | |
| theme::FontWeight | getFontWeight (void) const |
| Get the font weight. | |
| Text & | setFontWeight (theme::FontWeight fontWeight) |
| Set the font weight. | |
| float | getLineHeight (void) const |
| Get the minimum height of the text's bound. | |
| Text & | setLineHeight (float lineHeight) |
| Set the minimum height of the text's bound. | |
| float | getLetterSpacing (void) const |
| Get the extra space between letters. | |
| Text & | setLetterSpacing (float letterSpacing) |
| Set the extra space between letters. | |
| Text & | setTypeToken (const theme::TypeToken &token) |
| Apply the four metrics of a typescale token at once: font size, weight, line height and letter spacing. | |
| std::size_t | getCursorPosition (void) const |
| Get the position of the editing cursor. | |
| Text & | setCursorPosition (std::size_t position) |
| Move the editing cursor. | |
| bool | moveCursorLeft (void) |
| Move the cursor to the start of the previous UTF-8 character. Marks the component changed when it moves. | |
| bool | moveCursorRight (void) |
| Move the cursor past the next UTF-8 character. Marks the component changed when it moves. | |
| Text & | insertCharacter (char ch) |
| Insert one byte at the cursor and move the cursor after it. Marks the component changed. | |
| Text & | insertString (const std::string &str) |
| Insert a string at the cursor and move the cursor after it. Always marks the component changed, even for an empty string. | |
| bool | deleteCharacterBefore (void) |
| Delete the UTF-8 character before the cursor (backspace) and move the cursor back to where it started. Marks the component changed when a character is deleted. | |
| bool | deleteCharacterAfter (void) |
| Delete the UTF-8 character after the cursor (delete key); the cursor does not move. Marks the component changed when a character is deleted. | |
| Public Member Functions inherited from guillaume::ecs::Component | |
| bool | hasChanged (void) const |
| Tell whether a value of the component changed since the flags were last reset (the end of the previous frame). | |
| void | setHasChanged (bool hasChanged) |
| Raise or lower the changed flag. | |
| Component (void)=default | |
| Create a component that is not marked as changed. | |
| virtual | ~Component (void)=default |
| Virtual destructor, so components can be destroyed through the base class. | |
A run of text: its content, its font metrics and the position of the editing cursor.
Readers: systems::MeasureText (Measure phase) writes the size of the text into the entity's components::Bound, and systems::TextRender (Render phase) draws it at the entity's components::Transform in the entity's components::Color.
Writers: entities::Text and the widget systems set the content; systems::Typography writes the four font metrics every frame on an entity that also has a components::Typography; systems::TextInput appends typed text to the content and systems::KeyboardControl moves the cursor and deletes around it.
| bool guillaume::components::Text::deleteCharacterAfter | ( | void | ) |
Delete the UTF-8 character after the cursor (delete key); the cursor does not move. Marks the component changed when a character is deleted.
Definition at line 199 of file text.cpp.

| bool guillaume::components::Text::deleteCharacterBefore | ( | void | ) |
Delete the UTF-8 character before the cursor (backspace) and move the cursor back to where it started. Marks the component changed when a character is deleted.
Definition at line 180 of file text.cpp.

| const std::string & guillaume::components::Text::getContent | ( | void | ) | const |
| std::size_t guillaume::components::Text::getCursorPosition | ( | void | ) | const |
| float guillaume::components::Text::getFontSize | ( | void | ) | const |
| theme::FontWeight guillaume::components::Text::getFontWeight | ( | void | ) | const |
| float guillaume::components::Text::getLetterSpacing | ( | void | ) | const |
| float guillaume::components::Text::getLineHeight | ( | void | ) | const |
| Text & guillaume::components::Text::insertCharacter | ( | char | ch | ) |
Insert one byte at the cursor and move the cursor after it. Marks the component changed.
| ch | The byte to insert; use insertString() for a character that takes several bytes in UTF-8. |
Definition at line 164 of file text.cpp.

| Text & guillaume::components::Text::insertString | ( | const std::string & | str | ) |
| bool guillaume::components::Text::moveCursorLeft | ( | void | ) |
| bool guillaume::components::Text::moveCursorRight | ( | void | ) |
| Text & guillaume::components::Text::setContent | ( | const std::string & | content | ) |
Replace the text.
A cursor beyond the end of the new content is moved to its end. Marks the component changed only when the content differs.
| content | The new content, UTF-8. |
Definition at line 34 of file text.cpp.


| Text & guillaume::components::Text::setCursorPosition | ( | std::size_t | position | ) |
Move the editing cursor.
Always marks the component changed.
| position | A byte offset into the content; a value beyond the end is clamped to the content size. It is not checked against UTF-8 character boundaries. |
Definition at line 124 of file text.cpp.

| Text & guillaume::components::Text::setFontSize | ( | float | fontSize | ) |
| Text & guillaume::components::Text::setFontWeight | ( | theme::FontWeight | fontWeight | ) |
Set the font weight.
The weight selects the font file the text is measured and drawn with (see theme::fontPath). Marks the component changed only when the weight differs.
| fontWeight | The weight of the font. |
Definition at line 65 of file text.cpp.


| Text & guillaume::components::Text::setLetterSpacing | ( | float | letterSpacing | ) |
Set the extra space between letters.
The value is stored; the measure and render systems do not apply it. Marks the component changed only when the value differs.
| letterSpacing | The letter spacing, in dp. |
Definition at line 98 of file text.cpp.


| Text & guillaume::components::Text::setLineHeight | ( | float | lineHeight | ) |
Set the minimum height of the text's bound.
systems::MeasureText writes the larger of the measured height and this value into the Bound, so short text still takes a full line. Marks the component changed only when the value differs.
| lineHeight | The line height, in dp; must not be negative. |
| std::invalid_argument | If lineHeight is negative. |
Definition at line 80 of file text.cpp.


| Text & guillaume::components::Text::setTypeToken | ( | const theme::TypeToken & | token | ) |
Apply the four metrics of a typescale token at once: font size, weight, line height and letter spacing.
Marks the component changed only when at least one metric differs, so systems::Typography can call it every frame.
| token | The token, usually from getTypeToken(role). |
| std::invalid_argument | If the token's line height is negative. |
Definition at line 108 of file text.cpp.
