Magnum::Ui::Widget class

Base for widgets.

Derived classes

class Button
Button widget.
class Input
Input widget.
class Label
Label widget.
class Modal
Modal widget.

Public static functions

static void disable(std::initializer_list<Containers::Reference<Widget>> widgets)
Disable a set of widgets.
static void enable(std::initializer_list<Containers::Reference<Widget>> widgets)
Enable a set of widgets.
static void setEnabled(bool enabled, std::initializer_list<Containers::Reference<Widget>> widgets)
Enable or disable a set of widgets.
static void hide(std::initializer_list<Containers::Reference<Widget>> widgets)
Hide a set of widgets.
static void show(std::initializer_list<Containers::Reference<Widget>> widgets)
Show a set of widgets.
static void setVisible(bool visible, std::initializer_list<Containers::Reference<Widget>> widgets)
Set a set of widgets visible.

Constructors, destructors, conversion operators

Widget(AbstractPlane& plane, const Anchor& anchor, const Range2D& padding = {}) explicit
Constructor.

Public functions

auto rect() const -> Range2D
Widget rectangle.
auto padding() const -> Range2D
Padding for widgets inside.
auto flags() const -> WidgetFlags
Flags.
auto disable() -> Widget&
Disable widget.
auto enable() -> Widget&
Enable widget.
auto setEnabled(bool enabled) -> Widget&
Enable or disable widget.
auto hide() -> Widget&
Hide widget.
auto show() -> Widget&
Show widget.
auto setVisible(bool visible) -> Widget&
Set widget visible.

Protected functions

auto plane() -> AbstractPlane&
Plane this widget is a part of.
auto plane() const -> const AbstractPlane&
void update() virtual
Update the widget after its state changed.
auto hoverEvent() -> bool virtual
Hover event.
auto pressEvent() -> bool virtual
Press event.
auto releaseEvent() -> bool virtual
Release event.
auto focusEvent() -> bool virtual
Focus event.
auto blurEvent() -> bool virtual
Blur event.

Function documentation

static void Magnum::Ui::Widget::disable(std::initializer_list<Containers::Reference<Widget>> widgets)

Disable a set of widgets.

Convenience batch alternative to disable().

static void Magnum::Ui::Widget::enable(std::initializer_list<Containers::Reference<Widget>> widgets)

Enable a set of widgets.

Convenience batch alternative to enable().

static void Magnum::Ui::Widget::setEnabled(bool enabled, std::initializer_list<Containers::Reference<Widget>> widgets)

Enable or disable a set of widgets.

Convenience batch alternative to setEnabled().

static void Magnum::Ui::Widget::hide(std::initializer_list<Containers::Reference<Widget>> widgets)

Hide a set of widgets.

Convenience batch alternative to hide().

static void Magnum::Ui::Widget::show(std::initializer_list<Containers::Reference<Widget>> widgets)

Show a set of widgets.

Convenience batch alternative to show().

static void Magnum::Ui::Widget::setVisible(bool visible, std::initializer_list<Containers::Reference<Widget>> widgets)

Set a set of widgets visible.

Convenience batch alternative to setVisible().

Magnum::Ui::Widget::Widget(AbstractPlane& plane, const Anchor& anchor, const Range2D& padding = {}) explicit

Constructor.

Parameters
plane Plane this widget is a part of
anchor Positioning anchor
padding Padding for widgets inside

Widget& Magnum::Ui::Widget::disable()

Disable widget.

Returns Reference to self (for method chaining)

Disabled widget does not receive any input events until it is enabled again using enable().

Widget& Magnum::Ui::Widget::enable()

Enable widget.

Returns Reference to self (for method chaining)

Enables the widget again after it was disabled using disable().

Widget& Magnum::Ui::Widget::setEnabled(bool enabled)

Enable or disable widget.

Returns Reference to self (for method chaining)

Widget& Magnum::Ui::Widget::hide()

Hide widget.

Returns Reference to self (for method chaining)

Hidden widget is not visible and doesn't receive any input events until it is shown again using show().

Widget& Magnum::Ui::Widget::show()

Show widget.

Returns Reference to self (for method chaining)

Shows the widget again after it was hidden using hide().

Widget& Magnum::Ui::Widget::setVisible(bool visible)

Set widget visible.

Returns Reference to self (for method chaining)

const AbstractPlane& Magnum::Ui::Widget::plane() const protected

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::Widget::update() virtual protected

Update the widget after its state changed.

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

bool Magnum::Ui::Widget::hoverEvent() virtual protected

Hover event.

Returns True if the event was accepted, false if it was ignored

Called when the widget is hovered by the mouse or when the mouse leaves it again. Use Flag::Hovered to check for the state. Default implementation does nothing and returns false.

bool Magnum::Ui::Widget::pressEvent() virtual protected

Press event.

Returns True if the event was accepted, false if it was ignored

When the widget is pressed, Flag::Pressed is set and this function is called. Default implementation does nothing and returns false.

bool Magnum::Ui::Widget::releaseEvent() virtual protected

Release event.

Returns True if the event was accepted, false if it was ignored

On release after previous press event, Flag::Pressed flag is removed and this function is called. Default implementation does nothing and returns false.

bool Magnum::Ui::Widget::focusEvent() virtual protected

Focus event.

Returns True if the event was accepted, false if it was ignored

If both press and release event happened on the same widget, Flag::Active is set and this function is called. Default implementation does nothing and returns false.

bool Magnum::Ui::Widget::blurEvent() virtual protected

Blur event.

Returns True if the event was accepted, false if it was ignored

If the widget was active previously and the user tapped outside, Flag::Active is removed and this function is called. Default implementation does nothing and returns false.