18 transform.size = {
static_cast<float>(size.x),
static_cast<float>(size.y) };
23 if (
const auto& f =
pick_font(font, ctx.
theme); !text.empty() && f !=
nullptr) {
26 auto position = transform.position;
27 if (_fit_text || transform.size.x > 0.0F) {
29 position.x += transform.size.x / 2.0F;
31 position.x += transform.size.x;
Shared state for the UI system.
Theme theme
The current UI theme.
void draw(Context &ctx) override
Draw the label.
void measure(Context &ctx) override
Size to the text if set_text asked for it.
std::string text
The text to display.
void set_text(const std::string &t, bool auto_size=false)
Set the text, optionally sizing the label to fit it, so layouts such as VBox and Modal give it room.
Routines for drawing sprites and primitives to the screen.
Label widget for the ASW UI module.
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. The position is rounded to whole pixels after justification so glyphs stay sharp....
const asw::Font & pick_font(const asw::Font &own, const Theme &theme)
The font a widget draws with: its own, or the theme font.
asw::Vec2< int > get_text_size(const asw::Font &font, std::string_view text)
Get text size.
asw::Color text
Default text color.
General utility functions.