Skip to content

Commit 5d0da69

Browse files
committed
experimenting with clay
1 parent 9e571c9 commit 5d0da69

File tree

1 file changed

+64
-1
lines changed

1 file changed

+64
-1
lines changed

src/system/sokol/main.c

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,13 +695,15 @@ static void renderCommands(App *app, Clay_RenderCommandArray renderCommands)
695695
static void renderLayout(App *app)
696696
{
697697
const Clay_Color COLOR_BLACK = (Clay_Color) {.a = 255};
698+
const Clay_Color COLOR_RED = (Clay_Color) {.a = 255, .r = 255};
699+
const Clay_Color COLOR_BLUE = (Clay_Color) {.a = 255, .b = 255};
698700

699701
Clay_SetLayoutDimensions((Clay_Dimensions) { sapp_widthf(), sapp_heightf() });
700702
Clay_SetPointerState((Clay_Vector2) { app->pointer.x, app->pointer.y }, app->pointer.down);
701703

702704
Clay_BeginLayout();
703705

704-
CLAY(CLAY_ID("Layout"),
706+
CLAY_AUTO_ID(
705707
{
706708
.layout =
707709
{
@@ -720,6 +722,67 @@ static void renderLayout(App *app)
720722
.aspectRatio = (float)TIC80_FULLWIDTH / TIC80_FULLHEIGHT,
721723
.backgroundColor = COLOR_BLACK,
722724
}){}
725+
726+
CLAY_AUTO_ID(
727+
{
728+
.floating = { .attachTo = CLAY_ATTACH_TO_PARENT },
729+
730+
.layout =
731+
{
732+
.sizing = {CLAY_SIZING_GROW(), CLAY_SIZING_GROW()},
733+
.childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_CENTER },
734+
},
735+
})
736+
{
737+
738+
CLAY_AUTO_ID(
739+
{
740+
.layout =
741+
{
742+
.sizing = {CLAY_SIZING_GROW(), CLAY_SIZING_GROW()},
743+
.childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_CENTER },
744+
.childGap = 16,
745+
},
746+
})
747+
{
748+
for(s32 i = 0; i < 3; i++)
749+
{
750+
CLAY_AUTO_ID(
751+
{
752+
.layout =
753+
{
754+
.sizing = {CLAY_SIZING_FIXED(100), CLAY_SIZING_FIXED(100)},
755+
},
756+
757+
.backgroundColor = COLOR_RED,
758+
}){}
759+
}
760+
}
761+
762+
CLAY_AUTO_ID(
763+
{
764+
.layout =
765+
{
766+
.sizing = {CLAY_SIZING_GROW(), CLAY_SIZING_GROW()},
767+
.childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_CENTER },
768+
.childGap = 16,
769+
},
770+
})
771+
{
772+
for(s32 i = 0; i < 3; i++)
773+
{
774+
CLAY_AUTO_ID(
775+
{
776+
.layout =
777+
{
778+
.sizing = {CLAY_SIZING_FIXED(100), CLAY_SIZING_FIXED(100)},
779+
},
780+
781+
.backgroundColor = COLOR_BLUE,
782+
}){}
783+
}
784+
}
785+
}
723786
}
724787

725788
renderCommands(app, Clay_EndLayout());

0 commit comments

Comments
 (0)