#include static void draw_if_true( daguerre::hilbert_color &out, const bool &in, const daguerre::hilbert_color ¶m) { if (in) out = param; } namespace pake::widgets { fixed_text::fixed_text( std::string &&text, const daguerre::fixed_font *font, daguerre::hilbert_color bg, daguerre::hilbert_color fg) : font(font), bg(bg), fg(fg), text(std::move(text)) {} void fixed_text::render( dirtiable_image &onto, int x_off, int y_off, bool force) { if (force) { onto.image.fill( bg, x_off, y_off, width, height); onto.dirty.fill(true, x_off, y_off, width, height); //TODO: have options for alignment //TODO: check overflow onto.image.render_text( *font, fg, x_off, y_off, text.data(), draw_if_true); onto.dirty.fill( true, x_off, y_off, font->glyph_width * text.size(), font->glyph_height); } } void fixed_text::notify_size(int width, int height) { this->width = width; this->height = height; } }