summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/xplorer.c30
1 files 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(
41void CreateUi(State* state) { 41void CreateUi(State* state) {
42 assert(state); 42 assert(state);
43 43
44 uiFrame* frame = uiMakeFrame(); 44 uiFrame* frame = uiMakeFrame();
45 uiLayout* main_layout = uiMakeLayout(uiMakeFramePtr(frame), uiVertical);
46
47 uiLayout* toolbar = uiMakeLayout(uiMakeLayoutPtr(main_layout), uiHorizontal);
48 uiButton* button_back = uiMakeButton(
49 uiMakeLayoutPtr(toolbar), "<", &(uiParams){.stretch = uiStretchNone});
50 uiButton* button_forward = uiMakeButton(
51 uiMakeLayoutPtr(toolbar), ">", &(uiParams){.stretch = uiStretchNone});
45 52
46 const char* header[] = {"Name", "Size", "Modified"}; 53 const char* header[] = {"Name", "Size", "Modified"};
47 uiTable* table = uiMakeTable(0, sizeof(header) / sizeof(char*), header); 54 uiTable* table = uiMakeTable(
55 uiMakeLayoutPtr(main_layout), 0, sizeof(header) / sizeof(char*), header);
48 assert(table); 56 assert(table);
49 uiWidgetSetParent(uiMakeTablePtr(table), uiMakeFramePtr(frame));
50 57
51 // uiLabel* label = uiMakeLabel("Hello world, what is going on!?"); 58 // uiLabel* label = uiMakeLabel(frame, "Hello world, what is going on!?");
52 // uiWidgetSetParent(label, frame);
53 59
54 state->frame = frame; 60 state->frame = frame;
55 state->table = table; 61 state->table = table;
@@ -240,7 +246,9 @@ static bool Resize(State* state) {
240 // TODO: Fix the white 1-pixel vertical/horizontal line that appears at odd 246 // TODO: Fix the white 1-pixel vertical/horizontal line that appears at odd
241 // sizes when resizing the window. 247 // sizes when resizing the window.
242 // https://github.com/libsdl-org/SDL/issues/9653 248 // https://github.com/libsdl-org/SDL/issues/9653
243 uiResizeFrame(state->frame, width, height); 249 uiLayOut(state->frame, width, height);
250
251 uiPrint(uiMakeFramePtr(state->frame));
244 252
245 return true; 253 return true;
246} 254}
@@ -376,16 +384,16 @@ int main(
376 } else if (event.type == SDL_EVENT_MOUSE_WHEEL) { 384 } else if (event.type == SDL_EVENT_MOUSE_WHEEL) {
377 scroll += event.wheel.y; 385 scroll += event.wheel.y;
378 const int scroll_int = (int)scroll; 386 const int scroll_int = (int)scroll;
379 scroll = scroll - (float)scroll_int; 387 scroll = scroll - (float)scroll_int;
380 if (scroll_int != 0) { 388 if (scroll_int != 0) {
381 int x, y; 389 int x, y;
382 MouseCoordsToUiCoords( 390 MouseCoordsToUiCoords(
383 state.window, event.wheel.mouse_x, event.wheel.mouse_y, &x, &y); 391 state.window, event.wheel.mouse_x, event.wheel.mouse_y, &x, &y);
384 const uiInputEvent ev = { 392 const uiInputEvent ev = {
385 .type = uiEventMouseScroll, 393 .type = uiEventMouseScroll,
386 .mouse_scroll = 394 .mouse_scroll =
387 (uiMouseScrollEvent){.scroll_offset = scroll_int, 395 (uiMouseScrollEvent){.scroll_offset = scroll_int,
388 .mouse_position = (uiPoint){x, y}} 396 .mouse_position = (uiPoint){x, y}}
389 }; 397 };
390 redraw = uiSendEvent(state.frame, &ev); 398 redraw = uiSendEvent(state.frame, &ev);
391 } 399 }