diff --git a/csharp/Facebook.Yoga/Border.cs b/csharp/Facebook.Yoga/Border.cs index 27c15cf4..6f046664 100644 --- a/csharp/Facebook.Yoga/Border.cs +++ b/csharp/Facebook.Yoga/Border.cs @@ -9,6 +9,7 @@ namespace Facebook.Yoga { + [System.Obsolete] public class Border { public float? Top; @@ -28,4 +29,4 @@ namespace Facebook.Yoga Right = right; } } -} \ No newline at end of file +} diff --git a/csharp/Facebook.Yoga/Facebook.Yoga.Shared.projitems b/csharp/Facebook.Yoga/Facebook.Yoga.Shared.projitems index b48fb339..66fff377 100644 --- a/csharp/Facebook.Yoga/Facebook.Yoga.Shared.projitems +++ b/csharp/Facebook.Yoga/Facebook.Yoga.Shared.projitems @@ -29,6 +29,7 @@ + diff --git a/csharp/Facebook.Yoga/Spacing.cs b/csharp/Facebook.Yoga/Spacing.cs index 7f5dffbd..0c02800f 100644 --- a/csharp/Facebook.Yoga/Spacing.cs +++ b/csharp/Facebook.Yoga/Spacing.cs @@ -9,6 +9,7 @@ namespace Facebook.Yoga { + [System.Obsolete] public class Spacing { public YogaValue? Top; diff --git a/csharp/Facebook.Yoga/YogaNode.Create.cs b/csharp/Facebook.Yoga/YogaNode.Create.cs index ee0726b5..b44eb798 100644 --- a/csharp/Facebook.Yoga/YogaNode.Create.cs +++ b/csharp/Facebook.Yoga/YogaNode.Create.cs @@ -13,6 +13,7 @@ namespace Facebook.Yoga { public partial class YogaNode { + [Obsolete("use Object Initializer")] public static YogaNode Create( YogaDirection? styleDirection = null, YogaFlexDirection? flexDirection = null, @@ -109,22 +110,22 @@ namespace Facebook.Yoga { if (position.Top.HasValue) { - node.SetPosition(YogaEdge.Top, position.Top.Value); + node.Top = position.Top.Value; } if (position.Bottom.HasValue) { - node.SetPosition(YogaEdge.Bottom, position.Bottom.Value); + node.Bottom = position.Bottom.Value; } if (position.Left.HasValue) { - node.SetPosition(YogaEdge.Left, position.Left.Value); + node.Left = position.Left.Value; } if (position.Right.HasValue) { - node.SetPosition(YogaEdge.Right, position.Right.Value); + node.Right = position.Right.Value; } } @@ -132,22 +133,22 @@ namespace Facebook.Yoga { if (margin.Top.HasValue) { - node.SetMargin(YogaEdge.Top, margin.Top.Value); + node.MarginTop = margin.Top.Value; } if (margin.Bottom.HasValue) { - node.SetMargin(YogaEdge.Bottom, margin.Bottom.Value); + node.MarginBottom = margin.Bottom.Value; } if (margin.Left.HasValue) { - node.SetMargin(YogaEdge.Left, margin.Left.Value); + node.MarginLeft = margin.Left.Value; } if (margin.Right.HasValue) { - node.SetMargin(YogaEdge.Right, margin.Right.Value); + node.MarginRight = margin.Right.Value; } } @@ -155,22 +156,22 @@ namespace Facebook.Yoga { if (padding.Top.HasValue) { - node.SetPadding(YogaEdge.Top, padding.Top.Value); + node.PaddingTop = padding.Top.Value; } if (padding.Bottom.HasValue) { - node.SetPadding(YogaEdge.Bottom, padding.Bottom.Value); + node.PaddingBottom = padding.Bottom.Value; } if (padding.Left.HasValue) { - node.SetPadding(YogaEdge.Left, padding.Left.Value); + node.PaddingLeft = padding.Left.Value; } if (padding.Right.HasValue) { - node.SetPadding(YogaEdge.Right, padding.Right.Value); + node.PaddingRight = padding.Right.Value; } } @@ -178,22 +179,22 @@ namespace Facebook.Yoga { if (border.Top.HasValue) { - node.SetBorder(YogaEdge.Top, border.Top.Value); + node.BorderTopWidth = border.Top.Value; } if (border.Bottom.HasValue) { - node.SetBorder(YogaEdge.Bottom, border.Bottom.Value); + node.BorderBottomWidth = border.Bottom.Value; } if (border.Left.HasValue) { - node.SetBorder(YogaEdge.Left, border.Left.Value); + node.BorderLeftWidth = border.Left.Value; } if (border.Right.HasValue) { - node.SetBorder(YogaEdge.Right, border.Right.Value); + node.BorderRightWidth = border.Right.Value; } } diff --git a/csharp/Facebook.Yoga/YogaNode.Spacing.cs b/csharp/Facebook.Yoga/YogaNode.Spacing.cs new file mode 100644 index 00000000..ff93988d --- /dev/null +++ b/csharp/Facebook.Yoga/YogaNode.Spacing.cs @@ -0,0 +1,503 @@ +/** + * 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 System; + +namespace Facebook.Yoga +{ + public partial class YogaNode + { + public YogaValue Left + { + get + { + return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Left); + } + + set + { + SetStylePosition(YogaEdge.Left, value); + } + } + + public YogaValue Top + { + get + { + return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Top); + } + + set + { + SetStylePosition(YogaEdge.Top, value); + } + } + + public YogaValue Right + { + get + { + return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Right); + } + + set + { + SetStylePosition(YogaEdge.Right, value); + } + } + + public YogaValue Bottom + { + get + { + return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Bottom); + } + + set + { + SetStylePosition(YogaEdge.Bottom, value); + } + } + + public YogaValue Start + { + get + { + return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.Start); + } + + set + { + SetStylePosition(YogaEdge.Start, value); + } + } + + public YogaValue End + { + get + { + return Native.YGNodeStyleGetPosition(_ygNode, YogaEdge.End); + } + + set + { + SetStylePosition(YogaEdge.End, value); + } + } + + private void SetStylePosition(YogaEdge edge, YogaValue value) + { + if (value.Unit == YogaUnit.Percent) + { + Native.YGNodeStyleSetPositionPercent(_ygNode, edge, value.Value); + } + else + { + Native.YGNodeStyleSetPosition(_ygNode, edge, value.Value); + } + } + + public YogaValue MarginLeft + { + get + { + return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Left); + } + + set + { + SetStyleMargin(YogaEdge.Left, value); + } + } + + public YogaValue MarginTop + { + get + { + return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Top); + } + + set + { + SetStyleMargin(YogaEdge.Top, value); + } + } + + public YogaValue MarginRight + { + get + { + return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Right); + } + + set + { + SetStyleMargin(YogaEdge.Right, value); + } + } + + public YogaValue MarginBottom + { + get + { + return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Bottom); + } + + set + { + SetStyleMargin(YogaEdge.Bottom, value); + } + } + + public YogaValue MarginStart + { + get + { + return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Start); + } + + set + { + SetStyleMargin(YogaEdge.Start, value); + } + } + + public YogaValue MarginEnd + { + get + { + return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.End); + } + + set + { + SetStyleMargin(YogaEdge.End, value); + } + } + + public YogaValue MarginHorizontal + { + get + { + return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Horizontal); + } + + set + { + SetStyleMargin(YogaEdge.Horizontal, value); + } + } + + public YogaValue MarginVertical + { + get + { + return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.Vertical); + } + + set + { + SetStyleMargin(YogaEdge.Vertical, value); + } + } + + public YogaValue Margin + { + get + { + return Native.YGNodeStyleGetMargin(_ygNode, YogaEdge.All); + } + + set + { + SetStyleMargin(YogaEdge.All, value); + } + } + + private void SetStyleMargin(YogaEdge edge, YogaValue value) + { + if (value.Unit == YogaUnit.Percent) + { + Native.YGNodeStyleSetMarginPercent(_ygNode, edge, value.Value); + } + else + { + Native.YGNodeStyleSetMargin(_ygNode, edge, value.Value); + } + } + + public YogaValue PaddingLeft + { + get + { + return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Left); + } + + set + { + SetStylePadding(YogaEdge.Left, value); + } + } + + public YogaValue PaddingTop + { + get + { + return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Top); + } + + set + { + SetStylePadding(YogaEdge.Top, value); + } + } + + public YogaValue PaddingRight + { + get + { + return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Right); + } + + set + { + SetStylePadding(YogaEdge.Right, value); + } + } + + public YogaValue PaddingBottom + { + get + { + return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Bottom); + } + + set + { + SetStylePadding(YogaEdge.Bottom, value); + } + } + + public YogaValue PaddingStart + { + get + { + return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Start); + } + + set + { + SetStylePadding(YogaEdge.Start, value); + } + } + + public YogaValue PaddingEnd + { + get + { + return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.End); + } + + set + { + SetStylePadding(YogaEdge.End, value); + } + } + + public YogaValue PaddingHorizontal + { + get + { + return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Horizontal); + } + + set + { + SetStylePadding(YogaEdge.Horizontal, value); + } + } + + public YogaValue PaddingVertical + { + get + { + return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.Vertical); + } + + set + { + SetStylePadding(YogaEdge.Vertical, value); + } + } + + public YogaValue Padding + { + get + { + return Native.YGNodeStyleGetPadding(_ygNode, YogaEdge.All); + } + + set + { + SetStylePadding(YogaEdge.All, value); + } + } + + private void SetStylePadding(YogaEdge edge, YogaValue value) + { + if (value.Unit == YogaUnit.Percent) + { + Native.YGNodeStyleSetPaddingPercent(_ygNode, edge, value.Value); + } + else + { + Native.YGNodeStyleSetPadding(_ygNode, edge, value.Value); + } + } + + public float BorderLeftWidth + { + get + { + return Native.YGNodeStyleGetBorder(_ygNode, YogaEdge.Left); + } + + set + { + Native.YGNodeStyleSetBorder(_ygNode, YogaEdge.Left, value); + } + } + + public float BorderTopWidth + { + get + { + return Native.YGNodeStyleGetBorder(_ygNode, YogaEdge.Top); + } + + set + { + Native.YGNodeStyleSetBorder(_ygNode, YogaEdge.Top, value); + } + } + + public float BorderRightWidth + { + get + { + return Native.YGNodeStyleGetBorder(_ygNode, YogaEdge.Right); + } + + set + { + Native.YGNodeStyleSetBorder(_ygNode, YogaEdge.Right, value); + } + } + + public float BorderBottomWidth + { + get + { + return Native.YGNodeStyleGetBorder(_ygNode, YogaEdge.Bottom); + } + + set + { + Native.YGNodeStyleSetBorder(_ygNode, YogaEdge.Bottom, value); + } + } + + public float BorderStartWidth + { + get + { + return Native.YGNodeStyleGetBorder(_ygNode, YogaEdge.Start); + } + + set + { + Native.YGNodeStyleSetBorder(_ygNode, YogaEdge.Start, value); + } + } + + public float BorderEndWidth + { + get + { + return Native.YGNodeStyleGetBorder(_ygNode, YogaEdge.End); + } + + set + { + Native.YGNodeStyleSetBorder(_ygNode, YogaEdge.End, value); + } + } + + public float BorderWidth + { + get + { + return Native.YGNodeStyleGetBorder(_ygNode, YogaEdge.All); + } + + set + { + Native.YGNodeStyleSetBorder(_ygNode, YogaEdge.All, value); + } + } + + public float LayoutPaddingLeft + { + get + { + return Native.YGNodeLayoutGetPadding(_ygNode, YogaEdge.Left); + } + } + + public float LayoutPaddingTop + { + get + { + return Native.YGNodeLayoutGetPadding(_ygNode, YogaEdge.Top); + } + } + + public float LayoutPaddingRight + { + get + { + return Native.YGNodeLayoutGetPadding(_ygNode, YogaEdge.Right); + } + } + + public float LayoutPaddingBottom + { + get + { + return Native.YGNodeLayoutGetPadding(_ygNode, YogaEdge.Bottom); + } + } + + public float LayoutPaddingStart + { + get + { + return Native.YGNodeLayoutGetPadding(_ygNode, YogaEdge.Start); + } + } + + public float LayoutPaddingEnd + { + get + { + return Native.YGNodeLayoutGetPadding(_ygNode, YogaEdge.End); + } + } + } +} diff --git a/csharp/Facebook.Yoga/YogaNode.cs b/csharp/Facebook.Yoga/YogaNode.cs index ffc2c6f6..c7408a95 100644 --- a/csharp/Facebook.Yoga/YogaNode.cs +++ b/csharp/Facebook.Yoga/YogaNode.cs @@ -258,11 +258,13 @@ namespace Facebook.Yoga } } + [Obsolete("use Margin properties")] public YogaValue GetMargin(YogaEdge edge) { return Native.YGNodeStyleGetMargin(_ygNode, edge); } + [Obsolete("use Margin properties")] public void SetMargin(YogaEdge edge, YogaValue value) { if (value.Unit == YogaUnit.Percent) @@ -275,11 +277,13 @@ namespace Facebook.Yoga } } + [Obsolete("use Padding properties")] public YogaValue GetPadding(YogaEdge edge) { return Native.YGNodeStyleGetPadding(_ygNode, edge); } + [Obsolete("use Padding properties")] public void SetPadding(YogaEdge edge, YogaValue value) { if (value.Unit == YogaUnit.Percent) @@ -292,21 +296,25 @@ namespace Facebook.Yoga } } + [Obsolete("use BorderWidth properties")] public float GetBorder(YogaEdge edge) { return Native.YGNodeStyleGetBorder(_ygNode, edge); } + [Obsolete("use BorderWidth properties")] public void SetBorder(YogaEdge edge, float border) { Native.YGNodeStyleSetBorder(_ygNode, edge, border); } + [Obsolete("use Position properties")] public YogaValue GetPosition(YogaEdge edge) { return Native.YGNodeStyleGetPosition(_ygNode, edge); } + [Obsolete("use Position properties")] public void SetPosition(YogaEdge edge, YogaValue value) { if (value.Unit == YogaUnit.Percent) @@ -319,6 +327,7 @@ namespace Facebook.Yoga } } + [Obsolete("use LayoutPadding properties")] public float GetLayoutPadding(YogaEdge edge) { return Native.YGNodeLayoutGetPadding(_ygNode, edge); diff --git a/csharp/tests/Facebook.Yoga/YGAbsolutePositionTest.cs b/csharp/tests/Facebook.Yoga/YGAbsolutePositionTest.cs index 49f6605e..c9e25345 100644 --- a/csharp/tests/Facebook.Yoga/YGAbsolutePositionTest.cs +++ b/csharp/tests/Facebook.Yoga/YGAbsolutePositionTest.cs @@ -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); diff --git a/csharp/tests/Facebook.Yoga/YGAlignItemsTest.cs b/csharp/tests/Facebook.Yoga/YGAlignItemsTest.cs index 1ef9047d..01ff2c21 100644 --- a/csharp/tests/Facebook.Yoga/YGAlignItemsTest.cs +++ b/csharp/tests/Facebook.Yoga/YGAlignItemsTest.cs @@ -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); diff --git a/csharp/tests/Facebook.Yoga/YGBorderTest.cs b/csharp/tests/Facebook.Yoga/YGBorderTest.cs index 86029fca..d8efce38 100644 --- a/csharp/tests/Facebook.Yoga/YGBorderTest.cs +++ b/csharp/tests/Facebook.Yoga/YGBorderTest.cs @@ -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; diff --git a/csharp/tests/Facebook.Yoga/YGMarginTest.cs b/csharp/tests/Facebook.Yoga/YGMarginTest.cs index cc017ac4..dcf04ac2 100644 --- a/csharp/tests/Facebook.Yoga/YGMarginTest.cs +++ b/csharp/tests/Facebook.Yoga/YGMarginTest.cs @@ -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(); diff --git a/csharp/tests/Facebook.Yoga/YGPaddingTest.cs b/csharp/tests/Facebook.Yoga/YGPaddingTest.cs index b3f17014..bdf93edf 100644 --- a/csharp/tests/Facebook.Yoga/YGPaddingTest.cs +++ b/csharp/tests/Facebook.Yoga/YGPaddingTest.cs @@ -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); diff --git a/csharp/tests/Facebook.Yoga/YGPercentageTest.cs b/csharp/tests/Facebook.Yoga/YGPercentageTest.cs index 7c9bc423..7371cf43 100644 --- a/csharp/tests/Facebook.Yoga/YGPercentageTest.cs +++ b/csharp/tests/Facebook.Yoga/YGPercentageTest.cs @@ -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); diff --git a/csharp/tests/Facebook.Yoga/YGRoundingTest.cs b/csharp/tests/Facebook.Yoga/YGRoundingTest.cs index 2ed2c39d..dc68555a 100644 --- a/csharp/tests/Facebook.Yoga/YGRoundingTest.cs +++ b/csharp/tests/Facebook.Yoga/YGRoundingTest.cs @@ -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; diff --git a/csharp/tests/Facebook.Yoga/YogaNodeCreateTest.cs b/csharp/tests/Facebook.Yoga/YogaNodeCreateTest.cs deleted file mode 100644 index 74573a36..00000000 --- a/csharp/tests/Facebook.Yoga/YogaNodeCreateTest.cs +++ /dev/null @@ -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); - } - } -} diff --git a/csharp/tests/Facebook.Yoga/YogaNodeSpacingTest.cs b/csharp/tests/Facebook.Yoga/YogaNodeSpacingTest.cs new file mode 100644 index 00000000..d29b19e2 --- /dev/null +++ b/csharp/tests/Facebook.Yoga/YogaNodeSpacingTest.cs @@ -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); + } + } +} diff --git a/csharp/tests/Facebook.Yoga/YogaNodeTest.cs b/csharp/tests/Facebook.Yoga/YogaNodeTest.cs index a0fc5240..fb8ba9a6 100644 --- a/csharp/tests/Facebook.Yoga/YogaNodeTest.cs +++ b/csharp/tests/Facebook.Yoga/YogaNodeTest.cs @@ -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); } } } diff --git a/gentest/gentest-cs.js b/gentest/gentest-cs.js index 22ffa846..08b08588 100644 --- a/gentest/gentest-cs.js +++ b/gentest/gentest-cs.js @@ -102,12 +102,12 @@ CSEmitter.prototype = Object.create(Emitter.prototype, { YGDirectionLTR:{value:'YogaDirection.LTR'}, YGDirectionRTL:{value:'YogaDirection.RTL'}, - YGEdgeBottom:{value:'YogaEdge.Bottom'}, - YGEdgeEnd:{value:'YogaEdge.End'}, - YGEdgeLeft:{value:'YogaEdge.Left'}, - YGEdgeRight:{value:'YogaEdge.Right'}, - YGEdgeStart:{value:'YogaEdge.Start'}, - YGEdgeTop:{value:'YogaEdge.Top'}, + YGEdgeBottom:{value:'Bottom'}, + YGEdgeEnd:{value:'End'}, + YGEdgeLeft:{value:'Left'}, + YGEdgeRight:{value:'Right'}, + YGEdgeStart:{value:'Start'}, + YGEdgeTop:{value:'Top'}, YGFlexDirectionColumn:{value:'YogaFlexDirection.Column'}, YGFlexDirectionColumnReverse:{value:'YogaFlexDirection.ColumnReverse'}, @@ -169,7 +169,7 @@ CSEmitter.prototype = Object.create(Emitter.prototype, { }}, YGNodeStyleSetBorder:{value:function(nodeName, edge, value) { - this.push(nodeName + '.SetBorder(' + edge + ', ' + toValueCs(value) + ');'); + this.push(nodeName + '.Border' + edge + 'Width = ' + toValueCs(value) + ';'); }}, YGNodeStyleSetDirection:{value:function(nodeName, value) { @@ -205,7 +205,7 @@ CSEmitter.prototype = Object.create(Emitter.prototype, { }}, YGNodeStyleSetMargin:{value:function(nodeName, edge, value) { - this.push(nodeName + '.SetMargin(' + edge + ', ' + toCsUnitValue(value) + ');'); + this.push(nodeName + '.Margin' + edge + ' = ' + toCsUnitValue(value) + ';'); }}, YGNodeStyleSetMaxHeight:{value:function(nodeName, value) { @@ -229,11 +229,11 @@ CSEmitter.prototype = Object.create(Emitter.prototype, { }}, YGNodeStyleSetPadding:{value:function(nodeName, edge, value) { - this.push(nodeName + '.SetPadding(' + edge + ', ' + toCsUnitValue(value) + ');'); + this.push(nodeName + '.Padding' + edge + ' = ' + toCsUnitValue(value) + ';'); }}, YGNodeStyleSetPosition:{value:function(nodeName, edge, value) { - this.push(nodeName + '.SetPosition(' + edge + ', ' + toCsUnitValue(value) + ');'); + this.push(nodeName + '.' + edge + ' = ' + toCsUnitValue(value) + ';'); }}, YGNodeStyleSetPositionType:{value:function(nodeName, value) {