mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-05 02:33:03 +00:00
LibGUI: Make GWindow drive relayout and do it recursively
Instead of only doing a relayout in the widget you're invalidating, we now do a recursive top-down relayout so everything gets updated. This fixes invalid results after updating a preferred size in some situations with nested layouts.
This commit is contained in:
parent
d0799f3648
commit
98a6149b4f
Notes:
sideshowbarker
2024-07-19 11:32:20 +09:00
Author: https://github.com/awesomekling
Commit: 98a6149b4f
4 changed files with 24 additions and 14 deletions
|
@ -146,6 +146,10 @@ void GWidget::set_layout(OwnPtr<GLayout>&& layout)
|
|||
|
||||
void GWidget::do_layout()
|
||||
{
|
||||
for_each_child_widget([&](auto& child) {
|
||||
child.do_layout();
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
custom_layout();
|
||||
if (!m_layout)
|
||||
return;
|
||||
|
@ -434,19 +438,8 @@ void GWidget::set_size_policy(SizePolicy horizontal_policy, SizePolicy vertical_
|
|||
|
||||
void GWidget::invalidate_layout()
|
||||
{
|
||||
if (m_layout_dirty)
|
||||
return;
|
||||
m_layout_dirty = true;
|
||||
deferred_invoke([this](auto&) {
|
||||
m_layout_dirty = false;
|
||||
auto* w = window();
|
||||
if (!w)
|
||||
return;
|
||||
if (!w->main_widget())
|
||||
return;
|
||||
do_layout();
|
||||
w->main_widget()->do_layout();
|
||||
});
|
||||
if (window())
|
||||
window()->schedule_relayout();
|
||||
}
|
||||
|
||||
void GWidget::set_visible(bool visible)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue