summaryrefslogtreecommitdiff
path: root/gui.h
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2024-08-03 16:15:02 +1000
committerquou <quou@disroot.org>2024-08-03 16:15:02 +1000
commit496db167337e246cc12beb1ace2bdec35b916479 (patch)
treec3235b99c1605f62b29bf1b4d8e36133d9f64c4b /gui.h
parentee3406af08853b0ffb30efd203a373460300077f (diff)
scrollbars
Diffstat (limited to 'gui.h')
-rw-r--r--gui.h23
1 files changed, 22 insertions, 1 deletions
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