re-add max element exceeded warning for debug view

This commit is contained in:
Nic Barker 2026-03-31 12:28:33 +11:00
parent 0df6ad3e2f
commit 5d0649efc2

26
clay.h
View file

@ -4627,8 +4627,18 @@ Clay_RenderCommandArray Clay_EndLayout(float deltaTime) {
context->warningsEnabled = true;
}
Clay__CalculateFinalLayout(deltaTime, true, true);
Clay__CloneElementsWithExitTransition();
if (context->booleanWarnings.maxElementsExceeded) {
Clay_String message;
message = CLAY_STRING("Clay Error: Debug view caused layout element count to exceed Clay__maxElementCount");
Clay__AddRenderCommand(CLAY__INIT(Clay_RenderCommand ) {
.boundingBox = { context->layoutDimensions.width / 2 - 59 * 4, context->layoutDimensions.height / 2, 0, 0 },
.renderData = { .text = { .stringContents = CLAY__INIT(Clay_StringSlice) { .length = message.length, .chars = message.chars, .baseChars = message.chars }, .textColor = {255, 0, 0, 255}, .fontSize = 16 } },
.commandType = CLAY_RENDER_COMMAND_TYPE_TEXT
});
} else {
Clay__CalculateFinalLayout(deltaTime, true, true);
Clay__CloneElementsWithExitTransition();
}
} else {
if (context->debugModeEnabled) {
context->warningsEnabled = false;
@ -4636,7 +4646,17 @@ Clay_RenderCommandArray Clay_EndLayout(float deltaTime) {
context->warningsEnabled = true;
}
Clay__CalculateFinalLayout(deltaTime, false, true);
if (context->booleanWarnings.maxElementsExceeded) {
Clay_String message;
message = CLAY_STRING("Clay Error: Debug view caused layout element count to exceed Clay__maxElementCount");
Clay__AddRenderCommand(CLAY__INIT(Clay_RenderCommand ) {
.boundingBox = { context->layoutDimensions.width / 2 - 59 * 4, context->layoutDimensions.height / 2, 0, 0 },
.renderData = { .text = { .stringContents = CLAY__INIT(Clay_StringSlice) { .length = message.length, .chars = message.chars, .baseChars = message.chars }, .textColor = {255, 0, 0, 255}, .fontSize = 16 } },
.commandType = CLAY_RENDER_COMMAND_TYPE_TEXT
});
} else {
Clay__CalculateFinalLayout(deltaTime, false, true);
}
}
}
if (context->openLayoutElementStack.length > 1) {