mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:58:11 +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
|
@ -45,14 +45,14 @@ int main(int argc, char** argv)
|
|||
auto& layout = main_widget.set_layout<GUI::VerticalBoxLayout>();
|
||||
layout.set_margins({ 4, 4, 4, 4 });
|
||||
|
||||
auto label = main_widget.add<GUI::Label>();
|
||||
label->set_text("Hello\nWorld!");
|
||||
auto& label = main_widget.add<GUI::Label>();
|
||||
label.set_text("Hello\nWorld!");
|
||||
|
||||
auto button = main_widget.add<GUI::Button>();
|
||||
button->set_text("Good-bye");
|
||||
button->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
button->set_preferred_size(0, 20);
|
||||
button->on_click = [&] {
|
||||
auto& button = main_widget.add<GUI::Button>();
|
||||
button.set_text("Good-bye");
|
||||
button.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
button.set_preferred_size(0, 20);
|
||||
button.on_click = [&] {
|
||||
app.quit();
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue