Magnum::Ui::Label class

Label widget.

Just a text with no interactivity.

Styling

Ignores StateFlag::Hovered, StateFlag::Pressed and StateFlag::Active, Style::Flat.

Base classes

class Widget
Base for widgets.

Constructors, destructors, conversion operators

Label(Plane& plane, const Anchor& anchor, const std::string& text, Text::Alignment alignment, std::size_t capacity = 0, Style style = Style::Default) explicit
Label.
Label(Plane& plane, const Anchor& anchor, const std::string& text, Text::Alignment alignment, Style style) explicit
template<std::size_t size>
Label(Plane& plane, const Anchor& anchor, const char(&text)[size], Text::Alignment alignment, std::size_t capacity = 0, Style style = Style::Default) explicit
template<std::size_t size>
Label(Plane& plane, const Anchor& anchor, const char(&text)[size], Text::Alignment alignment, Style style) explicit
Label(Plane& plane, const Anchor& anchor, Containers::ArrayView<const char> text, Text::Alignment alignment, std::size_t capacity = 0, Style style = Style::Default) explicit
Label(Plane& plane, const Anchor& anchor, Containers::ArrayView<const char> text, Text::Alignment alignment, Style style = Style::Default) explicit

Public functions

auto setStyle(Style style) -> Label&
Set widget style.
auto setText(const std::string& text) -> Label&
Set text.
auto setText(Containers::ArrayView<const char> text) -> Label&
template<std::size_t size>
auto setText(const char(&text)[size]) -> Label&

Private functions

void update() override virtual
Update the widget after its state changed.

Function documentation

Magnum::Ui::Label::Label(Plane& plane, const Anchor& anchor, const std::string& text, Text::Alignment alignment, std::size_t capacity = 0, Style style = Style::Default) explicit

Label.

Parameters
plane Plane this widget is a part of
anchor Positioning anchor
text Label text
alignment Label text alignment
capacity Label text capacity (see setText())
style Widget style

Magnum::Ui::Label::Label(Plane& plane, const Anchor& anchor, const std::string& text, Text::Alignment alignment, Style style) explicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<std::size_t size>
Magnum::Ui::Label::Label(Plane& plane, const Anchor& anchor, const char(&text)[size], Text::Alignment alignment, std::size_t capacity = 0, Style style = Style::Default) explicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<std::size_t size>
Magnum::Ui::Label::Label(Plane& plane, const Anchor& anchor, const char(&text)[size], Text::Alignment alignment, Style style) explicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Magnum::Ui::Label::Label(Plane& plane, const Anchor& anchor, Containers::ArrayView<const char> text, Text::Alignment alignment, std::size_t capacity = 0, Style style = Style::Default) explicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Magnum::Ui::Label::Label(Plane& plane, const Anchor& anchor, Containers::ArrayView<const char> text, Text::Alignment alignment, Style style = Style::Default) explicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Label& Magnum::Ui::Label::setStyle(Style style)

Set widget style.

Returns Reference to self (for method chaining)

Label& Magnum::Ui::Label::setText(const std::string& text)

Set text.

Returns Reference to self (for method chaining)

The text is expected to not exceed the capacity defined in the constructor.

Label& Magnum::Ui::Label::setText(Containers::ArrayView<const char> text)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<std::size_t size>
Label& Magnum::Ui::Label::setText(const char(&text)[size])

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void Magnum::Ui::Label::update() override virtual private

Update the widget after its state changed.

Expects to do only visual update, should not do any expensive operations like text relayouting.