An interactive button widget.
More...
#include <button.h>
|
| | Button () |
| | Default constructor.
|
| |
| void | on_focus_changed (Context &ctx, bool focused) override |
| | Called when focus state changes.
|
| |
| bool | on_event (Context &ctx, const UIEvent &e) override |
| | Handle a UI event.
|
| |
| void | draw (Context &ctx) override |
| | Draw the button.
|
| |
| void | set_texture (const asw::Texture &tex, bool auto_size=false) |
| | Set the texture, optionally resizing the button to match.
|
| |
| void | set_text (const std::string &t, bool auto_size=false) |
| | Set the text, optionally resizing the button to match.
|
| |
| | Widget () |
| | Default constructor for Widget.
|
| |
| virtual | ~Widget ()=default |
| | Default virtual destructor.
|
| |
| | Widget (Widget &&)=default |
| | Move constructor.
|
| |
| Widget & | operator= (Widget &&)=default |
| | Move assignment operator.
|
| |
| | Widget (const Widget &)=delete |
| |
| Widget & | operator= (const Widget &)=delete |
| |
| WidgetId | id () const |
| | Get the unique identifier for this widget.
|
| |
| virtual void | layout (Context &ctx) |
| | Lay out this widget and its children.
|
| |
| template<class T , class... Args> |
| T & | add_child (Args &&... args) |
| | Add a child widget.
|
| |
| bool | is_hovered () const |
| | Whether the pointer is currently over this widget.
|
| |
| bool | is_pressed () const |
| | Whether this widget is currently being pressed.
|
| |
| bool | is_focused () const |
| | Whether this widget currently holds focus.
|
| |
|
| std::function< void()> | on_click |
| | Callback invoked when the button is clicked.
|
| |
| float | padding = 0.0f |
| | Padding applied inside the button on all sides.
|
| |
| asw::Font | font |
| | The font to use for the button text.
|
| |
| std::string | text |
| | The button text.
|
| |
| asw::Texture | texture |
| | The texture to display on the button.
|
| |
| bool | visible = true |
| | Whether the widget is visible.
|
| |
| bool | enabled = true |
| | Whether the widget is enabled.
|
| |
| bool | focusable = false |
| | Whether the widget can receive focus.
|
| |
| Widget * | parent = nullptr |
| | Pointer to the parent widget.
|
| |
| std::vector< std::unique_ptr< Widget > > | children |
| | Child widgets.
|
| |
| asw::Quad< float > | transform |
| | The transform (position and size) of the widget.
|
| |
An interactive button widget.
Definition at line 23 of file button.h.
◆ Button()
| asw::ui::Button::Button |
( |
| ) |
|
|
inline |
Default constructor.
Definition at line 27 of file button.h.
◆ draw()
| void asw::ui::Button::draw |
( |
Context & | ctx | ) |
|
|
overridevirtual |
◆ on_event()
Handle a UI event.
- Parameters
-
| ctx | The UI context. |
| e | The event to handle. |
- Returns
- True if the event was handled.
Reimplemented from asw::ui::Widget.
Definition at line 12 of file button.cpp.
◆ on_focus_changed()
| void asw::ui::Button::on_focus_changed |
( |
Context & | ctx, |
|
|
bool | focused ) |
|
overridevirtual |
Called when focus state changes.
- Parameters
-
| ctx | The UI context. |
| focused | Whether the widget is now focused. |
Reimplemented from asw::ui::Widget.
Definition at line 6 of file button.cpp.
◆ set_text()
| void asw::ui::Button::set_text |
( |
const std::string & | t, |
|
|
bool | auto_size = false ) |
Set the text, optionally resizing the button to match.
- Parameters
-
| t | The text to set. |
| auto_size | If true, resizes the button to fit the text. |
Definition at line 76 of file button.cpp.
◆ set_texture()
| void asw::ui::Button::set_texture |
( |
const asw::Texture & | tex, |
|
|
bool | auto_size = false ) |
Set the texture, optionally resizing the button to match.
- Parameters
-
| tex | The texture to set. |
| auto_size | If true, resizes the button to the texture dimensions. |
Definition at line 67 of file button.cpp.
◆ font
The font to use for the button text.
Definition at line 60 of file button.h.
◆ on_click
| std::function<void()> asw::ui::Button::on_click |
Callback invoked when the button is clicked.
Definition at line 33 of file button.h.
◆ padding
| float asw::ui::Button::padding = 0.0f |
Padding applied inside the button on all sides.
Definition at line 57 of file button.h.
◆ text
| std::string asw::ui::Button::text |
The button text.
Definition at line 63 of file button.h.
◆ texture
The texture to display on the button.
Definition at line 66 of file button.h.
The documentation for this class was generated from the following files: