#include #include "ui.h" #include "font.h" #include "render.h" #include "microui.h" extern mu_Context *mu_ctx; #define UNPACK_COLOR(c) (c).r, (c).g, (c).b, (c).a #define UNPACK_RECT(r) (r).x, (r).y, (r).w, (r).h void ui_draw(void) { static int warned = 0; mu_Command *cmd = NULL; while (mu_next_command(mu_ctx, &cmd)) switch (cmd->type) { case MU_COMMAND_TEXT: font_set_color(UNPACK_COLOR(cmd->text.color)); font_draw(cmd->text.pos.x, cmd->text.pos.y, cmd->text.str); break; case MU_COMMAND_RECT: r_draw_set_color(UNPACK_COLOR(cmd->rect.color)); r_draw_fill_rect(UNPACK_RECT(cmd->rect.rect)); break; case MU_COMMAND_CLIP: r_set_clip_rect(UNPACK_RECT(cmd->clip.rect)); break; default: if (!warned) { fprintf(stderr, "unsupported MU command: %d\n", cmd->type); warned = 1; } break; } r_reset_clip_rect(); }