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

Button widget.

Base classes

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

Constructors, destructors, conversion operators

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

Public functions

auto style() const -> ButtonStyle
Style.
void setStyle(ButtonStyle style)
Set style.
auto icon() const -> Icon
Icon.
void setIcon(Icon icon)
Set icon.
void setText(Containers::StringView text, const TextProperties& textProperties = {})
Set text.
auto backgroundData() const -> DataHandle
Background data.
auto iconData() const -> DataHandle
Icon data or DataHandle::Null.
auto textData() const -> DataHandle
Text data or DataHandle::Null.

Function documentation

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

Construct an icon button.

Parameters
anchor Positioning anchor
icon Button icon. Passing Icon::None makes the button empty.
style Button style

The button can be subsequently converted to text-only or icon + text using setIcon() and setText().

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

Construct a text button.

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

The button can be subsequently converted to icon-only or icon + text using setIcon() and setText().

Magnum::Ui::Button::Button(const Anchor& anchor, Containers::StringView text, ButtonStyle style = ButtonStyle::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::Button::Button(const Anchor& anchor, Icon icon, Containers::StringView text, const TextProperties& textProperties, ButtonStyle style = ButtonStyle::Default) explicit

Construct an icon + text button.

Parameters
anchor Positioning anchor
icon Button icon. Passing Icon::None creates the button without an icon.
text Button text. Passing an empty string creates the button without a text.
textProperties Text shaping and layouting properties
style Button style

The button can be subsequently converted to icon-only or text-only using setIcon() and setText().

Magnum::Ui::Button::Button(const Anchor& anchor, Icon icon, Containers::StringView text, ButtonStyle style = ButtonStyle::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::Button::Button(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.

void Magnum::Ui::Button::setStyle(ButtonStyle style)

Set style.

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.

void Magnum::Ui::Button::setIcon(Icon icon)

Set icon.

Passing Icon::None removes the icon.

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

Set text.

Passing an empty text removes the text.

DataHandle Magnum::Ui::Button::backgroundData() const

Background data.

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

DataHandle Magnum::Ui::Button::iconData() const

Icon data or DataHandle::Null.

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

DataHandle Magnum::Ui::Button::textData() const

Text data or DataHandle::Null.

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