mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-03 08:08:43 +00:00
LibGUI: Add existing children widgets when layout manager changed
If a widget gains a layout manager after it already has child widgets, the existing widgets are unknown to the layout. Additionally, if a layout is reused, it may end up managing children of multiple different widgets. To simplify this, clear the entries of a layout manager when its owner changes, and add any existing children when a new owner comes along.
This commit is contained in:
parent
34c5d33eb0
commit
037fbbf5d9
Notes:
sideshowbarker
2024-07-17 21:08:14 +09:00
Author: https://github.com/mhjacobson 🔰
Commit: 037fbbf5d9
Pull-request: https://github.com/SerenityOS/serenity/pull/11823
Reviewed-by: https://github.com/AtkinsSJ ✅
1 changed files with 5 additions and 0 deletions
|
@ -46,12 +46,17 @@ void Layout::notify_adopted(Badge<Widget>, Widget& widget)
|
||||||
if (m_owner == &widget)
|
if (m_owner == &widget)
|
||||||
return;
|
return;
|
||||||
m_owner = widget;
|
m_owner = widget;
|
||||||
|
m_owner->for_each_child_widget([&](Widget& child) {
|
||||||
|
add_widget(child);
|
||||||
|
return IterationDecision::Continue;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Layout::notify_disowned(Badge<Widget>, Widget& widget)
|
void Layout::notify_disowned(Badge<Widget>, Widget& widget)
|
||||||
{
|
{
|
||||||
VERIFY(m_owner == &widget);
|
VERIFY(m_owner == &widget);
|
||||||
m_owner.clear();
|
m_owner.clear();
|
||||||
|
m_entries.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<void> Layout::try_add_entry(Entry&& entry)
|
ErrorOr<void> Layout::try_add_entry(Entry&& entry)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue