9#ifndef ASW_MODULES_UI_MODAL_H
10#define ASW_MODULES_UI_MODAL_H
45 std::optional<ModalStyle>
style;
102 void draw(
Context& ctx)
override;
Shared state for the UI system.
A box over the rest of the UI that has to be dealt with first, e.g. a question or a login code.
std::optional< ModalStyle > style
Style for this modal only. Uses the theme modal style when empty.
bool on_event(Context &ctx, const UIEvent &e) override
Close on back.
Button & add_button(const std::string &text, std::function< void()> on_click)
Add a button, sized to its text.
bool closed() const
True once closed.
std::function< void()> on_close
Called once when the modal closes, from close() or back.
void measure(Context &ctx) override
Size to the children, at least the style's min_width.
Label & add_text(const std::string &text, const asw::Font &font=nullptr)
Add a line of text, sized to fit.
bool close_on_back
Close back when pressed. Turn off for a modal the player must answer with one of its buttons.
void close()
Close the modal. Calls on_close, then takes it off the screen. Safe to call from its own buttons or f...
Modal()
Default constructor.
const ModalStyle & get_style(const Context &ctx) const
Get the style this modal draws with.
Places children one after another, top to bottom or left to right.
Label widget for the ASW UI module.
Layout widgets for the ASW UI module.
std::shared_ptr< TTF_Font > Font
Alias for a shared pointer to an TTF_Font.
Look of a Modal and the dimmed screen behind it.
Event structure for UI interactions.
UI theme configuration for the ASW UI module.