From 0354ffdef9507ac05beb3476498999ba5fc6e972 Mon Sep 17 00:00:00 2001 From: Nic Barker Date: Tue, 4 Mar 2025 10:23:20 +1300 Subject: [PATCH] Fix readme and add comments to clay.h --- README.md | 12 ++++++------ clay.h | 4 ++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index f9d5340..ef3c768 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/clay.h b/clay.h index d78baa0..163c42d 100644 --- a/clay.h +++ b/clay.h @@ -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())