summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrHun <28605587+frhun@users.noreply.github.com>2022-08-13 15:32:01 +0200
committerLinus Groh <mail@linusgroh.de>2022-09-04 20:01:43 +0100
commit00acf56e941fcf6a236f008f79b472801aaedb0f (patch)
tree53a76314d0f2feb991a253eb164df4566f657145
parent8df09f6e13a7e1bed543981f0b87453dbac055ac (diff)
downloadserenity-00acf56e941fcf6a236f008f79b472801aaedb0f.zip
LibGUI: Add Widgets before the ResizeCorner by default in Statusbar
Before this, any Widgets added through e.g. GML appeared after the ResizeCorner, which didn't make sense. (see FileManager)
-rw-r--r--Userland/Libraries/LibGUI/Statusbar.cpp13
-rw-r--r--Userland/Libraries/LibGUI/Statusbar.h2
2 files changed, 15 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/Statusbar.cpp b/Userland/Libraries/LibGUI/Statusbar.cpp
index c5dd6075dc..0ae54eb3f8 100644
--- a/Userland/Libraries/LibGUI/Statusbar.cpp
+++ b/Userland/Libraries/LibGUI/Statusbar.cpp
@@ -38,6 +38,19 @@ NonnullRefPtr<Statusbar::Segment> Statusbar::create_segment()
return widget;
}
+void Statusbar::child_event(Core::ChildEvent& event)
+{
+ auto& event_to_forward = event;
+ // To ensure that the ResizeCorner is always the last widget, and thus stays in the corner,
+ // we replace ChildAdded events that do not request specific placement with events that request placement before the corner
+ if (event.type() == Event::ChildAdded && is<Widget>(*event.child()) && !event.insertion_before_child()) {
+ Core::ChildEvent new_event(Event::ChildAdded, *event.child(), m_corner.ptr());
+ event_to_forward = new_event;
+ }
+
+ return Widget::child_event(event_to_forward);
+}
+
void Statusbar::set_segment_count(size_t count)
{
if (count <= 1)
diff --git a/Userland/Libraries/LibGUI/Statusbar.h b/Userland/Libraries/LibGUI/Statusbar.h
index 197e8f7ceb..d36dd825e1 100644
--- a/Userland/Libraries/LibGUI/Statusbar.h
+++ b/Userland/Libraries/LibGUI/Statusbar.h
@@ -76,6 +76,8 @@ private:
void update_segment(size_t);
NonnullRefPtr<Segment> create_segment();
+ virtual void child_event(Core::ChildEvent&) override;
+
NonnullRefPtrVector<Segment> m_segments;
RefPtr<ResizeCorner> m_corner;
};