1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 06:37:43 +00:00

Minesweeper: Make a factory function for Field and propagate errors

This fixes a pleasant 8 FIXMEs. :^)
This commit is contained in:
Andreas Kling 2022-12-13 16:49:01 +01:00 committed by Linus Groh
parent cba9df1c53
commit 6ddc358a2b
3 changed files with 26 additions and 11 deletions

View file

@ -57,10 +57,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto& flag_label = *widget->find_descendant_of_type_named<GUI::Label>("flag_label");
auto& time_label = *widget->find_descendant_of_type_named<GUI::Label>("time_label");
auto& face_button = *widget->find_descendant_of_type_named<GUI::Button>("face_button");
auto field = TRY(widget->try_add<Field>(flag_label, time_label, face_button, [&](auto size) {
auto field = TRY(Field::create(flag_label, time_label, face_button, [&](auto size) {
size.set_height(size.height() + separator.height() + container.height());
window->resize(size);
}));
TRY(widget->try_add_child(field));
auto game_menu = TRY(window->try_add_menu("&Game"));