Skip to content

Commit

Permalink
Expose getter for max element counts
Browse files Browse the repository at this point in the history
  • Loading branch information
nicbarker committed Jan 8, 2025
1 parent 73d2186 commit f186024
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
15 changes: 14 additions & 1 deletion clay.h
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions examples/raylib-sidebar-scrolling-container/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit f186024

Please sign in to comment.