From 13b588d8c1ffda2f74ece848c610c963bd9cb73e Mon Sep 17 00:00:00 2001 From: Orcolom Date: Wed, 19 Feb 2025 21:54:08 +0100 Subject: [PATCH 1/3] added a pointer get method --- clay.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/clay.h b/clay.h index f893d3a..d5bba1a 100644 --- a/clay.h +++ b/clay.h @@ -778,6 +778,9 @@ Clay_Arena Clay_CreateArenaWithCapacityAndMemory(uint32_t capacity, void *memory // Sets the state of the "pointer" (i.e. the mouse or touch) in Clay's internal data. Used for detecting and responding to mouse events in the debug view, // as well as for Clay_Hovered() and scroll element handling. void Clay_SetPointerState(Clay_Vector2 position, bool pointerDown); +// Gets the state of the "pointer". This will return the position provided by `Clay_SetPointerState` +// and the frame pressed state. +Clay_PointerData Clay_GetPointerState(); // Initialize Clay's internal arena and setup required data before layout can begin. Only needs to be called once. // - arena can be created using Clay_CreateArenaWithCapacityAndMemory() // - layoutDimensions are the initial bounding dimensions of the layout (i.e. the screen width and height for a full screen layout) @@ -3698,6 +3701,12 @@ void Clay_SetPointerState(Clay_Vector2 position, bool isPointerDown) { } } +CLAY_WASM_EXPORT("Clay_GetPointerState") +Clay_PointerData Clay_GetPointerState() { + Clay_Context* context = Clay_GetCurrentContext(); + return context->pointerInfo; +} + CLAY_WASM_EXPORT("Clay_Initialize") Clay_Context* Clay_Initialize(Clay_Arena arena, Clay_Dimensions layoutDimensions, Clay_ErrorHandler errorHandler) { Clay_Context *context = Clay__Context_Allocate_Arena(&arena); From d1fd147b09f70581883b07129f60f5ef0f2943ed Mon Sep 17 00:00:00 2001 From: Orcolom Date: Wed, 19 Feb 2025 22:01:25 +0100 Subject: [PATCH 2/3] added getpointerstate to readme --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 202d0c1..57fc648 100644 --- a/README.md +++ b/README.md @@ -169,6 +169,7 @@ For help starting out or to discuss clay, considering joining [the discord serve - [Clay_SetCurrentContext](#clay_setcurrentcontext) - [Clay_SetLayoutDimensions](#clay_setlayoutdimensions) - [Clay_SetPointerState](#clay_setpointerstate) + - [Clay_GetPointerState](#clay_getpointerstate) - [Clay_UpdateScrollContainers](#clay_updatescrollcontainers) - [Clay_BeginLayout](#clay_beginlayout) - [Clay_EndLayout](#clay_endlayout) @@ -645,6 +646,14 @@ Sets the internal pointer position and state (i.e. current mouse / touch positio --- +### Clay_GetPointerState + +`Clay_PointerData Clay_GetPointerState()` + +Get the internal pointer position and state (i.e. current mouse / touch position). returns clay internal click start and stop state. + +--- + ### Clay_UpdateScrollContainers `void Clay_UpdateScrollContainers(bool enableDragScrolling, Clay_Vector2 scrollDelta, float deltaTime)` From af3d63ad0f2af944689c1cd313ad1a81194d2c59 Mon Sep 17 00:00:00 2001 From: Orcolom Date: Wed, 26 Feb 2025 21:13:36 +0100 Subject: [PATCH 3/3] added dll_export macro --- clay.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clay.h b/clay.h index c7c50fc..aecc047 100644 --- a/clay.h +++ b/clay.h @@ -783,10 +783,10 @@ CLAY_DLL_EXPORT uint32_t Clay_MinMemorySize(void); CLAY_DLL_EXPORT Clay_Arena Clay_CreateArenaWithCapacityAndMemory(uint32_t capacity, void *memory); // Sets the state of the "pointer" (i.e. the mouse or touch) in Clay's internal data. Used for detecting and responding to mouse events in the debug view, // as well as for Clay_Hovered() and scroll element handling. -void Clay_SetPointerState(Clay_Vector2 position, bool pointerDown); +CLAY_DLL_EXPORT void Clay_SetPointerState(Clay_Vector2 position, bool pointerDown); // Gets the state of the "pointer". This will return the position provided by `Clay_SetPointerState` // and the frame pressed state. -Clay_PointerData Clay_GetPointerState(); +CLAY_DLL_EXPORT Clay_PointerData Clay_GetPointerState(); // Initialize Clay's internal arena and setup required data before layout can begin. Only needs to be called once. // - arena can be created using Clay_CreateArenaWithCapacityAndMemory() // - layoutDimensions are the initial bounding dimensions of the layout (i.e. the screen width and height for a full screen layout)