1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 23:37:36 +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

@ -182,12 +182,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto container = TRY(window->set_main_widget<GUI::Frame>());
container->set_fill_with_background_color(true);
container->set_frame_shape(Gfx::FrameShape::Window);
auto& layout = container->set_layout<GUI::VerticalBoxLayout>();
layout.set_margins({ 8 });
container->set_layout<GUI::VerticalBoxLayout>(8);
auto& text_box = container->add<GUI::TextBox>();
auto& results_container = container->add<GUI::Widget>();
auto& results_layout = results_container.set_layout<GUI::VerticalBoxLayout>();
results_container.set_layout<GUI::VerticalBoxLayout>();
auto mark_selected_item = [&]() {
for (size_t i = 0; i < app_state.visible_result_count; ++i) {
@ -250,7 +249,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto update_ui_timer = TRY(Core::Timer::create_single_shot(10, [&] {
results_container.remove_all_children();
results_layout.set_margins(app_state.visible_result_count ? GUI::Margins { 4, 0, 0, 0 } : GUI::Margins { 0 });
results_container.layout()->set_margins(app_state.visible_result_count ? GUI::Margins { 4, 0, 0, 0 } : GUI::Margins { 0 });
for (size_t i = 0; i < app_state.visible_result_count; ++i) {
auto& result = app_state.results[i];

View file

@ -103,9 +103,7 @@ BookmarksBarWidget& BookmarksBarWidget::the()
BookmarksBarWidget::BookmarksBarWidget(DeprecatedString const& bookmarks_file, bool enabled)
{
s_the = this;
set_layout<GUI::HorizontalBoxLayout>();
layout()->set_spacing(0);
layout()->set_margins(2);
set_layout<GUI::HorizontalBoxLayout>(2, 0);
set_fixed_height(20);

View file

@ -59,8 +59,7 @@ DownloadWidget::DownloadWidget(const URL& url)
m_download->stream_into(*m_output_file_stream);
set_fill_with_background_color(true);
auto& layout = set_layout<GUI::VerticalBoxLayout>();
layout.set_margins(4);
set_layout<GUI::VerticalBoxLayout>(4);
auto& animation_container = add<GUI::Widget>();
animation_container.set_fixed_height(32);

View file

@ -77,15 +77,13 @@ InspectorWidget::InspectorWidget()
{
set_fill_with_background_color(true);
auto& layout = set_layout<GUI::VerticalBoxLayout>();
layout.set_margins({ 4, 4, 4, 4 });
set_layout<GUI::VerticalBoxLayout>(4);
auto& splitter = add<GUI::VerticalSplitter>();
auto& top_tab_widget = splitter.add<GUI::TabWidget>();
auto& dom_tree_container = top_tab_widget.add_tab<GUI::Widget>("DOM");
dom_tree_container.set_layout<GUI::VerticalBoxLayout>();
dom_tree_container.layout()->set_margins({ 4, 4, 4, 4 });
dom_tree_container.set_layout<GUI::VerticalBoxLayout>(4);
m_dom_tree_view = dom_tree_container.add<GUI::TreeView>();
m_dom_tree_view->on_selection_change = [this] {
const auto& index = m_dom_tree_view->selection().first();
@ -93,30 +91,25 @@ InspectorWidget::InspectorWidget()
};
auto& accessibility_tree_container = top_tab_widget.add_tab<GUI::Widget>("Accessibility");
accessibility_tree_container.set_layout<GUI::VerticalBoxLayout>();
accessibility_tree_container.layout()->set_margins({ 4, 4, 4, 4 });
accessibility_tree_container.set_layout<GUI::VerticalBoxLayout>(4);
m_accessibility_tree_view = accessibility_tree_container.add<GUI::TreeView>();
auto& bottom_tab_widget = splitter.add<GUI::TabWidget>();
auto& computed_style_table_container = bottom_tab_widget.add_tab<GUI::Widget>("Computed");
computed_style_table_container.set_layout<GUI::VerticalBoxLayout>();
computed_style_table_container.layout()->set_margins({ 4, 4, 4, 4 });
computed_style_table_container.set_layout<GUI::VerticalBoxLayout>(4);
m_computed_style_table_view = computed_style_table_container.add<GUI::TableView>();
auto& resolved_style_table_container = bottom_tab_widget.add_tab<GUI::Widget>("Resolved");
resolved_style_table_container.set_layout<GUI::VerticalBoxLayout>();
resolved_style_table_container.layout()->set_margins({ 4, 4, 4, 4 });
resolved_style_table_container.set_layout<GUI::VerticalBoxLayout>(4);
m_resolved_style_table_view = resolved_style_table_container.add<GUI::TableView>();
auto& custom_properties_table_container = bottom_tab_widget.add_tab<GUI::Widget>("Variables");
custom_properties_table_container.set_layout<GUI::VerticalBoxLayout>();
custom_properties_table_container.layout()->set_margins({ 4, 4, 4, 4 });
custom_properties_table_container.set_layout<GUI::VerticalBoxLayout>(4);
m_custom_properties_table_view = custom_properties_table_container.add<GUI::TableView>();
auto& box_model_widget = bottom_tab_widget.add_tab<GUI::Widget>("Box Model");
box_model_widget.set_layout<GUI::VerticalBoxLayout>();
box_model_widget.layout()->set_margins({ 4, 4, 4, 4 });
box_model_widget.set_layout<GUI::VerticalBoxLayout>(4);
m_element_size_view = box_model_widget.add<ElementSizePreviewWidget>();
m_element_size_view->set_should_hide_unnecessary_scrollbars(true);

View file

@ -33,9 +33,8 @@ AddEventDialog::AddEventDialog(Core::DateTime date_time, Window* parent_window)
widget->set_layout<GUI::VerticalBoxLayout>();
auto& top_container = widget->add<GUI::Widget>();
top_container.set_layout<GUI::VerticalBoxLayout>();
top_container.set_layout<GUI::VerticalBoxLayout>(4);
top_container.set_fixed_height(45);
top_container.layout()->set_margins(4);
auto& add_label = top_container.add<GUI::Label>("Add title & date:");
add_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
@ -46,14 +45,12 @@ AddEventDialog::AddEventDialog(Core::DateTime date_time, Window* parent_window)
event_title_textbox.set_fixed_height(20);
auto& middle_container = widget->add<GUI::Widget>();
middle_container.set_layout<GUI::HorizontalBoxLayout>();
middle_container.set_layout<GUI::HorizontalBoxLayout>(4);
middle_container.set_fixed_height(25);
middle_container.layout()->set_margins(4);
auto& time_container = widget->add<GUI::Widget>();
time_container.set_layout<GUI::HorizontalBoxLayout>();
time_container.set_layout<GUI::HorizontalBoxLayout>(4);
time_container.set_fixed_height(25);
time_container.layout()->set_margins(4);
auto& starting_month_combo = middle_container.add<GUI::ComboBox>();
starting_month_combo.set_only_allow_values_from_model(true);

View file

@ -216,8 +216,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto& tab_widget = *widget->find_descendant_of_type_named<GUI::TabWidget>("tab_widget");
auto backtrace_tab = TRY(tab_widget.try_add_tab<GUI::Widget>("Backtrace"));
(void)TRY(backtrace_tab->try_set_layout<GUI::VerticalBoxLayout>());
backtrace_tab->layout()->set_margins(4);
(void)TRY(backtrace_tab->try_set_layout<GUI::VerticalBoxLayout>(4));
auto backtrace_label = TRY(backtrace_tab->try_add<GUI::Label>("A backtrace for each thread alive during the crash is listed below:"));
backtrace_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
@ -227,8 +226,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
backtrace_tab_widget->set_tab_position(GUI::TabWidget::TabPosition::Bottom);
auto cpu_registers_tab = TRY(tab_widget.try_add_tab<GUI::Widget>("CPU Registers"));
cpu_registers_tab->set_layout<GUI::VerticalBoxLayout>();
cpu_registers_tab->layout()->set_margins(4);
cpu_registers_tab->set_layout<GUI::VerticalBoxLayout>(4);
auto cpu_registers_label = TRY(cpu_registers_tab->try_add<GUI::Label>("The CPU register state for each thread alive during the crash is listed below:"));
cpu_registers_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
@ -238,8 +236,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
cpu_registers_tab_widget->set_tab_position(GUI::TabWidget::TabPosition::Bottom);
auto environment_tab = TRY(tab_widget.try_add_tab<GUI::Widget>("Environment"));
(void)TRY(environment_tab->try_set_layout<GUI::VerticalBoxLayout>());
environment_tab->layout()->set_margins(4);
(void)TRY(environment_tab->try_set_layout<GUI::VerticalBoxLayout>(4));
auto environment_text_editor = TRY(environment_tab->try_add<GUI::TextEditor>());
environment_text_editor->set_text(DeprecatedString::join('\n', environment));
@ -248,8 +245,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
environment_text_editor->set_should_hide_unnecessary_scrollbars(true);
auto memory_regions_tab = TRY(tab_widget.try_add_tab<GUI::Widget>("Memory Regions"));
(void)TRY(memory_regions_tab->try_set_layout<GUI::VerticalBoxLayout>());
memory_regions_tab->layout()->set_margins(4);
(void)TRY(memory_regions_tab->try_set_layout<GUI::VerticalBoxLayout>(4));
auto memory_regions_text_editor = TRY(memory_regions_tab->try_add<GUI::TextEditor>());
memory_regions_text_editor->set_text(DeprecatedString::join('\n', memory_regions));
@ -307,8 +303,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
[&](auto results) -> ErrorOr<void> {
for (auto& backtrace : results.thread_backtraces) {
auto container = TRY(backtrace_tab_widget->try_add_tab<GUI::Widget>(backtrace.title));
(void)TRY(container->template try_set_layout<GUI::VerticalBoxLayout>());
container->layout()->set_margins(4);
(void)TRY(container->template try_set_layout<GUI::VerticalBoxLayout>(4));
auto backtrace_text_editor = TRY(container->template try_add<GUI::TextEditor>());
backtrace_text_editor->set_text(backtrace.text);
backtrace_text_editor->set_mode(GUI::TextEditor::Mode::ReadOnly);
@ -319,8 +314,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
for (auto& cpu_registers : results.thread_cpu_registers) {
auto container = TRY(cpu_registers_tab_widget->try_add_tab<GUI::Widget>(cpu_registers.title));
(void)TRY(container->template try_set_layout<GUI::VerticalBoxLayout>());
container->layout()->set_margins(4);
(void)TRY(container->template try_set_layout<GUI::VerticalBoxLayout>(4));
auto cpu_registers_text_editor = TRY(container->template try_add<GUI::TextEditor>());
cpu_registers_text_editor->set_text(cpu_registers.text);
cpu_registers_text_editor->set_mode(GUI::TextEditor::Mode::ReadOnly);

View file

@ -53,9 +53,7 @@ PropertiesWindow::PropertiesWindow(DeprecatedString const& path, Window* parent_
ErrorOr<void> PropertiesWindow::create_widgets(bool disable_rename)
{
auto main_widget = TRY(set_main_widget<GUI::Widget>());
(void)TRY(main_widget->try_set_layout<GUI::VerticalBoxLayout>());
main_widget->layout()->set_spacing(6);
main_widget->layout()->set_margins(4);
(void)TRY(main_widget->try_set_layout<GUI::VerticalBoxLayout>(4, 6));
main_widget->set_fill_with_background_color(true);
auto tab_widget = TRY(main_widget->try_add<GUI::TabWidget>());
@ -151,9 +149,8 @@ ErrorOr<void> PropertiesWindow::create_widgets(bool disable_rename)
TRY(setup_permission_checkboxes(*others_read, *others_write, *others_execute, { S_IROTH, S_IWOTH, S_IXOTH }, m_mode));
auto button_widget = TRY(main_widget->try_add<GUI::Widget>());
(void)TRY(button_widget->try_set_layout<GUI::HorizontalBoxLayout>());
(void)TRY(button_widget->try_set_layout<GUI::HorizontalBoxLayout>(GUI::Margins {}, 5));
button_widget->set_fixed_height(22);
button_widget->layout()->set_spacing(5);
TRY(button_widget->add_spacer());

View file

@ -11,8 +11,7 @@ namespace ImageViewer {
MainWidget::MainWidget()
{
set_fill_with_background_color(true);
set_layout<GUI::VerticalBoxLayout>();
layout()->set_spacing(2);
set_layout<GUI::VerticalBoxLayout>(GUI::Margins {}, 2);
}
void MainWidget::keydown_event(GUI::KeyEvent& event)

View file

@ -39,8 +39,7 @@ bool KeyboardMapperWidget::request_close()
void KeyboardMapperWidget::create_frame()
{
set_fill_with_background_color(true);
set_layout<GUI::VerticalBoxLayout>();
layout()->set_margins(4);
set_layout<GUI::VerticalBoxLayout>(4);
auto& main_widget = add<GUI::Widget>();
main_widget.set_relative_rect(0, 0, 200, 200);

View file

@ -18,8 +18,7 @@ SidebarWidget::SidebarWidget()
auto& tab_bar = add<GUI::TabWidget>();
auto& outline_container = tab_bar.add_tab<GUI::Widget>("Outline");
outline_container.set_layout<GUI::VerticalBoxLayout>();
outline_container.layout()->set_margins(4);
outline_container.set_layout<GUI::VerticalBoxLayout>(4);
m_outline_tree_view = outline_container.add<GUI::TreeView>();
m_outline_tree_view->set_activates_on_selection(true);
@ -34,8 +33,7 @@ SidebarWidget::SidebarWidget()
};
auto& thumbnails_container = tab_bar.add_tab<GUI::Widget>("Thumbnails");
thumbnails_container.set_layout<GUI::VerticalBoxLayout>();
thumbnails_container.layout()->set_margins(4);
thumbnails_container.set_layout<GUI::VerticalBoxLayout>(4);
// FIXME: Add thumbnail previews
}

View file

@ -34,9 +34,7 @@ MainWidget::MainWidget(TrackManager& track_manager, AudioPlayerLoop& loop)
ErrorOr<void> MainWidget::initialize()
{
(void)TRY(try_set_layout<GUI::VerticalBoxLayout>());
layout()->set_spacing(2);
layout()->set_margins(2);
(void)TRY(try_set_layout<GUI::VerticalBoxLayout>(2, 2));
set_fill_with_background_color(true);
m_wave_widget = TRY(try_add<WaveWidget>(m_track_manager));
@ -51,8 +49,7 @@ ErrorOr<void> MainWidget::initialize()
m_player_widget = TRY(try_add<PlayerWidget>(m_track_manager, m_audio_loop));
m_keys_and_knobs_container = TRY(try_add<GUI::Widget>());
(void)TRY(m_keys_and_knobs_container->try_set_layout<GUI::HorizontalBoxLayout>());
m_keys_and_knobs_container->layout()->set_spacing(2);
(void)TRY(m_keys_and_knobs_container->try_set_layout<GUI::HorizontalBoxLayout>(GUI::Margins {}, 2));
m_keys_and_knobs_container->set_fixed_height(130);
m_keys_and_knobs_container->set_fill_with_background_color(true);

View file

@ -40,14 +40,11 @@ void WaveEditor::paint_event(GUI::PaintEvent& event)
SamplerWidget::SamplerWidget(TrackManager& track_manager)
: m_track_manager(track_manager)
{
set_layout<GUI::VerticalBoxLayout>();
layout()->set_margins(10);
layout()->set_spacing(10);
set_layout<GUI::VerticalBoxLayout>(10, 10);
set_fill_with_background_color(true);
m_open_button_and_recorded_sample_name_container = add<GUI::Widget>();
m_open_button_and_recorded_sample_name_container->set_layout<GUI::HorizontalBoxLayout>();
m_open_button_and_recorded_sample_name_container->layout()->set_spacing(10);
m_open_button_and_recorded_sample_name_container->set_layout<GUI::HorizontalBoxLayout>(GUI::Margins {}, 10);
m_open_button_and_recorded_sample_name_container->set_fixed_height(24);
m_open_button = m_open_button_and_recorded_sample_name_container->add<GUI::Button>();

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);

View file

@ -46,7 +46,7 @@ CellTypeDialog::CellTypeDialog(Vector<Position> const& positions, Sheet& sheet,
resize(285, 360);
auto main_widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
main_widget->set_layout<GUI::VerticalBoxLayout>().set_margins(4);
main_widget->set_layout<GUI::VerticalBoxLayout>(4);
main_widget->set_fill_with_background_color(true);
auto& tab_widget = main_widget->add<GUI::TabWidget>();
@ -54,8 +54,7 @@ CellTypeDialog::CellTypeDialog(Vector<Position> const& positions, Sheet& sheet,
auto& buttonbox = main_widget->add<GUI::Widget>();
buttonbox.set_shrink_to_fit(true);
auto& button_layout = buttonbox.set_layout<GUI::HorizontalBoxLayout>();
button_layout.set_spacing(10);
buttonbox.set_layout<GUI::HorizontalBoxLayout>(GUI::Margins {}, 10);
buttonbox.add_spacer().release_value_but_fixme_should_propagate_errors();
auto& ok_button = buttonbox.add<GUI::Button>(String::from_utf8_short_string("OK"sv));
ok_button.set_fixed_width(80);
@ -134,7 +133,7 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, Vector<Position> const& po
}
auto& type_tab = tabs.add_tab<GUI::Widget>("Type");
type_tab.set_layout<GUI::HorizontalBoxLayout>().set_margins(4);
type_tab.set_layout<GUI::HorizontalBoxLayout>(4);
{
auto& left_side = type_tab.add<GUI::Widget>();
left_side.set_layout<GUI::VerticalBoxLayout>();
@ -199,14 +198,13 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, Vector<Position> const& po
}
auto& alignment_tab = tabs.add_tab<GUI::Widget>("Alignment");
alignment_tab.set_layout<GUI::VerticalBoxLayout>().set_margins(4);
alignment_tab.set_layout<GUI::VerticalBoxLayout>(4);
{
// FIXME: Frame?
// Horizontal alignment
{
auto& horizontal_alignment_selection_container = alignment_tab.add<GUI::Widget>();
horizontal_alignment_selection_container.set_layout<GUI::HorizontalBoxLayout>();
horizontal_alignment_selection_container.layout()->set_margins({ 4, 0, 0 });
horizontal_alignment_selection_container.set_layout<GUI::HorizontalBoxLayout>(GUI::Margins { 4, 0, 0 });
horizontal_alignment_selection_container.set_fixed_height(22);
auto& horizontal_alignment_label = horizontal_alignment_selection_container.add<GUI::Label>();
@ -237,8 +235,7 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, Vector<Position> const& po
// Vertical alignment
{
auto& vertical_alignment_container = alignment_tab.add<GUI::Widget>();
vertical_alignment_container.set_layout<GUI::HorizontalBoxLayout>();
vertical_alignment_container.layout()->set_margins({ 4, 0, 0 });
vertical_alignment_container.set_layout<GUI::HorizontalBoxLayout>(GUI::Margins { 4, 0, 0 });
vertical_alignment_container.set_fixed_height(22);
auto& vertical_alignment_label = vertical_alignment_container.add<GUI::Label>();
@ -268,7 +265,7 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, Vector<Position> const& po
}
auto& colors_tab = tabs.add_tab<GUI::Widget>("Color");
colors_tab.set_layout<GUI::VerticalBoxLayout>().set_margins(4);
colors_tab.set_layout<GUI::VerticalBoxLayout>(4);
{
// Static formatting
{
@ -279,8 +276,7 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, Vector<Position> const& po
{
// FIXME: Somehow allow unsetting these.
auto& foreground_container = static_formatting_container.add<GUI::Widget>();
foreground_container.set_layout<GUI::HorizontalBoxLayout>();
foreground_container.layout()->set_margins({ 4, 0, 0 });
foreground_container.set_layout<GUI::HorizontalBoxLayout>(GUI::Margins { 4, 0, 0 });
foreground_container.set_preferred_height(GUI::SpecialDimension::Fit);
auto& foreground_label = foreground_container.add<GUI::Label>();
@ -299,8 +295,7 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, Vector<Position> const& po
{
// FIXME: Somehow allow unsetting these.
auto& background_container = static_formatting_container.add<GUI::Widget>();
background_container.set_layout<GUI::HorizontalBoxLayout>();
background_container.layout()->set_margins({ 4, 0, 0 });
background_container.set_layout<GUI::HorizontalBoxLayout>(GUI::Margins { 4, 0, 0 });
background_container.set_preferred_height(GUI::SpecialDimension::Fit);
auto& background_label = background_container.add<GUI::Label>();
@ -427,9 +422,7 @@ ConditionView::~ConditionView()
ConditionsView::ConditionsView()
{
auto& layout = set_layout<GUI::VerticalBoxLayout>();
layout.set_spacing(4);
layout.set_margins({ 6 });
set_layout<GUI::VerticalBoxLayout>(6, 4);
}
void ConditionsView::set_formats(Vector<ConditionalFormat>* formats)

View file

@ -305,7 +305,7 @@ SpreadsheetView::SpreadsheetView(Sheet& sheet)
: m_sheet(sheet)
, m_sheet_model(SheetModel::create(*m_sheet))
{
set_layout<GUI::VerticalBoxLayout>().set_margins(2);
set_layout<GUI::VerticalBoxLayout>(2);
m_table_view = add<InfinitelyScrollableTableView>();
m_table_view->set_grid_style(GUI::TableView::GridStyle::Both);
m_table_view->set_selection_behavior(GUI::AbstractView::SelectionBehavior::SelectItems);

View file

@ -31,7 +31,7 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVe
: m_workbook(make<Workbook>(move(sheets), parent_window))
{
set_fill_with_background_color(true);
set_layout<GUI::VerticalBoxLayout>().set_margins(2);
set_layout<GUI::VerticalBoxLayout>(2);
auto& toolbar_container = add<GUI::ToolbarContainer>();
auto& toolbar = toolbar_container.add<GUI::Toolbar>();
@ -39,7 +39,7 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVe
auto& container = add<GUI::VerticalSplitter>();
auto& top_bar = container.add<GUI::Frame>();
top_bar.set_layout<GUI::HorizontalBoxLayout>().set_spacing(1);
top_bar.set_layout<GUI::HorizontalBoxLayout>(GUI::Margins {}, 1);
top_bar.set_preferred_height(26);
auto& current_cell_label = top_bar.add<GUI::Label>("");
current_cell_label.set_fixed_width(50);
@ -83,7 +83,7 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVe
m_inline_documentation_window->set_resizable(false);
auto inline_widget = m_inline_documentation_window->set_main_widget<GUI::Frame>().release_value_but_fixme_should_propagate_errors();
inline_widget->set_fill_with_background_color(true);
inline_widget->set_layout<GUI::VerticalBoxLayout>().set_margins(4);
inline_widget->set_layout<GUI::VerticalBoxLayout>(4);
inline_widget->set_frame_shape(Gfx::FrameShape::Box);
m_inline_documentation_label = inline_widget->add<GUI::Label>();
m_inline_documentation_label->set_fill_with_background_color(true);

View file

@ -43,9 +43,7 @@ MemoryStatsWidget::MemoryStatsWidget(GraphWidget* graph)
set_fixed_height(110);
set_layout<GUI::VerticalBoxLayout>();
layout()->set_margins({ 8, 0, 0 });
layout()->set_spacing(3);
set_layout<GUI::VerticalBoxLayout>(GUI::Margins { 8, 0, 0 }, 3);
auto build_widgets_for_label = [this](DeprecatedString const& description) -> RefPtr<GUI::Label> {
auto& container = add<GUI::Widget>();

View file

@ -22,8 +22,7 @@ namespace SystemMonitor {
NetworkStatisticsWidget::NetworkStatisticsWidget()
{
on_first_show = [this](auto&) {
set_layout<GUI::VerticalBoxLayout>();
layout()->set_margins(4);
set_layout<GUI::VerticalBoxLayout>(4);
set_fill_with_background_color(true);
m_network_connected_bitmap = Gfx::Bitmap::load_from_file("/res/icons/16x16/network-connected.png"sv).release_value_but_fixme_should_propagate_errors();
@ -38,8 +37,7 @@ NetworkStatisticsWidget::NetworkStatisticsWidget()
}
auto& adapters_group_box = add<GUI::GroupBox>("Adapters"sv);
adapters_group_box.set_layout<GUI::VerticalBoxLayout>();
adapters_group_box.layout()->set_margins(6);
adapters_group_box.set_layout<GUI::VerticalBoxLayout>(6);
adapters_group_box.set_fixed_height(120);
m_adapter_table_view = adapters_group_box.add<GUI::TableView>();
@ -94,8 +92,7 @@ NetworkStatisticsWidget::NetworkStatisticsWidget()
};
auto& tcp_sockets_group_box = add<GUI::GroupBox>("TCP Sockets"sv);
tcp_sockets_group_box.set_layout<GUI::VerticalBoxLayout>();
tcp_sockets_group_box.layout()->set_margins(6);
tcp_sockets_group_box.set_layout<GUI::VerticalBoxLayout>(6);
m_tcp_socket_table_view = tcp_sockets_group_box.add<GUI::TableView>();
@ -115,8 +112,7 @@ NetworkStatisticsWidget::NetworkStatisticsWidget()
m_tcp_socket_table_view->set_model(MUST(GUI::SortingProxyModel::create(*m_tcp_socket_model)));
auto& udp_sockets_group_box = add<GUI::GroupBox>("UDP Sockets"sv);
udp_sockets_group_box.set_layout<GUI::VerticalBoxLayout>();
udp_sockets_group_box.layout()->set_margins(6);
udp_sockets_group_box.set_layout<GUI::VerticalBoxLayout>(6);
m_udp_socket_table_view = udp_sockets_group_box.add<GUI::TableView>();

View file

@ -17,8 +17,7 @@ namespace SystemMonitor {
ProcessFileDescriptorMapWidget::ProcessFileDescriptorMapWidget()
{
set_layout<GUI::VerticalBoxLayout>();
layout()->set_margins(4);
set_layout<GUI::VerticalBoxLayout>(4);
m_table_view = add<GUI::TableView>();
Vector<GUI::JsonArrayModel::FieldSpec> pid_fds_fields;

View file

@ -51,8 +51,7 @@ public:
ProcessMemoryMapWidget::ProcessMemoryMapWidget()
{
set_layout<GUI::VerticalBoxLayout>();
layout()->set_margins(4);
set_layout<GUI::VerticalBoxLayout>(4);
m_table_view = add<GUI::TableView>();
Vector<GUI::JsonArrayModel::FieldSpec> pid_vm_fields;
pid_vm_fields.empend(

View file

@ -95,8 +95,7 @@ private:
ProcessStateWidget::ProcessStateWidget()
{
set_layout<GUI::VerticalBoxLayout>();
layout()->set_margins(4);
set_layout<GUI::VerticalBoxLayout>(4);
m_table_view = add<GUI::TableView>();
m_table_view->set_model(adopt_ref(*new ProcessStateModel(ProcessModel::the(), 0)));
m_table_view->column_header().set_visible(false);

View file

@ -18,8 +18,7 @@ namespace SystemMonitor {
ProcessUnveiledPathsWidget::ProcessUnveiledPathsWidget()
{
set_layout<GUI::VerticalBoxLayout>();
layout()->set_margins(4);
set_layout<GUI::VerticalBoxLayout>(4);
m_table_view = add<GUI::TableView>();
Vector<GUI::JsonArrayModel::FieldSpec> pid_unveil_fields;

View file

@ -73,8 +73,7 @@ private:
ThreadStackWidget::ThreadStackWidget()
{
set_layout<GUI::VerticalBoxLayout>();
layout()->set_margins(4);
set_layout<GUI::VerticalBoxLayout>(4);
m_stack_table = add<GUI::TableView>();
m_stack_table->set_model(adopt_ref(*new ThreadStackModel()));
}

View file

@ -561,8 +561,7 @@ void build_performance_tab(GUI::Widget& graphs_container)
Vector<SystemMonitor::GraphWidget&> cpu_graphs;
for (auto row = 0u; row < cpu_graph_rows; ++row) {
auto& cpu_graph_row = cpu_graph_group_box.add<GUI::Widget>();
cpu_graph_row.set_layout<GUI::HorizontalBoxLayout>();
cpu_graph_row.layout()->set_margins(6);
cpu_graph_row.set_layout<GUI::HorizontalBoxLayout>(6);
cpu_graph_row.set_fixed_height(108);
for (auto i = 0u; i < cpu_graphs_per_row; ++i) {
auto& cpu_graph = cpu_graph_row.add<SystemMonitor::GraphWidget>();

View file

@ -175,12 +175,10 @@ static ErrorOr<NonnullRefPtr<GUI::Window>> create_find_window(VT::TerminalWidget
auto main_widget = TRY(window->set_main_widget<GUI::Widget>());
main_widget->set_fill_with_background_color(true);
main_widget->set_background_role(ColorRole::Button);
(void)TRY(main_widget->try_set_layout<GUI::VerticalBoxLayout>());
main_widget->layout()->set_margins(4);
(void)TRY(main_widget->try_set_layout<GUI::VerticalBoxLayout>(4));
auto find = TRY(main_widget->try_add<GUI::Widget>());
(void)TRY(find->try_set_layout<GUI::HorizontalBoxLayout>());
find->layout()->set_margins(4);
(void)TRY(find->try_set_layout<GUI::HorizontalBoxLayout>(4));
find->set_fixed_height(30);
auto find_textbox = TRY(find->try_add<GUI::TextBox>());

View file

@ -435,16 +435,12 @@ ErrorOr<void> MainWidget::add_property_tab(PropertyTab const& property_tab)
auto properties_list = TRY(GUI::Widget::try_create());
scrollable_container->set_widget(properties_list);
(void)TRY(properties_list->try_set_layout<GUI::VerticalBoxLayout>());
properties_list->layout()->set_spacing(12);
properties_list->layout()->set_margins({ 8 });
(void)TRY(properties_list->try_set_layout<GUI::VerticalBoxLayout>(GUI::Margins { 8 }, 12));
for (auto const& group : property_tab.property_groups) {
NonnullRefPtr<GUI::GroupBox> group_box = TRY(properties_list->try_add<GUI::GroupBox>(group.title));
(void)TRY(group_box->try_set_layout<GUI::VerticalBoxLayout>());
group_box->layout()->set_spacing(12);
// 1px less on the left makes the text line up with the group title.
group_box->layout()->set_margins({ 8, 8, 8, 7 });
(void)TRY(group_box->try_set_layout<GUI::VerticalBoxLayout>(GUI::Margins { 8, 8, 8, 7 }, 12));
group_box->set_preferred_height(GUI::SpecialDimension::Fit);
for (auto const& property : group.properties) {