[Core] Add API to query element bounding boxes (#199)
Some checks failed
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) Failing after 12s
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Failing after 13s

Co-authored-by: hexmaster111 <hailey@not-an-email-address.fake>
This commit is contained in:
Nic Barker 2025-01-14 22:09:06 +13:00 committed by GitHub
parent 338852b3ce
commit 814c9392c6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

21
clay.h
View File

@ -443,6 +443,13 @@ CLAY__TYPEDEF(Clay_ScrollContainerData, struct {
bool found; bool found;
}); });
CLAY__TYPEDEF(Clay_ElementData, struct
{
Clay_BoundingBox boundingBox;
// Indicates whether an actual Element matched the provided ID or if the default struct was returned.
bool found;
});
CLAY__TYPEDEF(Clay_RenderCommandType, CLAY_PACKED_ENUM { CLAY__TYPEDEF(Clay_RenderCommandType, CLAY_PACKED_ENUM {
CLAY_RENDER_COMMAND_TYPE_NONE, CLAY_RENDER_COMMAND_TYPE_NONE,
CLAY_RENDER_COMMAND_TYPE_RECTANGLE, CLAY_RENDER_COMMAND_TYPE_RECTANGLE,
@ -515,6 +522,7 @@ void Clay_BeginLayout(void);
Clay_RenderCommandArray Clay_EndLayout(void); Clay_RenderCommandArray Clay_EndLayout(void);
Clay_ElementId Clay_GetElementId(Clay_String idString); Clay_ElementId Clay_GetElementId(Clay_String idString);
Clay_ElementId Clay_GetElementIdWithIndex(Clay_String idString, uint32_t index); Clay_ElementId Clay_GetElementIdWithIndex(Clay_String idString, uint32_t index);
Clay_ElementData Clay_GetElementData (Clay_ElementId id);
bool Clay_Hovered(void); bool Clay_Hovered(void);
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, intptr_t userData), intptr_t userData);
bool Clay_PointerOver(Clay_ElementId elementId); bool Clay_PointerOver(Clay_ElementId elementId);
@ -4005,6 +4013,19 @@ Clay_ScrollContainerData Clay_GetScrollContainerData(Clay_ElementId id) {
return CLAY__INIT(Clay_ScrollContainerData) CLAY__DEFAULT_STRUCT; return CLAY__INIT(Clay_ScrollContainerData) CLAY__DEFAULT_STRUCT;
} }
CLAY_WASM_EXPORT("Clay_GetElementData")
Clay_ElementData Clay_GetElementData(Clay_ElementId id){
Clay_LayoutElementHashMapItem * item = Clay__GetHashMapItem(id.id);
if(item == &CLAY__LAYOUT_ELEMENT_HASH_MAP_ITEM_DEFAULT) {
return CLAY__INIT(Clay_ElementData) CLAY__DEFAULT_STRUCT;
}
return CLAY__INIT(Clay_ElementData){
.boundingBox = item->boundingBox,
.found = true
};
}
CLAY_WASM_EXPORT("Clay_SetDebugModeEnabled") CLAY_WASM_EXPORT("Clay_SetDebugModeEnabled")
void Clay_SetDebugModeEnabled(bool enabled) { void Clay_SetDebugModeEnabled(bool enabled) {
Clay_Context* context = Clay_GetCurrentContext(); Clay_Context* context = Clay_GetCurrentContext();