From b9af89ef44bff8df8e76bc9c30de47bcad943f41 Mon Sep 17 00:00:00 2001 From: Brady Date: Tue, 7 Apr 2026 19:12:31 -0500 Subject: [PATCH] Implement `CLAY_TRANSITION_PROPERTY_CORNER_RADIUS` --- clay.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/clay.h b/clay.h index 797682b..b923211 100644 --- a/clay.h +++ b/clay.h @@ -563,6 +563,7 @@ typedef struct { Clay_BoundingBox boundingBox; Clay_Color backgroundColor; Clay_Color overlayColor; + Clay_CornerRadius cornerRadius; Clay_Color borderColor; Clay_BorderWidth borderWidth; } Clay_TransitionData; @@ -4397,6 +4398,9 @@ void Clay_ApplyTransitionedPropertiesToElement(Clay_LayoutElement* currentElemen if (properties & CLAY_TRANSITION_PROPERTY_BACKGROUND_COLOR) { currentElement->config.backgroundColor = currentTransitionData.backgroundColor; } + if (properties & CLAY_TRANSITION_PROPERTY_CORNER_RADIUS) { + currentElement->config.cornerRadius = currentTransitionData.cornerRadius; + } if (properties & CLAY_TRANSITION_PROPERTY_BORDER_COLOR) { currentElement->config.border.color = currentTransitionData.borderColor; } @@ -4538,6 +4542,7 @@ Clay_RenderCommandArray Clay_EndLayout(float deltaTime) { mapItem->boundingBox, currentElement->config.backgroundColor, currentElement->config.overlayColor, + currentElement->config.cornerRadius, currentElement->config.border.color, currentElement->config.border.width, }; @@ -4594,6 +4599,14 @@ Clay_RenderCommandArray Clay_EndLayout(float deltaTime) { activeProperties |= CLAY_TRANSITION_PROPERTY_OVERLAY_COLOR; } } + if (properties & CLAY_TRANSITION_PROPERTY_CORNER_RADIUS) { + if (!Clay__FloatEqual(oldTargetState.cornerRadius.topLeft, targetState.cornerRadius.topLeft) + || !Clay__FloatEqual(oldTargetState.cornerRadius.topRight, targetState.cornerRadius.topRight) + || !Clay__FloatEqual(oldTargetState.cornerRadius.bottomLeft, targetState.cornerRadius.bottomLeft) + || !Clay__FloatEqual(oldTargetState.cornerRadius.bottomRight, targetState.cornerRadius.bottomRight)) { + activeProperties |= CLAY_TRANSITION_PROPERTY_CORNER_RADIUS; + } + } if (properties & CLAY_TRANSITION_PROPERTY_BORDER_COLOR) { if (!Clay__MemCmp((char *) &oldTargetState.borderColor, (char *)&targetState.borderColor, sizeof(Clay_Color))) { activeProperties |= CLAY_TRANSITION_PROPERTY_BORDER_COLOR; @@ -4885,6 +4898,14 @@ CLAY_DLL_EXPORT bool Clay_EaseOut(Clay_TransitionCallbackArguments arguments) { .a = CLAY__LERP(arguments.initial.overlayColor.a, arguments.target.overlayColor.a, lerpAmount), }; } + if (arguments.properties & CLAY_TRANSITION_PROPERTY_CORNER_RADIUS) { + arguments.current->cornerRadius = CLAY__INIT(Clay_CornerRadius) { + .topLeft = CLAY__LERP(arguments.initial.cornerRadius.topLeft, arguments.target.cornerRadius.topLeft, lerpAmount), + .topRight = CLAY__LERP(arguments.initial.cornerRadius.topRight, arguments.target.cornerRadius.topRight, lerpAmount), + .bottomLeft = CLAY__LERP(arguments.initial.cornerRadius.bottomLeft, arguments.target.cornerRadius.bottomLeft, lerpAmount), + .bottomRight = CLAY__LERP(arguments.initial.cornerRadius.bottomRight, arguments.target.cornerRadius.bottomRight, lerpAmount), + }; + } if (arguments.properties & CLAY_TRANSITION_PROPERTY_BORDER_COLOR) { arguments.current->borderColor = CLAY__INIT(Clay_Color) { .r = CLAY__LERP(arguments.initial.borderColor.r, arguments.target.borderColor.r, lerpAmount),