mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 18:05:07 +00:00
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:
parent
fb09b6a8ce
commit
028c011760
46 changed files with 1035 additions and 1039 deletions
|
@ -109,28 +109,28 @@ void MessageBox::build()
|
|||
message_container->layout()->set_margins({ 8, 0, 8, 0 });
|
||||
message_container->layout()->set_spacing(8);
|
||||
|
||||
auto icon_label = message_container->add<Label>();
|
||||
icon_label->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
||||
icon_label->set_preferred_size(32, 32);
|
||||
icon_label->set_icon(icon());
|
||||
icon_width = icon_label->icon()->width();
|
||||
auto& icon_label = message_container->add<Label>();
|
||||
icon_label.set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
||||
icon_label.set_preferred_size(32, 32);
|
||||
icon_label.set_icon(icon());
|
||||
icon_width = icon_label.icon()->width();
|
||||
}
|
||||
|
||||
auto label = message_container->add<Label>(m_text);
|
||||
label->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
label->set_preferred_size(text_width, 16);
|
||||
auto& label = message_container->add<Label>(m_text);
|
||||
label.set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
label.set_preferred_size(text_width, 16);
|
||||
|
||||
auto button_container = widget.add<Widget>();
|
||||
button_container->set_layout<HorizontalBoxLayout>();
|
||||
button_container->layout()->set_spacing(5);
|
||||
button_container->layout()->set_margins({ 15, 0, 15, 0 });
|
||||
auto& button_container = widget.add<Widget>();
|
||||
button_container.set_layout<HorizontalBoxLayout>();
|
||||
button_container.layout()->set_spacing(5);
|
||||
button_container.layout()->set_margins({ 15, 0, 15, 0 });
|
||||
|
||||
auto add_button = [&](String label, Dialog::ExecResult result) {
|
||||
auto button = button_container->add<Button>();
|
||||
button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
button->set_preferred_size(0, 20);
|
||||
button->set_text(label);
|
||||
button->on_click = [this, label, result] {
|
||||
auto& button = button_container.add<Button>();
|
||||
button.set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
button.set_preferred_size(0, 20);
|
||||
button.set_text(label);
|
||||
button.on_click = [this, label, result] {
|
||||
dbg() << "GUI::MessageBox: '" << label << "' button clicked";
|
||||
done(result);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue