From bff97cbb09c07133af7878e6885b9df3b10bc69d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 24 Oct 2026 12:49:22 +0200 Subject: [PATCH] UI: Fix two LinearLayout measuring and layout bugs Lay out children across the layout direction within the layout's bounds rather than its measured size, which differ when a parent clamps it. And count weighted children's margins when growing to fit them. Co-Authored-By: Claude Opus 5.5 (1M context) --- Common/UI/ViewGroup.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Common/UI/ViewGroup.cpp b/Common/UI/ViewGroup.cpp index 61f95c6535..74daa8a19d 100644 --- a/Common/UI/ViewGroup.cpp +++ b/Common/UI/ViewGroup.cpp @@ -698,7 +698,7 @@ void LinearLayout::Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec v h.type = EXACTLY; } view->Measure(dc, h, v - (float)margins.vert() - (float)padding_.vert()); - usedWidth += view->GetMeasuredWidth(); + usedWidth += view->GetMeasuredWidth() + margins.horiz(); maxOther = std::max(maxOther, view->GetMeasuredHeight() + margins.vert()); } } @@ -746,7 +746,7 @@ void LinearLayout::Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec v v.type = EXACTLY; } view->Measure(dc, h - (float)margins.horiz() - (float)padding_.horiz(), v); - usedHeight += view->GetMeasuredHeight(); + usedHeight += view->GetMeasuredHeight() + margins.vert(); maxOther = std::max(maxOther, view->GetMeasuredWidth() + margins.horiz()); } } @@ -770,11 +770,11 @@ void LinearLayout::Layout() { if (orientation_ == ORIENT_HORIZONTAL) { pos = bounds.x + padding_.left; itemBounds.y = bounds.y + padding_.top; - itemBounds.h = measuredHeight_ - padding_.vert(); + itemBounds.h = bounds.h - padding_.vert(); } else { pos = bounds.y + padding_.top; itemBounds.x = bounds.x + padding_.left; - itemBounds.w = measuredWidth_ - padding_.horiz(); + itemBounds.w = bounds.w - padding_.horiz(); } for (size_t i = 0; i < views_.size(); i++) {