From 7e3be218116aed0f130fb8f659097cc67b735843 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20W=C3=B6hrl?= Date: Mon, 27 Nov 2017 03:40:01 -0800 Subject: [PATCH] Add justify-content: space-evenly Summary: Adds new ```space-evenly``` for ```justify-content```. Also adds a typofix in one of the other justify-content tests. Fixes #657 Closes https://github.com/facebook/yoga/pull/658 Differential Revision: D6407996 Pulled By: emilsjolander fbshipit-source-id: cc837409e1345624b4bd72c31e25fe68dcb0f6a3 --- csharp/Facebook.Yoga/YogaJustify.cs | 1 + .../Facebook.Yoga/YGJustifyContentTest.cs | 146 ++++++++++++++++- enums.py | 1 + gentest/fixtures/YGJustifyContentTest.html | 15 +- gentest/gentest-cpp.js | 1 + gentest/gentest-cs.js | 1 + gentest/gentest-java.js | 1 + gentest/gentest-javascript.js | 1 + gentest/gentest.js | 1 + java/com/facebook/yoga/YogaJustify.java | 5 +- .../facebook/yoga/YGJustifyContentTest.java | 144 ++++++++++++++++- javascript/sources/YGEnums.js | 3 +- .../Facebook.Yoga/YGJustifyContentTest.js | 152 +++++++++++++++++- tests/YGJustifyContentTest.cpp | 146 ++++++++++++++++- yoga/YGEnums.cpp | 2 + yoga/YGEnums.h | 15 +- yoga/Yoga.cpp | 5 + 17 files changed, 614 insertions(+), 26 deletions(-) diff --git a/csharp/Facebook.Yoga/YogaJustify.cs b/csharp/Facebook.Yoga/YogaJustify.cs index 9f1e9163..403763ca 100644 --- a/csharp/Facebook.Yoga/YogaJustify.cs +++ b/csharp/Facebook.Yoga/YogaJustify.cs @@ -16,5 +16,6 @@ namespace Facebook.Yoga FlexEnd, SpaceBetween, SpaceAround, + SpaceEvenly, } } diff --git a/csharp/tests/Facebook.Yoga/YGJustifyContentTest.cs b/csharp/tests/Facebook.Yoga/YGJustifyContentTest.cs index 2fd58f5a..fd02218b 100644 --- a/csharp/tests/Facebook.Yoga/YGJustifyContentTest.cs +++ b/csharp/tests/Facebook.Yoga/YGJustifyContentTest.cs @@ -375,6 +375,7 @@ namespace Facebook.Yoga root.Insert(0, root_child0); YogaNode root_child1 = new YogaNode(config); + root_child1.Height = 10; root.Insert(1, root_child1); YogaNode root_child2 = new YogaNode(config); @@ -396,10 +397,10 @@ namespace Facebook.Yoga Assert.AreEqual(0f, root_child1.LayoutX); Assert.AreEqual(10f, root_child1.LayoutY); Assert.AreEqual(102f, root_child1.LayoutWidth); - Assert.AreEqual(0f, root_child1.LayoutHeight); + Assert.AreEqual(10f, root_child1.LayoutHeight); Assert.AreEqual(0f, root_child2.LayoutX); - Assert.AreEqual(10f, root_child2.LayoutY); + Assert.AreEqual(20f, root_child2.LayoutY); Assert.AreEqual(102f, root_child2.LayoutWidth); Assert.AreEqual(10f, root_child2.LayoutHeight); @@ -419,10 +420,10 @@ namespace Facebook.Yoga Assert.AreEqual(0f, root_child1.LayoutX); Assert.AreEqual(10f, root_child1.LayoutY); Assert.AreEqual(102f, root_child1.LayoutWidth); - Assert.AreEqual(0f, root_child1.LayoutHeight); + Assert.AreEqual(10f, root_child1.LayoutHeight); Assert.AreEqual(0f, root_child2.LayoutX); - Assert.AreEqual(10f, root_child2.LayoutY); + Assert.AreEqual(20f, root_child2.LayoutY); Assert.AreEqual(102f, root_child2.LayoutWidth); Assert.AreEqual(10f, root_child2.LayoutHeight); } @@ -867,5 +868,142 @@ namespace Facebook.Yoga Assert.AreEqual(20f, root_child0.LayoutHeight); } + [Test] + public void Test_justify_content_column_space_evenly() + { + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); + root.JustifyContent = YogaJustify.SpaceEvenly; + root.Width = 102; + root.Height = 102; + + YogaNode root_child0 = new YogaNode(config); + root_child0.Height = 10; + root.Insert(0, root_child0); + + YogaNode root_child1 = new YogaNode(config); + root_child1.Height = 10; + root.Insert(1, root_child1); + + YogaNode root_child2 = new YogaNode(config); + root_child2.Height = 10; + root.Insert(2, root_child2); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(102f, root.LayoutWidth); + Assert.AreEqual(102f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(18f, root_child0.LayoutY); + Assert.AreEqual(102f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(46f, root_child1.LayoutY); + Assert.AreEqual(102f, root_child1.LayoutWidth); + Assert.AreEqual(10f, root_child1.LayoutHeight); + + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(74f, root_child2.LayoutY); + Assert.AreEqual(102f, root_child2.LayoutWidth); + Assert.AreEqual(10f, root_child2.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(102f, root.LayoutWidth); + Assert.AreEqual(102f, root.LayoutHeight); + + Assert.AreEqual(0f, root_child0.LayoutX); + Assert.AreEqual(18f, root_child0.LayoutY); + Assert.AreEqual(102f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); + + Assert.AreEqual(0f, root_child1.LayoutX); + Assert.AreEqual(46f, root_child1.LayoutY); + Assert.AreEqual(102f, root_child1.LayoutWidth); + Assert.AreEqual(10f, root_child1.LayoutHeight); + + Assert.AreEqual(0f, root_child2.LayoutX); + Assert.AreEqual(74f, root_child2.LayoutY); + Assert.AreEqual(102f, root_child2.LayoutWidth); + Assert.AreEqual(10f, root_child2.LayoutHeight); + } + + [Test] + public void Test_justify_content_row_space_evenly() + { + YogaConfig config = new YogaConfig(); + + YogaNode root = new YogaNode(config); + root.FlexDirection = YogaFlexDirection.Row; + root.JustifyContent = YogaJustify.SpaceEvenly; + root.Width = 102; + root.Height = 102; + + YogaNode root_child0 = new YogaNode(config); + root_child0.Height = 10; + root.Insert(0, root_child0); + + YogaNode root_child1 = new YogaNode(config); + root_child1.Height = 10; + root.Insert(1, root_child1); + + YogaNode root_child2 = new YogaNode(config); + root_child2.Height = 10; + root.Insert(2, root_child2); + root.StyleDirection = YogaDirection.LTR; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(102f, root.LayoutWidth); + Assert.AreEqual(102f, root.LayoutHeight); + + Assert.AreEqual(26f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(0f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); + + Assert.AreEqual(51f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(0f, root_child1.LayoutWidth); + Assert.AreEqual(10f, root_child1.LayoutHeight); + + Assert.AreEqual(77f, root_child2.LayoutX); + Assert.AreEqual(0f, root_child2.LayoutY); + Assert.AreEqual(0f, root_child2.LayoutWidth); + Assert.AreEqual(10f, root_child2.LayoutHeight); + + root.StyleDirection = YogaDirection.RTL; + root.CalculateLayout(); + + Assert.AreEqual(0f, root.LayoutX); + Assert.AreEqual(0f, root.LayoutY); + Assert.AreEqual(102f, root.LayoutWidth); + Assert.AreEqual(102f, root.LayoutHeight); + + Assert.AreEqual(77f, root_child0.LayoutX); + Assert.AreEqual(0f, root_child0.LayoutY); + Assert.AreEqual(0f, root_child0.LayoutWidth); + Assert.AreEqual(10f, root_child0.LayoutHeight); + + Assert.AreEqual(51f, root_child1.LayoutX); + Assert.AreEqual(0f, root_child1.LayoutY); + Assert.AreEqual(0f, root_child1.LayoutWidth); + Assert.AreEqual(10f, root_child1.LayoutHeight); + + Assert.AreEqual(26f, root_child2.LayoutX); + Assert.AreEqual(0f, root_child2.LayoutY); + Assert.AreEqual(0f, root_child2.LayoutWidth); + Assert.AreEqual(10f, root_child2.LayoutHeight); + } + } } diff --git a/enums.py b/enums.py index 11852cf2..716312bc 100644 --- a/enums.py +++ b/enums.py @@ -35,6 +35,7 @@ ENUMS = { 'FlexEnd', 'SpaceBetween', 'SpaceAround', + 'SpaceEvenly', ], 'Overflow': [ 'Visible', diff --git a/gentest/fixtures/YGJustifyContentTest.html b/gentest/fixtures/YGJustifyContentTest.html index a0808366..0dee8c3a 100644 --- a/gentest/fixtures/YGJustifyContentTest.html +++ b/gentest/fixtures/YGJustifyContentTest.html @@ -30,7 +30,7 @@
-
+
@@ -73,3 +73,16 @@
+ +
+
+
+
+
+ +
+
+
+
+
+ diff --git a/gentest/gentest-cpp.js b/gentest/gentest-cpp.js index 459681b8..95691555 100644 --- a/gentest/gentest-cpp.js +++ b/gentest/gentest-cpp.js @@ -104,6 +104,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { YGJustifyFlexStart:{value:'YGJustifyFlexStart'}, YGJustifySpaceAround:{value:'YGJustifySpaceAround'}, YGJustifySpaceBetween:{value:'YGJustifySpaceBetween'}, + YGJustifySpaceEvenly:{value:'YGJustifySpaceEvenly'}, YGOverflowHidden:{value:'YGOverflowHidden'}, YGOverflowVisible:{value:'YGOverflowVisible'}, diff --git a/gentest/gentest-cs.js b/gentest/gentest-cs.js index 0bfe5cdc..54199776 100644 --- a/gentest/gentest-cs.js +++ b/gentest/gentest-cs.js @@ -117,6 +117,7 @@ CSEmitter.prototype = Object.create(Emitter.prototype, { YGJustifyFlexStart:{value:'YogaJustify.FlexStart'}, YGJustifySpaceAround:{value:'YogaJustify.SpaceAround'}, YGJustifySpaceBetween:{value:'YogaJustify.SpaceBetween'}, + YGJustifySpaceEvenly:{value:'YogaJustify.SpaceEvenly'}, YGOverflowHidden:{value:'YogaOverflow.Hidden'}, YGOverflowVisible:{value:'YogaOverflow.Visible'}, diff --git a/gentest/gentest-java.js b/gentest/gentest-java.js index 5f293d3e..c24a6ed8 100644 --- a/gentest/gentest-java.js +++ b/gentest/gentest-java.js @@ -119,6 +119,7 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, { YGJustifyFlexStart:{value:'YogaJustify.FLEX_START'}, YGJustifySpaceAround:{value:'YogaJustify.SPACE_AROUND'}, YGJustifySpaceBetween:{value:'YogaJustify.SPACE_BETWEEN'}, + YGJustifySpaceEvenly:{value:'YogaJustify.SPACE_EVENLY'}, YGOverflowHidden:{value:'YogaOverflow.HIDDEN'}, YGOverflowVisible:{value:'YogaOverflow.VISIBLE'}, diff --git a/gentest/gentest-javascript.js b/gentest/gentest-javascript.js index 0c3c7418..94f201fc 100644 --- a/gentest/gentest-javascript.js +++ b/gentest/gentest-javascript.js @@ -119,6 +119,7 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, { YGJustifyFlexStart:{value:'Yoga.JUSTIFY_FLEX_START'}, YGJustifySpaceAround:{value:'Yoga.JUSTIFY_SPACE_AROUND'}, YGJustifySpaceBetween:{value:'Yoga.JUSTIFY_SPACE_BETWEEN'}, + YGJustifySpaceEvenly:{value:'Yoga.JUSTIFY_SPACE_EVENLY'}, YGOverflowHidden:{value:'Yoga.OVERFLOW_HIDDEN'}, YGOverflowVisible:{value:'Yoga.OVERFLOW_VISIBLE'}, diff --git a/gentest/gentest.js b/gentest/gentest.js index c69a09c6..e621eb83 100755 --- a/gentest/gentest.js +++ b/gentest/gentest.js @@ -355,6 +355,7 @@ function justifyValue(e, value) { case 'center': return e.YGJustifyCenter; case 'space-around': return e.YGJustifySpaceAround; case 'space-between': return e.YGJustifySpaceBetween; + case 'space-evenly': return e.YGJustifySpaceEvenly; case 'flex-start': return e.YGJustifyFlexStart; case 'flex-end': return e.YGJustifyFlexEnd; } diff --git a/java/com/facebook/yoga/YogaJustify.java b/java/com/facebook/yoga/YogaJustify.java index 87a15e8a..34a8922e 100644 --- a/java/com/facebook/yoga/YogaJustify.java +++ b/java/com/facebook/yoga/YogaJustify.java @@ -17,7 +17,8 @@ public enum YogaJustify { CENTER(1), FLEX_END(2), SPACE_BETWEEN(3), - SPACE_AROUND(4); + SPACE_AROUND(4), + SPACE_EVENLY(5); private int mIntValue; @@ -36,6 +37,8 @@ public enum YogaJustify { case 2: return FLEX_END; case 3: return SPACE_BETWEEN; case 4: return SPACE_AROUND; + case 5: + return SPACE_EVENLY; default: throw new IllegalArgumentException("Unknown enum value: " + value); } } diff --git a/java/tests/com/facebook/yoga/YGJustifyContentTest.java b/java/tests/com/facebook/yoga/YGJustifyContentTest.java index d6566785..114134ac 100644 --- a/java/tests/com/facebook/yoga/YGJustifyContentTest.java +++ b/java/tests/com/facebook/yoga/YGJustifyContentTest.java @@ -368,6 +368,7 @@ public class YGJustifyContentTest { root.addChildAt(root_child0, 0); final YogaNode root_child1 = new YogaNode(config); + root_child1.setHeight(10f); root.addChildAt(root_child1, 1); final YogaNode root_child2 = new YogaNode(config); @@ -389,10 +390,10 @@ public class YGJustifyContentTest { assertEquals(0f, root_child1.getLayoutX(), 0.0f); assertEquals(10f, root_child1.getLayoutY(), 0.0f); assertEquals(102f, root_child1.getLayoutWidth(), 0.0f); - assertEquals(0f, root_child1.getLayoutHeight(), 0.0f); + assertEquals(10f, root_child1.getLayoutHeight(), 0.0f); assertEquals(0f, root_child2.getLayoutX(), 0.0f); - assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child2.getLayoutY(), 0.0f); assertEquals(102f, root_child2.getLayoutWidth(), 0.0f); assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); @@ -412,10 +413,10 @@ public class YGJustifyContentTest { assertEquals(0f, root_child1.getLayoutX(), 0.0f); assertEquals(10f, root_child1.getLayoutY(), 0.0f); assertEquals(102f, root_child1.getLayoutWidth(), 0.0f); - assertEquals(0f, root_child1.getLayoutHeight(), 0.0f); + assertEquals(10f, root_child1.getLayoutHeight(), 0.0f); assertEquals(0f, root_child2.getLayoutX(), 0.0f); - assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child2.getLayoutY(), 0.0f); assertEquals(102f, root_child2.getLayoutWidth(), 0.0f); assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); } @@ -852,4 +853,139 @@ public class YGJustifyContentTest { assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); } + @Test + public void test_justify_content_column_space_evenly() { + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); + root.setJustifyContent(YogaJustify.SPACE_EVENLY); + root.setWidth(102f); + root.setHeight(102f); + + final YogaNode root_child0 = new YogaNode(config); + root_child0.setHeight(10f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = new YogaNode(config); + root_child1.setHeight(10f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = new YogaNode(config); + root_child2.setHeight(10f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(102f, root.getLayoutWidth(), 0.0f); + assertEquals(102f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(18f, root_child0.getLayoutY(), 0.0f); + assertEquals(102f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(46f, root_child1.getLayoutY(), 0.0f); + assertEquals(102f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(74f, root_child2.getLayoutY(), 0.0f); + assertEquals(102f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(102f, root.getLayoutWidth(), 0.0f); + assertEquals(102f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(18f, root_child0.getLayoutY(), 0.0f); + assertEquals(102f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(46f, root_child1.getLayoutY(), 0.0f); + assertEquals(102f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(74f, root_child2.getLayoutY(), 0.0f); + assertEquals(102f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_justify_content_row_space_evenly() { + YogaConfig config = new YogaConfig(); + + final YogaNode root = new YogaNode(config); + root.setFlexDirection(YogaFlexDirection.ROW); + root.setJustifyContent(YogaJustify.SPACE_EVENLY); + root.setWidth(102f); + root.setHeight(102f); + + final YogaNode root_child0 = new YogaNode(config); + root_child0.setHeight(10f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = new YogaNode(config); + root_child1.setHeight(10f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = new YogaNode(config); + root_child2.setHeight(10f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(102f, root.getLayoutWidth(), 0.0f); + assertEquals(102f, root.getLayoutHeight(), 0.0f); + + assertEquals(26f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(51f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(77f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(0f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(102f, root.getLayoutWidth(), 0.0f); + assertEquals(102f, root.getLayoutHeight(), 0.0f); + + assertEquals(77f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(51f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(26f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(0f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child2.getLayoutHeight(), 0.0f); + } + } diff --git a/javascript/sources/YGEnums.js b/javascript/sources/YGEnums.js index 373909da..6064b680 100644 --- a/javascript/sources/YGEnums.js +++ b/javascript/sources/YGEnums.js @@ -52,12 +52,13 @@ module.exports = { FLEX_DIRECTION_ROW: 2, FLEX_DIRECTION_ROW_REVERSE: 3, - JUSTIFY_COUNT: 5, + JUSTIFY_COUNT: 6, JUSTIFY_FLEX_START: 0, JUSTIFY_CENTER: 1, JUSTIFY_FLEX_END: 2, JUSTIFY_SPACE_BETWEEN: 3, JUSTIFY_SPACE_AROUND: 4, + JUSTIFY_SPACE_EVENLY: 5, LOG_LEVEL_COUNT: 6, LOG_LEVEL_ERROR: 0, diff --git a/javascript/tests/Facebook.Yoga/YGJustifyContentTest.js b/javascript/tests/Facebook.Yoga/YGJustifyContentTest.js index a1421e3f..5fb51296 100644 --- a/javascript/tests/Facebook.Yoga/YGJustifyContentTest.js +++ b/javascript/tests/Facebook.Yoga/YGJustifyContentTest.js @@ -383,6 +383,7 @@ it("justify_content_column_flex_start", function () { root.insertChild(root_child0, 0); var root_child1 = Yoga.Node.create(config); + root_child1.setHeight(10); root.insertChild(root_child1, 1); var root_child2 = Yoga.Node.create(config); @@ -403,10 +404,10 @@ it("justify_content_column_flex_start", function () { console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")"); console.assert(10 === root_child1.getComputedTop(), "10 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")"); console.assert(102 === root_child1.getComputedWidth(), "102 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")"); - console.assert(0 === root_child1.getComputedHeight(), "0 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")"); + console.assert(10 === root_child1.getComputedHeight(), "10 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")"); console.assert(0 === root_child2.getComputedLeft(), "0 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")"); - console.assert(10 === root_child2.getComputedTop(), "10 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")"); + console.assert(20 === root_child2.getComputedTop(), "20 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")"); console.assert(102 === root_child2.getComputedWidth(), "102 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")"); console.assert(10 === root_child2.getComputedHeight(), "10 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")"); @@ -425,10 +426,10 @@ it("justify_content_column_flex_start", function () { console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")"); console.assert(10 === root_child1.getComputedTop(), "10 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")"); console.assert(102 === root_child1.getComputedWidth(), "102 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")"); - console.assert(0 === root_child1.getComputedHeight(), "0 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")"); + console.assert(10 === root_child1.getComputedHeight(), "10 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")"); console.assert(0 === root_child2.getComputedLeft(), "0 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")"); - console.assert(10 === root_child2.getComputedTop(), "10 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")"); + console.assert(20 === root_child2.getComputedTop(), "20 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")"); console.assert(102 === root_child2.getComputedWidth(), "102 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")"); console.assert(10 === root_child2.getComputedHeight(), "10 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")"); } finally { @@ -903,3 +904,146 @@ it("justify_content_colunn_max_height_and_margin", function () { config.free(); } }); +it("justify_content_column_space_evenly", function () { + var config = Yoga.Config.create(); + + try { + var root = Yoga.Node.create(config); + root.setJustifyContent(Yoga.JUSTIFY_SPACE_EVENLY); + root.setWidth(102); + root.setHeight(102); + + var root_child0 = Yoga.Node.create(config); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + var root_child1 = Yoga.Node.create(config); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + var root_child2 = Yoga.Node.create(config); + root_child2.setHeight(10); + root.insertChild(root_child2, 2); + root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); + + console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")"); + console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")"); + console.assert(102 === root.getComputedWidth(), "102 === root.getComputedWidth() (" + root.getComputedWidth() + ")"); + console.assert(102 === root.getComputedHeight(), "102 === root.getComputedHeight() (" + root.getComputedHeight() + ")"); + + console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")"); + console.assert(18 === root_child0.getComputedTop(), "18 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")"); + console.assert(102 === root_child0.getComputedWidth(), "102 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")"); + console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")"); + + console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")"); + console.assert(46 === root_child1.getComputedTop(), "46 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")"); + console.assert(102 === root_child1.getComputedWidth(), "102 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")"); + console.assert(10 === root_child1.getComputedHeight(), "10 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")"); + + console.assert(0 === root_child2.getComputedLeft(), "0 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")"); + console.assert(74 === root_child2.getComputedTop(), "74 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")"); + console.assert(102 === root_child2.getComputedWidth(), "102 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")"); + console.assert(10 === root_child2.getComputedHeight(), "10 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")"); + + root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL); + + console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")"); + console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")"); + console.assert(102 === root.getComputedWidth(), "102 === root.getComputedWidth() (" + root.getComputedWidth() + ")"); + console.assert(102 === root.getComputedHeight(), "102 === root.getComputedHeight() (" + root.getComputedHeight() + ")"); + + console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")"); + console.assert(18 === root_child0.getComputedTop(), "18 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")"); + console.assert(102 === root_child0.getComputedWidth(), "102 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")"); + console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")"); + + console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")"); + console.assert(46 === root_child1.getComputedTop(), "46 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")"); + console.assert(102 === root_child1.getComputedWidth(), "102 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")"); + console.assert(10 === root_child1.getComputedHeight(), "10 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")"); + + console.assert(0 === root_child2.getComputedLeft(), "0 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")"); + console.assert(74 === root_child2.getComputedTop(), "74 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")"); + console.assert(102 === root_child2.getComputedWidth(), "102 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")"); + console.assert(10 === root_child2.getComputedHeight(), "10 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")"); + } finally { + if (typeof root !== "undefined") { + root.freeRecursive(); + } + + config.free(); + } +}); +it("justify_content_row_space_evenly", function () { + var config = Yoga.Config.create(); + + try { + var root = Yoga.Node.create(config); + root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); + root.setJustifyContent(Yoga.JUSTIFY_SPACE_EVENLY); + root.setWidth(102); + root.setHeight(102); + + var root_child0 = Yoga.Node.create(config); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + var root_child1 = Yoga.Node.create(config); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + var root_child2 = Yoga.Node.create(config); + root_child2.setHeight(10); + root.insertChild(root_child2, 2); + root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR); + + console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")"); + console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")"); + console.assert(102 === root.getComputedWidth(), "102 === root.getComputedWidth() (" + root.getComputedWidth() + ")"); + console.assert(102 === root.getComputedHeight(), "102 === root.getComputedHeight() (" + root.getComputedHeight() + ")"); + + console.assert(26 === root_child0.getComputedLeft(), "26 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")"); + console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")"); + console.assert(0 === root_child0.getComputedWidth(), "0 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")"); + console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")"); + + console.assert(51 === root_child1.getComputedLeft(), "51 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")"); + console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")"); + console.assert(0 === root_child1.getComputedWidth(), "0 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")"); + console.assert(10 === root_child1.getComputedHeight(), "10 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")"); + + console.assert(77 === root_child2.getComputedLeft(), "77 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")"); + console.assert(0 === root_child2.getComputedTop(), "0 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")"); + console.assert(0 === root_child2.getComputedWidth(), "0 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")"); + console.assert(10 === root_child2.getComputedHeight(), "10 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")"); + + root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL); + + console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")"); + console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")"); + console.assert(102 === root.getComputedWidth(), "102 === root.getComputedWidth() (" + root.getComputedWidth() + ")"); + console.assert(102 === root.getComputedHeight(), "102 === root.getComputedHeight() (" + root.getComputedHeight() + ")"); + + console.assert(77 === root_child0.getComputedLeft(), "77 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")"); + console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")"); + console.assert(0 === root_child0.getComputedWidth(), "0 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")"); + console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")"); + + console.assert(51 === root_child1.getComputedLeft(), "51 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")"); + console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")"); + console.assert(0 === root_child1.getComputedWidth(), "0 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")"); + console.assert(10 === root_child1.getComputedHeight(), "10 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")"); + + console.assert(26 === root_child2.getComputedLeft(), "26 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")"); + console.assert(0 === root_child2.getComputedTop(), "0 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")"); + console.assert(0 === root_child2.getComputedWidth(), "0 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")"); + console.assert(10 === root_child2.getComputedHeight(), "10 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")"); + } finally { + if (typeof root !== "undefined") { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/tests/YGJustifyContentTest.cpp b/tests/YGJustifyContentTest.cpp index bb0861e9..2064c238 100644 --- a/tests/YGJustifyContentTest.cpp +++ b/tests/YGJustifyContentTest.cpp @@ -368,6 +368,7 @@ TEST(YogaTest, justify_content_column_flex_start) { YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetHeight(root_child1, 10); YGNodeInsertChild(root, root_child1, 1); const YGNodeRef root_child2 = YGNodeNewWithConfig(config); @@ -388,10 +389,10 @@ TEST(YogaTest, justify_content_column_flex_start) { ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2)); ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2)); @@ -410,10 +411,10 @@ TEST(YogaTest, justify_content_column_flex_start) { ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2)); ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2)); @@ -861,3 +862,140 @@ TEST(YogaTest, justify_content_colunn_max_height_and_margin) { YGConfigFree(config); } + +TEST(YogaTest, justify_content_column_space_evenly) { + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root, YGJustifySpaceEvenly); + YGNodeStyleSetWidth(root, 102); + YGNodeStyleSetHeight(root, 102); + + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetHeight(root_child1, 10); + YGNodeInsertChild(root, root_child1, 1); + + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetHeight(root_child2, 10); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(18, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(46, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(74, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(18, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(46, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(74, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, justify_content_row_space_evenly) { + const YGConfigRef config = YGConfigNew(); + + const YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetJustifyContent(root, YGJustifySpaceEvenly); + YGNodeStyleSetWidth(root, 102); + YGNodeStyleSetHeight(root, 102); + + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetHeight(root_child1, 10); + YGNodeInsertChild(root, root_child1, 1); + + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetHeight(root_child2, 10); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(26, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(51, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(77, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(77, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(51, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(26, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/yoga/YGEnums.cpp b/yoga/YGEnums.cpp index 7baf5c26..af3c27cf 100644 --- a/yoga/YGEnums.cpp +++ b/yoga/YGEnums.cpp @@ -121,6 +121,8 @@ const char *YGJustifyToString(const YGJustify value){ return "space-between"; case YGJustifySpaceAround: return "space-around"; + case YGJustifySpaceEvenly: + return "space-evenly"; } return "unknown"; } diff --git a/yoga/YGEnums.h b/yoga/YGEnums.h index e12b9667..89567b16 100644 --- a/yoga/YGEnums.h +++ b/yoga/YGEnums.h @@ -77,13 +77,14 @@ typedef YG_ENUM_BEGIN(YGFlexDirection) { } YG_ENUM_END(YGFlexDirection); WIN_EXPORT const char *YGFlexDirectionToString(const YGFlexDirection value); -#define YGJustifyCount 5 -typedef YG_ENUM_BEGIN(YGJustify) { - YGJustifyFlexStart, - YGJustifyCenter, - YGJustifyFlexEnd, - YGJustifySpaceBetween, - YGJustifySpaceAround, +#define YGJustifyCount 6 +typedef YG_ENUM_BEGIN(YGJustify){ + YGJustifyFlexStart, + YGJustifyCenter, + YGJustifyFlexEnd, + YGJustifySpaceBetween, + YGJustifySpaceAround, + YGJustifySpaceEvenly, } YG_ENUM_END(YGJustify); WIN_EXPORT const char *YGJustifyToString(const YGJustify value); diff --git a/yoga/Yoga.cpp b/yoga/Yoga.cpp index ba5fb183..a5274936 100644 --- a/yoga/Yoga.cpp +++ b/yoga/Yoga.cpp @@ -2447,6 +2447,11 @@ static void YGNodelayoutImpl(const YGNodeRef node, betweenMainDim = 0; } break; + case YGJustifySpaceEvenly: + // Space is distributed evenly across all elements + betweenMainDim = remainingFreeSpace / (itemsOnLine + 1); + leadingMainDim = betweenMainDim; + break; case YGJustifySpaceAround: // Space on the edges is half of the space between elements betweenMainDim = remainingFreeSpace / itemsOnLine;