Skip to content

Commit 4ebe223

Browse files
authored
[Core] Fix local id calculation (#50)
1 parent 6cb9c7c commit 4ebe223

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

clay.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484

8585
#define CLAY_ID_LOCAL(label) CLAY_IDI_LOCAL(label, 0)
8686

87-
#define CLAY_IDI_LOCAL(label, index) Clay__AttachId(Clay__HashString(CLAY_STRING(label), Clay_LayoutElementArray_Get(&Clay__layoutElements, Clay__int32_tArray_Get(&Clay__openLayoutElementStack, Clay__openLayoutElementStack.length - 2))->children.length + 1, Clay__GetOpenLayoutElement()->id))
87+
#define CLAY_IDI_LOCAL(label, index) Clay__AttachId(Clay__HashString(CLAY_STRING(label), index, Clay__GetParentElementId()))
8888

8989
#define CLAY__STRING_LENGTH(s) ((sizeof(s) / sizeof((s)[0])) - sizeof((s)[0]))
9090

@@ -516,6 +516,7 @@ Clay_ScrollElementConfig * Clay__StoreScrollElementConfig(Clay_ScrollElementConf
516516
Clay_BorderElementConfig * Clay__StoreBorderElementConfig(Clay_BorderElementConfig config);
517517
Clay_ElementId Clay__HashString(Clay_String key, uint32_t offset, uint32_t seed);
518518
void Clay__OpenTextElement(Clay_String text, Clay_TextElementConfig *textConfig);
519+
uint32_t Clay__GetParentElementId(void);
519520

520521
extern Clay_Color Clay__debugViewHighlightColor;
521522
extern uint32_t Clay__debugViewWidth;
@@ -1486,6 +1487,10 @@ Clay_LayoutElement* Clay__GetOpenLayoutElement(void) {
14861487
return Clay_LayoutElementArray_Get(&Clay__layoutElements, Clay__int32_tArray_Get(&Clay__openLayoutElementStack, Clay__openLayoutElementStack.length - 1));
14871488
}
14881489

1490+
uint32_t Clay__GetParentElementId(void) {
1491+
return Clay_LayoutElementArray_Get(&Clay__layoutElements, Clay__int32_tArray_Get(&Clay__openLayoutElementStack, Clay__openLayoutElementStack.length - 2))->id;
1492+
}
1493+
14891494
bool Clay__ElementHasConfig(Clay_LayoutElement *element, Clay__ElementConfigType type) {
14901495
return (element->configsEnabled & type);
14911496
}

0 commit comments

Comments
 (0)