aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui.c')
-rw-r--r--src/ui.c35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/ui.c b/src/ui.c
index d83ec52..296f658 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -1,8 +1,8 @@
#include "ui.h"
-FloatingWindow createFloatingWindow()
+FloatingWindow createFloatingWindow(const char* title)
{
- return (FloatingWindow){
+ FloatingWindow window = (FloatingWindow){
.rect = (Rectangle){0.0, 0.0, 100.0, 100.0},
.minimized = false,
.moving = false,
@@ -11,6 +11,10 @@ FloatingWindow createFloatingWindow()
.contentSize = Vector2Zero(),
.scroll = Vector2Zero()
};
+
+ memcpy(window.title, title, UI_WINDOW_TITLE_MAX * sizeof(char));
+
+ return window;
}
void floatingWindowTransformCollisionCheck(FloatingWindow* window)
@@ -115,7 +119,7 @@ void updateFloatingWindowResizing(FloatingWindow* window)
}
}
-void updateFloatingWindowMinimized(FloatingWindow* window, const char* title)
+void updateFloatingWindowMinimized(FloatingWindow* window)
{
int closeTitleSizeDeltaHalf = (RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT -
RAYGUI_WINDOW_CLOSEBUTTON_SIZE) / 2;
@@ -123,7 +127,7 @@ void updateFloatingWindowMinimized(FloatingWindow* window, const char* title)
GuiStatusBar(
(Rectangle){window->rect.x, window->rect.y,
window->rect.width, RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT},
- title);
+ window->title);
if (GuiButton(
(Rectangle){window->rect.x + window->rect.width
@@ -138,11 +142,11 @@ void updateFloatingWindowMinimized(FloatingWindow* window, const char* title)
}
}
-void updateFloatingWindowNotMinimized(FloatingWindow* window, const char* title)
+void updateFloatingWindowNotMinimized(FloatingWindow* window)
{
window->minimized = GuiWindowBox(
(Rectangle){window->rect.x, window->rect.y, window->rect.width,
- window->rect.height}, title);
+ window->rect.height}, window->title);
// Scissor and draw content within a scroll panel.
if (window->callback != NULL)
@@ -183,7 +187,7 @@ void updateFloatingWindowNotMinimized(FloatingWindow* window, const char* title)
window->rect.y + window->rect.height - 20, 1, GREEN);
}
-void updateFloatingWindow(FloatingWindow* window, const char* title)
+void updateFloatingWindow(FloatingWindow* window)
{
// Window movement and resize input and collision check.
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON) && !window->moving
@@ -205,10 +209,23 @@ void updateFloatingWindow(FloatingWindow* window, const char* title)
// window and content drawing with scissor and scroll area
if(window->minimized)
{
- updateFloatingWindowMinimized(window, title);
+ updateFloatingWindowMinimized(window);
}
else
{
- updateFloatingWindowNotMinimized(window, title);
+ updateFloatingWindowNotMinimized(window);
+ }
+}
+
+void initWindowManager(WindowManager* windowManager)
+{
+ memset(windowManager, 0, sizeof(WindowManager));
+}
+
+void updateWindowManager(WindowManager* windowManager)
+{
+ for (int index = 0; index < windowManager->windowCount; ++index)
+ {
+ updateFloatingWindow(&windowManager->windows[index]);
}
}