Skip to content

Commit 00acf56

Browse files
frhunlinusg
authored andcommitted
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)
1 parent 8df09f6 commit 00acf56

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

Userland/Libraries/LibGUI/Statusbar.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@ NonnullRefPtr<Statusbar::Segment> Statusbar::create_segment()
3838
return widget;
3939
}
4040

41+
void Statusbar::child_event(Core::ChildEvent& event)
42+
{
43+
auto& event_to_forward = event;
44+
// To ensure that the ResizeCorner is always the last widget, and thus stays in the corner,
45+
// we replace ChildAdded events that do not request specific placement with events that request placement before the corner
46+
if (event.type() == Event::ChildAdded && is<Widget>(*event.child()) && !event.insertion_before_child()) {
47+
Core::ChildEvent new_event(Event::ChildAdded, *event.child(), m_corner.ptr());
48+
event_to_forward = new_event;
49+
}
50+
51+
return Widget::child_event(event_to_forward);
52+
}
53+
4154
void Statusbar::set_segment_count(size_t count)
4255
{
4356
if (count <= 1)

Userland/Libraries/LibGUI/Statusbar.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ class Statusbar : public Widget {
7676
void update_segment(size_t);
7777
NonnullRefPtr<Segment> create_segment();
7878

79+
virtual void child_event(Core::ChildEvent&) override;
80+
7981
NonnullRefPtrVector<Segment> m_segments;
8082
RefPtr<ResizeCorner> m_corner;
8183
};

0 commit comments

Comments
 (0)