Added the window destruction command
This commit is contained in:
@@ -195,6 +195,17 @@ void loop(void) {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case CmdDestroyWindow: {
|
||||||
|
uint8_t destroyedWinID = DestroyWindow::Destroy(payload, &mainScreen);
|
||||||
|
if (destroyedWinID < 0) {
|
||||||
|
LOG_WARN(F("Failed to destroy window\n"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_INFO(F("Succesfully destroy window: %d\n"), destroyedWinID);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
LOG_WARN(F("Command: `%s` has not been implemented yet."), CommandToStr(cmd));
|
LOG_WARN(F("Command: `%s` has not been implemented yet."), CommandToStr(cmd));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,4 +41,19 @@ namespace CreateWindow {
|
|||||||
};
|
};
|
||||||
|
|
||||||
namespace DestroyWindow {
|
namespace DestroyWindow {
|
||||||
|
void printUIDestroyWindowPacket(UIDestroyWindowPacket *win) {
|
||||||
|
LOG_INFO(F("Destroy window:\n"));
|
||||||
|
LOG_INFO(F(" WinID: %d\n"), win->WinID);
|
||||||
|
}
|
||||||
|
|
||||||
|
int8_t Destroy(uint8_t *payload, Curses::Screen *mainScreen) {
|
||||||
|
DestroyWindow::UIDestroyWindowPacket win;
|
||||||
|
memcpy(&win, payload, sizeof(DestroyWindow::UIDestroyWindowPacket));
|
||||||
|
printUIDestroyWindowPacket(&win);
|
||||||
|
|
||||||
|
UIElement *mainWindow = mainScreen->mainWindowHandle;
|
||||||
|
mainWindow->RemoveChild(win.WinID);
|
||||||
|
|
||||||
|
return win.WinID;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -20,6 +20,12 @@ namespace CreateWindow {
|
|||||||
};
|
};
|
||||||
|
|
||||||
namespace DestroyWindow {
|
namespace DestroyWindow {
|
||||||
|
struct UIDestroyWindowPacket {
|
||||||
|
int16_t WinID;
|
||||||
|
};
|
||||||
|
|
||||||
|
void printUIDestroyWindowPacket(UIDestroyWindowPacket *win);
|
||||||
|
int8_t Destroy(uint8_t *payload, Curses::Screen *mainScreen);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user