diff --git a/examples/cairo-pdf-rendering/main.c b/examples/cairo-pdf-rendering/main.c index 3555b95..244161c 100644 --- a/examples/cairo-pdf-rendering/main.c +++ b/examples/cairo-pdf-rendering/main.c @@ -109,6 +109,10 @@ void Layout() { } } +void HandleClayErrors(Clay_ErrorData errorData) { + printf("%s", errorData.errorText.chars); +} + int main(void) { // First we set up our cairo surface. // In this example we will use the PDF backend, @@ -131,11 +135,11 @@ int main(void) { Clay_Cairo_Initialize(cr); uint64_t totalMemorySize = Clay_MinMemorySize(); - Clay_Arena clayMemory = (Clay_Arena) { .label = CLAY_STRING("Clay Memory Arena"), .memory = malloc(totalMemorySize), .capacity = totalMemorySize }; + Clay_Arena clayMemory = Clay_CreateArenaWithCapacityAndMemory(totalMemorySize, malloc(totalMemorySize)); Clay_SetMeasureTextFunction(Clay_Cairo_MeasureText); // We initialize Clay with the same size - Clay_Initialize(clayMemory, (Clay_Dimensions) { width, height }); + Clay_Initialize(clayMemory, (Clay_Dimensions) { width, height }, (Clay_ErrorHandler) { HandleClayErrors }); Clay_BeginLayout(); diff --git a/examples/cpp-project-example/main.cpp b/examples/cpp-project-example/main.cpp index 8c26fd7..832034c 100644 --- a/examples/cpp-project-example/main.cpp +++ b/examples/cpp-project-example/main.cpp @@ -4,10 +4,15 @@ Clay_LayoutConfig layoutElement = Clay_LayoutConfig { .padding = {5} }; + +void HandleClayErrors(Clay_ErrorData errorData) { + printf("%s", errorData.errorText.chars); +} + int main(void) { uint64_t totalMemorySize = Clay_MinMemorySize(); - Clay_Arena clayMemory = Clay_Arena { .label = CLAY_STRING("Clay Memory Arena"), .capacity = totalMemorySize, .memory = (char *)malloc(totalMemorySize) }; - Clay_Initialize(clayMemory, Clay_Dimensions {1024,768}); + Clay_Arena clayMemory = Clay_CreateArenaWithCapacityAndMemory(totalMemorySize, (char *)malloc(totalMemorySize)); + Clay_Initialize(clayMemory, Clay_Dimensions {1024,768}, (Clay_ErrorHandler) { HandleClayErrors }); Clay_BeginLayout(); CLAY(CLAY_RECTANGLE({ .color = {255,255,255,0} }), CLAY_LAYOUT(layoutElement)) {} Clay_EndLayout(); diff --git a/examples/raylib-sidebar-scrolling-container/main.c b/examples/raylib-sidebar-scrolling-container/main.c index fd7e0ae..5a39fc1 100644 --- a/examples/raylib-sidebar-scrolling-container/main.c +++ b/examples/raylib-sidebar-scrolling-container/main.c @@ -211,13 +211,13 @@ void HandleClayErrors(Clay_ErrorData errorData) { Clay_SetMaxElementCount(Clay__maxElementCount * 2); } else if (errorData.errorType == CLAY_ERROR_TYPE_TEXT_MEASUREMENT_CAPACITY_EXCEEDED) { reinitializeClay = true; - Clay_SetMeasureTextCacheSize(Clay__measureTextCacheSize * 2); + Clay_SetMaxMeasureTextCacheWordCount(Clay__maxMeasureTextCacheWordCount * 2); } } int main(void) { uint64_t totalMemorySize = Clay_MinMemorySize(); - Clay_Arena clayMemory = (Clay_Arena) { .label = CLAY_STRING("Clay Memory Arena"), .memory = malloc(totalMemorySize), .capacity = totalMemorySize }; + Clay_Arena clayMemory = Clay_CreateArenaWithCapacityAndMemory(totalMemorySize, malloc(totalMemorySize)); Clay_SetMeasureTextFunction(Raylib_MeasureText); Clay_Initialize(clayMemory, (Clay_Dimensions) { (float)GetScreenWidth(), (float)GetScreenHeight() }, (Clay_ErrorHandler) { HandleClayErrors }); Clay_Raylib_Initialize(1024, 768, "Clay - Raylib Renderer Example", FLAG_VSYNC_HINT | FLAG_WINDOW_RESIZABLE | FLAG_WINDOW_HIGHDPI | FLAG_MSAA_4X_HINT); @@ -242,7 +242,7 @@ int main(void) { if (reinitializeClay) { Clay_SetMaxElementCount(8192); totalMemorySize = Clay_MinMemorySize(); - clayMemory = (Clay_Arena) { .label = CLAY_STRING("Clay Memory Arena"), .memory = malloc(totalMemorySize), .capacity = totalMemorySize }; + clayMemory = Clay_CreateArenaWithCapacityAndMemory(totalMemorySize, malloc(totalMemorySize)); Clay_Initialize(clayMemory, (Clay_Dimensions) { (float)GetScreenWidth(), (float)GetScreenHeight() }, (Clay_ErrorHandler) { HandleClayErrors }); reinitializeClay = false; }