Magnum::Ui::Label class new in Git master

Label widget.

Base classes

template<class UserInterface>
class BasicWidget<UserInterface> new in Git master
Templated abstract base for stateful widgets.

Constructors, destructors, conversion operators

Label(const Anchor& anchor, Icon icon, LabelStyle style = LabelStyle::Default) explicit
Construct an icon label.
Label(const Anchor& anchor, Containers::StringView text, const TextProperties& textProperties, LabelStyle style = LabelStyle::Default) explicit
Construct a text label.
Label(const Anchor& anchor, Containers::StringView text, LabelStyle style = LabelStyle::Default) explicit
Label(NoCreateT, UserInterface& ui) explicit
Construct with no underlying node.

Public functions

auto style() const -> LabelStyle
Style.
auto setStyle(LabelStyle style) -> Label&
Set style.
auto icon() const -> Icon
Icon.
auto setIcon(Icon icon) -> Label&
Set icon.
auto setText(Containers::StringView text, const TextProperties& textProperties = {}) -> Label&
Set text.
auto data() const -> DataHandle
Icon / text data or DataHandle::Null.

Function documentation

Magnum::Ui::Label::Label(const Anchor& anchor, Icon icon, LabelStyle style = LabelStyle::Default) explicit

Construct an icon label.

Parameters
anchor Positioning anchor
icon Label icon. Passing Icon::None makes the label empty.
style Label style

The label can be subsequently converted to a text label using setText().

Magnum::Ui::Label::Label(const Anchor& anchor, Containers::StringView text, const TextProperties& textProperties, LabelStyle style = LabelStyle::Default) explicit

Construct a text label.

Parameters
anchor Positioning anchor
text Label text. Passing an empty string makes the label empty.
textProperties Text shaping and layouting properties
style Label style

The label can be subsequently converted to an icon label using setIcon().

Magnum::Ui::Label::Label(const Anchor& anchor, Containers::StringView text, LabelStyle style = LabelStyle::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(NoCreateT, UserInterface& ui) explicit

Construct with no underlying node.

The instance is equivalent to a moved-out state, i.e. not usable for anything. Move another instance over it to make it useful.

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

Set style.

Returns Reference to self (for method chaining)

Note that calling this function doesn't change the font if the new style uses a different one, you have to call setText() afterwards to make it pick it up.

Icon Magnum::Ui::Label::icon() const

Icon.

If the label is text-only or has neither an icon nor a text, returns Icon::None.

Label& Magnum::Ui::Label::setIcon(Icon icon)

Set icon.

Returns Reference to self (for method chaining)

If the label had a text before, it's replaced with the icon. Passing Icon::None makes the label empty.

Label& Magnum::Ui::Label::setText(Containers::StringView text, const TextProperties& textProperties = {})

Set text.

Returns Reference to self (for method chaining)

If the label had an icon before, it's replaced with a text. Passing an empty text makes the label empty.

DataHandle Magnum::Ui::Label::data() const

Icon / text data or DataHandle::Null.

Exposed mainly for testing purposes, not meant to be modified directly.