diff options
Diffstat (limited to 'render/button.c')
-rw-r--r-- | render/button.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/render/button.c b/render/button.c new file mode 100644 index 0000000..eb96f59 --- /dev/null +++ b/render/button.c @@ -0,0 +1,21 @@ +#include <stdlib.h> +#include <stdio.h> +#include <button.h> + +#include <intersect.h> + +bool mouse_in_button (float pt[], txtd *t, button *b) { + int width = get_text_width(b->txt, t); + float size[2] = { width+b->pad*2, 10+b->pad*2 }; + if (pt_rect(pt, b->pos, size)) return true; + return false; +} + +void render_button (SDL_Renderer* rend, txtd *t, button *b) { + int width = get_text_width(b->txt, t); + SDL_Rect rect = { b->pos[0], b->pos[1], width+b->pad*2, 10+b->pad*2 }; + SDL_SetRenderDrawColor(rend, 0, 0, 0, 255); + SDL_RenderDrawRect(rend, &rect); + float offpad[2] = { b->pos[0]+b->pad, b->pos[1]+b->pad }; + render_text(rend, b->txt, offpad, t); +}
\ No newline at end of file |