[Layout] Scroll content height incorrectly considers padding
When the number of elements in a container exceeds its size / padding, then each additional element increases the scroll container dimension by the padding size.
For example, with the loop set to 82 elements this computes a container height of 1000 as expected. Increasing it to 83 reports 1008, and increasing it to 84 reports 1020.
float padding = 12;
Clay_SetLayoutDimensions((Clay_Dimensions){.width = 1600, .height = 1000});
CLAY({
.id = CLAY_ID("Thumbnails"),
.layout = {
.sizing = {.width = CLAY_SIZING_PERCENT(0.2f), .height = CLAY_SIZING_GROW(0)},
.layoutDirection = CLAY_TOP_TO_BOTTOM,
.padding = CLAY_PADDING_ALL(padding),
.childGap = padding,
},
.clip = {.horizontal = false, .vertical = true, .childOffset = Clay_GetScrollOffset()},
})
{
Clay_ElementId id = Clay_GetElementId(CLAY_STRING("Thumbnails"));
Clay_ScrollContainerData scrollContainerData = Clay_GetScrollContainerData(id);
printf("Scroll container height: %f\n", scrollContainerData.scrollContainerDimensions.height);
for (size_t i = 0; i < 83; ++i)
{
CLAY({
.layout = {
.sizing = {.width = CLAY_SIZING_FIXED(100), .height = CLAY_SIZING_FIXED(100)},
},
.backgroundColor = (Clay_Color){0, 0, 0, 255},
.border = {
.width = CLAY_BORDER_OUTSIDE(2),
.color = Clay_Hovered() ? (Clay_Color){255, 255, 255, 255} : (Clay_Color){0, 0, 0, 0},
},
})
{}
}
}
That definitely sounds like a bug, will take a look! Thanks for reporting 🙂
Sorry about the delay getting to this one, should be fixed here: https://github.com/nicbarker/clay/commit/3ccfa0f8faad419aad4be48786230f15222bcc14
I think this one should be all good to close now!