|
ASW Lib
A.D.S. Games SDL Wrapper Library. A library targeted at Allegro4 users who want to switch to SDL3 and use modern c++.
|
A text input widget. More...
#include <input_box.h>
Public Member Functions | |
| InputBox () | |
| 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 input box. | |
Public Member Functions inherited from asw::ui::Widget | |
| 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. | |
Public Attributes | |
| std::function< void(const std::string &)> | on_change |
| Callback invoked when the value changes. | |
| asw::Font | font |
| The font to use for the input text. | |
| std::string | value |
| The current text value. | |
| std::string | placeholder |
| Placeholder text shown when value is empty. | |
Public Attributes inherited from asw::ui::Widget | |
| 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. | |
Private Attributes | |
| bool | hovered_ = false |
| bool | focused_ = false |
| std::size_t | cursor_pos_ = 0 |
A text input widget.
Definition at line 23 of file input_box.h.
|
inline |
Default constructor.
Definition at line 27 of file input_box.h.
|
overridevirtual |
Draw the input box.
| ctx | The UI context. |
Reimplemented from asw::ui::Widget.
Definition at line 113 of file input_box.cpp.
Handle a UI event.
| ctx | The UI context. |
| e | The event to handle. |
Reimplemented from asw::ui::Widget.
Definition at line 23 of file input_box.cpp.
|
overridevirtual |
Called when focus state changes.
| ctx | The UI context. |
| focused | Whether the widget is now focused. |
Reimplemented from asw::ui::Widget.
Definition at line 10 of file input_box.cpp.
|
private |
Definition at line 68 of file input_box.h.
|
private |
Definition at line 67 of file input_box.h.
| asw::Font asw::ui::InputBox::font |
The font to use for the input text.
Definition at line 57 of file input_box.h.
|
private |
Definition at line 66 of file input_box.h.
| std::function<void(const std::string&)> asw::ui::InputBox::on_change |
Callback invoked when the value changes.
Definition at line 33 of file input_box.h.
| std::string asw::ui::InputBox::placeholder |
Placeholder text shown when value is empty.
Definition at line 63 of file input_box.h.
| std::string asw::ui::InputBox::value |
The current text value.
Definition at line 60 of file input_box.h.