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:
parent
8df09f6e13
commit
00acf56e94
Notes:
sideshowbarker
2024-07-17 07:31:38 +09:00
Author: https://github.com/frhun Commit: https://github.com/SerenityOS/serenity/commit/00acf56e94 Pull-request: https://github.com/SerenityOS/serenity/pull/14845 Reviewed-by: https://github.com/MacDue Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/kleinesfilmroellchen ✅ Reviewed-by: https://github.com/linusg
2 changed files with 15 additions and 0 deletions
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue