mirror of
https://github.com/nicbarker/clay.git
synced 2025-09-18 12:36:17 +00:00
Merge bae8b2ea25
into 0d6969c8c3
This commit is contained in:
commit
5c8dbcf10d
13
clay.h
13
clay.h
|
@ -863,6 +863,8 @@ CLAY_DLL_EXPORT Clay_ElementId Clay_GetElementId(Clay_String idString);
|
||||||
// - index is used to avoid constructing dynamic ID strings in loops.
|
// - index is used to avoid constructing dynamic ID strings in loops.
|
||||||
// Generally only used for dynamic strings when CLAY_IDI("stringLiteral", index) can't be used.
|
// Generally only used for dynamic strings when CLAY_IDI("stringLiteral", index) can't be used.
|
||||||
CLAY_DLL_EXPORT Clay_ElementId Clay_GetElementIdWithIndex(Clay_String idString, uint32_t index);
|
CLAY_DLL_EXPORT Clay_ElementId Clay_GetElementIdWithIndex(Clay_String idString, uint32_t index);
|
||||||
|
// Returns the ID of the currently open layout element.
|
||||||
|
CLAY_DLL_EXPORT Clay_ElementId Clay_GetCurrentElementId(void);
|
||||||
// Returns layout data such as the final calculated bounding box for an element with a given ID.
|
// Returns layout data such as the final calculated bounding box for an element with a given ID.
|
||||||
// The returned Clay_ElementData contains a `found` bool that will be true if an element with the provided ID was found.
|
// The returned Clay_ElementData contains a `found` bool that will be true if an element with the provided ID was found.
|
||||||
// This ID can be calculated either with CLAY_ID() for string literal IDs, or Clay_GetElementId for dynamic strings.
|
// This ID can be calculated either with CLAY_ID() for string literal IDs, or Clay_GetElementId for dynamic strings.
|
||||||
|
@ -4071,6 +4073,17 @@ Clay_Context* Clay_GetCurrentContext(void) {
|
||||||
return Clay__currentContext;
|
return Clay__currentContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CLAY_WASM_EXPORT("Clay_GetCurrentElementId")
|
||||||
|
Clay_ElementId Clay_GetCurrentElementId(void) {
|
||||||
|
Clay_Context* context = Clay_GetCurrentContext();
|
||||||
|
if (context->openLayoutElementStack.length == 0) {
|
||||||
|
// Return a default or invalid ElementId if no element is open
|
||||||
|
return CLAY__INIT(Clay_ElementId) CLAY__DEFAULT_STRUCT;
|
||||||
|
}
|
||||||
|
Clay_LayoutElement* currentElement = Clay_LayoutElementArray_Get(&context->layoutElements, Clay__int32_tArray_GetValue(&context->openLayoutElementStack, context->openLayoutElementStack.length - 1));
|
||||||
|
return CLAY__INIT(Clay_ElementId) { .id = currentElement->id };
|
||||||
|
}
|
||||||
|
|
||||||
CLAY_WASM_EXPORT("Clay_SetCurrentContext")
|
CLAY_WASM_EXPORT("Clay_SetCurrentContext")
|
||||||
void Clay_SetCurrentContext(Clay_Context* context) {
|
void Clay_SetCurrentContext(Clay_Context* context) {
|
||||||
Clay__currentContext = context;
|
Clay__currentContext = context;
|
||||||
|
|
Loading…
Reference in a new issue