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

Userland+LibGUI: Make Margins arguments match CSS ordering

Previously the argument order for Margins was (left, top, right,
bottom). To make it more familiar and closer to how CSS does it, the
argument order is now (top, right, bottom, left).
This commit is contained in:
sin-ack 2021-08-17 00:10:51 +00:00 committed by Andreas Kling
parent c17f9adb12
commit 9c9a5c55cb
43 changed files with 78 additions and 78 deletions

View file

@ -43,7 +43,7 @@ AboutDialog::AboutDialog(const StringView& name, const Gfx::Bitmap* icon, Window
auto& left_container = content_container.add<Widget>();
left_container.set_fixed_width(60);
left_container.set_layout<VerticalBoxLayout>();
left_container.layout()->set_margins({ 0, 12, 0, 0 });
left_container.layout()->set_margins({ 12, 0, 0, 0 });
if (icon) {
auto& icon_wrapper = left_container.add<Widget>();
@ -56,13 +56,13 @@ AboutDialog::AboutDialog(const StringView& name, const Gfx::Bitmap* icon, Window
auto& right_container = content_container.add<Widget>();
right_container.set_layout<VerticalBoxLayout>();
right_container.layout()->set_margins({ 0, 12, 4, 4 });
right_container.layout()->set_margins({ 12, 4, 4, 0 });
auto make_label = [&](const StringView& text, bool bold = false) {
auto& label = right_container.add<Label>(text);
label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
label.set_fixed_height(14);
label.set_content_margins({ 0, 0, 8, 0 });
label.set_content_margins({ 0, 8, 0, 0 });
if (bold)
label.set_font(Gfx::FontDatabase::default_font().bold_variant());
};

View file

@ -240,7 +240,7 @@ 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({ 8, 0, 0, 0 });
vertical_container.layout()->set_margins({ 0, 0, 0, 8 });
vertical_container.set_fixed_width(128);
auto& preview_container = vertical_container.add<Frame>();

View file

@ -9,7 +9,7 @@
@GUI::Widget {
shrink_to_fit: true
layout: @GUI::VerticalBoxLayout {
margins: [4, 0, 4, 0]
margins: [0, 4, 0, 4]
}
@GUI::Label {

View file

@ -83,7 +83,7 @@ void InputBox::build(InputType input_type)
auto& button_container_inner = button_container_outer.add<Widget>();
button_container_inner.set_layout<HorizontalBoxLayout>();
button_container_inner.layout()->set_spacing(6);
button_container_inner.layout()->set_margins({ 4, 4, 0, 4 });
button_container_inner.layout()->set_margins({ 4, 0, 4, 4 });
button_container_inner.layout()->add_spacer();
m_ok_button = button_container_inner.add<Button>();

View file

@ -11,26 +11,26 @@ namespace GUI {
class Margins {
public:
Margins() { }
Margins(int left, int top, int right, int bottom)
: m_left(left)
, m_top(top)
Margins(int top, int right, int bottom, int left)
: m_top(top)
, m_right(right)
, m_bottom(bottom)
, m_left(left)
{
}
~Margins() { }
bool is_null() const { return !m_left && !m_top && !m_right && !m_bottom; }
int left() const { return m_left; }
int top() const { return m_top; }
int right() const { return m_right; }
int bottom() const { return m_bottom; }
int left() const { return m_left; }
void set_left(int value) { m_left = value; }
void set_top(int value) { m_top = value; }
void set_right(int value) { m_right = value; }
void set_bottom(int value) { m_bottom = value; }
void set_left(int value) { m_left = value; }
bool operator==(const Margins& other) const
{
@ -41,10 +41,10 @@ public:
}
private:
int m_left { 0 };
int m_top { 0 };
int m_right { 0 };
int m_bottom { 0 };
int m_left { 0 };
};
}

View file

@ -102,7 +102,7 @@ void MessageBox::build()
if (icon()) {
icon_width = icon()->width();
if (icon_width > 0)
message_container.layout()->set_margins({ 8, 0, 0, 0 });
message_container.layout()->set_margins({ 0, 0, 0, 8 });
}
}

View file

@ -48,8 +48,8 @@ ProcessChooser::ProcessChooser(const StringView& window_title, const StringView&
auto& button_container = widget.add<GUI::Widget>();
button_container.set_fixed_height(30);
button_container.set_layout<GUI::HorizontalBoxLayout>();
button_container.set_content_margins({ 0, 4, 0, 4 });
button_container.layout()->set_margins({ 0, 0, 4, 0 });
button_container.set_content_margins({ 4, 0, 4, 0 });
button_container.layout()->set_margins({ 0, 4, 0, 0 });
button_container.layout()->add_spacer();
auto& select_button = button_container.add<GUI::Button>(m_button_label);

View file

@ -41,7 +41,7 @@ WizardDialog::WizardDialog(Window* parent_window)
auto& nav_container_widget = main_widget.add<Widget>();
nav_container_widget.set_layout<HorizontalBoxLayout>();
nav_container_widget.set_fixed_height(42);
nav_container_widget.layout()->set_margins({ 10, 0, 10, 0 });
nav_container_widget.layout()->set_margins({ 0, 10, 0, 10 });
nav_container_widget.layout()->set_spacing(0);
nav_container_widget.layout()->add_spacer();

View file

@ -26,7 +26,7 @@ WizardPage::WizardPage(const String& title_text, const String& subtitle_text)
header_widget.set_fixed_height(58);
header_widget.set_layout<VerticalBoxLayout>();
header_widget.layout()->set_margins({ 30, 15, 30, 0 });
header_widget.layout()->set_margins({ 15, 30, 0, 30 });
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);