summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrHun <28605587+frhun@users.noreply.github.com>2022-06-12 20:19:05 +0200
committerSam Atkins <atkinssj@gmail.com>2022-06-28 17:52:42 +0100
commite29314f837ef15467c3b15e54a041ee4968923f1 (patch)
treeba35d76e31e9feba46dfabd600252ca8b0ef588a
parente08508dcc1b2db02eb60bf896412e99675c0b944 (diff)
downloadserenity-e29314f837ef15467c3b15e54a041ee4968923f1.zip
LibGUI: Refactor BoxLayout for minor readability improvements
-rw-r--r--Userland/Libraries/LibGUI/BoxLayout.cpp11
1 files changed, 2 insertions, 9 deletions
diff --git a/Userland/Libraries/LibGUI/BoxLayout.cpp b/Userland/Libraries/LibGUI/BoxLayout.cpp
index 6a6ea8dccf..98e7358091 100644
--- a/Userland/Libraries/LibGUI/BoxLayout.cpp
+++ b/Userland/Libraries/LibGUI/BoxLayout.cpp
@@ -191,11 +191,7 @@ void BoxLayout::run(Widget& widget)
int current_x = margins().left() + content_rect.x();
int current_y = margins().top() + content_rect.y();
- auto widget_rect_with_margins_subtracted = content_rect;
- widget_rect_with_margins_subtracted.take_from_left(margins().left());
- widget_rect_with_margins_subtracted.take_from_top(margins().top());
- widget_rect_with_margins_subtracted.take_from_right(margins().right());
- widget_rect_with_margins_subtracted.take_from_bottom(margins().bottom());
+ auto widget_rect_with_margins_subtracted = margins().applied_to(content_rect);
for (auto& item : items) {
Gfx::IntRect rect { current_x, current_y, 0, 0 };
@@ -204,10 +200,6 @@ void BoxLayout::run(Widget& widget)
if (item.widget) {
int secondary = widget.content_size().secondary_size_for_orientation(orientation());
- if (orientation() == Gfx::Orientation::Horizontal)
- secondary -= margins().top() + margins().bottom();
- else
- secondary -= margins().left() + margins().right();
int min_secondary = item.widget->min_size().secondary_size_for_orientation(orientation());
int max_secondary = item.widget->max_size().secondary_size_for_orientation(orientation());
@@ -215,6 +207,7 @@ void BoxLayout::run(Widget& widget)
secondary = max(secondary, min_secondary);
if (max_secondary >= 0)
secondary = min(secondary, max_secondary);
+ secondary -= margins().secondary_total_for_orientation(orientation());
rect.set_secondary_size_for_orientation(orientation(), secondary);