From 92978a10576d52a0f6c9983d3b6afae7c40eff40 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Thu, 12 Mar 2026 15:29:23 -0700 Subject: Support scrolling by dragging scrollbars --- src/uiLibrary.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/uiLibrary.h') diff --git a/src/uiLibrary.h b/src/uiLibrary.h index 98719d7..f6faf01 100644 --- a/src/uiLibrary.h +++ b/src/uiLibrary.h @@ -6,8 +6,31 @@ #include +#ifndef NDEBUG +#include +#define UI_LOG(...) printf("[ui] " __VA_ARGS__ "\n") +#else +#define UI_LOG +#endif + +/// Input handling of scrollbars. +typedef struct uiScrollState { + int scrollbar_handle_y_start; // y-coordinate of the scrollbar handle at the + // start of the scroll. + int table_offset_start; // Row offset of a table at the start of the scroll. + bool scrolling; // Whether a scrollbar is being dragged. +} uiScrollState; + +/// Input handling of mouse-down events. +typedef struct uiMouseDownState { + uiPtr widget; // The widget currently processing a mouse down event. + uiPoint start_point; // Mouse position when the mouse went down. +} uiMouseDownState; + typedef struct uiLibrary { FontAtlas* font; + uiScrollState scroll; + uiMouseDownState mouse_down; uiMouseButtonState mouse_button_state[uiMouseButtonMax]; uiWidgetEvent widget_events[MaxWidgetEvents]; int num_widget_events; -- cgit v1.2.3