From 496db167337e246cc12beb1ace2bdec35b916479 Mon Sep 17 00:00:00 2001 From: quou Date: Sat, 3 Aug 2024 16:15:02 +1000 Subject: scrollbars --- gui.h | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'gui.h') diff --git a/gui.h b/gui.h index 50927f4..5b3063b 100644 --- a/gui.h +++ b/gui.h @@ -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 -- cgit v1.2.3-54-g00ecf