diff options
| author | nathan <nathansmith@disroot.org> | 2025-11-17 05:50:31 +0000 |
|---|---|---|
| committer | nathan <nathansmith@disroot.org> | 2025-11-17 05:50:31 +0000 |
| commit | f6922dc12deb981cf95498afeb939f24171a5fc4 (patch) | |
| tree | 4add44cdcdc1d4801d43cb4a557f7332fc6eef56 /src/ui.c | |
| parent | fe39cc897fbc8d8470d790df5306550c841d95d4 (diff) | |
| download | FindThings-f6922dc12deb981cf95498afeb939f24171a5fc4.tar.gz FindThings-f6922dc12deb981cf95498afeb939f24171a5fc4.tar.bz2 FindThings-f6922dc12deb981cf95498afeb939f24171a5fc4.zip | |
Testing widgets in the wm
Diffstat (limited to 'src/ui.c')
| -rw-r--r-- | src/ui.c | 23 |
1 files changed, 14 insertions, 9 deletions
@@ -10,7 +10,8 @@ FloatingWindow createFloatingWindow(const char* title, Rectangle rect) .callback = NULL, .contentSize = Vector2Zero(), .scroll = Vector2Zero(), - .hasFocus = false + .hasFocus = false, + .data = NULL }; memcpy(window.title, title, UI_WINDOW_TITLE_MAX * sizeof(char)); @@ -144,8 +145,11 @@ void updateFloatingWindowMinimized(FloatingWindow* window) } } -void updateFloatingWindowNotMinimized(FloatingWindow* window) +FocusCommand updateFloatingWindowNotMinimized(FloatingWindow* window, + Game* game) { + FocusCommand focus = NO_FOCUS_ACTION; + window->minimized = GuiWindowBox( (Rectangle){window->rect.x, window->rect.y, window->rect.width, window->rect.height}, window->title) & window->hasFocus; @@ -175,8 +179,7 @@ void updateFloatingWindowNotMinimized(FloatingWindow* window) BeginScissorMode(scissor.x, scissor.y, scissor.width, scissor.height); } - window->callback((Vector2){window->rect.x, window->rect.y}, - window->scroll); + focus = window->callback(window, game); if (requireScissor) { @@ -187,9 +190,11 @@ void updateFloatingWindowNotMinimized(FloatingWindow* window) // Draw the resize button/icon. GuiDrawIcon(71, window->rect.x + window->rect.width - 20, window->rect.y + window->rect.height - 20, 1, GREEN); + + return focus; } -FocusCommand updateFloatingWindow(FloatingWindow* window) +FocusCommand updateFloatingWindow(FloatingWindow* window, Game* game) { FocusCommand focus = NO_FOCUS_ACTION; bool isMouseLeftClick = IsMouseButtonPressed(MOUSE_LEFT_BUTTON); @@ -224,7 +229,8 @@ FocusCommand updateFloatingWindow(FloatingWindow* window) } else { - updateFloatingWindowNotMinimized(window); + FocusCommand result = updateFloatingWindowNotMinimized(window, game); + focus = result == NO_FOCUS_ACTION ? focus : result; } return focus; @@ -235,14 +241,14 @@ void initWindowManager(WindowManager* wm) memset(wm, 0, sizeof(WindowManager)); } -void updateWindowManager(WindowManager* wm) +void updateWindowManager(WindowManager* wm, Game* game) { Vector2 mousePosition = GetMousePosition(); int focusOnto = -1; for (int index = 0; index < wm->windowCount; ++index) { - FocusCommand focus = updateFloatingWindow(&wm->windows[index]); + FocusCommand focus = updateFloatingWindow(&wm->windows[index], game); if (focusOnto != -1) { @@ -255,7 +261,6 @@ void updateWindowManager(WindowManager* wm) break; case REQUEST_FOCUS: { - puts("hi"); bool canFocus = true; // Windows ontop of it prevent focus. |
