git.lucas.co / cce-ui
GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git

commitcf66717e5379d8ff1f5ea3d90bcac8f16cac7cf7
parent7c62f4cfcd
authorLucas Galante <[email protected]>
date2026-06-20 12:05
style: cap parent section columns count to 2 to improve layout readability

 src/layout.rs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/layout.rs b/src/layout.rs
index c27b61e..719da09 100644
--- a/src/layout.rs
+++ b/src/layout.rs
@@ -2121,7 +2121,7 @@ impl Section {
         let max_cols = if is_child {
             1
         } else {
-            ((usable_w + gap) / (min_col_width + gap)).floor().max(1.0) as usize
+            ((usable_w + gap) / (min_col_width + gap)).floor().max(1.0).min(2.0) as usize
         };
         let content_start_y = top + font_size + 5.0;
         let grid = Grid::new(left + margin_x, content_start_y, usable_w, min_col_width, gap, max_cols);
@@ -2866,7 +2866,7 @@ impl<'a, P: RenderTarget> SectionContext<'a, P> {
         let max_cols = if is_child {
             1
         } else {
-            ((usable_w + gap) / (min_col_width + gap)).floor().max(1.0) as usize
+            ((usable_w + gap) / (min_col_width + gap)).floor().max(1.0).min(2.0) as usize
         };
         let content_start_y = top + font_size + 5.0;
         let grid = Grid::new(left + margin_x, content_start_y, usable_w, min_col_width, gap, max_cols);
@@ -3407,7 +3407,7 @@ mod tests {
     fn test_parent_section_side_by_side_child_sections() {
         let mut mock_pc = MockRenderTarget { rects: Vec::new() };
         let mut parent_ctx = SectionContext::new(&mut mock_pc, 10.0, 20.0, 500.0, "Parent Section", false, false);
-        assert!(parent_ctx.grid.col_heights.len() >= 2);
+        assert_eq!(parent_ctx.grid.col_heights.len(), 2);
 
         let mut sub_left_1 = 0.0;
         let mut sub_left_2 = 0.0;