Add better ui_test example

This commit is contained in:
2024-01-13 10:16:48 +01:00
parent 8692d89479
commit e35cee7e7a

View File

@@ -19,9 +19,13 @@ void render(float dt, int *game) {
bzUIBegin(ui, GetScreenWidth(), GetScreenHeight()); bzUIBegin(ui, GetScreenWidth(), GetScreenHeight());
static BzUIFlags flags = BZ_UI_FLEX_DIR_COLUMN | BZ_UI_FLEX_ALIGN_CENTER | BZ_UI_FLEX_JUSTIFY_CENTER;
static i32 width = 1280;
static i32 height = 720;
SetWindowSize(width, height);
bzUISetParentLayout(ui, *&(BzUILayout) { bzUISetParentLayout(ui, *&(BzUILayout) {
.type = BZ_UI_LAYOUT_FLEX_BOX, .type = BZ_UI_LAYOUT_FLEX_BOX,
.flags = BZ_UI_FLEX_DIR_COLUMN | BZ_UI_FLEX_ALIGN_CENTER | BZ_UI_FLEX_JUSTIFY_CENTER, .flags = flags
}); });
if (bzUIButton(ui, "Hello world")) { if (bzUIButton(ui, "Hello world")) {
bzLogInfo("Hello world"); bzLogInfo("Hello world");
@@ -35,7 +39,23 @@ void render(float dt, int *game) {
bzUIEnd(ui); bzUIEnd(ui);
rlImGuiBegin(); rlImGuiBegin();
igShowDemoWindow(NULL); igBegin("DebugUI", NULL, 0);
igSliderInt("Width", &width, 200, 1600, "%d", 0);
igSliderInt("Height", &height, 100, 1000, "%d", 0);
const char *flexOpt[] = {"DIR_ROW", "DIR_COLUMN", "ALIGN_START",
"ALIGN_CENTER", "ALIGN_END", "JUSTIFY_START",
"JUSTIFY_CENTER", "JUSTIFY_END", "JUSTIFY_SPACE_BETWEEN",
"JUSTIFY_SPACE_AROUND", "JUSTIFY_SPACE_EVENLY"};
i32 numOpts = sizeof(flexOpt) / sizeof(*flexOpt);
for (i32 i = 0; i < numOpts; i++) {
bool opt = (flags & (1 << i)) != 0;
igCheckbox(flexOpt[i], &opt);
flags &= ~(1 << i);
if (opt)
flags |= (1 << i);
}
igEnd();
rlImGuiEnd(); rlImGuiEnd();
} }