summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrHun <28605587+frhun@users.noreply.github.com>2022-06-28 18:06:28 +0200
committerAndreas Kling <kling@serenityos.org>2022-06-30 11:53:50 +0200
commit247e3ef6e74c0e9c4fb794162fe092a76e29f77b (patch)
tree6dbdbcb5e1cf0d19078d6079f6805ad77b366d57
parentd0a418540e92f4fe24c175dca502261b5dd6390f (diff)
downloadserenity-247e3ef6e74c0e9c4fb794162fe092a76e29f77b.zip
LibGUI: Add custom layout change handling to ScrollableContainerWidget
-rw-r--r--Userland/Libraries/LibGUI/ScrollableContainerWidget.cpp19
-rw-r--r--Userland/Libraries/LibGUI/ScrollableContainerWidget.h2
2 files changed, 21 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/ScrollableContainerWidget.cpp b/Userland/Libraries/LibGUI/ScrollableContainerWidget.cpp
index b7335dcde7..0ff235e602 100644
--- a/Userland/Libraries/LibGUI/ScrollableContainerWidget.cpp
+++ b/Userland/Libraries/LibGUI/ScrollableContainerWidget.cpp
@@ -58,11 +58,29 @@ void ScrollableContainerWidget::update_widget_size()
}
}
+void ScrollableContainerWidget::update_widget_min_size()
+{
+ if (!m_widget)
+ set_min_content_size({});
+ else
+ set_min_content_size(Gfx::IntSize(m_widget->effective_min_size().replace_component_if_matching_with(SpecialDimension::Shrink, UISize { 0, 0 })));
+}
+
void ScrollableContainerWidget::resize_event(GUI::ResizeEvent& event)
{
AbstractScrollableWidget::resize_event(event);
+ update_widget_size();
update_widget_position();
+}
+
+void ScrollableContainerWidget::layout_relevant_change_occured()
+{
+ update_widget_min_size();
+ update_scrollbar_visibility();
+ update_scrollbar_ranges();
update_widget_size();
+ update_widget_position();
+ update();
}
void ScrollableContainerWidget::set_widget(GUI::Widget* widget)
@@ -79,6 +97,7 @@ void ScrollableContainerWidget::set_widget(GUI::Widget* widget)
add_child(*m_widget);
m_widget->move_to_back();
}
+ update_widget_min_size();
update_widget_size();
update_widget_position();
}
diff --git a/Userland/Libraries/LibGUI/ScrollableContainerWidget.h b/Userland/Libraries/LibGUI/ScrollableContainerWidget.h
index 3064af9866..6846047873 100644
--- a/Userland/Libraries/LibGUI/ScrollableContainerWidget.h
+++ b/Userland/Libraries/LibGUI/ScrollableContainerWidget.h
@@ -24,10 +24,12 @@ public:
protected:
virtual void did_scroll() override;
virtual void resize_event(GUI::ResizeEvent&) override;
+ virtual void layout_relevant_change_occured() override;
private:
void update_widget_size();
void update_widget_position();
+ void update_widget_min_size();
virtual bool load_from_gml_ast(NonnullRefPtr<GUI::GML::Node> ast, RefPtr<Core::Object> (*unregistered_child_handler)(String const&)) override;
ScrollableContainerWidget();