Skip to content

Label

#include <Label.hpp>

Inherits: Widget

A read-only text display widget.

Label displays static text and is not focusable. It’s useful for titles, descriptions, and other informational text. The label automatically sizes itself based on its text.

Example Usage:

auto label = std::make_shared<Label>("Hello, World!");
ReturnNameDescription
LabelCreates an empty label.
Label inline explicitCreates a label with initial text.
voidsetText inlineSets the label’s text.
const std::string &getText const inlineGets the label’s text.
core::Sizemeasure virtualMeasures how much space this widget needs.

Label() = default

Creates an empty label.


inline explicit

inline explicit Label(const std::string & text)

Creates a label with initial text.

  • text The text to display

inline

inline void setText(const std::string & t)

Sets the label’s text.

  • t The new text to display

const inline

inline const std::string & getText() const

Gets the label’s text.

The current text


virtual

virtual core::Size measure(int availW, int availH)

Measures how much space this widget needs.

Called during the measurement pass to determine widget size requirements. Should return the preferred size based on available space.

  • availW Maximum available width (may be ignored by widget)

  • availH Maximum available height (may be ignored by widget)

The Size this widget wants, or needs at minimum

ReturnNameDescription
voiddrawContent virtualDraws this widget’s content.

virtual

virtual void drawContent(backend::Buffer & buf, core::Rect inner)

Draws this widget’s content.

Called by render() after background and borders are drawn. This is where you should draw your widget’s actual content. The inner rectangle accounts for borders and padding.

  • buf The buffer to draw to

  • inner The inner rectangle (excluding border/padding)

ReturnNameDescription
std::stringtext

std::string text