ソースを参照

LibGUI: Add direction totals to Margins

FrHun 3 年 前
コミット
e08508dcc1
1 ファイル変更17 行追加0 行削除
  1. 17 0
      Userland/Libraries/LibGUI/Margins.h

+ 17 - 0
Userland/Libraries/LibGUI/Margins.h

@@ -6,6 +6,7 @@
 
 #pragma once
 
+#include <LibGfx/Orientation.h>
 #include <LibGfx/Rect.h>
 
 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 };