Repository: nicbarker/clay
File: clay.h (C/C++)

Code before:

#define CLAY_BORDER_CONFIG_OUTSIDE(...)  Clay__StoreBorderElementConfig((Clay_BorderElementConfig) { .left = { __VA_ARGS__ }, .right = { __VA_ARGS__ }, .top = { __VA_ARGS__ }, .bottom = { __VA_ARGS__ } })

#define CLAY_BORDER_CONFIG_OUTSIDE_RADIUS(width, color, radius)  Clay__StoreBorderElementConfig((Clay_BorderElementConfig) { .left = { width, color }, .right = { width, color }, .top = { width, color }, .bottom = { width, color }, .cornerRadius = { radius, radius, radius, radius } })

#define CLAY_BORDER_CONFIG_ALL(...)  Clay__StoreBorderElementConfig((Clay_BorderElementConfig) { .left = { __VA_ARGS__ }, .right = { __VA_ARGS__ }, .top = { __VA_ARGS__ }, .bottom = { __VA_ARGS__ }, .betweenChildren = { __VA_ARGS__ } })

#define CLAY_BORDER_CONFIG_ALL_RADIUS(width, color, radius)  Clay__StoreBorderElementConfig((Clay_BorderElementConfig) { .left = { width, color }, .right = { width, color }, .top = { width, color }, .bottom = { width, color }, .betweenChildren = { width, color }, .cornerRadius = { radius, radius, radius, radius }})

#define CLAY_CORNER_RADIUS(radius) (Clay_CornerRadius) { radius, radius, radius, radius }

#define CLAY_SIZING_FIT(...) (Clay_SizingAxis) { .type = CLAY__SIZING_TYPE_FIT, .sizeMinMax = (Clay_SizingMinMax) {__VA_ARGS__} }

#define CLAY_SIZING_GROW(...) (Clay_SizingAxis) { .type = CLAY__SIZING_TYPE_GROW, .sizeMinMax = (Clay_SizingMinMax) {__VA_ARGS__} }

#define CLAY_SIZING_FIXED(fixedSize) (Clay_SizingAxis) { .type = CLAY__SIZING_TYPE_GROW, .sizeMinMax = { fixedSize, fixedSize } }

#define CLAY_SIZING_PERCENT(percentOfParent) (Clay_SizingAxis) { .type = CLAY__SIZING_TYPE_PERCENT, .sizePercent = (percentOfParent) }

#define CLAY_ID(label) Clay__HashString(CLAY_STRING(label), 0, 0)

#define CLAY_IDI(label, index) Clay__HashString(CLAY_STRING(label), index, 0)

#define CLAY_LOCAL_ID(label) CLAY_LOCAL_IDI(label, 0)

#define CLAY_LOCAL_IDI(label, index) Clay__HashString(CLAY_STRING(label), index, Clay__GetParentId())

#define CLAY_ID_AUTO (Clay_ElementId) { .stringId = CLAY_STRING("Auto Generated ID"), .id = Clay__RehashWithNumber(Clay__dynamicElementIndexBaseHash.id, Clay__dynamicElementIndex++) }

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

#define CLAY_STRING(string) (Clay_String) { .length = CLAY__STRING_LENGTH(string), .chars = (string) }

// Publicly visible layout element macros -----------------------------------------------------
#define CLAY_CONTAINER(id, layoutConfig, children)  \
    Clay__OpenContainerElement(id, layoutConfig);   \
    children                                        \
    Clay__CloseElementWithChildren()

#define CLAY_RECTANGLE(id, layoutConfig, rectangleConfig, children)     \
    Clay__OpenRectangleElement(id, layoutConfig, rectangleConfig);      \
    children                                                            \
    Clay__CloseElementWithChildren()

#define CLAY_TEXT(id, text, textConfig) Clay__OpenTextElement(id, text, textConfig)

#define CLAY_IMAGE(id, layoutConfig, imageConfig, children)         \
    Clay__OpenImageElement(id, layoutConfig, imageConfig);          \
    children                                                        \
    Clay__CloseElementWithChildren()


