From 8536d6b60bc9d2600838e19ab12020bedd1851f1 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Sun, 5 Apr 2026 10:51:06 -0700 Subject: Toolbar WIP --- src/xplorer.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/xplorer.c b/src/xplorer.c index da66f0d..ff98b2c 100644 --- a/src/xplorer.c +++ b/src/xplorer.c @@ -41,15 +41,21 @@ uiMouseButtonState MouseButtonStateFromFlags( void CreateUi(State* state) { assert(state); - uiFrame* frame = uiMakeFrame(); + uiFrame* frame = uiMakeFrame(); + uiLayout* main_layout = uiMakeLayout(uiMakeFramePtr(frame), uiVertical); + + uiLayout* toolbar = uiMakeLayout(uiMakeLayoutPtr(main_layout), uiHorizontal); + uiButton* button_back = uiMakeButton( + uiMakeLayoutPtr(toolbar), "<", &(uiParams){.stretch = uiStretchNone}); + uiButton* button_forward = uiMakeButton( + uiMakeLayoutPtr(toolbar), ">", &(uiParams){.stretch = uiStretchNone}); const char* header[] = {"Name", "Size", "Modified"}; - uiTable* table = uiMakeTable(0, sizeof(header) / sizeof(char*), header); + uiTable* table = uiMakeTable( + uiMakeLayoutPtr(main_layout), 0, sizeof(header) / sizeof(char*), header); assert(table); - uiWidgetSetParent(uiMakeTablePtr(table), uiMakeFramePtr(frame)); - // uiLabel* label = uiMakeLabel("Hello world, what is going on!?"); - // uiWidgetSetParent(label, frame); + // uiLabel* label = uiMakeLabel(frame, "Hello world, what is going on!?"); state->frame = frame; state->table = table; @@ -240,7 +246,9 @@ static bool Resize(State* state) { // TODO: Fix the white 1-pixel vertical/horizontal line that appears at odd // sizes when resizing the window. // https://github.com/libsdl-org/SDL/issues/9653 - uiResizeFrame(state->frame, width, height); + uiLayOut(state->frame, width, height); + + uiPrint(uiMakeFramePtr(state->frame)); return true; } @@ -376,16 +384,16 @@ int main( } else if (event.type == SDL_EVENT_MOUSE_WHEEL) { scroll += event.wheel.y; const int scroll_int = (int)scroll; - scroll = scroll - (float)scroll_int; + scroll = scroll - (float)scroll_int; if (scroll_int != 0) { int x, y; MouseCoordsToUiCoords( state.window, event.wheel.mouse_x, event.wheel.mouse_y, &x, &y); const uiInputEvent ev = { - .type = uiEventMouseScroll, - .mouse_scroll = - (uiMouseScrollEvent){.scroll_offset = scroll_int, - .mouse_position = (uiPoint){x, y}} + .type = uiEventMouseScroll, + .mouse_scroll = + (uiMouseScrollEvent){.scroll_offset = scroll_int, + .mouse_position = (uiPoint){x, y}} }; redraw = uiSendEvent(state.frame, &ev); } -- cgit v1.2.3