mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:58:11 +00:00
LibGUI: Add "Vector<GWidget*> GWidget::child_widgets()"
This is quite inefficient since it constructs a new Vector each time.
This commit is contained in:
parent
3ef287eb9f
commit
524da0ad01
2 changed files with 16 additions and 1 deletions
|
@ -675,3 +675,15 @@ void GWidget::save_to(AK::JsonObject& json)
|
|||
json.set("size_policy", String::format("[%s,%s]", to_string(horizontal_size_policy()), to_string(vertical_size_policy())));
|
||||
CObject::save_to(json);
|
||||
}
|
||||
|
||||
Vector<GWidget*> GWidget::child_widgets() const
|
||||
{
|
||||
Vector<GWidget*> widgets;
|
||||
widgets.ensure_capacity(children().size());
|
||||
for (auto& child : const_cast<GWidget*>(this)->children()) {
|
||||
if (child.is_widget())
|
||||
widgets.append(static_cast<GWidget*>(&child));
|
||||
}
|
||||
return widgets;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue