Classes

UI/Label

Brief descriptions

Structures

nau::ui::SymbolParams

nau::ui::FontLetterDefinition

nau::ui::SymbolDefinition

Encapsulates text symbol data.

nau::ui::TextLineDefinition

Encapsulates text line data.

nau::ui::TextDefinition

Encapsulates text block (a collection of text lines) data.

Classes

nau::ui::NauLabel

Manages a text block.

Detailed information

ui::SymbolParams

engine/core/modules/ui/include/nau/ui/label.h

struct SymbolParams

Public Members

std::u32string Color = {}
std::u32string Font = {}
std::u32string Image = {}
float ImageWidth = {0.0f}
float ImageHeight = {0.0f}
float ImageScale = {0.0f}
float ImageRotation = {0.0f}

ui::FontLetterDefinition

engine/core/modules/ui/include/nau/ui/label.h

struct FontLetterDefinition

Public Members

float U = {0.0f}
float V = {0.0f}
float width = {0.0f}
float height = {0.0f}
float offsetX = {0.0f}
float offsetY = {0.0f}
int textureID = {0}
bool validDefinition = {false}
int xAdvance = {0}
bool rotated = {false}

ui::SymbolDefinition

engine/core/modules/ui/include/nau/ui/label.h

struct SymbolDefinition

Encapsulates text symbol data.

Public Members

char32_t utf32Code = 0xFFFFFFFF

Symbol UTF-32 code.

FontLetterDefinition letterDefinition = {}
SymbolParams richParams = {}

ui::TextLineDefinition

engine/core/modules/ui/include/nau/ui/label.h

struct TextLineDefinition

Encapsulates text line data.

Public Members

float lineWidth = {0.0f}
float lineMaxHeight = {0.0f}
bool IsCustomAlignment = {false}
HorizontalAlignment Alignment = {}
std::vector<SymbolDefinition> symbolDefinitions = {}

A collection of per-symbol data.


ui::TextDefinition

engine/core/modules/ui/include/nau/ui/label.h

struct TextDefinition

Encapsulates text block (a collection of text lines) data.

Public Functions

inline TextDefinition(std::vector<TextLineDefinition> &lines, float height)

Public Members

std::vector<TextLineDefinition> lineDefinitions = {}

A collection of per-line data.

float totalTextHeight = {0.0f}

ui::NauLabel

engine/core/modules/ui/include/nau/ui/label.h

class NauLabel : public nau::ui::Node

Manages a text block.

Public Types

enum class LabelType

Enumerates text label font types.

Values:

enumerator ttf

True type.

enumerator bmfont

Bitmap font.

enum class Overflow

Enumerates text label strategies when the text line exceeds label borders.

Values:

enumerator none

Text label will not react to a text line exceeding the label borders.

enumerator clamp

When a text line exceeds the label borders, the text outside the borders will be clipped.

enum class Wrapping

Enumerates text line wrapping mechanisms.

Values:

enumerator disable

Wrapping is disabled.

enumerator word

Wrapping can occur only in-between words.

enumerator character

Wrapping can occur in-between symbols.

Public Functions

NauLabel()

Default constructor.

virtual ~NauLabel()

Destructor.

void addFont(const std::string &fontFilePath)
void removeFont(const std::string &fontFilePath)
void setText(const eastl::string &text)

Changes the content of the text label.

Parameters:

text[in] Text to assign.

eastl::string_view getText() const

Retrieves the content of the text label.

Returns:

Text block contained in the label.

void updateLabel()

Commits changes and updates the label visuals.

void enableRichText(bool enable)

Turns rich text parsing for the text label on or off.

Parameters:

enable[in] Indicates whether rich text parsing should be turned on or off.

void setSymbolFactory(eastl::unique_ptr<SymbolFactory> &&symbolFactory)
void setVerticalAlignment(VerticalAlignment alignment)

Changes the label text vertical alignment type.

Parameters:

alignment[in] Text vertical elignment type to use.

void setHorizontalAlignment(HorizontalAlignment alignment)

Changes the label text horizontal alignment type.

Parameters:

alignment[in] Text horizontal elignment type to use.

void setWrapping(Wrapping wrapping)

Changes the label text wrapping mechanism.

Parameters:

wrapping[in] Text wrapping mechaninsm to use.

void setOverflowType(Overflow overflow)

Changes the label overflow strategy.

Parameters:

overflow[in] Overflow strategy to use.

virtual void setColor(const nau::math::E3DCOLOR &color) override
virtual void setOpacity(uint8_t opacity) override
virtual void setCascadeColorEnabled(bool cascadeColorEnabled) override
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled) override
virtual void redrawDebug() override

Public Static Functions

static NauLabel *create()

Creates an empty text label.

Returns:

A pointer to the created label.

static NauLabel *create(const eastl::string &text, const std::string &fontPath)

Creates a text label.

Parameters:
  • text[in] Label text.

  • fontPath[in] Path to the font file to use for the label.

Returns:

A pointer to the created label.

static NauLabel *create(const eastl::string &text, const std::string &fontPath, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, Overflow overflow, Wrapping wrapping)

Creates a text label.

Parameters:
  • text[in] Label text.

  • fontPath[in] Path to the font file to use for the label.

  • horizontalAlignment[in] Indicates how to align the text along horizontal axis within the label.

  • verticalAlignment[in] Indicates how to align the text along vertical axis within the label.

  • overflow[in] Text line overflow strategy to use.

  • wrapping[in] Text line wrapping mechanism to use.

Returns:

A pointer to the created label.

static NauLabel *create(eastl::unique_ptr<SymbolFactory> symbolFactory)

Protected Functions

void setupLetter(const SymbolDefinition &definition, int letterIndex, float renderX, float renderY)
void setupImage(const SymbolDefinition &definition, int letterIndex, float x, float y)
float getLineHorizontalOffset(float lineWidth)
float getLineVerticalOffset(const std::vector<TextLineDefinition> &lineDefinitions, size_t lineIndex, float totalHeight)
bool isCharacterOverflow(float x, float y, float letterWidth, float letterHeight)
bool isWrappingToNextLine(char32_t character, FontLetterDefinition &letterDef, float currentLineWidth, float nextWordLenght)
Sprite *getLetterSprite(size_t letterIndex)
void hideLettersSprite()
float getNextWordLenght(const eastl::u32string &utf32Text, size_t startIndex, const std::u32string &font)
bool isCharacterEndOfWord(char32_t character)
void setLetterColor(Sprite *letterSprite, const SymbolParams &params)
void removeSpacesAtEdges(std::vector<SymbolDefinition> &symbolDefinitions)

Private Functions

void drawText(const std::vector<TextLineDefinition> &lineDefinitions, float totalLinesHeight)
TextDefinition calculateTextDefinition(const eastl::u32string &text)

Private Members

Overflow m_overflow = {Overflow::none}
Wrapping m_wrapping = {Wrapping::disable}
HorizontalAlignment m_horizontalAlignment = {HorizontalAlignment::left}
VerticalAlignment m_verticalAlignment = {VerticalAlignment::top}
eastl::unique_ptr<SymbolFactory> m_symbolFactory = {}
eastl::vector<Sprite*> m_spriteCache = {}
eastl::string m_utf8Text = {}
eastl::u32string m_utf32Text = {}
bool m_isRichText = {true}