Compare commits

...

3 Commits

Author SHA1 Message Date
__hexmaster111
a9e52f2305
Merge cbfa75e310 into c24a41b9e4 2024-12-30 00:27:50 +01:00
Junior Rantila
c24a41b9e4
Add Clay_IsDebugModeEnabled() (#130) 2024-12-30 12:04:48 +13:00
Hailey
cbfa75e310 [Core] Access bounding boxes of scrolling containers 2024-12-26 08:31:30 -06:00

31
clay.h
View File

@ -393,6 +393,14 @@ typedef struct
bool found; bool found;
} Clay_ScrollContainerData; } Clay_ScrollContainerData;
typedef struct
{
Clay_BoundingBox elementLocation;
// Indicates whether an actual Element matched the provided ID or if the default struct was returned.
bool found;
} Clay_ElementLocationData;
typedef enum { typedef enum {
CLAY_RENDER_COMMAND_TYPE_NONE, CLAY_RENDER_COMMAND_TYPE_NONE,
CLAY_RENDER_COMMAND_TYPE_RECTANGLE, CLAY_RENDER_COMMAND_TYPE_RECTANGLE,
@ -477,9 +485,11 @@ void Clay_SetMeasureTextFunction(Clay_Dimensions (*measureTextFunction)(Clay_Str
void Clay_SetQueryScrollOffsetFunction(Clay_Vector2 (*queryScrollOffsetFunction)(uint32_t elementId)); void Clay_SetQueryScrollOffsetFunction(Clay_Vector2 (*queryScrollOffsetFunction)(uint32_t elementId));
Clay_RenderCommand * Clay_RenderCommandArray_Get(Clay_RenderCommandArray* array, int32_t index); Clay_RenderCommand * Clay_RenderCommandArray_Get(Clay_RenderCommandArray* array, int32_t index);
void Clay_SetDebugModeEnabled(bool enabled); void Clay_SetDebugModeEnabled(bool enabled);
bool Clay_IsDebugModeEnabled(void);
void Clay_SetCullingEnabled(bool enabled); void Clay_SetCullingEnabled(bool enabled);
void Clay_SetMaxElementCount(uint32_t maxElementCount); void Clay_SetMaxElementCount(uint32_t maxElementCount);
void Clay_SetMaxMeasureTextCacheWordCount(uint32_t maxMeasureTextCacheWordCount); void Clay_SetMaxMeasureTextCacheWordCount(uint32_t maxMeasureTextCacheWordCount);
Clay_ElementLocationData Clay_GetElementLocationData (Clay_ElementId id);
// Internal API functions required by macros // Internal API functions required by macros
void Clay__OpenElement(void); void Clay__OpenElement(void);
@ -3847,11 +3857,32 @@ Clay_ScrollContainerData Clay_GetScrollContainerData(Clay_ElementId id) {
return CLAY__INIT(Clay_ScrollContainerData) {}; return CLAY__INIT(Clay_ScrollContainerData) {};
} }
CLAY_WASM_EXPORT("Clay_GetElementLocationData")
Clay_ElementLocationData Clay_GetElementLocationData(Clay_ElementId id){
Clay_LayoutElementHashMapItem * item =Clay__GetHashMapItem(id.id);
if(item == &CLAY__LAYOUT_ELEMENT_HASH_MAP_ITEM_DEFAULT) {
return CLAY__INIT(Clay_ElementLocationData){
.found=false,
.elementLocation=CLAY__INIT(Clay_BoundingBox){}
};
}
return CLAY__INIT(Clay_ElementLocationData){
.elementLocation=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__debugModeEnabled = enabled; Clay__debugModeEnabled = enabled;
} }
CLAY_WASM_EXPORT("Clay_IsDebugModeEnabled")
bool Clay_IsDebugModeEnabled(void) {
return Clay__debugModeEnabled;
}
CLAY_WASM_EXPORT("Clay_SetCullingEnabled") CLAY_WASM_EXPORT("Clay_SetCullingEnabled")
void Clay_SetCullingEnabled(bool enabled) { void Clay_SetCullingEnabled(bool enabled) {
Clay__disableCulling = !enabled; Clay__disableCulling = !enabled;