From 3ac556b541edefdae799368e0044bf72a677ffdd Mon Sep 17 00:00:00 2001 From: Alessandro Mauri Date: Mon, 27 Oct 2025 12:53:13 +0100 Subject: [PATCH] fix negative grow element size --- src/layout.c3 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/layout.c3 b/src/layout.c3 index 8f63c5f..8ed464d 100644 --- a/src/layout.c3 +++ b/src/layout.c3 @@ -104,8 +104,8 @@ macro Point Layout.get_dimensions(&el) macro Point Elem.content_space(&e) { return { - .x = e.bounds.w - e.layout.content_offset.x - e.layout.content_offset.w, - .y = e.bounds.h - e.layout.content_offset.y - e.layout.content_offset.h, + .x = (short)max(e.bounds.w - e.layout.content_offset.x - e.layout.content_offset.w, 0), + .y = (short)max(e.bounds.h - e.layout.content_offset.y - e.layout.content_offset.h, 0), }; } @@ -168,7 +168,7 @@ fn void resolve_grow_elements(Elem* e, Elem* p) if (e.layout.absolute) { // absolute children do not need to share space e.bounds.w = p.content_space().x; } else if (p.layout.dir == ROW) { // grow along the axis, divide the parent size - short slot = (short)((p.content_space().x - p.layout.occupied) / p.layout.grow_children); + short slot = (short)max(((p.content_space().x - p.layout.occupied) / p.layout.grow_children), 0); e.bounds.w = slot; p.layout.grow_children--; p.layout.occupied += slot; @@ -182,7 +182,7 @@ fn void resolve_grow_elements(Elem* e, Elem* p) if (e.layout.absolute) { // absolute children do not need to share space e.bounds.h = p.content_space().y; } else if (p.layout.dir == COLUMN) { // grow along the axis, divide the parent size - short slot = (short)((p.content_space().y - p.layout.occupied) / p.layout.grow_children); + short slot = (short)max(((p.content_space().y - p.layout.occupied) / p.layout.grow_children), 0); e.bounds.h = slot; p.layout.grow_children--; p.layout.occupied += slot;