LibCore: Make Core::Object::add<ChildType> return a ChildType&

Since the returned object is now owned by the callee object, we can
simply vend a ChildType&. This allows us to use "." instead of "->"
at the call site, which is quite nice. :^)
This commit is contained in:
Andreas Kling 2020-03-04 19:07:55 +01:00
commit 028c011760
Notes: sideshowbarker 2024-07-19 08:54:42 +09:00
46 changed files with 1035 additions and 1039 deletions

View file

@ -57,15 +57,15 @@ MemoryStatsWidget::MemoryStatsWidget(GraphWidget& graph)
layout()->set_spacing(3);
auto build_widgets_for_label = [this](const String& description) -> RefPtr<GUI::Label> {
auto container = add<GUI::Widget>();
container->set_layout<GUI::HorizontalBoxLayout>();
container->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
container->set_preferred_size(275, 12);
auto description_label = container->add<GUI::Label>(description);
description_label->set_font(Gfx::Font::default_bold_font());
description_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
auto label = container->add<GUI::Label>();
label->set_text_alignment(Gfx::TextAlignment::CenterRight);
auto& container = add<GUI::Widget>();
container.set_layout<GUI::HorizontalBoxLayout>();
container.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
container.set_preferred_size(275, 12);
auto& description_label = container.add<GUI::Label>(description);
description_label.set_font(Gfx::Font::default_bold_font());
description_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
auto& label = container.add<GUI::Label>();
label.set_text_alignment(Gfx::TextAlignment::CenterRight);
return label;
};