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!");Public Methods
Section titled “Public Methods”| Return | Name | Description |
|---|---|---|
Label | Creates an empty label. | |
Label inline explicit | Creates a label with initial text. | |
void | setText inline | Sets the label’s text. |
const std::string & | getText const inline | Gets the label’s text. |
core::Size | measure virtual | Measures how much space this widget needs. |
Label() = defaultCreates an empty label.
inline explicit
inline explicit Label(const std::string & text)Creates a label with initial text.
Parameters
Section titled “Parameters”textThe text to display
setText
Section titled “setText”inline
inline void setText(const std::string & t)Sets the label’s text.
Parameters
Section titled “Parameters”tThe new text to display
getText
Section titled “getText”const inline
inline const std::string & getText() constGets the label’s text.
Returns
Section titled “Returns”The current text
measure
Section titled “measure”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.
Parameters
Section titled “Parameters”-
availWMaximum available width (may be ignored by widget) -
availHMaximum available height (may be ignored by widget)
Returns
Section titled “Returns”The Size this widget wants, or needs at minimum
Protected Methods
Section titled “Protected Methods”| Return | Name | Description |
|---|---|---|
void | drawContent virtual | Draws this widget’s content. |
drawContent
Section titled “drawContent”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.
Parameters
Section titled “Parameters”-
bufThe buffer to draw to -
innerThe inner rectangle (excluding border/padding)
Private Attributes
Section titled “Private Attributes”| Return | Name | Description |
|---|---|---|
std::string | text |
std::string text