mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:27:46 +00:00
Userland: Specify margins and spacing in the GUI::Layout constructor
This commit is contained in:
parent
9561ec15f4
commit
77ad0fdb07
64 changed files with 136 additions and 288 deletions
|
@ -60,8 +60,7 @@ private:
|
|||
|
||||
Breadcrumbbar::Breadcrumbbar()
|
||||
{
|
||||
auto& layout = set_layout<HorizontalBoxLayout>();
|
||||
layout.set_spacing(0);
|
||||
set_layout<HorizontalBoxLayout>(GUI::Margins {}, 0);
|
||||
}
|
||||
|
||||
void Breadcrumbbar::clear_segments()
|
||||
|
|
|
@ -207,31 +207,25 @@ void ColorPicker::set_color_has_alpha_channel(bool has_alpha)
|
|||
void ColorPicker::build_ui()
|
||||
{
|
||||
auto root_container = set_main_widget<Widget>().release_value_but_fixme_should_propagate_errors();
|
||||
root_container->set_layout<VerticalBoxLayout>();
|
||||
root_container->layout()->set_margins(4);
|
||||
root_container->set_layout<VerticalBoxLayout>(4);
|
||||
root_container->set_fill_with_background_color(true);
|
||||
|
||||
auto& tab_widget = root_container->add<GUI::TabWidget>();
|
||||
|
||||
auto& tab_palette = tab_widget.add_tab<Widget>("Palette");
|
||||
tab_palette.set_layout<VerticalBoxLayout>();
|
||||
tab_palette.layout()->set_margins(4);
|
||||
tab_palette.layout()->set_spacing(4);
|
||||
tab_palette.set_layout<VerticalBoxLayout>(4, 4);
|
||||
|
||||
build_ui_palette(tab_palette);
|
||||
|
||||
auto& tab_custom_color = tab_widget.add_tab<Widget>("Custom Color");
|
||||
tab_custom_color.set_layout<VerticalBoxLayout>();
|
||||
tab_custom_color.layout()->set_margins(4);
|
||||
tab_custom_color.layout()->set_spacing(4);
|
||||
tab_custom_color.set_layout<VerticalBoxLayout>(4, 4);
|
||||
|
||||
build_ui_custom(tab_custom_color);
|
||||
|
||||
auto& button_container = root_container->add<Widget>();
|
||||
button_container.set_preferred_height(GUI::SpecialDimension::Fit);
|
||||
button_container.set_layout<HorizontalBoxLayout>();
|
||||
button_container.layout()->set_spacing(4);
|
||||
button_container.layout()->add_spacer();
|
||||
button_container.set_layout<HorizontalBoxLayout>(4);
|
||||
button_container.add_spacer().release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
auto& ok_button = button_container.add<DialogButton>();
|
||||
ok_button.set_text(String::from_utf8_short_string("OK"sv));
|
||||
|
@ -315,14 +309,11 @@ void ColorPicker::build_ui_custom(Widget& root_container)
|
|||
|
||||
// Right Side
|
||||
auto& vertical_container = horizontal_container.add<Widget>();
|
||||
vertical_container.set_layout<VerticalBoxLayout>();
|
||||
vertical_container.layout()->set_margins({ 0, 0, 0, 8 });
|
||||
vertical_container.set_layout<VerticalBoxLayout>(GUI::Margins { 0, 0, 0, 8 });
|
||||
vertical_container.set_min_width(120);
|
||||
|
||||
auto& preview_container = vertical_container.add<Frame>();
|
||||
preview_container.set_layout<VerticalBoxLayout>();
|
||||
preview_container.layout()->set_margins(2);
|
||||
preview_container.layout()->set_spacing(0);
|
||||
preview_container.set_layout<VerticalBoxLayout>(2, 0);
|
||||
preview_container.set_fixed_height(100);
|
||||
|
||||
// Current color
|
||||
|
|
|
@ -186,8 +186,7 @@ CommandPalette::CommandPalette(GUI::Window& parent_window, ScreenPosition screen
|
|||
main_widget->set_frame_shape(Gfx::FrameShape::Window);
|
||||
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);
|
||||
|
||||
m_text_box = main_widget->add<GUI::TextBox>();
|
||||
m_table_view = main_widget->add<GUI::TableView>();
|
||||
|
|
|
@ -219,9 +219,7 @@ void EmojiInputDialog::update_displayed_emoji()
|
|||
for (size_t row = 0; row < rows && index < m_emojis.size(); ++row) {
|
||||
auto& horizontal_container = m_emojis_widget->add<Widget>();
|
||||
horizontal_container.set_preferred_height(SpecialDimension::Fit);
|
||||
|
||||
auto& horizontal_layout = horizontal_container.set_layout<HorizontalBoxLayout>();
|
||||
horizontal_layout.set_spacing(0);
|
||||
horizontal_container.set_layout<HorizontalBoxLayout>(GUI::Margins {}, 0);
|
||||
|
||||
for (size_t column = 0; column < columns; ++column) {
|
||||
bool found_match = false;
|
||||
|
|
|
@ -67,13 +67,10 @@ void InputBox::build()
|
|||
int title_width = widget->font().width(title()) + 24 /* icon, plus a little padding -- not perfect */;
|
||||
int max_width = max(text_width, title_width);
|
||||
|
||||
widget->set_layout<VerticalBoxLayout>();
|
||||
widget->set_layout<VerticalBoxLayout>(6, 6);
|
||||
widget->set_fill_with_background_color(true);
|
||||
widget->set_preferred_height(SpecialDimension::Fit);
|
||||
|
||||
widget->layout()->set_margins(6);
|
||||
widget->layout()->set_spacing(6);
|
||||
|
||||
auto& label_editor_container = widget->add<Widget>();
|
||||
label_editor_container.set_layout<HorizontalBoxLayout>();
|
||||
label_editor_container.set_preferred_height(SpecialDimension::Fit);
|
||||
|
@ -101,9 +98,8 @@ void InputBox::build()
|
|||
button_container_outer.set_layout<VerticalBoxLayout>();
|
||||
|
||||
auto& button_container_inner = button_container_outer.add<Widget>();
|
||||
button_container_inner.set_layout<HorizontalBoxLayout>();
|
||||
button_container_inner.set_layout<HorizontalBoxLayout>(GUI::Margins {}, 6);
|
||||
button_container_inner.set_preferred_height(SpecialDimension::Fit);
|
||||
button_container_inner.layout()->set_spacing(6);
|
||||
button_container_inner.add_spacer().release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
m_ok_button = button_container_inner.add<DialogButton>();
|
||||
|
|
|
@ -121,15 +121,11 @@ void MessageBox::build()
|
|||
int total_text_height = number_of_lines * padded_text_height;
|
||||
int icon_width = 0;
|
||||
|
||||
widget->set_layout<VerticalBoxLayout>();
|
||||
widget->set_layout<VerticalBoxLayout>(8, 6);
|
||||
widget->set_fill_with_background_color(true);
|
||||
|
||||
widget->layout()->set_margins(8);
|
||||
widget->layout()->set_spacing(6);
|
||||
|
||||
auto& message_container = widget->add<Widget>();
|
||||
message_container.set_layout<HorizontalBoxLayout>();
|
||||
message_container.layout()->set_spacing(8);
|
||||
message_container.set_layout<HorizontalBoxLayout>(GUI::Margins {}, 8);
|
||||
|
||||
if (m_type != Type::None) {
|
||||
auto& icon_image = message_container.add<ImageWidget>();
|
||||
|
@ -147,9 +143,8 @@ void MessageBox::build()
|
|||
label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||
|
||||
auto& button_container = widget->add<Widget>();
|
||||
button_container.set_layout<HorizontalBoxLayout>();
|
||||
button_container.set_layout<HorizontalBoxLayout>(GUI::Margins {}, 8);
|
||||
button_container.set_fixed_height(24);
|
||||
button_container.layout()->set_spacing(8);
|
||||
|
||||
constexpr int button_width = 80;
|
||||
int button_count = 0;
|
||||
|
|
|
@ -48,8 +48,7 @@ ProcessChooser::ProcessChooser(StringView window_title, String button_label, Gfx
|
|||
|
||||
auto& button_container = widget->add<GUI::Widget>();
|
||||
button_container.set_fixed_height(30);
|
||||
button_container.set_layout<GUI::HorizontalBoxLayout>();
|
||||
button_container.layout()->set_margins({ 0, 4, 0 });
|
||||
button_container.set_layout<GUI::HorizontalBoxLayout>(GUI::Margins { 0, 4, 0 });
|
||||
button_container.add_spacer().release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
auto& select_button = button_container.add<GUI::Button>(m_button_label);
|
||||
|
|
|
@ -34,16 +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);
|
||||
(void)TRY(main_widget->try_set_layout<GUI::VerticalBoxLayout>());
|
||||
main_widget->layout()->set_margins(4);
|
||||
main_widget->layout()->set_spacing(6);
|
||||
(void)TRY(main_widget->try_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 });
|
||||
(void)TRY(button_container->try_set_layout<GUI::HorizontalBoxLayout>());
|
||||
button_container->layout()->set_spacing(6);
|
||||
(void)TRY(button_container->try_set_layout<GUI::HorizontalBoxLayout>(GUI::Margins {}, 6));
|
||||
|
||||
if (show_defaults_button == ShowDefaultsButton::Yes) {
|
||||
window->m_reset_button = TRY(button_container->try_add<GUI::DialogButton>(TRY(String::from_utf8("Defaults"sv))));
|
||||
|
|
|
@ -20,9 +20,7 @@ namespace GUI {
|
|||
Statusbar::Statusbar(int count)
|
||||
{
|
||||
set_fixed_height(18);
|
||||
set_layout<HorizontalBoxLayout>();
|
||||
layout()->set_margins(0);
|
||||
layout()->set_spacing(2);
|
||||
set_layout<HorizontalBoxLayout>(0, 2);
|
||||
|
||||
m_corner = add<ResizeCorner>();
|
||||
set_segment_count(count);
|
||||
|
|
|
@ -34,9 +34,7 @@ Toolbar::Toolbar(Orientation orientation, int button_size)
|
|||
else
|
||||
set_fixed_width(button_size);
|
||||
|
||||
set_layout<BoxLayout>(orientation);
|
||||
layout()->set_spacing(0);
|
||||
layout()->set_margins({ 2, 2, 2, 2 });
|
||||
set_layout<BoxLayout>(orientation, GUI::Margins { 2, 2, 2, 2 }, 0);
|
||||
}
|
||||
|
||||
class ToolbarButton final : public Button {
|
||||
|
|
|
@ -23,8 +23,7 @@ ToolbarContainer::ToolbarContainer(Gfx::Orientation orientation)
|
|||
set_frame_shape(Gfx::FrameShape::Box);
|
||||
set_frame_shadow(Gfx::FrameShadow::Sunken);
|
||||
|
||||
auto& layout = set_layout<VerticalBoxLayout>();
|
||||
layout.set_spacing(2);
|
||||
set_layout<VerticalBoxLayout>(GUI::Margins {}, 2);
|
||||
set_shrink_to_fit(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,8 +24,7 @@ CoverWizardPage::CoverWizardPage()
|
|||
m_banner_image_widget->load_from_file("/res/graphics/wizard-banner-simple.png"sv);
|
||||
|
||||
m_content_widget = add<Widget>();
|
||||
m_content_widget->set_layout<VerticalBoxLayout>();
|
||||
m_content_widget->layout()->set_margins(20);
|
||||
m_content_widget->set_layout<VerticalBoxLayout>(20);
|
||||
|
||||
m_header_label = m_content_widget->add<Label>();
|
||||
m_header_label->set_font(Gfx::FontDatabase::the().get("Pebbleton", 14, 700, Gfx::FontWidth::Normal, 0));
|
||||
|
|
|
@ -29,8 +29,7 @@ WizardDialog::WizardDialog(Window* parent_window)
|
|||
|
||||
auto main_widget = set_main_widget<Widget>().release_value_but_fixme_should_propagate_errors();
|
||||
main_widget->set_fill_with_background_color(true);
|
||||
main_widget->set_layout<VerticalBoxLayout>();
|
||||
main_widget->layout()->set_spacing(0);
|
||||
main_widget->set_layout<VerticalBoxLayout>(GUI::Margins {}, 0);
|
||||
|
||||
m_page_container_widget = main_widget->add<Widget>();
|
||||
m_page_container_widget->set_fixed_size(500, 315);
|
||||
|
@ -40,10 +39,8 @@ WizardDialog::WizardDialog(Window* parent_window)
|
|||
separator.set_fixed_height(2);
|
||||
|
||||
auto& nav_container_widget = main_widget->add<Widget>();
|
||||
nav_container_widget.set_layout<HorizontalBoxLayout>();
|
||||
nav_container_widget.set_layout<HorizontalBoxLayout>(GUI::Margins { 0, 10 }, 0);
|
||||
nav_container_widget.set_fixed_height(42);
|
||||
nav_container_widget.layout()->set_margins({ 0, 10 });
|
||||
nav_container_widget.layout()->set_spacing(0);
|
||||
nav_container_widget.add_spacer().release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
m_back_button = nav_container_widget.add<DialogButton>(String::from_utf8_short_string("< Back"sv));
|
||||
|
|
|
@ -17,16 +17,14 @@ namespace GUI {
|
|||
WizardPage::WizardPage(DeprecatedString const& title_text, DeprecatedString const& subtitle_text)
|
||||
: AbstractWizardPage()
|
||||
{
|
||||
set_layout<VerticalBoxLayout>();
|
||||
layout()->set_spacing(0);
|
||||
set_layout<VerticalBoxLayout>(GUI::Margins {}, 0);
|
||||
|
||||
auto& header_widget = add<Widget>();
|
||||
header_widget.set_fill_with_background_color(true);
|
||||
header_widget.set_background_role(Gfx::ColorRole::Base);
|
||||
header_widget.set_fixed_height(58);
|
||||
|
||||
header_widget.set_layout<VerticalBoxLayout>();
|
||||
header_widget.layout()->set_margins({ 15, 30, 0 });
|
||||
header_widget.set_layout<VerticalBoxLayout>(GUI::Margins { 15, 30, 0 });
|
||||
m_title_label = header_widget.add<Label>(title_text);
|
||||
m_title_label->set_font(Gfx::FontDatabase::default_font().bold_variant());
|
||||
m_title_label->set_fixed_height(m_title_label->font().glyph_height() + 2);
|
||||
|
@ -40,8 +38,7 @@ WizardPage::WizardPage(DeprecatedString const& title_text, DeprecatedString cons
|
|||
separator.set_fixed_height(2);
|
||||
|
||||
m_body_widget = add<Widget>();
|
||||
m_body_widget->set_layout<VerticalBoxLayout>();
|
||||
m_body_widget->layout()->set_margins(20);
|
||||
m_body_widget->set_layout<VerticalBoxLayout>(20);
|
||||
}
|
||||
|
||||
void WizardPage::set_page_title(DeprecatedString const& text)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue