From 962926333f31ca459bf098b8892f5aa49ce651ce Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Thu, 13 Nov 2025 21:56:25 +0000 Subject: [PATCH] Need to add a deallocator for the windows --- src/UIComponent.cpp | 9 ++++++++- src/UIComponent.h | 9 +++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/UIComponent.cpp b/src/UIComponent.cpp index 4c74fb2..7f7a6c6 100644 --- a/src/UIComponent.cpp +++ b/src/UIComponent.cpp @@ -163,7 +163,6 @@ std::uint8_t UIElement::ChildrenCount() { namespace WindowPool { UIElement pool[MAX_WINDOWS]; bool inUse[MAX_WINDOWS] = {false}; - // int16_t poolIndex = 0; static inline int16_t getNextIndex() { for (int k = 0; k < MAX_WINDOWS; k++) { @@ -191,6 +190,14 @@ namespace WindowPool { return nextIndex; } + void Deallocate(int16_t id) { + pool[id].SetTitle((char*)""); + pool[id].SetUIDimensions(UIDimensions(0, 0, 0, 0)); + pool[id].SetUIDecorations(UIDecorations()); + + inUse[id] = false; + } + UIElement* GetHandle(int16_t id) { return &pool[id]; } diff --git a/src/UIComponent.h b/src/UIComponent.h index fbf0af1..cccab39 100644 --- a/src/UIComponent.h +++ b/src/UIComponent.h @@ -73,15 +73,12 @@ public: namespace WindowPool { extern UIElement pool[MAX_WINDOWS]; - // extern int16_t poolIndex; extern bool inUse[MAX_WINDOWS]; - // I need to add a list of available IDs - // And maybe a list of unavailable IDs or just create a custome type - // then make a list of that custom and have a bool saying if its available or not - // Although having a list of available IDs is best - int16_t Allocate(); + // I will finish this later on, still have to figure out how to properly + // destroy the UIComponent + void Deallocate(); UIElement* GetHandle(int16_t index); // Debugging