From d3c4d4dfb28a518bff924764e74ca4ededf1bd41 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Thu, 12 Mar 2026 15:30:15 -0700 Subject: Support for scrolling by dragging scrollbars --- src/xplorer.c | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/xplorer.c b/src/xplorer.c index c03a16e..6dd1bbf 100644 --- a/src/xplorer.c +++ b/src/xplorer.c @@ -10,6 +10,7 @@ #include #include +// TODO: Set window dimensions and font size based on pixel area density. static const char* WindowTitle = "XPLORER"; static const int DefaultWidth = 720; static const int DefaultHeight = 450; @@ -34,6 +35,9 @@ uiMouseButton ToUiButton(Uint8 button); void MouseCoordsToUiCoords( SDL_Window*, float mouse_x, float mouse_y, int* x, int* y); +uiMouseButtonState MouseButtonStateFromFlags( + SDL_MouseButtonFlags flags, uiMouseButton button); + void CreateUi(State* state) { assert(state); @@ -345,7 +349,7 @@ int main( .type = uiEventMouseButton, .mouse_button = (uiMouseButtonEvent){.button = ToUiButton(event.button.button), - .state = uiMouseDown, + .button_state = uiMouseDown, .mouse_position = (uiPoint){x, y}} }; redraw = uiSendEvent(state.frame, &ui_event); @@ -357,7 +361,7 @@ int main( .type = uiEventMouseButton, .mouse_button = (uiMouseButtonEvent){.button = ToUiButton(event.button.button), - .state = uiMouseUp, + .button_state = uiMouseUp, .mouse_position = (uiPoint){x, y}} }; redraw = uiSendEvent(state.frame, &ev); @@ -365,6 +369,11 @@ int main( int x, y; MouseCoordsToUiCoords( state.window, event.wheel.mouse_x, event.wheel.mouse_y, &x, &y); + // TODO: Scrolling on a trackpad results in 0