From 91402af14063d71d997ab13ec3a24c65f96a7332 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Fri, 20 Feb 2026 21:52:28 +0000 Subject: [PATCH] Added UIOptions still need to make it work with bitflags instead tho --- src/methods/methods.cpp | 25 ++++++++++++++++++++++--- src/methods/methods.h | 11 +++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/methods/methods.cpp b/src/methods/methods.cpp index e7bae2d..44e9f78 100644 --- a/src/methods/methods.cpp +++ b/src/methods/methods.cpp @@ -30,10 +30,18 @@ namespace Window { LOG_INFO(F(" TextSize : %d\n"), decor->textSize); } + void printUIOptionsPacket(UIWindowOpts* opts) { + LOG_INFO(F(" Options:\n")); + LOG_INFO(F(" ShowID : %d\n"), opts->ShowID); + LOG_INFO(F(" Type : %d\n"), opts->WinType); + LOG_INFO(F(" PreviewValue: %s\n"), opts->PreviewValue); + } + void printUIWindowPacket(UICreateWindowPacket *win) { LOG_INFO(F("New window:\n")); printUIDimsPacket(&win->dims); printUIDecorPacket(&win->decor); + printUIOptionsPacket(&win->opts); LOG_INFO(F(" Title: %s\n"), win->title); } @@ -45,6 +53,14 @@ namespace Window { UICreateWindowPacket::UICreateWindowPacket() {} + void setTitleWithOpts(UICreateWindowPacket* win, UIElement* elem, int16_t ID) { + if (win->opts.ShowID == ShowIDTrue) { + elem->SetTitle((char *)"%s [%2d]", (const char *)win->title, ID); + } else { + elem->SetTitle((char *)"%s", (const char *)win->title); + } + } + int8_t Create(uint8_t *payload, Curses::Screen *mainScreen) { // Load the payload into a struct // UICreateWindowPacket* win; @@ -62,13 +78,14 @@ namespace Window { UIElement *childComponent = mainWindow->GetChild(childID); - childComponent->SetTitle((char *)"%s [%2d]", (const char *)win.title, childID); - childComponent->SetUIDecorations(UIDecorations()); + setTitleWithOpts(&win, childComponent, childID); + childComponent->SetUIDecorations(win.decor); childComponent->SetUIDimensions(UIDimensions(win.dims.x, win.dims.y, win.dims.width, win.dims.height)); childComponent->SetDisplay(mainScreen->display); childComponent->drawBox(); + childComponent->Update(win.opts.PreviewValue, true); return childID; } @@ -93,6 +110,7 @@ namespace Window { // Redraw the window win->drawBox(); + win->Redraw(); return true; } @@ -116,9 +134,10 @@ namespace Window { // Update the windows dimensons, decor and title win->dims = pkt.data.dims; win->decor = pkt.data.decor; - win->SetTitle((char*)"%s [ %d]", pkt.data.title, pkt.WinID); + setTitleWithOpts(&pkt.data, win, pkt.WinID); win->drawBox(); + win->Update(pkt.data.opts.PreviewValue, true); return true; } diff --git a/src/methods/methods.h b/src/methods/methods.h index f48b75d..ad50747 100644 --- a/src/methods/methods.h +++ b/src/methods/methods.h @@ -8,10 +8,21 @@ #include "UIDecorations.h" namespace Window { + const uint8_t ShowIDFalse = 0; + const uint8_t ShowIDTrue = 1; + + struct UIWindowOpts { + uint8_t ShowID; + uint8_t WinType; + // NOTE: I recon we need to change this yo + char PreviewValue[32]; + }; + // Window creation struct UICreateWindowPacket { UIDimensions dims; UIDecorations decor; + UIWindowOpts opts; char title[32]; // Note: we optimize this type of data transfer if necessary // we are sending 32 - len(title) extra bytes everytime