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++.
Loading...
Searching...
No Matches
include
asw
modules
ui
input_box.h
Go to the documentation of this file.
1
8
9
#ifndef ASW_MODULES_UI_INPUT_BOX_H
10
#define ASW_MODULES_UI_INPUT_BOX_H
11
12
#include <functional>
13
#include <string>
14
15
#include "
../types.h
"
16
#include "
context.h
"
17
#include "
widget.h
"
18
19
namespace
asw::ui
{
20
23
class
InputBox
:
public
Widget
{
24
public
:
27
InputBox
()
28
{
29
focusable
=
true
;
30
}
31
33
std::function<void(
const
std::string&)>
on_change
;
34
40
void
on_focus_changed
(
Context
& ctx,
bool
focused)
override
;
41
48
bool
on_event
(
Context
& ctx,
const
UIEvent
& e)
override
;
49
54
void
draw
(
Context
& ctx)
override
;
55
57
asw::Font
font
;
58
60
std::string
value
;
61
63
std::string
placeholder
;
64
65
private
:
66
bool
hovered_
=
false
;
67
bool
focused_
=
false
;
68
std::size_t
cursor_pos_
= 0;
69
};
70
71
}
// namespace asw::ui
72
73
#endif
// ASW_MODULES_UI_INPUT_BOX_H
asw::ui::Context
Shared state for the UI system.
Definition
context.h:75
asw::ui::InputBox
A text input widget.
Definition
input_box.h:23
asw::ui::InputBox::font
asw::Font font
The font to use for the input text.
Definition
input_box.h:57
asw::ui::InputBox::hovered_
bool hovered_
Definition
input_box.h:66
asw::ui::InputBox::draw
void draw(Context &ctx) override
Draw the input box.
Definition
input_box.cpp:113
asw::ui::InputBox::on_focus_changed
void on_focus_changed(Context &ctx, bool focused) override
Called when focus state changes.
Definition
input_box.cpp:10
asw::ui::InputBox::cursor_pos_
std::size_t cursor_pos_
Definition
input_box.h:68
asw::ui::InputBox::InputBox
InputBox()
Default constructor.
Definition
input_box.h:27
asw::ui::InputBox::on_change
std::function< void(const std::string &)> on_change
Callback invoked when the value changes.
Definition
input_box.h:33
asw::ui::InputBox::placeholder
std::string placeholder
Placeholder text shown when value is empty.
Definition
input_box.h:63
asw::ui::InputBox::on_event
bool on_event(Context &ctx, const UIEvent &e) override
Handle a UI event.
Definition
input_box.cpp:23
asw::ui::InputBox::focused_
bool focused_
Definition
input_box.h:67
asw::ui::InputBox::value
std::string value
The current text value.
Definition
input_box.h:60
asw::ui::Widget
Base class for all UI widgets.
Definition
widget.h:28
asw::ui::Widget::focusable
bool focusable
Whether the widget can receive focus.
Definition
widget.h:66
context.h
UI context and focus management for the ASW UI module.
asw::ui
Definition
button.h:19
asw::Font
std::shared_ptr< TTF_Font > Font
Alias for a shared pointer to an TTF_Font.
Definition
types.h:41
asw::ui::UIEvent
Event structure for UI interactions.
Definition
event.h:21
types.h
Types used throughout the ASW library.
widget.h
Base widget class for the ASW UI module.
Generated by
1.12.0