class new in Git master
#include <Magnum/Ui/Button.h>
Button 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.
- auto setStyle(ButtonStyle style) -> Button&
- Set style.
- auto icon() const -> Icon
- Icon.
- auto setIcon(Icon icon) -> Button&
- Set icon.
-
auto setText(Containers::
StringView text, const TextProperties& textProperties = {}) -> Button& - 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:: |
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:: |
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.
Button& Magnum:: Ui:: Button:: setStyle(ButtonStyle 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.
Button& Magnum:: Ui:: Button:: setIcon(Icon icon)
Set icon.
Returns | Reference to self (for method chaining) |
---|
Passing Icon::
Button& Magnum:: Ui:: Button:: setText(Containers:: StringView text,
const TextProperties& textProperties = {})
Set text.
Returns | Reference to self (for method chaining) |
---|
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::
Exposed mainly for testing purposes, not meant to be modified directly.
DataHandle Magnum:: Ui:: Button:: textData() const
Text data or DataHandle::
Exposed mainly for testing purposes, not meant to be modified directly.