diff options
author | quou <quou@disroot.org> | 2024-08-03 16:15:02 +1000 |
---|---|---|
committer | quou <quou@disroot.org> | 2024-08-03 16:15:02 +1000 |
commit | 496db167337e246cc12beb1ace2bdec35b916479 (patch) | |
tree | c3235b99c1605f62b29bf1b4d8e36133d9f64c4b /gui.h | |
parent | ee3406af08853b0ffb30efd203a373460300077f (diff) |
scrollbars
Diffstat (limited to 'gui.h')
-rw-r--r-- | gui.h | 23 |
1 files changed, 22 insertions, 1 deletions
@@ -10,7 +10,8 @@ struct Renderer; typedef enum { gui_el_type_btn, - gui_el_type_scrollable + gui_el_type_scrollable, + gui_el_type_scrollbar } GUI_El_Type; typedef struct GUI_El { @@ -27,8 +28,18 @@ typedef struct { typedef struct { int x, y; + short grabbed[2]; + short graboff[2]; } GUI_Scroll_State; +typedef struct { + GUI_El el; + GUI_Scroll_State* s; + Rect handle; + int h; + int hover, active; +} GUI_Scrollbar; + typedef void (*GUI_Scrollable_Draw_Fn)( struct GUI*, struct Renderer*, @@ -40,6 +51,8 @@ typedef struct { GUI_El el; GUI_Scrollable_Draw_Fn draw; GUI_Scroll_State* ss; + int cs[2]; + int vp[2]; } GUI_Scrollable; typedef struct GUI { @@ -63,8 +76,16 @@ int gui_btn(GUI* g, Rect r, const char* text); void gui_scrollable( GUI* g, Rect r, + const int* cs, GUI_Scroll_State* state, GUI_Scrollable_Draw_Fn fn ); +void gui_scrollbar( + GUI* g, + GUI_Scroll_State* state, + Rect r, + int diff, + int horizontal +); #endif |