Review comment (suggestion):
```suggestion
#define CLAY_LOCAL_IDI(label, index) Clay__HashString(CLAY_STRING(label), index, Clay__GetOpenLayoutElementId())
```

Code after:

#define CLAY_BORDER_CONFIG_OUTSIDE(...)  Clay__StoreBorderElementConfig((Clay_BorderElementConfig) { .left = { __VA_ARGS__ }, .right = { __VA_ARGS__ }, .top = { __VA_ARGS__ }, .bottom = { __VA_ARGS__ } })

#define CLAY_BORDER_CONFIG_OUTSIDE_RADIUS(width, color, radius)  Clay__StoreBorderElementConfig((Clay_BorderElementConfig) { .left = { width, color }, .right = { width, color }, .top = { width, color }, .bottom = { width, color }, .cornerRadius = { radius, radius, radius, radius } })

#define CLAY_BORDER_CONFIG_ALL(...)  Clay__StoreBorderElementConfig((Clay_BorderElementConfig) { .left = { __VA_ARGS__ }, .right = { __VA_ARGS__ }, .top = { __VA_ARGS__ }, .bottom = { __VA_ARGS__ }, .betweenChildren = { __VA_ARGS__ } })

#define CLAY_BORDER_CONFIG_ALL_RADIUS(width, color, radius)  Clay__StoreBorderElementConfig((Clay_BorderElementConfig) { .left = { width, color }, .right = { width, color }, .top = { width, color }, .bottom = { width, color }, .betweenChildren = { width, color }, .cornerRadius = { radius, radius, radius, radius }})

#define CLAY_CORNER_RADIUS(radius) (Clay_CornerRadius) { radius, radius, radius, radius }

#define CLAY_SIZING_FIT(...) (Clay_SizingAxis) { .type = CLAY__SIZING_TYPE_FIT, .sizeMinMax = (Clay_SizingMinMax) {__VA_ARGS__} }

#define CLAY_SIZING_GROW(...) (Clay_SizingAxis) { .type = CLAY__SIZING_TYPE_GROW, .sizeMinMax = (Clay_SizingMinMax) {__VA_ARGS__} }

#define CLAY_SIZING_FIXED(fixedSize) (Clay_SizingAxis) { .type = CLAY__SIZING_TYPE_GROW, .sizeMinMax = { fixedSize, fixedSize } }

#define CLAY_SIZING_PERCENT(percentOfParent) (Clay_SizingAxis) { .type = CLAY__SIZING_TYPE_PERCENT, .sizePercent = (percentOfParent) }

#define CLAY_ID(label) Clay__HashString(CLAY_STRING(label), 0, 0)

#define CLAY_IDI(label, index) Clay__HashString(CLAY_STRING(label), index, 0)

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

#define CLAY_IDI_LOCAL(label, index) Clay__HashString(CLAY_STRING(label), index, Clay__GetOpenLayoutElementId())

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

#define CLAY_STRING(string) (Clay_String) { .length = CLAY__STRING_LENGTH(string), .chars = (string) }

// Publicly visible layout element macros -----------------------------------------------------
#define CLAY_CONTAINER(id, layoutConfig, children)  \
    Clay__OpenContainerElement(id, layoutConfig);   \
    children                                        \
    Clay__CloseElementWithChildren()

#define CLAY_RECTANGLE(id, layoutConfig, rectangleConfig, children)     \
    Clay__OpenRectangleElement(id, layoutConfig, rectangleConfig);      \
    children                                                            \
    Clay__CloseElementWithChildren()

#define CLAY_TEXT(id, text, textConfig) Clay__OpenTextElement(id, text, textConfig)

#define CLAY_IMAGE(id, layoutConfig, imageConfig, children)         \
    Clay__OpenImageElement(id, layoutConfig, imageConfig);          \
    children                                                        \
    Clay__CloseElementWithChildren()

#define CLAY_SCROLL_CONTAINER(id, layoutConfig, scrollConfig, children)     \
    Clay__OpenScrollElement(id, layoutConfig, scrollConfig);                \