summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarol Kosek <krkk@serenityos.org>2022-05-07 10:41:11 +0200
committerAndreas Kling <kling@serenityos.org>2022-05-11 20:24:57 +0200
commitf505f1ab5ed89965e06d37f21a4acfc4eac02f7e (patch)
tree6e98e2229f81d474f711ab0495e6b43bd6b52768
parent9156614de3ed45ec35838a46d6a99d476ed62d67 (diff)
downloadserenity-f505f1ab5ed89965e06d37f21a4acfc4eac02f7e.zip
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.
-rw-r--r--Userland/Libraries/LibGUI/ScrollableContainerWidget.cpp18
1 files 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();