Skip to content

Commit

Permalink
Fix incorrect border between children after 2nd element
Browse files Browse the repository at this point in the history
  • Loading branch information
nicbarker committed Jan 12, 2025
1 parent c2c445e commit 208c7cb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions clay.h
Original file line number Diff line number Diff line change
Expand Up @@ -2804,7 +2804,8 @@ void Clay__CalculateFinalLayout() {
Clay__AddRenderCommand(renderCommand);
if (borderConfig->betweenChildren.width > 0 && borderConfig->betweenChildren.color.a > 0) {
Clay_RectangleElementConfig *rectangleConfig = Clay__StoreRectangleElementConfig(CLAY__INIT(Clay_RectangleElementConfig) {.color = borderConfig->betweenChildren.color});
Clay_Vector2 borderOffset = { (float)layoutConfig->padding.x, (float)layoutConfig->padding.y };
float halfGap = layoutConfig->childGap / 2;
Clay_Vector2 borderOffset = { (float)layoutConfig->padding.x - halfGap, (float)layoutConfig->padding.y - halfGap };
if (layoutConfig->layoutDirection == CLAY_LEFT_TO_RIGHT) {
for (int32_t i = 0; i < currentElement->childrenOrTextContent.children.length; ++i) {
Clay_LayoutElement *childElement = Clay_LayoutElementArray_Get(&context->layoutElements, currentElement->childrenOrTextContent.children.elements[i]);
Expand All @@ -2816,7 +2817,7 @@ void Clay__CalculateFinalLayout() {
.commandType = CLAY_RENDER_COMMAND_TYPE_RECTANGLE,
});
}
borderOffset.x += (childElement->dimensions.width + (float)layoutConfig->childGap / 2);
borderOffset.x += (childElement->dimensions.width + (float)layoutConfig->childGap);
}
} else {
for (int32_t i = 0; i < currentElement->childrenOrTextContent.children.length; ++i) {
Expand All @@ -2829,7 +2830,7 @@ void Clay__CalculateFinalLayout() {
.commandType = CLAY_RENDER_COMMAND_TYPE_RECTANGLE,
});
}
borderOffset.y += (childElement->dimensions.height + (float)layoutConfig->childGap / 2);
borderOffset.y += (childElement->dimensions.height + (float)layoutConfig->childGap);
}
}
}
Expand Down

0 comments on commit 208c7cb

Please sign in to comment.