Kanzi  3.9.6
Kanzi Engine API
kanzi::TextInputLayout Class Reference

Use TextInputLayout to precalculate information on text layout properties, such as glyph directionality, width, buffer index to glyph mapping, and so on. More...

#include <kanzi/core.ui/text/text_input_layout.hpp>

Public Member Functions

void calculateLayout (string_view text, TextLayout &textLayout, bool isMarked)
 Calculates the layout information for the given text. More...
 
vector< pair< float, float > > calculateSelectionCoordinates (size_t selectionStart, size_t selectionEnd) const
 Returns all intervals to highlight due to a selection. More...
 
float getCaretX (size_t characterIndex) const
 Returns the caret position for the character at a given character index. More...
 
float getCaretXAfter (size_t characterIndex) const
 Returns the caret position after the character at a given character index. More...
 
size_t getCharacterAt (float x, bool round) const
 Finds the index of the character at a given x axis coordinate. More...
 
size_t getClustersPositionBackward (size_t position, size_t distance) const
 Returns the position distance clusters backward. More...
 
size_t getClustersPositionForward (size_t position, size_t distance) const
 Returns the position distance clusters forward. More...
 
size_t startOfFollowingCluster (size_t characterIndex) const
 Returns the index of the first character in the cluster that follows the cluster to which characterIndex belongs. More...
 
size_t startOfPrecedingCluster (size_t characterIndex) const
 Returns the index of the first character in the cluster that precedes the cluster to which characterIndex belongs. More...
 
 TextInputLayout ()=default
 Constructor. More...
 

Detailed Description

Use TextInputLayout to precalculate information on text layout properties, such as glyph directionality, width, buffer index to glyph mapping, and so on.

Since
Kanzi 3.9.0

Constructor & Destructor Documentation

◆ TextInputLayout()

kanzi::TextInputLayout::TextInputLayout ( )
explicitdefault

Constructor.

Member Function Documentation

◆ calculateLayout()

void kanzi::TextInputLayout::calculateLayout ( string_view  text,
TextLayout textLayout,
bool  isMarked 
)

Calculates the layout information for the given text.

Call this function whenever the text or its layout changes.

Parameters
textThe text for which this function computes the layout information.
textLayoutThe text layout that this function uses to compute the positions of characters in the text.
isMarkedIndicates whether the text is prefixed with a directionality marker.

◆ startOfPrecedingCluster()

size_t kanzi::TextInputLayout::startOfPrecedingCluster ( size_t  characterIndex) const

Returns the index of the first character in the cluster that precedes the cluster to which characterIndex belongs.

Parameters
characterIndexThe character index for which this function returns the index of the first character in the preceding cluster.
Returns
The index of the first character in the cluster that precedes the cluster to which characterIndex belongs.

◆ getClustersPositionForward()

size_t kanzi::TextInputLayout::getClustersPositionForward ( size_t  position,
size_t  distance 
) const

Returns the position distance clusters forward.

◆ getClustersPositionBackward()

size_t kanzi::TextInputLayout::getClustersPositionBackward ( size_t  position,
size_t  distance 
) const

Returns the position distance clusters backward.

◆ startOfFollowingCluster()

size_t kanzi::TextInputLayout::startOfFollowingCluster ( size_t  characterIndex) const

Returns the index of the first character in the cluster that follows the cluster to which characterIndex belongs.

Parameters
characterIndexThe character index for which this function returns the index of the first character in the following cluster.
Returns
The index of the first character in the cluster that follows the cluster to which characterIndex belongs.

◆ getCaretX()

float kanzi::TextInputLayout::getCaretX ( size_t  characterIndex) const

Returns the caret position for the character at a given character index.

If characterIndex is greater than the length of the text, the caret position is the logical end of the text.

Parameters
characterIndexThe character index whose caret position this function returns.
Returns
The caret position of characterIndex.

◆ getCaretXAfter()

float kanzi::TextInputLayout::getCaretXAfter ( size_t  characterIndex) const

Returns the caret position after the character at a given character index.

If characterIndex is greater than the length of the text, the caret position is the logical end of the text.

Parameters
characterIndexThe character index whose caret position this function returns.
Returns
The caret end position of characterIndex.

◆ getCharacterAt()

size_t kanzi::TextInputLayout::getCharacterAt ( float  x,
bool  round 
) const

Finds the index of the character at a given x axis coordinate.

Parameters
xThe x axis coordinate to translate to a character position.
roundIndicates whether to round to the nearest cursor position. To round use true, to not round use false.
Returns
The character position translated from the x axis coordinate.

◆ calculateSelectionCoordinates()

vector<pair<float, float> > kanzi::TextInputLayout::calculateSelectionCoordinates ( size_t  selectionStart,
size_t  selectionEnd 
) const

Returns all intervals to highlight due to a selection.

Parameters
selectionStartThe first character of a selection.
selectionEndThe final character of a selection.
Returns
A vector that contains the highlighted intervals.

The documentation for this class was generated from the following file: