From f298e34bdc28f66021457ca0a3f1574c0db72582 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Thu, 20 Mar 2025 10:45:44 -0400 Subject: [PATCH 1/4] clay.h: update Clay_OnHover to take void* --- clay.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/clay.h b/clay.h index ca0d5a4..23841dc 100644 --- a/clay.h +++ b/clay.h @@ -841,7 +841,7 @@ CLAY_DLL_EXPORT bool Clay_Hovered(void); // Bind a callback that will be called when the pointer position provided by Clay_SetPointerState is within the current element's bounding box. // - onHoverFunction is a function pointer to a user defined function. // - userData is a pointer that will be transparently passed through when the onHoverFunction is called. -CLAY_DLL_EXPORT void Clay_OnHover(void (*onHoverFunction)(Clay_ElementId elementId, Clay_PointerData pointerData, intptr_t userData), intptr_t userData); +CLAY_DLL_EXPORT void Clay_OnHover(void (*onHoverFunction)(Clay_ElementId elementId, Clay_PointerData pointerData, void *userData), void *userData); // An imperative function that returns true if the pointer position provided by Clay_SetPointerState is within the element with the provided ID's bounding box. // This ID can be calculated either with CLAY_ID() for string literal IDs, or Clay_GetElementId for dynamic strings. CLAY_DLL_EXPORT bool Clay_PointerOver(Clay_ElementId elementId); @@ -1134,8 +1134,8 @@ typedef struct { // todo get this struct into a single cache line Clay_BoundingBox boundingBox; Clay_ElementId elementId; Clay_LayoutElement* layoutElement; - void (*onHoverFunction)(Clay_ElementId elementId, Clay_PointerData pointerInfo, intptr_t userData); - intptr_t hoverFunctionUserData; + void (*onHoverFunction)(Clay_ElementId elementId, Clay_PointerData pointerInfo, void *userData); + void *hoverFunctionUserData; int32_t nextIndex; uint32_t generation; uint32_t idAlias; @@ -3976,7 +3976,7 @@ bool Clay_Hovered(void) { return false; } -void Clay_OnHover(void (*onHoverFunction)(Clay_ElementId elementId, Clay_PointerData pointerInfo, intptr_t userData), intptr_t userData) { +void Clay_OnHover(void (*onHoverFunction)(Clay_ElementId elementId, Clay_PointerData pointerInfo, void *userData), void *userData) { Clay_Context* context = Clay_GetCurrentContext(); if (context->booleanWarnings.maxElementsExceeded) { return; From 80caa0f4e7ee85b2e39ebf99f9c7166ce30e6119 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Thu, 20 Mar 2025 21:28:28 -0400 Subject: [PATCH 2/4] update signature of debug view close button handler --- clay.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clay.h b/clay.h index 23841dc..28cc490 100644 --- a/clay.h +++ b/clay.h @@ -3205,7 +3205,7 @@ void Clay__RenderDebugViewCornerRadius(Clay_CornerRadius cornerRadius, Clay_Text } } -void HandleDebugViewCloseButtonInteraction(Clay_ElementId elementId, Clay_PointerData pointerInfo, intptr_t userData) { +void HandleDebugViewCloseButtonInteraction(Clay_ElementId elementId, Clay_PointerData pointerInfo, void *userData) { Clay_Context* context = Clay_GetCurrentContext(); (void) elementId; (void) pointerInfo; (void) userData; if (pointerInfo.state == CLAY_POINTER_DATA_PRESSED_THIS_FRAME) { From 6935abbbfb9702e1c8f09fa4065cd546fb6cd8ad Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Thu, 20 Mar 2025 21:47:09 -0400 Subject: [PATCH 3/4] fix other files too --- README.md | 6 +++--- examples/clay-official-website/main.c | 4 ++-- examples/shared-layouts/clay-video-demo.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 352069d..9f8706e 100644 --- a/README.md +++ b/README.md @@ -313,7 +313,7 @@ CLAY({ .backgroundColor = Clay_Hovered() ? COLOR_BLUE : COLOR_ORANGE }) { The function `void Clay_OnHover()` allows you to attach a function pointer to the currently open element, which will be called if the mouse / pointer is over the element. ```C -void HandleButtonInteraction(Clay_ElementId elementId, Clay_PointerData pointerInfo, intptr_t userData) { +void HandleButtonInteraction(Clay_ElementId elementId, Clay_PointerData pointerInfo, void *userData) { ButtonData *buttonData = (ButtonData *)userData; // Pointer state allows you to detect mouse down / hold / release if (pointerInfo.state == CLAY_POINTER_DATA_PRESSED_THIS_FRAME) { @@ -684,12 +684,12 @@ Called **during** layout declaration, and returns `true` if the pointer position ### Clay_OnHover -`void Clay_OnHover(void (*onHoverFunction)(Clay_ElementId elementId, Clay_PointerData pointerData, intptr_t userData), intptr_t userData)` +`void Clay_OnHover(void (*onHoverFunction)(Clay_ElementId elementId, Clay_PointerData pointerData, void *userData), void *userData)` Called **during** layout declaration, this function allows you to attach a function pointer to the currently open element that will be called once per layout if the pointer position previously set with `Clay_SetPointerState` is inside the bounding box of the currently open element. See [Clay_PointerData](#clay_pointerdata) for more information on the `pointerData` argument. ```C -void HandleButtonInteraction(Clay_ElementId elementId, Clay_PointerData pointerData, intptr_t userData) { +void HandleButtonInteraction(Clay_ElementId elementId, Clay_PointerData pointerData, void *userData) { ButtonData *buttonData = (ButtonData *)userData; // Pointer state allows you to detect mouse down / hold / release if (pointerData.state == CLAY_POINTER_DATA_PRESSED_THIS_FRAME) { diff --git a/examples/clay-official-website/main.c b/examples/clay-official-website/main.c index 0c5d632..3d99bb8 100644 --- a/examples/clay-official-website/main.c +++ b/examples/clay-official-website/main.c @@ -232,7 +232,7 @@ void HighPerformancePageMobile(float lerpValue) { } } -void HandleRendererButtonInteraction(Clay_ElementId elementId, Clay_PointerData pointerInfo, intptr_t userData) { +void HandleRendererButtonInteraction(Clay_ElementId elementId, Clay_PointerData pointerInfo, void *userData) { if (pointerInfo.state == CLAY_POINTER_DATA_PRESSED_THIS_FRAME) { ACTIVE_RENDERER_INDEX = (uint32_t)userData; Clay_SetCullingEnabled(ACTIVE_RENDERER_INDEX == 1); @@ -259,7 +259,7 @@ void RendererButtonInactive(Clay_String text, size_t rendererIndex) { .cornerRadius = CLAY_CORNER_RADIUS(10), .userData = FrameAllocateCustomData((CustomHTMLData) { .disablePointerEvents = true, .cursorPointer = true }) }) { - Clay_OnHover(HandleRendererButtonInteraction, rendererIndex); + Clay_OnHover(HandleRendererButtonInteraction, (void *)rendererIndex); CLAY_TEXT(text, CLAY_TEXT_CONFIG({ .fontSize = 28, .fontId = FONT_ID_BODY_36, .textColor = COLOR_RED })); } } diff --git a/examples/shared-layouts/clay-video-demo.c b/examples/shared-layouts/clay-video-demo.c index e7400a3..e4b4353 100644 --- a/examples/shared-layouts/clay-video-demo.c +++ b/examples/shared-layouts/clay-video-demo.c @@ -64,7 +64,7 @@ typedef struct { void HandleSidebarInteraction( Clay_ElementId elementId, Clay_PointerData pointerData, - intptr_t userData + void *userData ) { SidebarClickData *clickData = (SidebarClickData*)userData; // If this button was clicked @@ -222,7 +222,7 @@ Clay_RenderCommandArray ClayVideoDemo_CreateLayout(ClayVideoDemo_Data *data) { *clickData = (SidebarClickData) { .requestedDocumentIndex = i, .selectedDocumentIndex = &data->selectedDocumentIndex }; data->frameArena.offset += sizeof(SidebarClickData); CLAY({ .layout = sidebarButtonLayout, .backgroundColor = (Clay_Color) { 120, 120, 120, Clay_Hovered() ? 120 : 0 }, .cornerRadius = CLAY_CORNER_RADIUS(8) }) { - Clay_OnHover(HandleSidebarInteraction, (intptr_t)clickData); + Clay_OnHover(HandleSidebarInteraction, (void *)clickData); CLAY_TEXT(document.title, CLAY_TEXT_CONFIG({ .fontId = FONT_ID_BODY_16, .fontSize = 20, From 63d3af6372241b46c53da665d71f7f89f2b2c133 Mon Sep 17 00:00:00 2001 From: TotallyGamerJet Date: Thu, 20 Mar 2025 21:54:25 -0400 Subject: [PATCH 4/4] remove unnecessary cast --- examples/shared-layouts/clay-video-demo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/shared-layouts/clay-video-demo.c b/examples/shared-layouts/clay-video-demo.c index e4b4353..6779023 100644 --- a/examples/shared-layouts/clay-video-demo.c +++ b/examples/shared-layouts/clay-video-demo.c @@ -222,7 +222,7 @@ Clay_RenderCommandArray ClayVideoDemo_CreateLayout(ClayVideoDemo_Data *data) { *clickData = (SidebarClickData) { .requestedDocumentIndex = i, .selectedDocumentIndex = &data->selectedDocumentIndex }; data->frameArena.offset += sizeof(SidebarClickData); CLAY({ .layout = sidebarButtonLayout, .backgroundColor = (Clay_Color) { 120, 120, 120, Clay_Hovered() ? 120 : 0 }, .cornerRadius = CLAY_CORNER_RADIUS(8) }) { - Clay_OnHover(HandleSidebarInteraction, (void *)clickData); + Clay_OnHover(HandleSidebarInteraction, clickData); CLAY_TEXT(document.title, CLAY_TEXT_CONFIG({ .fontId = FONT_ID_BODY_16, .fontSize = 20,