mirror of
https://github.com/nicbarker/clay.git
synced 2026-04-18 09:11:16 +00:00
Implement CLAY_TRANSITION_PROPERTY_CORNER_RADIUS
This commit is contained in:
parent
f70b8c7ff3
commit
b9af89ef44
1 changed files with 21 additions and 0 deletions
21
clay.h
21
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),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue