clay
clay copied to clipboard
[2x BUG Readme] Example Layout does not compile in MSVC & MainContent container is in wrong scope!
Hey! [Sorry for not doing a PR - I am not really doing anything in github 🙈]
I noticed that the code in the readme does not compile in C++ due to out of order initializers and that the maincontent is in the scope of the sidebar.
This would be a working version:
// An example of laying out a UI with a fixed width sidebar and flexible width main content
CLAY({ .id = CLAY_ID("OuterContainer"), .layout = {.sizing = {CLAY_SIZING_GROW(0), CLAY_SIZING_GROW(0)}, .padding = CLAY_PADDING_ALL(16), .childGap = 16 }, .backgroundColor = {250,250,255,255} }) {
CLAY({
.id = CLAY_ID("SideBar"),
.layout = {.sizing = {.width = CLAY_SIZING_FIXED(300), .height = CLAY_SIZING_GROW(0) }, .padding = CLAY_PADDING_ALL(16), .childGap = 16,.layoutDirection = CLAY_TOP_TO_BOTTOM },
.backgroundColor = COLOR_LIGHT
}) {
CLAY({ .id = CLAY_ID("ProfilePictureOuter"), .layout = {.sizing = {.width = CLAY_SIZING_GROW(0) }, .padding = CLAY_PADDING_ALL(16), .childGap = 16, .childAlignment = {.y = CLAY_ALIGN_Y_CENTER } }, .backgroundColor = COLOR_RED }) {
CLAY({ .id = CLAY_ID("ProfilePicture"), .layout = {.sizing = {.width = CLAY_SIZING_FIXED(60), .height = CLAY_SIZING_FIXED(60) }}, .image = {.imageData = &profilePicture } }) {}
CLAY_TEXT(CLAY_STRING("Clay - UI Library"), CLAY_TEXT_CONFIG({ .textColor = {255, 255, 255, 255},.fontSize = 24 }));
}
// Standard C code like loops etc work inside components
for (int i = 0; i < 5; i++) {
SidebarItemComponent();
}
}
CLAY({ .id = CLAY_ID("MainContent"), .layout = {.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0) } }, .backgroundColor = COLOR_LIGHT }) {}
}