#ifndef UI_H #define UI_H #include "SDL_events.h" #include "aliases/aliases.h" #include "window.h" #include #define MAX_UI_ELEMENTS 4096 #define BUTTON_WIDTH 100 #define BUTTON_HEIGHT 40 #define NODE_WIDTH 70 #define NODE_HEIGHT 20 typedef enum ui_elem_type ui_elem_type_t; typedef struct ui_elem ui_elem_t; typedef struct ui_ctx ui_ctx_t; enum ui_elem_type { UI_ELEM_NODE, UI_ELEM_BUTTON, COUNT_UI_ELEM, }; struct ui_elem { u64 id; rect_t rect; ui_elem_type_t type; }; struct ui_ctx { u64 count; i64 hovered; i64 active; i64 mouse_x; i64 mouse_y; i64 rel_x; i64 rel_y; bool mouse_down; bool mouse_up; const window_t *wnd; ui_elem_t elements[MAX_UI_ELEMENTS]; }; void reset_ui_ctx(ui_ctx_t *ctx); void handle_ui_events(const window_t *wnd, ui_ctx_t *ctx, const SDL_Event *event); bool button(const window_t *wnd, ui_ctx_t *ctx, rect_t rect); rect_t node(const window_t *wnd, ui_ctx_t *ctx, rect_t rect); #endif // !UI_H