fix last couple of compatibility problems

This commit is contained in:
Nic Barker 2025-01-29 16:52:13 +13:00
parent 9b100c2456
commit 0c6d19c8ce
5 changed files with 21 additions and 19 deletions

12
clay.h
View File

@ -54,7 +54,7 @@
#define CLAY_FLOATING(...) Clay__AttachElementConfig(CLAY__INIT(Clay_ElementConfigUnion) { .floatingElementConfig = Clay__StoreFloatingElementConfig(CLAY__CONFIG_WRAPPER(Clay_FloatingElementConfig, __VA_ARGS__)) }, CLAY__ELEMENT_CONFIG_TYPE_FLOATING_CONTAINER) #define CLAY_FLOATING(...) Clay__AttachElementConfig(CLAY__INIT(Clay_ElementConfigUnion) { .floatingElementConfig = Clay__StoreFloatingElementConfig(CLAY__CONFIG_WRAPPER(Clay_FloatingElementConfig, __VA_ARGS__)) }, CLAY__ELEMENT_CONFIG_TYPE_FLOATING_CONTAINER)
#define CLAY_CUSTOM_ELEMENT(...) Clay__AttachElementConfig(CLAY__INIT(Clay_ElementConfigUnion) { .customElementConfig = Clay__StoreCustomElementConfig(CLAY__INIT(Clay_CustomElementConfig, __VA_ARGS__)))}, CLAY__ELEMENT_CONFIG_TYPE_CUSTOM) #define CLAY_CUSTOM_ELEMENT(...) Clay__AttachElementConfig(CLAY__INIT(Clay_ElementConfigUnion) { .customElementConfig = Clay__StoreCustomElementConfig(CLAY__CONFIG_WRAPPER(Clay_CustomElementConfig, __VA_ARGS__)) }, CLAY__ELEMENT_CONFIG_TYPE_CUSTOM)
#define CLAY_SCROLL(...) Clay__AttachElementConfig(CLAY__INIT(Clay_ElementConfigUnion) { .scrollElementConfig = Clay__StoreScrollElementConfig(CLAY__CONFIG_WRAPPER(Clay_ScrollElementConfig, __VA_ARGS__)) }, CLAY__ELEMENT_CONFIG_TYPE_SCROLL_CONTAINER) #define CLAY_SCROLL(...) Clay__AttachElementConfig(CLAY__INIT(Clay_ElementConfigUnion) { .scrollElementConfig = Clay__StoreScrollElementConfig(CLAY__CONFIG_WRAPPER(Clay_ScrollElementConfig, __VA_ARGS__)) }, CLAY__ELEMENT_CONFIG_TYPE_SCROLL_CONTAINER)
@ -70,7 +70,7 @@
#define CLAY_CORNER_RADIUS(radius) (CLAY__INIT(Clay_CornerRadius) { radius, radius, radius, radius }) #define CLAY_CORNER_RADIUS(radius) (CLAY__INIT(Clay_CornerRadius) { radius, radius, radius, radius })
#define CLAY_PADDING_ALL(padding) CLAY__INIT(Clay_Padding) { padding, padding, padding, padding } #define CLAY_PADDING_ALL(padding) CLAY__CONFIG_WRAPPER(Clay_Padding, { padding, padding, padding, padding })
#define CLAY_SIZING_FIT(...) (CLAY__INIT(Clay_SizingAxis) { .size = { .minMax = { __VA_ARGS__ } }, .type = CLAY__SIZING_TYPE_FIT }) #define CLAY_SIZING_FIT(...) (CLAY__INIT(Clay_SizingAxis) { .size = { .minMax = { __VA_ARGS__ } }, .type = CLAY__SIZING_TYPE_FIT })
@ -284,6 +284,8 @@ typedef struct {
uint16_t bottom; uint16_t bottom;
} Clay_Padding; } Clay_Padding;
CLAY__WRAPPER_STRUCT(Clay_Padding);
typedef struct { typedef struct {
Clay_Sizing sizing; Clay_Sizing sizing;
Clay_Padding padding; Clay_Padding padding;
@ -1786,7 +1788,7 @@ bool Clay__ElementIsOffscreen(Clay_BoundingBox *boundingBox) {
(boundingBox->y + boundingBox->height < 0); (boundingBox->y + boundingBox->height < 0);
} }
void Clay__CalculateFinalLayout() { void Clay__CalculateFinalLayout(void) {
Clay_Context* context = Clay_GetCurrentContext(); Clay_Context* context = Clay_GetCurrentContext();
// Calculate sizing along the X axis // Calculate sizing along the X axis
Clay__SizeContainersAlongAxis(true); Clay__SizeContainersAlongAxis(true);
@ -2642,7 +2644,7 @@ void HandleDebugViewCloseButtonInteraction(Clay_ElementId elementId, Clay_Pointe
} }
} }
void Clay__RenderDebugView() { void Clay__RenderDebugView(void) {
Clay_Context* context = Clay_GetCurrentContext(); Clay_Context* context = Clay_GetCurrentContext();
Clay_ElementId closeButtonId = Clay__HashString(CLAY_STRING("Clay__DebugViewTopHeaderCloseButtonOuter"), 0, 0); Clay_ElementId closeButtonId = Clay__HashString(CLAY_STRING("Clay__DebugViewTopHeaderCloseButtonOuter"), 0, 0);
if (context->pointerInfo.state == CLAY_POINTER_DATA_PRESSED_THIS_FRAME) { if (context->pointerInfo.state == CLAY_POINTER_DATA_PRESSED_THIS_FRAME) {
@ -3337,7 +3339,7 @@ void Clay_BeginLayout(void) {
Clay_TextElementConfig Clay__DebugView_ErrorTextConfig = {.textColor = {255, 0, 0, 255}, .fontSize = 16, .wrapMode = CLAY_TEXT_WRAP_NONE }; Clay_TextElementConfig Clay__DebugView_ErrorTextConfig = {.textColor = {255, 0, 0, 255}, .fontSize = 16, .wrapMode = CLAY_TEXT_WRAP_NONE };
CLAY_WASM_EXPORT("Clay_EndLayout") CLAY_WASM_EXPORT("Clay_EndLayout")
Clay_RenderCommandArray Clay_EndLayout() { Clay_RenderCommandArray Clay_EndLayout(void) {
Clay_Context* context = Clay_GetCurrentContext(); Clay_Context* context = Clay_GetCurrentContext();
Clay__CloseElement(); Clay__CloseElement();
if (context->debugModeEnabled) { if (context->debugModeEnabled) {

View File

@ -25,7 +25,7 @@ target_include_directories(clay_examples_raylib_multi_context PUBLIC .)
target_link_libraries(clay_examples_raylib_multi_context PUBLIC raylib) target_link_libraries(clay_examples_raylib_multi_context PUBLIC raylib)
set(CMAKE_C_FLAGS_DEBUG "-Wall -Werror -Wno-error=missing-braces -DCLAY_DEBUG") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
set(CMAKE_C_FLAGS_RELEASE "-O3") set(CMAKE_C_FLAGS_RELEASE "-O3")
add_custom_command( add_custom_command(

View File

@ -10,7 +10,7 @@ void RenderHeaderButton(Clay_String text) {
CLAY_LAYOUT({ .padding = { 16, 16, 8, 8 }}), CLAY_LAYOUT({ .padding = { 16, 16, 8, 8 }}),
CLAY_RECTANGLE({ CLAY_RECTANGLE({
.color = { 140, 140, 140, 255 }, .color = { 140, 140, 140, 255 },
.cornerRadius = 5 .cornerRadius = CLAY_CORNER_RADIUS(5)
}) })
) { ) {
CLAY_TEXT(text, CLAY_TEXT_CONFIG({ CLAY_TEXT(text, CLAY_TEXT_CONFIG({
@ -79,7 +79,7 @@ typedef struct {
intptr_t memory; intptr_t memory;
} Arena; } Arena;
Arena frameArena = {}; Arena frameArena = {0};
Clay_RenderCommandArray CreateLayout(Clay_Context* context, float yOffset, int32_t* documentIndex) { Clay_RenderCommandArray CreateLayout(Clay_Context* context, float yOffset, int32_t* documentIndex) {
Clay_SetCurrentContext(context); Clay_SetCurrentContext(context);
@ -104,13 +104,13 @@ Clay_RenderCommandArray CreateLayout(Clay_Context* context, float yOffset, int32
); );
Clay_Sizing layoutExpand = { Clay_Sizing layoutExpand = {
.width = CLAY_SIZING_GROW(), .width = CLAY_SIZING_GROW(0),
.height = CLAY_SIZING_GROW() .height = CLAY_SIZING_GROW(0)
}; };
Clay_RectangleElementConfig contentBackgroundConfig = { Clay_RectangleElementConfig contentBackgroundConfig = {
.color = { 90, 90, 90, 255 }, .color = { 90, 90, 90, 255 },
.cornerRadius = 8 .cornerRadius = CLAY_CORNER_RADIUS(8)
}; };
Clay_BeginLayout(); Clay_BeginLayout();
@ -138,14 +138,14 @@ Clay_RenderCommandArray CreateLayout(Clay_Context* context, float yOffset, int32
.childGap = 8, .childGap = 8,
.sizing = { .sizing = {
.width = CLAY_SIZING_FIXED(250), .width = CLAY_SIZING_FIXED(250),
.height = CLAY_SIZING_GROW() .height = CLAY_SIZING_GROW(0)
} }
}) })
) { ) {
for (int i = 0; i < documents.length; i++) { for (int i = 0; i < documents.length; i++) {
Document document = documents.documents[i]; Document document = documents.documents[i];
Clay_LayoutConfig sidebarButtonLayout = { Clay_LayoutConfig sidebarButtonLayout = {
.sizing = { .width = CLAY_SIZING_GROW() }, .sizing = { .width = CLAY_SIZING_GROW(0) },
.padding = CLAY_PADDING_ALL(16) .padding = CLAY_PADDING_ALL(16)
}; };
@ -154,7 +154,7 @@ Clay_RenderCommandArray CreateLayout(Clay_Context* context, float yOffset, int32
CLAY_LAYOUT(sidebarButtonLayout), CLAY_LAYOUT(sidebarButtonLayout),
CLAY_RECTANGLE({ CLAY_RECTANGLE({
.color = { 120, 120, 120, 255 }, .color = { 120, 120, 120, 255 },
.cornerRadius = 8, .cornerRadius = CLAY_CORNER_RADIUS(8),
}) })
) { ) {
CLAY_TEXT(document.title, CLAY_TEXT_CONFIG({ CLAY_TEXT(document.title, CLAY_TEXT_CONFIG({
@ -173,9 +173,9 @@ Clay_RenderCommandArray CreateLayout(Clay_Context* context, float yOffset, int32
Clay_Hovered() Clay_Hovered()
? CLAY_RECTANGLE({ ? CLAY_RECTANGLE({
.color = { 120, 120, 120, 120 }, .color = { 120, 120, 120, 120 },
.cornerRadius = 8 .cornerRadius = CLAY_CORNER_RADIUS(8)
}) })
: 0 : (void)0
) { ) {
CLAY_TEXT(document.title, CLAY_TEXT_CONFIG({ CLAY_TEXT(document.title, CLAY_TEXT_CONFIG({
.fontId = FONT_ID_BODY_16, .fontId = FONT_ID_BODY_16,

View File

@ -27,7 +27,7 @@ target_link_libraries(clay_examples_raylib_sidebar_scrolling_container PUBLIC ra
if(MSVC) if(MSVC)
set(CMAKE_C_FLAGS_DEBUG "/D CLAY_DEBUG") set(CMAKE_C_FLAGS_DEBUG "/D CLAY_DEBUG")
else() else()
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DCLAY_DEBUG -fsanitize=address") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3")
endif() endif()

View File

@ -35,7 +35,7 @@ typedef struct
CustomLayoutElementType type; CustomLayoutElementType type;
union { union {
CustomLayoutElement_3DModel model; CustomLayoutElement_3DModel model;
}; } customData;
} CustomLayoutElement; } CustomLayoutElement;
// Get a ray trace from the screen position (i.e mouse) within a specific section of the screen // Get a ray trace from the screen position (i.e mouse) within a specific section of the screen
@ -216,7 +216,7 @@ void Clay_Raylib_Render(Clay_RenderCommandArray renderCommands)
float scaleValue = CLAY__MIN(CLAY__MIN(1, 768 / rootBox.height) * CLAY__MAX(1, rootBox.width / 1024), 1.5f); float scaleValue = CLAY__MIN(CLAY__MIN(1, 768 / rootBox.height) * CLAY__MAX(1, rootBox.width / 1024), 1.5f);
Ray positionRay = GetScreenToWorldPointWithZDistance((Vector2) { renderCommand->boundingBox.x + renderCommand->boundingBox.width / 2, renderCommand->boundingBox.y + (renderCommand->boundingBox.height / 2) + 20 }, Raylib_camera, (int)roundf(rootBox.width), (int)roundf(rootBox.height), 140); Ray positionRay = GetScreenToWorldPointWithZDistance((Vector2) { renderCommand->boundingBox.x + renderCommand->boundingBox.width / 2, renderCommand->boundingBox.y + (renderCommand->boundingBox.height / 2) + 20 }, Raylib_camera, (int)roundf(rootBox.width), (int)roundf(rootBox.height), 140);
BeginMode3D(Raylib_camera); BeginMode3D(Raylib_camera);
DrawModel(customElement->model.model, positionRay.position, customElement->model.scale * scaleValue, WHITE); // Draw 3d model with texture DrawModel(customElement->customData.model.model, positionRay.position, customElement->customData.model.scale * scaleValue, WHITE); // Draw 3d model with texture
EndMode3D(); EndMode3D();
break; break;
} }