mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 23:07:34 +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;
|
||||
}
|
||||
|
||||
|
|
|
@ -124,7 +124,8 @@ public:
|
|||
bool is_focused() const;
|
||||
void set_focus(bool);
|
||||
|
||||
enum class ShouldRespectGreediness { No = 0, Yes };
|
||||
enum class ShouldRespectGreediness { No = 0,
|
||||
Yes };
|
||||
struct HitTestResult {
|
||||
GWidget* widget { nullptr };
|
||||
Point local_position;
|
||||
|
@ -220,6 +221,8 @@ public:
|
|||
});
|
||||
}
|
||||
|
||||
Vector<GWidget*> child_widgets() const;
|
||||
|
||||
virtual bool is_radio_button() const { return false; }
|
||||
virtual bool is_abstract_button() const { return false; }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue