class GUIInputTool

Base class for input helper tools, like caret and text selection.

Public

Constructors

GUIInputTool

GUIInputTool() = default

Methods

~GUIInputTool

~GUIInputTool() = default

UpdateText

void UpdateText(const GUIInteractable *element, const TextSpriteInformation &textDesc)

Updates the input tool with new text descriptor and parent GUI element.

These values will be used for all further calculations.

Protected

Methods

GetLineCount

u32 GetLineCount() const

Returns number of lines in the current text string.

GetLineDesc

const GUIInputLineDesc &GetLineDesc(u32 lineIndex) const

Returns descriptor for a line with the specified index.

GetLineForChar

u32 GetLineForChar(u32 characterIndex, bool newlineCountsOnNextLine = false) const

Returns index of a line containing the specified character.

characterIndex
Index of the character to look for.
newlineCountsOnNextLine
If true, newline characters will return the next line and not the line they're actually on.

GetCharacterBounds

Area2I GetCharacterBounds(u32 characterIndex) const

Returns a rectangle containing position and size of the character with the provided index, relative to parent GUI element.

GetCharIdxAtPos

i32 GetCharIdxAtPos(const GUIPhysicalPoint &position) const

Returns character index nearest to the specified position.

Position should be relative to parent GUI element.

IsDescValid

bool IsDescValid() const

Returns true if the currently set text desctiptor is valid (has any characters).

GetCharIdxAtInputIdx

u32 GetCharIdxAtInputIdx(u32 inputIdx) const

Gets a character index after the input index.

Input index represents the empty areas between the characters. Newline counts as a character. (for example 0 is before the first character, 1 is after the first character but before the second, etc.)

IsNewlineChar

bool IsNewlineChar(u32 characterIndex) const

Checks is the specified character index a newline.

IsNewline

bool IsNewline(u32 inputIdx) const

Checks is the character after the specified input index a newline.

Fields

mElement

const GUIInteractable * mElement

mQuads

Vector2 * mQuads

mQuadCount

u32 mQuadCount

mTextDesc

mCharacterCount

u32 mCharacterCount

mLineDescs

Vector<GUIInputLineDesc> mLineDescs