From f505f1ab5ed89965e06d37f21a4acfc4eac02f7e Mon Sep 17 00:00:00 2001 From: Karol Kosek Date: Sat, 7 May 2022 10:41:11 +0200 Subject: LibGUI: Try use layout's preferred size for the content size Previously this was only done if the widget had shrink_to_fit property enabled. --- .../Libraries/LibGUI/ScrollableContainerWidget.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Userland/Libraries/LibGUI/ScrollableContainerWidget.cpp b/Userland/Libraries/LibGUI/ScrollableContainerWidget.cpp index e22d91caa6..749958339f 100644 --- a/Userland/Libraries/LibGUI/ScrollableContainerWidget.cpp +++ b/Userland/Libraries/LibGUI/ScrollableContainerWidget.cpp @@ -38,12 +38,20 @@ void ScrollableContainerWidget::update_widget_size() return; m_widget->do_layout(); auto new_size = Widget::content_size(); - if (m_widget->is_shrink_to_fit() && m_widget->layout()) { + + if (m_widget->layout()) { auto preferred_size = m_widget->layout()->preferred_size(); - if (preferred_size.width() != -1) - new_size.set_width(preferred_size.width()); - if (preferred_size.height() != -1) - new_size.set_height(preferred_size.height()); + if (m_widget->is_shrink_to_fit()) { + if (preferred_size.width() != -1) + new_size.set_width(preferred_size.width()); + if (preferred_size.height() != -1) + new_size.set_height(preferred_size.height()); + } else { + new_size = Gfx::Size { + max(new_size.width(), preferred_size.width()), + max(new_size.height(), preferred_size.height()) + }; + } } auto min_size = m_widget->min_size(); -- cgit v1.2.3