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

Userland: Specify margins and spacing in the GUI::Layout constructor

This commit is contained in:
Sam Atkins 2023-02-16 21:07:06 +00:00 committed by Sam Atkins
parent 9561ec15f4
commit 77ad0fdb07
64 changed files with 136 additions and 288 deletions

View file

@ -30,8 +30,7 @@ CreateNewImageDialog::CreateNewImageDialog(GUI::Window* parent_window)
auto main_widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
main_widget->set_fill_with_background_color(true);
auto& layout = main_widget->set_layout<GUI::VerticalBoxLayout>();
layout.set_margins(4);
main_widget->set_layout<GUI::VerticalBoxLayout>(4);
auto& name_label = main_widget->add<GUI::Label>("Name:");
name_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);

View file

@ -22,9 +22,7 @@ CreateNewLayerDialog::CreateNewLayerDialog(Gfx::IntSize suggested_size, GUI::Win
auto main_widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
main_widget->set_fill_with_background_color(true);
auto& layout = main_widget->set_layout<GUI::VerticalBoxLayout>();
layout.set_margins(4);
main_widget->set_layout<GUI::VerticalBoxLayout>(4);
auto& name_label = main_widget->add<GUI::Label>("Name:");
name_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);

View file

@ -52,8 +52,7 @@ private:
main_widget->set_frame_shape(Gfx::FrameShape::Container);
main_widget->set_frame_shadow(Gfx::FrameShadow::Raised);
main_widget->set_fill_with_background_color(true);
auto& layout = main_widget->template set_layout<GUI::VerticalBoxLayout>();
layout.set_margins(4);
main_widget->template set_layout<GUI::VerticalBoxLayout>(4);
size_t index = 0;
size_t columns = N;

View file

@ -47,8 +47,7 @@ ErrorOr<RefPtr<GUI::Widget>> Bloom::get_settings_widget()
auto luma_lower_container = TRY(settings_widget->try_add<GUI::Widget>());
luma_lower_container->set_fixed_height(50);
auto luma_lower_container_layout = TRY(luma_lower_container->try_set_layout<GUI::VerticalBoxLayout>());
luma_lower_container_layout->set_margins({ 4, 0, 4, 0 });
(void)TRY(luma_lower_container->try_set_layout<GUI::VerticalBoxLayout>(GUI::Margins { 4, 0, 4, 0 }));
auto luma_lower_label = TRY(luma_lower_container->try_add<GUI::Label>("Luma lower bound:"));
luma_lower_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
@ -64,8 +63,7 @@ ErrorOr<RefPtr<GUI::Widget>> Bloom::get_settings_widget()
auto radius_container = TRY(settings_widget->try_add<GUI::Widget>());
radius_container->set_fixed_height(50);
auto radius_container_layout = TRY(radius_container->try_set_layout<GUI::VerticalBoxLayout>());
radius_container_layout->set_margins({ 4, 0, 4, 0 });
(void)TRY(radius_container->try_set_layout<GUI::VerticalBoxLayout>(GUI::Margins { 4, 0, 4, 0 }));
auto radius_label = TRY(radius_container->try_add<GUI::Label>("Blur Radius:"));
radius_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);

View file

@ -86,8 +86,7 @@ ErrorOr<RefPtr<GUI::Widget>> FastBoxBlur::get_settings_widget()
m_radius_container = TRY(settings_widget->try_add<GUI::Widget>());
m_radius_container->set_fixed_height(20);
auto radius_container_layout = TRY(m_radius_container->try_set_layout<GUI::HorizontalBoxLayout>());
radius_container_layout->set_margins({ 4, 0, 4, 0 });
(void)TRY(m_radius_container->try_set_layout<GUI::HorizontalBoxLayout>(GUI::Margins { 4, 0, 4, 0 }));
auto radius_label = TRY(m_radius_container->try_add<GUI::Label>("Radius:"));
radius_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
@ -104,8 +103,7 @@ ErrorOr<RefPtr<GUI::Widget>> FastBoxBlur::get_settings_widget()
m_asymmetric_radius_container = TRY(settings_widget->try_add<GUI::Widget>());
m_asymmetric_radius_container->set_visible(false);
m_asymmetric_radius_container->set_fixed_height(50);
auto asymmetric_radius_container_label = TRY(m_asymmetric_radius_container->try_set_layout<GUI::VerticalBoxLayout>());
asymmetric_radius_container_label->set_margins({ 4, 0, 4, 0 });
(void)TRY(m_asymmetric_radius_container->try_set_layout<GUI::VerticalBoxLayout>(GUI::Margins { 4, 0, 4, 0 }));
auto radius_x_container = TRY(m_asymmetric_radius_container->try_add<GUI::Widget>());
radius_x_container->set_fixed_height(20);
@ -142,8 +140,7 @@ ErrorOr<RefPtr<GUI::Widget>> FastBoxBlur::get_settings_widget()
m_vector_container = TRY(settings_widget->try_add<GUI::Widget>());
m_vector_container->set_visible(false);
m_vector_container->set_fixed_height(50);
auto vector_container_layout = TRY(m_vector_container->try_set_layout<GUI::VerticalBoxLayout>());
vector_container_layout->set_margins({ 4, 0, 4, 0 });
(void)TRY(m_vector_container->try_set_layout<GUI::VerticalBoxLayout>(GUI::Margins { 4, 0, 4, 0 }));
auto angle_container = TRY(m_vector_container->try_add<GUI::Widget>());
angle_container->set_fixed_height(20);
@ -179,8 +176,7 @@ ErrorOr<RefPtr<GUI::Widget>> FastBoxBlur::get_settings_widget()
auto gaussian_container = TRY(settings_widget->try_add<GUI::Widget>());
gaussian_container->set_fixed_height(20);
auto gaussian_container_layout = TRY(gaussian_container->try_set_layout<GUI::HorizontalBoxLayout>());
gaussian_container_layout->set_margins({ 4, 0, 4, 0 });
(void)TRY(gaussian_container->try_set_layout<GUI::HorizontalBoxLayout>(GUI::Margins { 4, 0, 4, 0 }));
m_gaussian_checkbox = TRY(gaussian_container->try_add<GUI::CheckBox>(TRY(String::from_utf8("Approximate Gaussian Blur"sv))));
m_gaussian_checkbox->set_checked(m_approximate_gauss);

