mirror of
https://github.com/nicbarker/clay.git
synced 2025-04-18 20:28:01 +00:00
[Core] Check whether the maximum number of elements has been exceeded before rendering the debug view (#255)
This commit is contained in:
parent
a5983dee96
commit
fd76ce62f3
10
clay.h
10
clay.h
@ -3521,13 +3521,19 @@ CLAY_WASM_EXPORT("Clay_EndLayout")
|
|||||||
Clay_RenderCommandArray Clay_EndLayout(void) {
|
Clay_RenderCommandArray Clay_EndLayout(void) {
|
||||||
Clay_Context* context = Clay_GetCurrentContext();
|
Clay_Context* context = Clay_GetCurrentContext();
|
||||||
Clay__CloseElement();
|
Clay__CloseElement();
|
||||||
if (context->debugModeEnabled) {
|
bool elementsExceededBeforeDebugView = context->booleanWarnings.maxElementsExceeded;
|
||||||
|
if (context->debugModeEnabled && !elementsExceededBeforeDebugView) {
|
||||||
context->warningsEnabled = false;
|
context->warningsEnabled = false;
|
||||||
Clay__RenderDebugView();
|
Clay__RenderDebugView();
|
||||||
context->warningsEnabled = true;
|
context->warningsEnabled = true;
|
||||||
}
|
}
|
||||||
if (context->booleanWarnings.maxElementsExceeded) {
|
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 ) {
|
Clay__AddRenderCommand(CLAY__INIT(Clay_RenderCommand ) {
|
||||||
.boundingBox = { context->layoutDimensions.width / 2 - 59 * 4, context->layoutDimensions.height / 2, 0, 0 },
|
.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 } },
|
.renderData = { .text = { .stringContents = CLAY__INIT(Clay_StringSlice) { .length = message.length, .chars = message.chars, .baseChars = message.chars }, .textColor = {255, 0, 0, 255}, .fontSize = 16 } },
|
||||||
|
Loading…
Reference in New Issue
Block a user