Skip to content

Commit

Permalink
[Core] Check whether the maximum number of elements has been exceeded…
Browse files Browse the repository at this point in the history
… before rendering the debug view (#255)
  • Loading branch information
FelixBreitweiser authored Feb 10, 2025
1 parent a5983de commit fd76ce6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions clay.h
Original file line number Diff line number Diff line change
Expand Up @@ -3521,13 +3521,19 @@ CLAY_WASM_EXPORT("Clay_EndLayout")
Clay_RenderCommandArray Clay_EndLayout(void) {
Clay_Context* context = Clay_GetCurrentContext();
Clay__CloseElement();
if (context->debugModeEnabled) {
bool elementsExceededBeforeDebugView = context->booleanWarnings.maxElementsExceeded;
if (context->debugModeEnabled && !elementsExceededBeforeDebugView) {
context->warningsEnabled = false;
Clay__RenderDebugView();
context->warningsEnabled = true;
}
if (context->booleanWarnings.maxElementsExceeded) {
Clay_String message = CLAY_STRING("Clay Error: Layout elements exceeded Clay__maxElementCount");
Clay_String message;
if (!elementsExceededBeforeDebugView) {
message = CLAY_STRING("Clay Error: Layout elements exceeded Clay__maxElementCount after adding the debug-view to the layout.");
} else {
message = CLAY_STRING("Clay Error: Layout elements exceeded 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 } },
Expand Down

0 comments on commit fd76ce6

Please sign in to comment.