1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 19:57:44 +00:00

LibGUI: Remove Widget::try_set_layout<T>()

And fall back to the infallible set_layout<T>().

Work towards #20557.
This commit is contained in:
Andreas Kling 2023-08-13 14:52:36 +02:00
parent 341626e2ea
commit 8322b31b97
52 changed files with 127 additions and 135 deletions

View file

@ -24,13 +24,13 @@ ErrorOr<void> CoverWizardPage::build(String title, String subtitle)
{
set_fill_with_background_color(true);
set_background_role(Gfx::ColorRole::Base);
TRY(try_set_layout<HorizontalBoxLayout>());
set_layout<HorizontalBoxLayout>();
m_banner_image_widget = TRY(try_add<ImageWidget>());
m_banner_image_widget->set_fixed_size(160, 315);
m_banner_image_widget->load_from_file("/res/graphics/wizard-banner-simple.png"sv);
m_content_widget = TRY(try_add<Widget>());
TRY(m_content_widget->try_set_layout<VerticalBoxLayout>(20));
m_content_widget->set_layout<VerticalBoxLayout>(20);
m_header_label = TRY(m_content_widget->try_add<Label>(move(title)));
m_header_label->set_font(Gfx::FontDatabase::the().get("Pebbleton", 14, 700, Gfx::FontWidth::Normal, 0));

View file

@ -27,17 +27,17 @@ ErrorOr<void> WizardDialog::build()
{
auto main_widget = TRY(set_main_widget<Widget>());
main_widget->set_fill_with_background_color(true);
TRY(main_widget->try_set_layout<VerticalBoxLayout>(Margins {}, 0));
main_widget->set_layout<VerticalBoxLayout>(Margins {}, 0);
m_page_container_widget = TRY(main_widget->try_add<Widget>());
m_page_container_widget->set_fixed_size(500, 315);
TRY(m_page_container_widget->try_set_layout<VerticalBoxLayout>());
m_page_container_widget->set_layout<VerticalBoxLayout>();
auto separator = TRY(main_widget->try_add<SeparatorWidget>(Gfx::Orientation::Horizontal));
separator->set_fixed_height(2);
auto nav_container_widget = TRY(main_widget->try_add<Widget>());
TRY(nav_container_widget->try_set_layout<HorizontalBoxLayout>(Margins { 0, 10 }, 0));
nav_container_widget->set_layout<HorizontalBoxLayout>(Margins { 0, 10 }, 0);
nav_container_widget->set_fixed_height(42);
TRY(nav_container_widget->add_spacer());

View file

@ -23,14 +23,14 @@ ErrorOr<NonnullRefPtr<WizardPage>> WizardPage::create(StringView title, StringVi
ErrorOr<void> WizardPage::build(String title, String subtitle)
{
TRY(try_set_layout<VerticalBoxLayout>(Margins {}, 0));
set_layout<VerticalBoxLayout>(Margins {}, 0);
auto header_widget = TRY(try_add<Widget>());
header_widget->set_fill_with_background_color(true);
header_widget->set_background_role(Gfx::ColorRole::Base);
header_widget->set_fixed_height(58);
TRY(header_widget->try_set_layout<VerticalBoxLayout>(Margins { 15, 30, 0 }));
header_widget->set_layout<VerticalBoxLayout>(Margins { 15, 30, 0 });
m_title_label = TRY(header_widget->try_add<Label>(move(title)));
m_title_label->set_font(Gfx::FontDatabase::default_font().bold_variant());
m_title_label->set_fixed_height(m_title_label->font().pixel_size_rounded_up() + 2);
@ -45,7 +45,7 @@ ErrorOr<void> WizardPage::build(String title, String subtitle)
separator->set_fixed_height(2);
m_body_widget = TRY(try_add<Widget>());
TRY(m_body_widget->try_set_layout<VerticalBoxLayout>(20));
m_body_widget->set_layout<VerticalBoxLayout>(20);
return {};
}