Fixed more issues with grid and scroll area
This commit is contained in:
parent
0853df4d2a
commit
4e1ab6fc50
6 changed files with 9 additions and 29 deletions
|
|
@ -13,10 +13,12 @@ ScrollArea* scroll_area_many_entries(GUIManager& gui, const char* id, const Scro
|
|||
.innerContent = [&](const ScrollArea::InnerContentParameters& params) {
|
||||
if(options.innerContentExtraCallback) options.innerContentExtraCallback(params);
|
||||
|
||||
if(params.containerDimensions.y() == 0.0f)
|
||||
return;
|
||||
|
||||
float absScrollAmount = std::fabs(params.scrollOffset->y());
|
||||
size_t startPoint = absScrollAmount / options.entryHeight;
|
||||
size_t elementsContainable = (params.containerDimensions.y() / options.entryHeight) + 2; // Displaying 2 more elements ensures that there isn't any empty space in the container
|
||||
elementsContainable = std::min<size_t>(elementsContainable, 100);
|
||||
size_t endPoint = std::min(options.entryCount, startPoint + elementsContainable);
|
||||
|
||||
if(startPoint != 0) {
|
||||
|
|
@ -29,7 +31,7 @@ ScrollArea* scroll_area_many_entries(GUIManager& gui, const char* id, const Scro
|
|||
|
||||
gui.new_id("many element list", [&] {
|
||||
for(size_t i = startPoint; i < endPoint; i++) {
|
||||
gui.new_id(i, [&] {
|
||||
gui.new_id(i - startPoint, [&] {
|
||||
gui.element<LayoutElement>("elem", [&] (LayoutElement*, const Clay_ElementId& lId) {
|
||||
CLAY(lId, {
|
||||
.layout = { .sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED(options.entryHeight)}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue