Added UIOptions

still need to make it work with bitflags instead tho
This commit is contained in:
2026-02-20 21:52:28 +00:00
parent 8ccb066d1f
commit 91402af140
2 changed files with 33 additions and 3 deletions
+22 -3
View File
@@ -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;
}
+11
View File
@@ -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