Add spacing properties

Summary:
Align C# implementation with YogaKit #322
Closes https://github.com/facebook/yoga/pull/327

Reviewed By: emilsjolander

Differential Revision: D4390687

Pulled By: splhack

fbshipit-source-id: 28c87a45898fcd958a422d5e254ead0ec00d3562
This commit is contained in:
Kazuki Sakamoto
2017-01-08 07:58:31 -08:00
committed by Facebook Github Bot
parent 969b3709db
commit 8ed71b2777
17 changed files with 805 additions and 318 deletions

View File

@@ -26,8 +26,8 @@ namespace Facebook.Yoga
YogaNode root_child0 = new YogaNode();
root_child0.PositionType = YogaPositionType.Absolute;
root_child0.SetPosition(YogaEdge.Start, 10);
root_child0.SetPosition(YogaEdge.Top, 10);
root_child0.Start = 10;
root_child0.Top = 10;
root_child0.Width = 10;
root_child0.Height = 10;
root.Insert(0, root_child0);
@@ -67,8 +67,8 @@ namespace Facebook.Yoga
YogaNode root_child0 = new YogaNode();
root_child0.PositionType = YogaPositionType.Absolute;
root_child0.SetPosition(YogaEdge.End, 10);
root_child0.SetPosition(YogaEdge.Bottom, 10);
root_child0.End = 10;
root_child0.Bottom = 10;
root_child0.Width = 10;
root_child0.Height = 10;
root.Insert(0, root_child0);
@@ -108,10 +108,10 @@ namespace Facebook.Yoga
YogaNode root_child0 = new YogaNode();
root_child0.PositionType = YogaPositionType.Absolute;
root_child0.SetPosition(YogaEdge.Start, 10);
root_child0.SetPosition(YogaEdge.Top, 10);
root_child0.SetPosition(YogaEdge.End, 10);
root_child0.SetPosition(YogaEdge.Bottom, 10);
root_child0.Start = 10;
root_child0.Top = 10;
root_child0.End = 10;
root_child0.Bottom = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -149,10 +149,10 @@ namespace Facebook.Yoga
YogaNode root_child0 = new YogaNode();
root_child0.PositionType = YogaPositionType.Absolute;
root_child0.SetPosition(YogaEdge.Start, 10);
root_child0.SetPosition(YogaEdge.Top, 10);
root_child0.SetPosition(YogaEdge.End, 10);
root_child0.SetPosition(YogaEdge.Bottom, 10);
root_child0.Start = 10;
root_child0.Top = 10;
root_child0.End = 10;
root_child0.Bottom = 10;
root_child0.Width = 10;
root_child0.Height = 10;
root.Insert(0, root_child0);
@@ -194,8 +194,8 @@ namespace Facebook.Yoga
YogaNode root_child0 = new YogaNode();
root_child0.PositionType = YogaPositionType.Absolute;
root_child0.SetPosition(YogaEdge.Start, 0);
root_child0.SetPosition(YogaEdge.Top, 0);
root_child0.Start = 0;
root_child0.Top = 0;
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
@@ -243,33 +243,33 @@ namespace Facebook.Yoga
public void Test_absolute_layout_within_border()
{
YogaNode root = new YogaNode();
root.SetMargin(YogaEdge.Left, 10);
root.SetMargin(YogaEdge.Top, 10);
root.SetMargin(YogaEdge.Right, 10);
root.SetMargin(YogaEdge.Bottom, 10);
root.SetPadding(YogaEdge.Left, 10);
root.SetPadding(YogaEdge.Top, 10);
root.SetPadding(YogaEdge.Right, 10);
root.SetPadding(YogaEdge.Bottom, 10);
root.SetBorder(YogaEdge.Left, 10);
root.SetBorder(YogaEdge.Top, 10);
root.SetBorder(YogaEdge.Right, 10);
root.SetBorder(YogaEdge.Bottom, 10);
root.MarginLeft = 10;
root.MarginTop = 10;
root.MarginRight = 10;
root.MarginBottom = 10;
root.PaddingLeft = 10;
root.PaddingTop = 10;
root.PaddingRight = 10;
root.PaddingBottom = 10;
root.BorderLeftWidth = 10;
root.BorderTopWidth = 10;
root.BorderRightWidth = 10;
root.BorderBottomWidth = 10;
root.Width = 100;
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.PositionType = YogaPositionType.Absolute;
root_child0.SetPosition(YogaEdge.Left, 0);
root_child0.SetPosition(YogaEdge.Top, 0);
root_child0.Left = 0;
root_child0.Top = 0;
root_child0.Width = 50;
root_child0.Height = 50;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.PositionType = YogaPositionType.Absolute;
root_child1.SetPosition(YogaEdge.Right, 0);
root_child1.SetPosition(YogaEdge.Bottom, 0);
root_child1.Right = 0;
root_child1.Bottom = 0;
root_child1.Width = 50;
root_child1.Height = 50;
root.Insert(1, root_child1);

View File

@@ -660,7 +660,7 @@ namespace Facebook.Yoga
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.SetPosition(YogaEdge.Top, 10);
root_child0.Top = 10;
root_child0.Width = 50;
root_child0.Height = 50;
root.Insert(0, root_child0);
@@ -736,7 +736,7 @@ namespace Facebook.Yoga
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.SetPosition(YogaEdge.Top, 5);
root_child1.Top = 5;
root_child1.Width = 50;
root_child1.Height = 20;
root.Insert(1, root_child1);
@@ -941,10 +941,10 @@ namespace Facebook.Yoga
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.SetMargin(YogaEdge.Left, 5);
root_child0.SetMargin(YogaEdge.Top, 5);
root_child0.SetMargin(YogaEdge.Right, 5);
root_child0.SetMargin(YogaEdge.Bottom, 5);
root_child0.MarginLeft = 5;
root_child0.MarginTop = 5;
root_child0.MarginRight = 5;
root_child0.MarginBottom = 5;
root_child0.Width = 50;
root_child0.Height = 50;
root.Insert(0, root_child0);
@@ -955,10 +955,10 @@ namespace Facebook.Yoga
root.Insert(1, root_child1);
YogaNode root_child1_child0 = new YogaNode();
root_child1_child0.SetMargin(YogaEdge.Left, 1);
root_child1_child0.SetMargin(YogaEdge.Top, 1);
root_child1_child0.SetMargin(YogaEdge.Right, 1);
root_child1_child0.SetMargin(YogaEdge.Bottom, 1);
root_child1_child0.MarginLeft = 1;
root_child1_child0.MarginTop = 1;
root_child1_child0.MarginRight = 1;
root_child1_child0.MarginBottom = 1;
root_child1_child0.Width = 50;
root_child1_child0.Height = 10;
root_child1.Insert(0, root_child1_child0);
@@ -1015,10 +1015,10 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.AlignItems = YogaAlign.Baseline;
root.SetPadding(YogaEdge.Left, 5);
root.SetPadding(YogaEdge.Top, 5);
root.SetPadding(YogaEdge.Right, 5);
root.SetPadding(YogaEdge.Bottom, 5);
root.PaddingLeft = 5;
root.PaddingTop = 5;
root.PaddingRight = 5;
root.PaddingBottom = 5;
root.Width = 100;
root.Height = 100;
@@ -1028,10 +1028,10 @@ namespace Facebook.Yoga
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.SetPadding(YogaEdge.Left, 5);
root_child1.SetPadding(YogaEdge.Top, 5);
root_child1.SetPadding(YogaEdge.Right, 5);
root_child1.SetPadding(YogaEdge.Bottom, 5);
root_child1.PaddingLeft = 5;
root_child1.PaddingTop = 5;
root_child1.PaddingRight = 5;
root_child1.PaddingBottom = 5;
root_child1.Width = 50;
root_child1.Height = 20;
root.Insert(1, root_child1);

View File

@@ -21,10 +21,10 @@ namespace Facebook.Yoga
public void Test_border_no_size()
{
YogaNode root = new YogaNode();
root.SetBorder(YogaEdge.Left, 10);
root.SetBorder(YogaEdge.Top, 10);
root.SetBorder(YogaEdge.Right, 10);
root.SetBorder(YogaEdge.Bottom, 10);
root.BorderLeftWidth = 10;
root.BorderTopWidth = 10;
root.BorderRightWidth = 10;
root.BorderBottomWidth = 10;
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -46,10 +46,10 @@ namespace Facebook.Yoga
public void Test_border_container_match_child()
{
YogaNode root = new YogaNode();
root.SetBorder(YogaEdge.Left, 10);
root.SetBorder(YogaEdge.Top, 10);
root.SetBorder(YogaEdge.Right, 10);
root.SetBorder(YogaEdge.Bottom, 10);
root.BorderLeftWidth = 10;
root.BorderTopWidth = 10;
root.BorderRightWidth = 10;
root.BorderBottomWidth = 10;
YogaNode root_child0 = new YogaNode();
root_child0.Width = 10;
@@ -86,10 +86,10 @@ namespace Facebook.Yoga
public void Test_border_flex_child()
{
YogaNode root = new YogaNode();
root.SetBorder(YogaEdge.Left, 10);
root.SetBorder(YogaEdge.Top, 10);
root.SetBorder(YogaEdge.Right, 10);
root.SetBorder(YogaEdge.Bottom, 10);
root.BorderLeftWidth = 10;
root.BorderTopWidth = 10;
root.BorderRightWidth = 10;
root.BorderBottomWidth = 10;
root.Width = 100;
root.Height = 100;
@@ -128,10 +128,10 @@ namespace Facebook.Yoga
public void Test_border_stretch_child()
{
YogaNode root = new YogaNode();
root.SetBorder(YogaEdge.Left, 10);
root.SetBorder(YogaEdge.Top, 10);
root.SetBorder(YogaEdge.Right, 10);
root.SetBorder(YogaEdge.Bottom, 10);
root.BorderLeftWidth = 10;
root.BorderTopWidth = 10;
root.BorderRightWidth = 10;
root.BorderBottomWidth = 10;
root.Width = 100;
root.Height = 100;
@@ -171,9 +171,9 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode();
root.JustifyContent = YogaJustify.Center;
root.AlignItems = YogaAlign.Center;
root.SetBorder(YogaEdge.Start, 10);
root.SetBorder(YogaEdge.End, 20);
root.SetBorder(YogaEdge.Bottom, 20);
root.BorderStartWidth = 10;
root.BorderEndWidth = 20;
root.BorderBottomWidth = 20;
root.Width = 100;
root.Height = 100;

View File

@@ -26,7 +26,7 @@ namespace Facebook.Yoga
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.SetMargin(YogaEdge.Start, 10);
root_child0.MarginStart = 10;
root_child0.Width = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
@@ -64,7 +64,7 @@ namespace Facebook.Yoga
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.SetMargin(YogaEdge.Top, 10);
root_child0.MarginTop = 10;
root_child0.Height = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
@@ -104,7 +104,7 @@ namespace Facebook.Yoga
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.SetMargin(YogaEdge.End, 10);
root_child0.MarginEnd = 10;
root_child0.Width = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
@@ -143,7 +143,7 @@ namespace Facebook.Yoga
root.Height = 100;
YogaNode root_child0 = new YogaNode();
root_child0.SetMargin(YogaEdge.Bottom, 10);
root_child0.MarginBottom = 10;
root_child0.Height = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
@@ -183,7 +183,7 @@ namespace Facebook.Yoga
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1;
root_child0.SetMargin(YogaEdge.Start, 10);
root_child0.MarginStart = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -221,7 +221,7 @@ namespace Facebook.Yoga
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1;
root_child0.SetMargin(YogaEdge.Top, 10);
root_child0.MarginTop = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -260,7 +260,7 @@ namespace Facebook.Yoga
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1;
root_child0.SetMargin(YogaEdge.Top, 10);
root_child0.MarginTop = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -298,7 +298,7 @@ namespace Facebook.Yoga
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1;
root_child0.SetMargin(YogaEdge.Start, 10);
root_child0.MarginStart = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();

View File

@@ -21,10 +21,10 @@ namespace Facebook.Yoga
public void Test_padding_no_size()
{
YogaNode root = new YogaNode();
root.SetPadding(YogaEdge.Left, 10);
root.SetPadding(YogaEdge.Top, 10);
root.SetPadding(YogaEdge.Right, 10);
root.SetPadding(YogaEdge.Bottom, 10);
root.PaddingLeft = 10;
root.PaddingTop = 10;
root.PaddingRight = 10;
root.PaddingBottom = 10;
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
@@ -46,10 +46,10 @@ namespace Facebook.Yoga
public void Test_padding_container_match_child()
{
YogaNode root = new YogaNode();
root.SetPadding(YogaEdge.Left, 10);
root.SetPadding(YogaEdge.Top, 10);
root.SetPadding(YogaEdge.Right, 10);
root.SetPadding(YogaEdge.Bottom, 10);
root.PaddingLeft = 10;
root.PaddingTop = 10;
root.PaddingRight = 10;
root.PaddingBottom = 10;
YogaNode root_child0 = new YogaNode();
root_child0.Width = 10;
@@ -86,10 +86,10 @@ namespace Facebook.Yoga
public void Test_padding_flex_child()
{
YogaNode root = new YogaNode();
root.SetPadding(YogaEdge.Left, 10);
root.SetPadding(YogaEdge.Top, 10);
root.SetPadding(YogaEdge.Right, 10);
root.SetPadding(YogaEdge.Bottom, 10);
root.PaddingLeft = 10;
root.PaddingTop = 10;
root.PaddingRight = 10;
root.PaddingBottom = 10;
root.Width = 100;
root.Height = 100;
@@ -128,10 +128,10 @@ namespace Facebook.Yoga
public void Test_padding_stretch_child()
{
YogaNode root = new YogaNode();
root.SetPadding(YogaEdge.Left, 10);
root.SetPadding(YogaEdge.Top, 10);
root.SetPadding(YogaEdge.Right, 10);
root.SetPadding(YogaEdge.Bottom, 10);
root.PaddingLeft = 10;
root.PaddingTop = 10;
root.PaddingRight = 10;
root.PaddingBottom = 10;
root.Width = 100;
root.Height = 100;
@@ -171,9 +171,9 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode();
root.JustifyContent = YogaJustify.Center;
root.AlignItems = YogaAlign.Center;
root.SetPadding(YogaEdge.Start, 10);
root.SetPadding(YogaEdge.End, 20);
root.SetPadding(YogaEdge.Bottom, 20);
root.PaddingStart = 10;
root.PaddingEnd = 20;
root.PaddingBottom = 20;
root.Width = 100;
root.Height = 100;
@@ -218,10 +218,10 @@ namespace Facebook.Yoga
root.Height = 200;
YogaNode root_child0 = new YogaNode();
root_child0.SetPadding(YogaEdge.Left, 20);
root_child0.SetPadding(YogaEdge.Top, 20);
root_child0.SetPadding(YogaEdge.Right, 20);
root_child0.SetPadding(YogaEdge.Bottom, 20);
root_child0.PaddingLeft = 20;
root_child0.PaddingTop = 20;
root_child0.PaddingRight = 20;
root_child0.PaddingBottom = 20;
root_child0.Width = 100;
root_child0.Height = 100;
root.Insert(0, root_child0);

View File

@@ -71,8 +71,8 @@ namespace Facebook.Yoga
root.Height = 400;
YogaNode root_child0 = new YogaNode();
root_child0.SetPosition(YogaEdge.Left, 10.Percent());
root_child0.SetPosition(YogaEdge.Top, 20.Percent());
root_child0.Left = 10.Percent();
root_child0.Top = 20.Percent();
root_child0.Width = 45.Percent();
root_child0.Height = 55.Percent();
root.Insert(0, root_child0);
@@ -116,8 +116,8 @@ namespace Facebook.Yoga
root.Height = 500;
YogaNode root_child0 = new YogaNode();
root_child0.SetPosition(YogaEdge.Right, 20.Percent());
root_child0.SetPosition(YogaEdge.Bottom, 10.Percent());
root_child0.Right = 20.Percent();
root_child0.Bottom = 10.Percent();
root_child0.Width = 55.Percent();
root_child0.Height = 15.Percent();
root.Insert(0, root_child0);
@@ -691,38 +691,38 @@ namespace Facebook.Yoga
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 10.Percent();
root_child0.SetMargin(YogaEdge.Left, 5);
root_child0.SetMargin(YogaEdge.Top, 5);
root_child0.SetMargin(YogaEdge.Right, 5);
root_child0.SetMargin(YogaEdge.Bottom, 5);
root_child0.SetPadding(YogaEdge.Left, 3);
root_child0.SetPadding(YogaEdge.Top, 3);
root_child0.SetPadding(YogaEdge.Right, 3);
root_child0.SetPadding(YogaEdge.Bottom, 3);
root_child0.MarginLeft = 5;
root_child0.MarginTop = 5;
root_child0.MarginRight = 5;
root_child0.MarginBottom = 5;
root_child0.PaddingLeft = 3;
root_child0.PaddingTop = 3;
root_child0.PaddingRight = 3;
root_child0.PaddingBottom = 3;
root_child0.MinWidth = 60.Percent();
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
root_child0_child0.SetMargin(YogaEdge.Left, 5);
root_child0_child0.SetMargin(YogaEdge.Top, 5);
root_child0_child0.SetMargin(YogaEdge.Right, 5);
root_child0_child0.SetMargin(YogaEdge.Bottom, 5);
root_child0_child0.SetPadding(YogaEdge.Left, 3.Percent());
root_child0_child0.SetPadding(YogaEdge.Top, 3.Percent());
root_child0_child0.SetPadding(YogaEdge.Right, 3.Percent());
root_child0_child0.SetPadding(YogaEdge.Bottom, 3.Percent());
root_child0_child0.MarginLeft = 5;
root_child0_child0.MarginTop = 5;
root_child0_child0.MarginRight = 5;
root_child0_child0.MarginBottom = 5;
root_child0_child0.PaddingLeft = 3.Percent();
root_child0_child0.PaddingTop = 3.Percent();
root_child0_child0.PaddingRight = 3.Percent();
root_child0_child0.PaddingBottom = 3.Percent();
root_child0_child0.Width = 50.Percent();
root_child0.Insert(0, root_child0_child0);
YogaNode root_child0_child0_child0 = new YogaNode();
root_child0_child0_child0.SetMargin(YogaEdge.Left, 5.Percent());
root_child0_child0_child0.SetMargin(YogaEdge.Top, 5.Percent());
root_child0_child0_child0.SetMargin(YogaEdge.Right, 5.Percent());
root_child0_child0_child0.SetMargin(YogaEdge.Bottom, 5.Percent());
root_child0_child0_child0.SetPadding(YogaEdge.Left, 3);
root_child0_child0_child0.SetPadding(YogaEdge.Top, 3);
root_child0_child0_child0.SetPadding(YogaEdge.Right, 3);
root_child0_child0_child0.SetPadding(YogaEdge.Bottom, 3);
root_child0_child0_child0.MarginLeft = 5.Percent();
root_child0_child0_child0.MarginTop = 5.Percent();
root_child0_child0_child0.MarginRight = 5.Percent();
root_child0_child0_child0.MarginBottom = 5.Percent();
root_child0_child0_child0.PaddingLeft = 3;
root_child0_child0_child0.PaddingTop = 3;
root_child0_child0_child0.PaddingRight = 3;
root_child0_child0_child0.PaddingBottom = 3;
root_child0_child0_child0.Width = 45.Percent();
root_child0_child0.Insert(0, root_child0_child0_child0);
@@ -801,10 +801,10 @@ namespace Facebook.Yoga
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1;
root_child0.SetMargin(YogaEdge.Left, 10.Percent());
root_child0.SetMargin(YogaEdge.Top, 10.Percent());
root_child0.SetMargin(YogaEdge.Right, 10.Percent());
root_child0.SetMargin(YogaEdge.Bottom, 10.Percent());
root_child0.MarginLeft = 10.Percent();
root_child0.MarginTop = 10.Percent();
root_child0.MarginRight = 10.Percent();
root_child0.MarginBottom = 10.Percent();
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
@@ -861,10 +861,10 @@ namespace Facebook.Yoga
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1;
root_child0.SetPadding(YogaEdge.Left, 10.Percent());
root_child0.SetPadding(YogaEdge.Top, 10.Percent());
root_child0.SetPadding(YogaEdge.Right, 10.Percent());
root_child0.SetPadding(YogaEdge.Bottom, 10.Percent());
root_child0.PaddingLeft = 10.Percent();
root_child0.PaddingTop = 10.Percent();
root_child0.PaddingRight = 10.Percent();
root_child0.PaddingBottom = 10.Percent();
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
@@ -921,8 +921,8 @@ namespace Facebook.Yoga
YogaNode root_child0 = new YogaNode();
root_child0.PositionType = YogaPositionType.Absolute;
root_child0.SetPosition(YogaEdge.Left, 30.Percent());
root_child0.SetPosition(YogaEdge.Top, 10.Percent());
root_child0.Left = 30.Percent();
root_child0.Top = 10.Percent();
root_child0.Width = 10;
root_child0.Height = 10;
root.Insert(0, root_child0);

View File

@@ -420,14 +420,14 @@ namespace Facebook.Yoga
YogaNode root_child0_child0 = new YogaNode();
root_child0_child0.FlexGrow = 1;
root_child0_child0.FlexBasis = 0.3f;
root_child0_child0.SetPosition(YogaEdge.Bottom, 13.3f);
root_child0_child0.Bottom = 13.3f;
root_child0_child0.Height = 9.9f;
root_child0.Insert(0, root_child0_child0);
YogaNode root_child0_child1 = new YogaNode();
root_child0_child1.FlexGrow = 4;
root_child0_child1.FlexBasis = 0.3f;
root_child0_child1.SetPosition(YogaEdge.Top, 13.3f);
root_child0_child1.Top = 13.3f;
root_child0_child1.Height = 1.1f;
root_child0.Insert(1, root_child0_child1);
@@ -661,7 +661,7 @@ namespace Facebook.Yoga
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.SetPosition(YogaEdge.Top, 0.3f);
root.Top = 0.3f;
root.Width = 100;
root.Height = 113.4f;
@@ -735,7 +735,7 @@ namespace Facebook.Yoga
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.SetPosition(YogaEdge.Top, 0.7f);
root.Top = 0.7f;
root.Width = 100;
root.Height = 113.4f;

View File

@@ -1,143 +0,0 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
using NUnit.Framework;
using System;
/**
* Tests for {@link YogaNode}.
*/
namespace Facebook.Yoga
{
[TestFixture]
public class YogaNodeCreateTest
{
[Test]
public void TestSimple()
{
YogaNode nodeDefault = new YogaNode();
YogaNode nodeCreated = YogaNode.Create(flexDirection: YogaFlexDirection.Row);
Assert.AreEqual(YogaFlexDirection.Row, nodeCreated.FlexDirection);
Assert.IsFalse(nodeDefault.IsDirty);
nodeDefault.CopyStyle(nodeCreated);
Assert.IsTrue(nodeDefault.IsDirty);
}
[Test]
public void TestSame()
{
YogaNode nodeDefault = new YogaNode();
YogaNode nodeCreated = YogaNode.Create();
Assert.IsFalse(nodeDefault.IsDirty);
nodeDefault.CopyStyle(nodeCreated);
Assert.IsFalse(nodeDefault.IsDirty);
}
[Test]
public void TestMultiple()
{
YogaNode node = YogaNode.Create(
positionType: YogaPositionType.Absolute,
wrap: YogaWrap.Wrap,
position: new Spacing(top:6, right:4),
margin: new Spacing(bottom:5, left:3));
Assert.AreEqual(YogaFlexDirection.Column, node.FlexDirection);
Assert.AreEqual(YogaPositionType.Absolute, node.PositionType);
Assert.AreEqual(YogaWrap.Wrap, node.Wrap);
Assert.AreEqual(6.Px(), node.GetPosition(YogaEdge.Top));
Assert.IsTrue(YogaConstants.IsUndefined(node.GetPosition(YogaEdge.Bottom)));
Assert.AreEqual(4.Px(), node.GetPosition(YogaEdge.Right));
Assert.IsTrue(YogaConstants.IsUndefined(node.GetPosition(YogaEdge.Left)));
Assert.AreEqual(0.Px(), node.GetMargin(YogaEdge.Top));
Assert.AreEqual(5.Px(), node.GetMargin(YogaEdge.Bottom));
Assert.AreEqual(3.Px(), node.GetMargin(YogaEdge.Left));
Assert.AreEqual(0.Px(), node.GetMargin(YogaEdge.Right));
}
[Test]
public void TestFull()
{
YogaNode node = YogaNode.Create(
styleDirection: YogaDirection.RTL,
flexDirection: YogaFlexDirection.RowReverse,
justifyContent: YogaJustify.SpaceAround,
alignContent: YogaAlign.Center,
alignItems: YogaAlign.FlexEnd,
alignSelf: YogaAlign.Stretch,
positionType: YogaPositionType.Absolute,
wrap: YogaWrap.Wrap,
overflow: YogaOverflow.Scroll,
flex: 1,
flexGrow: 2,
flexShrink: 3,
flexBasis: 4,
position: new Spacing(top: 5, bottom: 6, left: 7, right: 8),
margin: new Spacing(top: 9, bottom: 10, left: 11, right: 12),
padding: new Spacing(top: 13, bottom: 14, left: 15, right: 16),
border: new Border(top: 17, bottom: 18, left: 19, right: 20),
width: 21,
height: 22,
minWidth: 23,
minHeight: 24,
maxWidth: 25,
maxHeight: 26);
Assert.AreEqual(YogaDirection.RTL, node.StyleDirection);
Assert.AreEqual(YogaFlexDirection.RowReverse, node.FlexDirection);
Assert.AreEqual(YogaJustify.SpaceAround, node.JustifyContent);
Assert.AreEqual(YogaAlign.Center, node.AlignContent);
Assert.AreEqual(YogaAlign.FlexEnd, node.AlignItems);
Assert.AreEqual(YogaAlign.Stretch, node.AlignSelf);
Assert.AreEqual(YogaPositionType.Absolute, node.PositionType);
Assert.AreEqual(YogaWrap.Wrap, node.Wrap);
Assert.AreEqual(YogaOverflow.Scroll, node.Overflow);
Assert.AreEqual(2, node.FlexGrow);
Assert.AreEqual(3, node.FlexShrink);
Assert.AreEqual(4.Px(), node.FlexBasis);
node.FlexGrow = YogaConstants.Undefined;
Assert.AreEqual(1, node.FlexGrow);
Assert.AreEqual(5.Px(), node.GetPosition(YogaEdge.Top));
Assert.AreEqual(6.Px(), node.GetPosition(YogaEdge.Bottom));
Assert.AreEqual(7.Px(), node.GetPosition(YogaEdge.Left));
Assert.AreEqual(8.Px(), node.GetPosition(YogaEdge.Right));
Assert.AreEqual(9.Px(), node.GetMargin(YogaEdge.Top));
Assert.AreEqual(10.Px(), node.GetMargin(YogaEdge.Bottom));
Assert.AreEqual(11.Px(), node.GetMargin(YogaEdge.Left));
Assert.AreEqual(12.Px(), node.GetMargin(YogaEdge.Right));
Assert.AreEqual(13.Px(), node.GetPadding(YogaEdge.Top));
Assert.AreEqual(14.Px(), node.GetPadding(YogaEdge.Bottom));
Assert.AreEqual(15.Px(), node.GetPadding(YogaEdge.Left));
Assert.AreEqual(16.Px(), node.GetPadding(YogaEdge.Right));
Assert.AreEqual(17, node.GetBorder(YogaEdge.Top));
Assert.AreEqual(18, node.GetBorder(YogaEdge.Bottom));
Assert.AreEqual(19, node.GetBorder(YogaEdge.Left));
Assert.AreEqual(20, node.GetBorder(YogaEdge.Right));
Assert.AreEqual(21.Px(), node.Width);
Assert.AreEqual(22.Px(), node.Height);
Assert.AreEqual(23.Px(), node.MinWidth);
Assert.AreEqual(24.Px(), node.MinHeight);
Assert.AreEqual(25.Px(), node.MaxWidth);
Assert.AreEqual(26.Px(), node.MaxHeight);
}
}
}

View File

@@ -0,0 +1,114 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
using NUnit.Framework;
using System;
/**
* Tests for {@link YogaNode}.
*/
namespace Facebook.Yoga
{
[TestFixture]
public class YogaNodeSpacingTest
{
[Test]
public void TestObjectInitializer()
{
YogaNode node = new YogaNode
{
Top = 1,
Bottom = 2,
Left = 3,
Right = 4,
MarginTop = 5,
MarginBottom = 6,
MarginLeft = 7,
MarginRight = 8,
PaddingTop = 9,
PaddingBottom = 10,
PaddingLeft = 11,
PaddingRight = 12,
BorderTopWidth = 13,
BorderBottomWidth = 14,
BorderLeftWidth = 15,
BorderRightWidth = 16,
};
Assert.AreEqual(1.Px(), node.Top);
Assert.AreEqual(2.Px(), node.Bottom);
Assert.AreEqual(3.Px(), node.Left);
Assert.AreEqual(4.Px(), node.Right);
Assert.AreEqual(5.Px(), node.MarginTop);
Assert.AreEqual(6.Px(), node.MarginBottom);
Assert.AreEqual(7.Px(), node.MarginLeft);
Assert.AreEqual(8.Px(), node.MarginRight);
Assert.AreEqual(9.Px(), node.PaddingTop);
Assert.AreEqual(10.Px(), node.PaddingBottom);
Assert.AreEqual(11.Px(), node.PaddingLeft);
Assert.AreEqual(12.Px(), node.PaddingRight);
Assert.AreEqual(13, node.BorderTopWidth);
Assert.AreEqual(14, node.BorderBottomWidth);
Assert.AreEqual(15, node.BorderLeftWidth);
Assert.AreEqual(16, node.BorderRightWidth);
}
[Test]
public void TestWriteRead()
{
YogaNode node = new YogaNode();
node.Top = 1;
node.Bottom = 2;
node.Left = 3;
node.Right = 4;
node.MarginTop = 5;
node.MarginBottom = 6;
node.MarginLeft = 7;
node.MarginRight = 8;
node.PaddingTop = 9;
node.PaddingBottom = 10;
node.PaddingLeft = 11;
node.PaddingRight = 12;
node.BorderTopWidth = 13;
node.BorderBottomWidth = 14;
node.BorderLeftWidth = 15;
node.BorderRightWidth = 16;
Assert.AreEqual(1.Px(), node.Top);
Assert.AreEqual(2.Px(), node.Bottom);
Assert.AreEqual(3.Px(), node.Left);
Assert.AreEqual(4.Px(), node.Right);
Assert.AreEqual(5.Px(), node.MarginTop);
Assert.AreEqual(6.Px(), node.MarginBottom);
Assert.AreEqual(7.Px(), node.MarginLeft);
Assert.AreEqual(8.Px(), node.MarginRight);
Assert.AreEqual(9.Px(), node.PaddingTop);
Assert.AreEqual(10.Px(), node.PaddingBottom);
Assert.AreEqual(11.Px(), node.PaddingLeft);
Assert.AreEqual(12.Px(), node.PaddingRight);
Assert.AreEqual(13, node.BorderTopWidth);
Assert.AreEqual(14, node.BorderBottomWidth);
Assert.AreEqual(15, node.BorderLeftWidth);
Assert.AreEqual(16, node.BorderRightWidth);
}
}
}

View File

@@ -409,16 +409,16 @@ namespace Facebook.Yoga
YogaNode node = new YogaNode();
node.Width = 100;
node.Height = 100;
node.SetPadding(YogaEdge.Start, 1);
node.SetPadding(YogaEdge.End, 2);
node.SetPadding(YogaEdge.Top, 3);
node.SetPadding(YogaEdge.Bottom, 4);
node.PaddingStart = 1;
node.PaddingEnd = 2;
node.PaddingTop = 3;
node.PaddingBottom = 4;
node.CalculateLayout();
Assert.AreEqual(1, node.GetLayoutPadding(YogaEdge.Left));
Assert.AreEqual(2, node.GetLayoutPadding(YogaEdge.Right));
Assert.AreEqual(3, node.GetLayoutPadding(YogaEdge.Top));
Assert.AreEqual(4, node.GetLayoutPadding(YogaEdge.Bottom));
Assert.AreEqual(1, node.LayoutPaddingLeft);
Assert.AreEqual(2, node.LayoutPaddingRight);
Assert.AreEqual(3, node.LayoutPaddingTop);
Assert.AreEqual(4, node.LayoutPaddingBottom);
}
}
}