diff options
author | Karol Kosek <krkk@serenityos.org> | 2022-05-07 13:06:20 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-05-11 20:24:57 +0200 |
commit | 3e4f912479e4585dc3b7b3ba9a268b5e6163b272 (patch) | |
tree | f44959535ff9e65fede01290d0c5979d8d528003 /Userland | |
parent | ea99589d042af8f3ac3c1dace8213b683cd447ac (diff) | |
download | serenity-3e4f912479e4585dc3b7b3ba9a268b5e6163b272.zip |
LibGUI: Reuse common parts in ScrollableContainerWidget
No functional changes.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibGUI/ScrollableContainerWidget.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/Userland/Libraries/LibGUI/ScrollableContainerWidget.cpp b/Userland/Libraries/LibGUI/ScrollableContainerWidget.cpp index c0abe4af61..761ae2332b 100644 --- a/Userland/Libraries/LibGUI/ScrollableContainerWidget.cpp +++ b/Userland/Libraries/LibGUI/ScrollableContainerWidget.cpp @@ -37,25 +37,22 @@ void ScrollableContainerWidget::update_widget_size() if (!m_widget) return; m_widget->do_layout(); + auto new_size = Widget::content_size(); if (m_widget->is_shrink_to_fit() && m_widget->layout()) { - auto new_size = Widget::content_size(); 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()); - m_widget->resize(new_size); - set_content_size(new_size); } else { - auto inner_size = Widget::content_size(); auto min_size = m_widget->min_size(); - auto new_size = Gfx::Size { - max(inner_size.width(), min_size.width()), - max(inner_size.height(), min_size.height()) + new_size = Gfx::Size { + max(new_size.width(), min_size.width()), + max(new_size.height(), min_size.height()) }; - m_widget->resize(new_size); - set_content_size(new_size); } + m_widget->resize(new_size); + set_content_size(new_size); } void ScrollableContainerWidget::resize_event(GUI::ResizeEvent& event) |