diff options
author | quou <quou@disroot.org> | 2024-07-31 22:12:48 +1000 |
---|---|---|
committer | quou <quou@disroot.org> | 2024-07-31 22:12:48 +1000 |
commit | 205f7d49530e6c32ec0a09045d9cb45dcf9b1752 (patch) | |
tree | e1d3432a677ff3511ed191aabfde6cf240f784b7 /gui.h | |
parent | 8d729883b3e134df8b9fc10f094df9fc3618bdb4 (diff) |
GUI + map editor beginnings
Diffstat (limited to 'gui.h')
-rw-r--r-- | gui.h | 70 |
1 files changed, 70 insertions, 0 deletions
@@ -0,0 +1,70 @@ +#ifndef gui_h +#define gui_h + +#include "rect.h" + +struct App; +struct Arena; +struct GUI; +struct Renderer; + +typedef enum { + gui_el_type_btn, + gui_el_type_scrollable +} GUI_El_Type; + +typedef struct GUI_El { + GUI_El_Type type; + struct GUI_El* next; + Rect r; +} GUI_El; + +typedef struct { + GUI_El el; + char* text; + int hover, active; +} GUI_Btn; + +typedef struct { + int x, y; +} GUI_Scroll_State; + +typedef void (*GUI_Scrollable_Draw_Fn)( + struct GUI*, + struct Renderer*, + const Rect*, + const GUI_Scroll_State* +); + +typedef struct { + GUI_El el; + GUI_Scrollable_Draw_Fn draw; + GUI_Scroll_State* ss; +} GUI_Scrollable; + +typedef struct GUI { + const struct App* app; + struct Arena* a; + GUI_El* first, * prev; + int cursor[2], pad; +} GUI; + +int gui_text_width(const char* text, int len); +int gui_text_height(void); + +void gui_begin(GUI* g, const struct App* app, struct Arena* a); +void gui_end(GUI* g, struct Renderer* r); +Rect gui_viewport(GUI* g); +Rect gui_cut_left(Rect* a, int v); +Rect gui_cut_right(Rect* a, int v); +Rect gui_cut_down(Rect* a, int v); +Rect gui_cut_up(Rect* a, int v); +int gui_btn(GUI* g, Rect r, const char* text); +void gui_scrollable( + GUI* g, + Rect r, + GUI_Scroll_State* state, + GUI_Scrollable_Draw_Fn fn +); + +#endif |