27#include <utility/graphic/color.hpp>
29#include "guillaume/ecs/component.hpp"
30#include "guillaume/theme/typescale.hpp"
68 std::string _content {};
69 float _fontSize { 24 };
74 float _lineHeight { 0.0f };
75 float _letterSpacing { 0.0f };
76 std::size_t _cursorPosition {
bool deleteCharacterBefore(void)
Delete the UTF-8 character before the cursor (backspace) and move the cursor back to where it started...
Text & insertString(const std::string &str)
Insert a string at the cursor and move the cursor after it. Always marks the component changed,...
bool moveCursorLeft(void)
Move the cursor to the start of the previous UTF-8 character. Marks the component changed when it mov...
float getLetterSpacing(void) const
Get the extra space between letters.
Text & setLineHeight(float lineHeight)
Set the minimum height of the text's bound.
float getLineHeight(void) const
Get the minimum height of the text's bound.
Text & setFontWeight(theme::FontWeight fontWeight)
Set the font weight.
Text & setLetterSpacing(float letterSpacing)
Set the extra space between letters.
Text & setCursorPosition(std::size_t position)
Move the editing cursor.
~Text(void)=default
Default destructor for the Text component.
Text & setFontSize(float fontSize)
Set the font size.
Text(void)=default
Default constructor for the Text component.
std::size_t getCursorPosition(void) const
Get the position of the editing cursor.
bool moveCursorRight(void)
Move the cursor past the next UTF-8 character. Marks the component changed when it moves.
const std::string & getContent(void) const
Get the text.
theme::FontWeight getFontWeight(void) const
Get the font weight.
float getFontSize(void) const
Get the font size.
Text & insertCharacter(char ch)
Insert one byte at the cursor and move the cursor after it. Marks the component changed.
Text & setContent(const std::string &content)
Replace the text.
Text & setTypeToken(const theme::TypeToken &token)
Apply the four metrics of a typescale token at once: font size, weight, line height and letter spacin...
bool deleteCharacterAfter(void)
Delete the UTF-8 character after the cursor (delete key); the cursor does not move....
Base class of every component: a piece of state attached to an entity, plus a "changed" flag.
State. Every class here is plain data attached to an entity.
FontWeight
Font weights available to the typescale. The value is the usual numeric weight (400 regular,...
One text style: everything needed to measure and draw a piece of text.