[Core] restore compatibility with C99

This commit is contained in:
gmasil 2025-05-12 12:25:41 +02:00
parent 76265e4c3c
commit 5c67b957bb
No known key found for this signature in database
GPG key ID: 135FC0B941F3ECC7

9
clay.h
View file

@ -819,7 +819,7 @@ CLAY_DLL_EXPORT void Clay_SetCurrentContext(Clay_Context* context);
CLAY_DLL_EXPORT void Clay_UpdateScrollContainers(bool enableDragScrolling, Clay_Vector2 scrollDelta, float deltaTime); CLAY_DLL_EXPORT void Clay_UpdateScrollContainers(bool enableDragScrolling, Clay_Vector2 scrollDelta, float deltaTime);
// Returns the internally stored scroll offset for the currently open element. // Returns the internally stored scroll offset for the currently open element.
// Generally intended for use with clip elements to create scrolling containers. // Generally intended for use with clip elements to create scrolling containers.
CLAY_DLL_EXPORT Clay_Vector2 Clay_GetScrollOffset(); CLAY_DLL_EXPORT Clay_Vector2 Clay_GetScrollOffset(void);
// Updates the layout dimensions in response to the window or outer container being resized. // Updates the layout dimensions in response to the window or outer container being resized.
CLAY_DLL_EXPORT void Clay_SetLayoutDimensions(Clay_Dimensions dimensions); CLAY_DLL_EXPORT void Clay_SetLayoutDimensions(Clay_Dimensions dimensions);
// Called before starting any layout declarations. // Called before starting any layout declarations.
@ -3897,24 +3897,23 @@ void Clay_SetCurrentContext(Clay_Context* context) {
} }
CLAY_WASM_EXPORT("Clay_GetScrollOffset") CLAY_WASM_EXPORT("Clay_GetScrollOffset")
Clay_Vector2 Clay_GetScrollOffset() { Clay_Vector2 Clay_GetScrollOffset(void) {
Clay_Context* context = Clay_GetCurrentContext(); Clay_Context* context = Clay_GetCurrentContext();
if (context->booleanWarnings.maxElementsExceeded) { if (context->booleanWarnings.maxElementsExceeded) {
return CLAY__INIT(Clay_Vector2){}; return CLAY__INIT(Clay_Vector2){0};
} }
Clay_LayoutElement *openLayoutElement = Clay__GetOpenLayoutElement(); Clay_LayoutElement *openLayoutElement = Clay__GetOpenLayoutElement();
// If the element has no id attached at this point, we need to generate one // If the element has no id attached at this point, we need to generate one
if (openLayoutElement->id == 0) { if (openLayoutElement->id == 0) {
Clay__GenerateIdForAnonymousElement(openLayoutElement); Clay__GenerateIdForAnonymousElement(openLayoutElement);
} }
Clay_ClipElementConfig *clipConfig = Clay__FindElementConfigWithType(openLayoutElement, CLAY__ELEMENT_CONFIG_TYPE_CLIP).clipElementConfig;
for (int32_t i = 0; i < context->scrollContainerDatas.length; i++) { for (int32_t i = 0; i < context->scrollContainerDatas.length; i++) {
Clay__ScrollContainerDataInternal *mapping = Clay__ScrollContainerDataInternalArray_Get(&context->scrollContainerDatas, i); Clay__ScrollContainerDataInternal *mapping = Clay__ScrollContainerDataInternalArray_Get(&context->scrollContainerDatas, i);
if (mapping->layoutElement == openLayoutElement) { if (mapping->layoutElement == openLayoutElement) {
return mapping->scrollPosition; return mapping->scrollPosition;
} }
} }
return CLAY__INIT(Clay_Vector2){}; return CLAY__INIT(Clay_Vector2){0};
} }
CLAY_WASM_EXPORT("Clay_UpdateScrollContainers") CLAY_WASM_EXPORT("Clay_UpdateScrollContainers")