Compare commits

...

3 Commits

Author SHA1 Message Date
Yaroslav Erohin
61711977c2
Merge 642eedaa30 into 19a27b39f2 2025-03-09 10:33:54 +13:00
Daniel Collin
19a27b39f2
[Compilers] Fixed SIMD related compile error on some ARM compilers (#316)
Some checks are pending
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Waiting to run
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Waiting to run
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Waiting to run
2025-03-09 10:28:09 +13:00
Iaroslav Erokhin
642eedaa30 Add bool Clay_GetElementHovered(Clay_ElementId) 2025-03-05 08:31:24 +01:00

17
clay.h
View File

@ -834,6 +834,8 @@ CLAY_DLL_EXPORT Clay_ElementData Clay_GetElementData(Clay_ElementId id);
// Returns true if the pointer position provided by Clay_SetPointerState is within the current element's bounding box.
// Works during element declaration, e.g. CLAY({ .backgroundColor = Clay_Hovered() ? BLUE : RED });
CLAY_DLL_EXPORT bool Clay_Hovered(void);
// Returns true if an element with the specified id is found and if the pointer position provided by Clay_SetPointerState is within the element's bounding box.
CLAY_DLL_EXPORT bool Clay_GetElementHovered(Clay_ElementId elementId);
// 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.
@ -1771,7 +1773,7 @@ bool Clay__MemCmp(const char *s1, const char *s2, int32_t length);
uint8x16_t v2 = vld1q_u8((const uint8_t *)s2);
// Compare vectors
if (vminvq_u32(vceqq_u8(v1, v2)) != 0xFFFFFFFF) { // If there's a difference
if (vminvq_u32(vreinterpretq_u32_u8(vceqq_u8(v1, v2))) != 0xFFFFFFFF) { // If there's a difference
return false;
}
@ -3962,6 +3964,19 @@ bool Clay_Hovered(void) {
return false;
}
bool Clay_GetElementHovered(Clay_ElementId elementId) {
Clay_Context* context = Clay_GetCurrentContext();
if (context->booleanWarnings.maxElementsExceeded) {
return false;
}
for (int32_t i = 0; i < context->pointerOverIds.length; ++i) {
if (Clay__ElementIdArray_Get(&context->pointerOverIds, i)->id == elementId.id) {
return true;
}
}
return false;
}
void Clay_OnHover(void (*onHoverFunction)(Clay_ElementId elementId, Clay_PointerData pointerInfo, intptr_t userData), intptr_t userData) {
Clay_Context* context = Clay_GetCurrentContext();
if (context->booleanWarnings.maxElementsExceeded) {