View file

@ -30,8 +30,7 @@ ErrorOr<RefPtr<GUI::Widget>> Sepia::get_settings_widget()
auto amount_container = TRY(settings_widget->try_add<GUI::Widget>());
amount_container->set_fixed_height(20);
auto amount_layout = TRY(amount_container->try_set_layout<GUI::HorizontalBoxLayout>());
amount_layout->set_margins({ 4, 0, 4, 0 });
(void)TRY(amount_container->try_set_layout<GUI::HorizontalBoxLayout>(GUI::Margins { 4, 0, 4, 0 }));
auto amount_label = TRY(amount_container->try_add<GUI::Label>("Amount:"));
amount_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);

View file

@ -24,9 +24,7 @@ LayerPropertiesWidget::LayerPropertiesWidget()
set_layout<GUI::VerticalBoxLayout>();
auto& group_box = add<GUI::GroupBox>("Layer properties"sv);
auto& layout = group_box.set_layout<GUI::VerticalBoxLayout>();
layout.set_margins({ 8 });
group_box.set_layout<GUI::VerticalBoxLayout>(8);
auto& name_container = group_box.add<GUI::Widget>();
name_container.set_fixed_height(20);

View file

@ -118,18 +118,15 @@ PaletteWidget::PaletteWidget()
m_color_container = add<GUI::Widget>();
m_color_container->set_relative_rect(m_secondary_color_widget->relative_rect().right() + 2, 2, 500, 33);
m_color_container->set_layout<GUI::VerticalBoxLayout>();
m_color_container->layout()->set_spacing(1);
m_color_container->set_layout<GUI::VerticalBoxLayout>(GUI::Margins {}, 1);
auto& top_color_container = m_color_container->add<GUI::Widget>();
top_color_container.set_name("top_color_container");
top_color_container.set_layout<GUI::HorizontalBoxLayout>();
top_color_container.layout()->set_spacing(1);
top_color_container.set_layout<GUI::HorizontalBoxLayout>(GUI::Margins {}, 1);
auto& bottom_color_container = m_color_container->add<GUI::Widget>();
bottom_color_container.set_name("bottom_color_container");
bottom_color_container.set_layout<GUI::HorizontalBoxLayout>();
bottom_color_container.layout()->set_spacing(1);
bottom_color_container.set_layout<GUI::HorizontalBoxLayout>(GUI::Margins {}, 1);
auto result = load_palette_path("/res/color-palettes/default.palette");
if (result.is_error()) {

View file

@ -20,8 +20,7 @@ ToolPropertiesWidget::ToolPropertiesWidget()
set_layout<GUI::VerticalBoxLayout>();
m_group_box = add<GUI::GroupBox>("Tool properties"sv);
auto& layout = m_group_box->set_layout<GUI::VerticalBoxLayout>();
layout.set_margins({ 8 });
m_group_box->set_layout<GUI::VerticalBoxLayout>(8);
m_tool_widget_stack = m_group_box->add<GUI::StackWidget>();
m_blank_widget = m_tool_widget_stack->add<GUI::Widget>();
m_error_label = m_tool_widget_stack->add<GUI::Label>();

View file

@ -39,10 +39,7 @@ ToolboxWidget::ToolboxWidget()
set_fill_with_background_color(true);
set_fixed_width(26);
set_layout<GUI::VerticalBoxLayout>();
layout()->set_spacing(0);
layout()->set_margins(2);
set_layout<GUI::VerticalBoxLayout>(2, 0);
m_action_group.set_exclusive(true);
m_action_group.set_unchecking_allowed(false);