diff options
Diffstat (limited to 'src/ui.c')
| -rw-r--r-- | src/ui.c | 73 |
1 files changed, 46 insertions, 27 deletions
@@ -138,8 +138,7 @@ void updateFloatingWindowMinimized(FloatingWindow* window) window->rect.y + closeTitleSizeDeltaHalf, RAYGUI_WINDOW_CLOSEBUTTON_SIZE, RAYGUI_WINDOW_CLOSEBUTTON_SIZE}, - "#120#") - && window->hasFocus) + "#120#")) { window->minimized = false; } @@ -152,7 +151,7 @@ FocusCommand updateFloatingWindowNotMinimized(FloatingWindow* window, window->minimized = GuiWindowBox( (Rectangle){window->rect.x, window->rect.y, window->rect.width, - window->rect.height}, window->title) & window->hasFocus; + window->rect.height}, window->title); // Scissor and draw content within a scroll panel. if (window->callback != NULL) @@ -160,29 +159,17 @@ FocusCommand updateFloatingWindowNotMinimized(FloatingWindow* window, Rectangle scissor; // Handle scrolling. - if (window->hasFocus) - { - GuiScrollPanel( - (Rectangle){ - window->rect.x, window->rect.y + RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT, - window->rect.width, - window->rect.height - RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT}, - NULL, - (Rectangle){ - window->rect.x, window->rect.y, - window->contentSize.x, window->contentSize.y}, - &window->scroll, - &scissor); - } - else - { - scissor = (Rectangle){ - window->rect.x, - window->rect.y + RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT, + GuiScrollPanel( + (Rectangle){ + window->rect.x, window->rect.y + RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT, window->rect.width, - window->rect.height - RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT - }; - } + window->rect.height - RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT}, + NULL, + (Rectangle){ + window->rect.x, window->rect.y, + window->contentSize.x, window->contentSize.y}, + &window->scroll, + &scissor); bool requireScissor = window->rect.width < window->contentSize.x || window->rect.height < window->contentSize.x; @@ -207,10 +194,16 @@ FocusCommand updateFloatingWindowNotMinimized(FloatingWindow* window, return focus; } -FocusCommand updateFloatingWindow(FloatingWindow* window, Game* game) +FocusCommand updateFloatingWindow(FloatingWindow* window, WindowManager* wm, + Game* game) { FocusCommand focus = NO_FOCUS_ACTION; bool isMouseLeftClick = IsMouseButtonPressed(MOUSE_LEFT_BUTTON); + + if (wm->enabled && !window->hasFocus) + { + GuiSetState(STATE_DISABLED); + } // Window movement and resize input and collision check. if (isMouseLeftClick && !window->moving && !window->resizing) @@ -246,22 +239,33 @@ FocusCommand updateFloatingWindow(FloatingWindow* window, Game* game) focus = result == NO_FOCUS_ACTION ? focus : result; } + if (wm->enabled && !window->hasFocus) + { + GuiSetState(STATE_NORMAL); + } + return focus; } void initWindowManager(WindowManager* wm) { memset(wm, 0, sizeof(WindowManager)); + wm->enabled = true; } void updateWindowManager(WindowManager* wm, Game* game) { Vector2 mousePosition = GetMousePosition(); int focusOnto = -1; + + if (!wm->enabled) + { + GuiSetState(STATE_DISABLED); + } for (int index = 0; index < wm->windowCount; ++index) { - FocusCommand focus = updateFloatingWindow(&wm->windows[index], game); + FocusCommand focus = updateFloatingWindow(&wm->windows[index], wm, game); if (focusOnto != -1) { @@ -303,6 +307,11 @@ void updateWindowManager(WindowManager* wm, Game* game) } } + if (!wm->enabled) + { + GuiSetState(STATE_NORMAL); + } + if (focusOnto != -1) { focusOnWindow(wm, focusOnto); @@ -346,3 +355,13 @@ void focusOnWindow(WindowManager* wm, int windowIndex) window.hasFocus = true; wm->windows[wm->windowCount - 1] = window; } + +void enableWindowManager(WindowManager* wm) +{ + wm->enabled = true; +} + +void disableWindowManager(WindowManager* wm) +{ + wm->enabled = false; +} |
