Fix readme and add comments to clay.h

This commit is contained in:
Nic Barker 2025-03-04 10:23:20 +13:00
parent 500caa0ad8
commit 0354ffdef9
2 changed files with 10 additions and 6 deletions

View File

@ -926,7 +926,7 @@ if (buttonIsHovered && leftMouseButtonPressed) {
### CLAY_SID()
`Clay_ElementId CLAY_SID(char *label)`
`Clay_ElementId CLAY_SID(Clay_String idString)`
A version of [CLAY_ID](#clay_id) that can be used with heap allocated `char *` data. The underlying `char` data will not be copied internally and should live until at least the next frame.
@ -934,7 +934,7 @@ A version of [CLAY_ID](#clay_id) that can be used with heap allocated `char *` d
### CLAY_IDI()
`Clay_ElementId CLAY_IDI(STRING_LITERAL label, int32_t index)`
`Clay_ElementId CLAY_IDI(STRING_LITERAL idString, int32_t index)`
An offset version of [CLAY_ID](#clay_id). Generates a [Clay_ElementId](#clay_elementid) string id from the provided `char *label`, combined with the `int index`.
@ -946,7 +946,7 @@ Note this macro only works with String literals and won't compile if used with a
### CLAY_SIDI()
`Clay_ElementId CLAY_SIDI(char *label, int32_t index)`
`Clay_ElementId CLAY_SIDI(Clay_String idString, int32_t index)`
A version of [CLAY_IDI](#clay_idi) that can be used with heap allocated `char *` data. The underlying `char` data will not be copied internally and should live until at least the next frame.
@ -993,7 +993,7 @@ for (int i = 0; i < headerButtons.length; i++) {
### CLAY_SID_LOCAL()
`Clay_ElementId CLAY_SID_LOCAL(char *label)`
`Clay_ElementId CLAY_SID_LOCAL(Clay_String idString)`
A version of [CLAY_ID_LOCAL](#clay_id_local) that can be used with heap allocated `char *` data. The underlying `char` data will not be copied internally and should live until at least the next frame.
@ -1001,7 +1001,7 @@ A version of [CLAY_ID_LOCAL](#clay_id_local) that can be used with heap allocate
### CLAY_IDI_LOCAL()
`Clay_ElementId CLAY_IDI_LOCAL(STRING_LITERAL label, int32_t index)`
`Clay_ElementId CLAY_IDI_LOCAL(STRING_LITERAL idString, int32_t index)`
An offset version of [CLAY_ID_LOCAL](#clay_local_id). Generates a [Clay_ElementId](#clay_elementid) string id from the provided `char *label`, combined with the `int index`.
@ -1013,7 +1013,7 @@ Note this macro only works with String literals and won't compile if used with a
### CLAY_SIDI_LOCAL()
`Clay_ElementId CLAY_SIDI_LOCAL(char *label, int32_t index)`
`Clay_ElementId CLAY_SIDI_LOCAL(Clay_String idString, int32_t index)`
A version of [CLAY_IDI_LOCAL](#clay_idi_local) that can be used with heap allocated `char *` data. The underlying `char` data will not be copied internally and should live until at least the next frame.

4
clay.h
View File

@ -65,18 +65,22 @@
#define CLAY_SIZING_PERCENT(percentOfParent) (CLAY__INIT(Clay_SizingAxis) { .size = { .percent = (percentOfParent) }, .type = CLAY__SIZING_TYPE_PERCENT })
// Note: If a compile error led you here, you might be trying to use CLAY_ID with something other than a string literal. To construct an ID with a dynamic string, use CLAY_SID instead.
#define CLAY_ID(label) CLAY_IDI(label, 0)
#define CLAY_SID(label) CLAY_SIDI(label, 0)
// Note: If a compile error led you here, you might be trying to use CLAY_IDI with something other than a string literal. To construct an ID with a dynamic string, use CLAY_SIDI instead.
#define CLAY_IDI(label, index) CLAY_SIDI(CLAY_STRING(label), index)
#define CLAY_SIDI(label, index) Clay__HashString(label, index, 0)
// Note: If a compile error led you here, you might be trying to use CLAY_ID_LOCAL with something other than a string literal. To construct an ID with a dynamic string, use CLAY_SID_LOCAL instead.
#define CLAY_ID_LOCAL(label) CLAY_IDI_LOCAL(label, 0)
#define CLAY_SID_LOCAL(label) CLAY_SIDI_LOCAL(label, 0)
// Note: If a compile error led you here, you might be trying to use CLAY_IDI_LOCAL with something other than a string literal. To construct an ID with a dynamic string, use CLAY_SIDI_LOCAL instead.
#define CLAY_IDI_LOCAL(label, index) CLAY_SIDI_LOCAL(CLAY_STRING(label), index)
#define CLAY_SIDI_LOCAL(label, index) Clay__HashString(label, index, Clay__GetParentElementId())