From e08508dcc1b2db02eb60bf896412e99675c0b944 Mon Sep 17 00:00:00 2001 From: FrHun <28605587+frhun@users.noreply.github.com> Date: Sun, 12 Jun 2022 20:12:58 +0200 Subject: [PATCH] LibGUI: Add direction totals to Margins --- Userland/Libraries/LibGUI/Margins.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Userland/Libraries/LibGUI/Margins.h b/Userland/Libraries/LibGUI/Margins.h index f1a3405cad..0f4de1410c 100644 --- a/Userland/Libraries/LibGUI/Margins.h +++ b/Userland/Libraries/LibGUI/Margins.h @@ -6,6 +6,7 @@ #pragma once +#include #include namespace GUI { @@ -78,6 +79,22 @@ public: return Margins { top() + other.top(), right() + other.right(), bottom() + other.bottom(), left() + other.left() }; } + [[nodiscard]] int primary_total_for_orientation(Gfx::Orientation const orientation) const + { + if (orientation == Gfx::Orientation::Horizontal) + return m_left + m_right; + else + return m_top + m_bottom; + } + + [[nodiscard]] int secondary_total_for_orientation(Gfx::Orientation const orientation) const + { + if (orientation == Gfx::Orientation::Vertical) + return m_left + m_right; + else + return m_top + m_bottom; + } + private: int m_top { 0 }; int m_right { 0 };