From 295aedbdb577dcb33274daae4519719d0348e5ac Mon Sep 17 00:00:00 2001
From: HJfod <60038575+HJfod@users.noreply.github.com>
Date: Thu, 23 Feb 2023 21:18:43 +0200
Subject: [PATCH] add cross axis line alignment to layouts

---
 loader/include/Geode/cocos/base_nodes/Layout.hpp | 15 +++++++++++----
 loader/src/cocos2d-ext/Layout.cpp                | 11 ++++++++++-
 2 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/loader/include/Geode/cocos/base_nodes/Layout.hpp b/loader/include/Geode/cocos/base_nodes/Layout.hpp
index b9f74edf..afc1d19b 100644
--- a/loader/include/Geode/cocos/base_nodes/Layout.hpp
+++ b/loader/include/Geode/cocos/base_nodes/Layout.hpp
@@ -204,6 +204,7 @@ protected:
     Axis m_axis;
     AxisAlignment m_axisAlignment = AxisAlignment::Center;
     AxisAlignment m_crossAlignment = AxisAlignment::Center;
+    AxisAlignment m_crossLineAlignment = AxisAlignment::Center;
     float m_gap = 5.f;
     bool m_autoScale = true;
     bool m_axisReverse = false;
@@ -256,6 +257,7 @@ public:
     Axis getAxis() const;
     AxisAlignment getAxisAlignment() const;
     AxisAlignment getCrossAxisAlignment() const;
+    AxisAlignment getCrossAxisLineAlignment() const;
     float getGap() const;
     bool getAxisReverse() const;
     bool getCrossAxisReverse() const;
@@ -265,15 +267,20 @@ public:
 
     AxisLayout* setAxis(Axis axis);
     /**
-     * Sets where to align the target node's children on the main axis (X for 
-     * Row, Y for Column)
+     * Sets where to align the target node's children on the main axis (X-axis 
+     * for Row, Y-axis for Column)
      */
     AxisLayout* setAxisAlignment(AxisAlignment align);
     /**
-     * Sets where to align the target node's children on the cross-axis (Y for 
-     * Row, X for Column)
+     * Sets where to align the target node's children on the cross-axis (Y-axis 
+     * for Row, X-axis for Column)
      */
     AxisLayout* setCrossAxisAlignment(AxisAlignment align);
+    /**
+     * Sets where to align the target node's children on the cross-axis for 
+     * each row (Y-axis for Row, X-axis for Column)
+     */
+    AxisLayout* setCrossAxisLineAlignment(AxisAlignment align);
     /**
      * The spacing between the children of the node this layout applies to. 
      * Measured as the space between their edges, not centres. Does not apply 
diff --git a/loader/src/cocos2d-ext/Layout.cpp b/loader/src/cocos2d-ext/Layout.cpp
index 5e3e3883..5d8150bb 100644
--- a/loader/src/cocos2d-ext/Layout.cpp
+++ b/loader/src/cocos2d-ext/Layout.cpp
@@ -636,7 +636,7 @@ void AxisLayout::tryFitLayout(
                     row->axisEndsLength * row->scale * (1.f - row->squish) * 1.f / nodes->count();
             }
             float crossOffset;
-            switch (m_crossAlignment) {
+            switch (m_crossLineAlignment) {
                 case AxisAlignment::Start: {
                     crossOffset = pos.crossLength * pos.crossAnchor;
                 } break;
@@ -725,6 +725,10 @@ AxisAlignment AxisLayout::getCrossAxisAlignment() const {
     return m_crossAlignment;
 }
 
+AxisAlignment AxisLayout::getCrossAxisLineAlignment() const {
+    return m_crossLineAlignment;
+}
+
 AxisAlignment AxisLayout::getAxisAlignment() const {
     return m_axisAlignment;
 }
@@ -763,6 +767,11 @@ AxisLayout* AxisLayout::setCrossAxisAlignment(AxisAlignment align) {
     return this;
 }
 
+AxisLayout* AxisLayout::setCrossAxisLineAlignment(AxisAlignment align) {
+    m_crossLineAlignment = align;
+    return this;
+}
+
 AxisLayout* AxisLayout::setAxisAlignment(AxisAlignment align) {
     m_axisAlignment = align;
     return this;