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)
This commit is contained in:
FrHun 2022-08-13 15:32:01 +02:00 committed by Linus Groh
parent 8df09f6e13
commit 00acf56e94
Notes: sideshowbarker 2024-07-17 07:31:38 +09:00
2 changed files with 15 additions and 0 deletions

View file

@ -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)

View file

@ -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;
};