Basic UI system

This commit is contained in:
2023-12-21 15:27:49 +01:00
parent 70cc2eae8c
commit 569294f292
5 changed files with 552 additions and 67 deletions

View File

@@ -19,3 +19,6 @@ target_link_libraries(array_test LINK_PRIVATE Breeze)
add_executable(pan_test pan_test.c)
target_link_libraries(pan_test LINK_PRIVATE Breeze)
add_executable(ui_test ui_test.c)
target_link_libraries(ui_test LINK_PRIVATE Breeze)

47
engine/tests/ui_test.c Normal file
View File

@@ -0,0 +1,47 @@
#define BZ_ENTRYPOINT
#include <breeze.h>
#include <raylib.h>
#include <rlImGui.h>
BzUI *ui;
bool init(int *game) {
rlImGuiSetup(true);
ui = bzUICreate();
return true;
}
void render(float dt, int *game) {
ClearBackground(WHITE);
bzUIBegin(ui, GetScreenWidth(), GetScreenHeight());
bzUIPushLayout(ui, *&(BzUILayout) {
.type = BZ_UI_LAYOUT_FLEX_BOX,
.flags = BZ_UI_FLEX_DIR_COLUMN | BZ_UI_FLEX_ALIGN_CENTER | BZ_UI_FLEX_JUSTIFY_CENTER,
});
if (bzUIButton(ui, "Hello world", NULL)) {
bzLogInfo("Hello world");
}
if (bzUIButton(ui, "foo", NULL)) {
bzLogInfo("foo");
}
if (bzUIButton(ui, "bar", NULL)) {
bzLogInfo("bar");
}
bzUIEnd(ui);
rlImGuiBegin();
igShowDemoWindow(NULL);
rlImGuiEnd();
}
bool bzMain(BzAppDesc *appDesc, int argc, const char **argv) {
appDesc->init = (BzAppInitFunc) init;
appDesc->render = (BzAppRenderFunc) render;
return true;
}