42 const bool wasPressed = pressed_;
47 if (wasPressed && in) {
72 }
else if (pressed_) {
74 }
else if (hovered_) {
80 if (!text.empty() && font !=
nullptr) {
83 = transform.get_center() -
asw::Vec2<float>(text_size.x / 2.0f, text_size.y / 2.0f);
Shared state for the UI system.
Widget * pointer_capture
The widget that has captured pointer input.
FocusManager focus
The focus manager.
Theme theme
The current UI theme.
void set_focus(Context &ctx, Widget *w)
Set focus to a specific widget.
Routines for drawing sprites and primitives to the screen.
void text(const asw::Font &font, const std::string &text, const asw::Vec2< float > &position, asw::Color color, asw::TextJustify justify=asw::TextJustify::Left)
Draw text.
void rect(const asw::Quad< float > &position, asw::Color color)
Draw a rectangle.
void rect_fill(const asw::Quad< float > &position, asw::Color color)
Draw a filled rectangle.
asw::Vec2< int > get_text_size(const asw::Font &font, const std::string &text)
Get text size.
RGBA color struct with 8-bit channels.
asw::Color text
Default text color.
bool show_focus
Show focus rings around focused widgets. Enabled by default when using keyboard navigation.
asw::Color panel_bg
Panel background color.
asw::Color btn_pressed
Button pressed color.
asw::Color btn_focus_ring
Button focus ring color.
asw::Color btn_hover
Button hover color.
asw::Color btn_bg
Button background color.
Event structure for UI interactions.
asw::Vec2< float > pointer_pos
The pointer position.
Type type
The type of the event.
General utility functions.