1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-05 13:47:36 +00:00

LibGUI: Add GWidget::for_each_child_widget(callback).

This commit is contained in:
Andreas Kling 2019-05-27 03:52:33 +02:00
parent 906fde8f8c
commit 723ba91f74
6 changed files with 43 additions and 40 deletions

View file

@ -116,15 +116,15 @@ void GWidget::handle_paint_event(GPaintEvent& event)
#endif
}
paint_event(event);
for (auto* ch : children()) {
auto* child = (GWidget*)ch;
if (!child->is_visible())
continue;
if (child->relative_rect().intersects(event.rect())) {
GPaintEvent local_event(event.rect().intersected(child->relative_rect()).translated(-child->relative_position()));
child->event(local_event);
for_each_child_widget([&] (auto& child) {
if (!child.is_visible())
return IterationDecision::Continue;
if (child.relative_rect().intersects(event.rect())) {
GPaintEvent local_event(event.rect().intersected(child.relative_rect()).translated(-child.relative_position()));
child.event(local_event);
}
}
return IterationDecision::Continue;
});
second_paint_event(event);
}