mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:07:36 +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:
parent
341626e2ea
commit
8322b31b97
52 changed files with 127 additions and 135 deletions
|
@ -128,12 +128,12 @@ void InputBox::on_done(ExecResult result)
|
|||
ErrorOr<void> InputBox::build()
|
||||
{
|
||||
auto main_widget = TRY(set_main_widget<Widget>());
|
||||
TRY(main_widget->try_set_layout<VerticalBoxLayout>(6, 6));
|
||||
main_widget->set_layout<VerticalBoxLayout>(6, 6);
|
||||
main_widget->set_fill_with_background_color(true);
|
||||
|
||||
if (!m_prompt.is_empty()) {
|
||||
auto prompt_container = TRY(main_widget->try_add<Widget>());
|
||||
TRY(prompt_container->try_set_layout<HorizontalBoxLayout>(0, 8));
|
||||
prompt_container->set_layout<HorizontalBoxLayout>(0, 8);
|
||||
if (m_icon) {
|
||||
auto image_widget = TRY(prompt_container->try_add<ImageWidget>());
|
||||
image_widget->set_bitmap(m_icon);
|
||||
|
@ -158,7 +158,7 @@ ErrorOr<void> InputBox::build()
|
|||
}
|
||||
|
||||
auto button_container = TRY(main_widget->try_add<Widget>());
|
||||
TRY(button_container->try_set_layout<HorizontalBoxLayout>(0, 6));
|
||||
button_container->set_layout<HorizontalBoxLayout>(0, 6);
|
||||
TRY(button_container->add_spacer());
|
||||
|
||||
m_ok_button = TRY(button_container->try_add<DialogButton>("OK"_string));
|
||||
|
|
|
@ -152,11 +152,11 @@ ErrorOr<void> MessageBox::build()
|
|||
{
|
||||
auto main_widget = TRY(set_main_widget<Widget>());
|
||||
main_widget->set_fill_with_background_color(true);
|
||||
TRY(main_widget->try_set_layout<VerticalBoxLayout>(8, 6));
|
||||
main_widget->set_layout<VerticalBoxLayout>(8, 6);
|
||||
|
||||
auto message_container = TRY(main_widget->try_add<Widget>());
|
||||
auto message_margins = Margins { 8, m_type != Type::None ? 8 : 0 };
|
||||
TRY(message_container->try_set_layout<HorizontalBoxLayout>(message_margins, 8));
|
||||
message_container->set_layout<HorizontalBoxLayout>(message_margins, 8);
|
||||
|
||||
if (auto icon = TRY(this->icon()); icon && m_type != Type::None) {
|
||||
auto image_widget = TRY(message_container->try_add<ImageWidget>());
|
||||
|
@ -170,7 +170,7 @@ ErrorOr<void> MessageBox::build()
|
|||
m_text_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||
|
||||
auto button_container = TRY(main_widget->try_add<Widget>());
|
||||
TRY(button_container->try_set_layout<HorizontalBoxLayout>(Margins {}, 8));
|
||||
button_container->set_layout<HorizontalBoxLayout>(Margins {}, 8);
|
||||
|
||||
auto add_button = [&](String text, ExecResult result) -> ErrorOr<NonnullRefPtr<Button>> {
|
||||
auto button = TRY(button_container->try_add<DialogButton>());
|
||||
|
|
|
@ -27,7 +27,7 @@ ErrorOr<NonnullRefPtr<PathBreadcrumbbar>> PathBreadcrumbbar::try_create()
|
|||
auto breadcrumbbar = TRY(Breadcrumbbar::try_create());
|
||||
|
||||
auto path_breadcrumbbar = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) PathBreadcrumbbar(*location_text_box, *breadcrumbbar)));
|
||||
(void)TRY(path_breadcrumbbar->try_set_layout<GUI::VerticalBoxLayout>());
|
||||
path_breadcrumbbar->set_layout<GUI::VerticalBoxLayout>();
|
||||
TRY(path_breadcrumbbar->try_add_child(location_text_box));
|
||||
TRY(path_breadcrumbbar->try_add_child(breadcrumbbar));
|
||||
|
||||
|
|
|
@ -34,13 +34,13 @@ ErrorOr<NonnullRefPtr<SettingsWindow>> SettingsWindow::create(DeprecatedString t
|
|||
|
||||
auto main_widget = TRY(window->set_main_widget<GUI::Widget>());
|
||||
main_widget->set_fill_with_background_color(true);
|
||||
TRY(main_widget->try_set_layout<GUI::VerticalBoxLayout>(4, 6));
|
||||
main_widget->set_layout<GUI::VerticalBoxLayout>(4, 6);
|
||||
|
||||
window->m_tab_widget = TRY(main_widget->try_add<GUI::TabWidget>());
|
||||
|
||||
auto button_container = TRY(main_widget->try_add<GUI::Widget>());
|
||||
button_container->set_preferred_size({ SpecialDimension::Grow, SpecialDimension::Fit });
|
||||
TRY(button_container->try_set_layout<GUI::HorizontalBoxLayout>(GUI::Margins {}, 6));
|
||||
button_container->set_layout<GUI::HorizontalBoxLayout>(GUI::Margins {}, 6);
|
||||
|
||||
if (show_defaults_button == ShowDefaultsButton::Yes) {
|
||||
window->m_reset_button = TRY(button_container->try_add<GUI::DialogButton>("Defaults"_string));
|
||||
|
|
|
@ -80,14 +80,6 @@ public:
|
|||
Layout const* layout() const { return m_layout.ptr(); }
|
||||
void set_layout(NonnullRefPtr<Layout>);
|
||||
|
||||
template<class T, class... Args>
|
||||
ErrorOr<void> try_set_layout(Args&&... args)
|
||||
{
|
||||
auto layout = TRY(T::try_create(forward<Args>(args)...));
|
||||
set_layout(*layout);
|
||||
return {};
|
||||
}
|
||||
|
||||
template<class T, class... Args>
|
||||
inline void set_layout(Args&&... args)
|
||||
{
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -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 {};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue