Expose getter for max element counts

This commit is contained in:
Nic Barker 2025-01-09 12:21:20 +13:00
parent 73d2186d95
commit f186024e74
2 changed files with 16 additions and 3 deletions

15
clay.h
View File

@ -3975,9 +3975,22 @@ void Clay_SetExternalScrollHandlingEnabled(bool enabled) {
context->externalScrollHandlingEnabled = enabled;
}
CLAY_WASM_EXPORT("Clay_GetMaxElementCount")
int32_t Clay_GetMaxElementCount(void) {
Clay_Context* context = Clay_GetCurrentContext();
return context->maxElementCount;
}
CLAY_WASM_EXPORT("Clay_SetMaxElementCount")
void Clay_SetMaxElementCount(int32_t maxElementCount) {
Clay__currentContext->maxElementCount = maxElementCount;
Clay_Context* context = Clay_GetCurrentContext();
context->maxElementCount = maxElementCount;
}
CLAY_WASM_EXPORT("Clay_GetMaxMeasureTextCacheWordCount")
int32_t Clay_GetMaxMeasureTextCacheWordCount(void) {
Clay_Context* context = Clay_GetCurrentContext();
return context->maxMeasureTextCacheWordCount;
}
CLAY_WASM_EXPORT("Clay_SetMaxMeasureTextCacheWordCount")

View File

@ -208,10 +208,10 @@ void HandleClayErrors(Clay_ErrorData errorData) {
printf("%s", errorData.errorText.chars);
if (errorData.errorType == CLAY_ERROR_TYPE_ELEMENTS_CAPACITY_EXCEEDED) {
reinitializeClay = true;
// Clay_SetMaxElementCount(Clay_SetMaxElementCount() * 2);
Clay_SetMaxElementCount(Clay_GetMaxElementCount() * 2);
} else if (errorData.errorType == CLAY_ERROR_TYPE_TEXT_MEASUREMENT_CAPACITY_EXCEEDED) {
reinitializeClay = true;
// Clay_SetMaxMeasureTextCacheWordCount(Clay__maxMeasureTextCacheWordCount * 2);
Clay_SetMaxMeasureTextCacheWordCount(Clay_GetMaxMeasureTextCacheWordCount() * 2);
}
}