diff --git a/csharp/Facebook.Yoga/BaselineFunction.cs b/csharp/Facebook.Yoga/BaselineFunction.cs
new file mode 100644
index 00000000..cf055b19
--- /dev/null
+++ b/csharp/Facebook.Yoga/BaselineFunction.cs
@@ -0,0 +1,13 @@
+/**
+ * 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.
+ */
+
+namespace Facebook.Yoga
+{
+ public delegate float BaselineFunction(YogaNode node, float width, float height);
+}
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 5889d249..66fff377 100644
--- a/csharp/Facebook.Yoga/Facebook.Yoga.Shared.projitems
+++ b/csharp/Facebook.Yoga/Facebook.Yoga.Shared.projitems
@@ -9,12 +9,14 @@
Facebook.Yoga.Shared
+
+
@@ -27,6 +29,7 @@
+
diff --git a/csharp/Facebook.Yoga/Native.cs b/csharp/Facebook.Yoga/Native.cs
index b66cf8a6..248fc17f 100644
--- a/csharp/Facebook.Yoga/Native.cs
+++ b/csharp/Facebook.Yoga/Native.cs
@@ -104,8 +104,9 @@ namespace Facebook.Yoga
[MarshalAs(UnmanagedType.FunctionPtr)] YogaMeasureFunc measureFunc);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
- [return: MarshalAs(UnmanagedType.FunctionPtr)]
- public static extern YogaMeasureFunc YGNodeGetMeasureFunc(YGNodeHandle node);
+ public static extern void YGNodeSetBaselineFunc(
+ YGNodeHandle node,
+ [MarshalAs(UnmanagedType.FunctionPtr)] YogaBaselineFunc baselineFunc);
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern void YGNodeSetHasNewLayout(YGNodeHandle node, [MarshalAs(UnmanagedType.I1)] bool hasNewLayout);
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/YogaBaselineFunc.cs b/csharp/Facebook.Yoga/YogaBaselineFunc.cs
new file mode 100644
index 00000000..78575434
--- /dev/null
+++ b/csharp/Facebook.Yoga/YogaBaselineFunc.cs
@@ -0,0 +1,17 @@
+/**
+ * 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;
+using System.Runtime.InteropServices;
+
+namespace Facebook.Yoga
+{
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ public delegate float YogaBaselineFunc(IntPtr node, float width, float height);
+}
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 5732748b..112d2b3f 100644
--- a/csharp/Facebook.Yoga/YogaNode.cs
+++ b/csharp/Facebook.Yoga/YogaNode.cs
@@ -21,6 +21,8 @@ namespace Facebook.Yoga
private List _children;
private MeasureFunction _measureFunction;
private YogaMeasureFunc _ygMeasureFunc;
+ private BaselineFunction _baselineFunction;
+ private YogaBaselineFunc _ygBaselineFunc;
private object _data;
public YogaNode()
@@ -34,9 +36,16 @@ namespace Facebook.Yoga
}
}
+ public YogaNode(YogaNode srcNode)
+ : this()
+ {
+ CopyStyle(srcNode);
+ }
+
public void Reset()
{
_measureFunction = null;
+ _baselineFunction = null;
_data = null;
Native.YGNodeReset(_ygNode);
@@ -84,6 +93,14 @@ namespace Facebook.Yoga
}
}
+ public bool IsBaselineDefined
+ {
+ get
+ {
+ return _baselineFunction != null;
+ }
+ }
+
public void CopyStyle(YogaNode srcNode)
{
Native.YGNodeCopyStyle(_ygNode, srcNode._ygNode);
@@ -247,11 +264,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)
@@ -264,11 +283,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)
@@ -281,21 +302,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)
@@ -308,6 +333,7 @@ namespace Facebook.Yoga
}
}
+ [Obsolete("use LayoutPadding properties")]
public float GetLayoutPadding(YogaEdge edge)
{
return Native.YGNodeLayoutGetPadding(_ygNode, edge);
@@ -585,6 +611,13 @@ namespace Facebook.Yoga
Native.YGNodeSetMeasureFunc(_ygNode, _ygMeasureFunc);
}
+ public void SetBaselineFunction(BaselineFunction baselineFunction)
+ {
+ _baselineFunction = baselineFunction;
+ _ygBaselineFunc = baselineFunction != null ? BaselineInternal : (YogaBaselineFunc)null;
+ Native.YGNodeSetBaselineFunc(_ygNode, _ygBaselineFunc);
+ }
+
public void CalculateLayout()
{
Native.YGNodeCalculateLayout(
@@ -609,6 +642,16 @@ namespace Facebook.Yoga
return _measureFunction(this, width, widthMode, height, heightMode);
}
+ private float BaselineInternal(IntPtr node, float width, float height)
+ {
+ if (_baselineFunction == null)
+ {
+ throw new InvalidOperationException("Baseline function is not defined.");
+ }
+
+ return _baselineFunction(this, width, height);
+ }
+
public string Print(YogaPrintOptions options =
YogaPrintOptions.Layout|YogaPrintOptions.Style|YogaPrintOptions.Children)
{
diff --git a/csharp/Mac/.gitignore b/csharp/Mac/.gitignore
new file mode 100644
index 00000000..1cf1debb
--- /dev/null
+++ b/csharp/Mac/.gitignore
@@ -0,0 +1,2 @@
+libyoga.dylib
+*.userprefs
diff --git a/csharp/Mac/ApiDefinition.cs b/csharp/Mac/ApiDefinition.cs
new file mode 100644
index 00000000..9fec5cd6
--- /dev/null
+++ b/csharp/Mac/ApiDefinition.cs
@@ -0,0 +1,23 @@
+/**
+ * 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;
+
+using AppKit;
+using Foundation;
+using ObjCRuntime;
+using CoreGraphics;
+
+namespace Facebook.Yoga.Mac
+{
+ // Xamarin.Mac binding projects allow you to include native libraries inside C# DLLs for easy consumption
+ // later. However, the binding project build files currently assume you are binding some objective-c API
+ // and that you need an ApiDefinition.cs for that. yoga is all C APIs, so just include this "blank" file so
+ // the dylib gets packaged
+}
diff --git a/csharp/Mac/CustomBuildAction.targets b/csharp/Mac/CustomBuildAction.targets
new file mode 100644
index 00000000..e20e70b8
--- /dev/null
+++ b/csharp/Mac/CustomBuildAction.targets
@@ -0,0 +1,11 @@
+
+
+
+ CopyInNativeLib;$(CompileDependsOn)
+
+
+
+
+
+
+
diff --git a/csharp/Mac/Facebook.Yoga.Mac.Test/AppDelegate.cs b/csharp/Mac/Facebook.Yoga.Mac.Test/AppDelegate.cs
new file mode 100644
index 00000000..f6a46196
--- /dev/null
+++ b/csharp/Mac/Facebook.Yoga.Mac.Test/AppDelegate.cs
@@ -0,0 +1,30 @@
+/**
+ * Copyright 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the license found in the
+ * LICENSE-examples file in the root directory of this source tree.
+ */
+
+using AppKit;
+using Foundation;
+
+namespace Facebook.Yoga.Mac.Test
+{
+ [Register("AppDelegate")]
+ public class AppDelegate : NSApplicationDelegate
+ {
+ public AppDelegate()
+ {
+ }
+
+ public override void DidFinishLaunching(NSNotification notification)
+ {
+ }
+
+ public override void WillTerminate(NSNotification notification)
+ {
+ // Insert code here to tear down your application
+ }
+ }
+}
diff --git a/csharp/Mac/Facebook.Yoga.Mac.Test/Entitlements.plist b/csharp/Mac/Facebook.Yoga.Mac.Test/Entitlements.plist
new file mode 100644
index 00000000..9ae59937
--- /dev/null
+++ b/csharp/Mac/Facebook.Yoga.Mac.Test/Entitlements.plist
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/csharp/Mac/Facebook.Yoga.Mac.Test/Facebook.Yoga.Mac.Test.csproj b/csharp/Mac/Facebook.Yoga.Mac.Test/Facebook.Yoga.Mac.Test.csproj
new file mode 100644
index 00000000..70535e37
--- /dev/null
+++ b/csharp/Mac/Facebook.Yoga.Mac.Test/Facebook.Yoga.Mac.Test.csproj
@@ -0,0 +1,84 @@
+
+
+
+ Debug
+ AnyCPU
+ {64E0AB97-A904-4607-A535-EEA5A966C09E}
+ {A3F8F2AB-B479-4A4A-A458-A89E7DC349F1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ Exe
+ Facebook.Yoga.Mac.Test
+ Facebook.Yoga.Mac.Test
+ v2.0
+ Xamarin.Mac
+ Resources
+
+
+ true
+ full
+ false
+ bin\Debug
+ DEBUG;
+ prompt
+ 4
+ false
+ Mac Developer
+ false
+ false
+ false
+ true
+ true
+ true
+ HttpClientHandler
+ Default
+ None
+ x86_64
+
+
+ pdbonly
+ true
+ bin\Release
+
+ prompt
+ 4
+ false
+ true
+ false
+ true
+ true
+ true
+ SdkOnly
+ HttpClientHandler
+ Default
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ViewController.cs
+
+
+
+
+
+
+
+ {19A1C7D7-C9CC-476A-B604-DF6A3DE1BA71}
+ Facebook.Yoga.Mac
+
+
+
+
diff --git a/csharp/Mac/Facebook.Yoga.Mac.Test/Info.plist b/csharp/Mac/Facebook.Yoga.Mac.Test/Info.plist
new file mode 100644
index 00000000..7e955671
--- /dev/null
+++ b/csharp/Mac/Facebook.Yoga.Mac.Test/Info.plist
@@ -0,0 +1,30 @@
+
+
+
+
+ CFBundleName
+ Facebook.Yoga.Mac.Test
+ CFBundleIdentifier
+ com.companyname.facebook-yoga-mac-test
+ CFBundleShortVersionString
+ 1.0
+ CFBundleVersion
+ 1
+ LSMinimumSystemVersion
+ 10.11
+ CFBundleDevelopmentRegion
+ en
+ CFBundleInfoDictionaryVersion
+ 6.0
+ CFBundlePackageType
+ APPL
+ CFBundleSignature
+ ????
+ NSHumanReadableCopyright
+ ${AuthorCopyright}
+ NSPrincipalClass
+ NSApplication
+ NSMainStoryboardFile
+ Main
+
+
diff --git a/csharp/Mac/Facebook.Yoga.Mac.Test/Main.cs b/csharp/Mac/Facebook.Yoga.Mac.Test/Main.cs
new file mode 100644
index 00000000..97adb4db
--- /dev/null
+++ b/csharp/Mac/Facebook.Yoga.Mac.Test/Main.cs
@@ -0,0 +1,21 @@
+/**
+ * Copyright 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the license found in the
+ * LICENSE-examples file in the root directory of this source tree.
+ */
+
+using AppKit;
+
+namespace Facebook.Yoga.Mac.Test
+{
+ static class MainClass
+ {
+ static void Main(string[] args)
+ {
+ NSApplication.Init();
+ NSApplication.Main(args);
+ }
+ }
+}
diff --git a/csharp/Mac/Facebook.Yoga.Mac.Test/Main.storyboard b/csharp/Mac/Facebook.Yoga.Mac.Test/Main.storyboard
new file mode 100644
index 00000000..1d8f728d
--- /dev/null
+++ b/csharp/Mac/Facebook.Yoga.Mac.Test/Main.storyboard
@@ -0,0 +1,681 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/csharp/Mac/Facebook.Yoga.Mac.Test/ViewController.cs b/csharp/Mac/Facebook.Yoga.Mac.Test/ViewController.cs
new file mode 100644
index 00000000..e802aa4e
--- /dev/null
+++ b/csharp/Mac/Facebook.Yoga.Mac.Test/ViewController.cs
@@ -0,0 +1,137 @@
+/**
+ * Copyright 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the license found in the
+ * LICENSE-examples file in the root directory of this source tree.
+ */
+
+//#define DEBUG_LAYOUT
+using System;
+
+using AppKit;
+using Foundation;
+using CoreGraphics;
+
+namespace Facebook.Yoga.Mac.Test
+{
+ public static class NSViewYogaExtensions
+ {
+ public static void ApplyYogaLayout (this NSView view, YogaNode n, bool root = true)
+ {
+#if DEBUG_LAYOUT
+ Console.WriteLine ($"ApplyYogaLayout {view.ToolTip}, {n.LayoutX}, {n.LayoutY}, {n.LayoutWidth}, {n.LayoutHeight}");
+#endif
+
+ // A bit of gross special casing
+ // This really should mostly go away if/when the UIView+Yoga.m magic gets ported to AppKit
+ if (root)
+ view.Frame = new CGRect (n.LayoutX, n.LayoutY, n.LayoutWidth, n.LayoutHeight);
+#if DEBUG_LAYOUT
+ Console.WriteLine ($"Setting {view.ToolTip} frame to {view.Frame}");
+#endif
+
+ // This assumes your YogaNode and NSView children were inserted in same order
+ for (int i = 0; i < n.Count; ++i) {
+ YogaNode childNode = n[i];
+ // Cocoa coord space is from bottom left not top left
+ view.Subviews[i].Frame = new CGRect (childNode.LayoutX, n.LayoutHeight - childNode.LayoutY - childNode.LayoutHeight, childNode.LayoutWidth, childNode.LayoutHeight);
+#if DEBUG_LAYOUT
+ Console.WriteLine ($"Setting {view.Subviews[i].ToolTip} frame to {view.Subviews[i].Frame}");
+#endif
+ if (childNode.Count > 0){
+#if DEBUG_LAYOUT
+ Console.WriteLine ($"Calling ApplyYogaLayout recursively on {view.Subviews[i].ToolTip}");
+#endif
+ ApplyYogaLayout (view.Subviews[i], childNode, false);
+ }
+ }
+ }
+ }
+
+ public partial class ViewController : NSViewController
+ {
+ public ViewController(IntPtr handle) : base(handle)
+ {
+ }
+
+ public override void ViewDidLoad()
+ {
+ base.ViewDidLoad ();
+
+ NSImage image = NSImage.ImageNamed (NSImageName.TrashFull);
+
+ NSView root = CreateViewHierarchy (image);
+ var rootNode = CalculateLayout (View.Frame, image.Size);
+
+ root.ApplyYogaLayout (rootNode);
+
+ View.AddSubview (root);
+ }
+
+ static NSView CreateViewHierarchy (NSImage image)
+ {
+ var root = new NSView () {
+ WantsLayer = true,
+ ToolTip = "Root"
+ };
+ root.Layer.BackgroundColor = NSColor.Red.CGColor;
+
+ NSView child1 = new NSView () {
+ WantsLayer = true,
+ ToolTip = "Child 1"
+ };
+ child1.Layer.BackgroundColor = NSColor.Blue.CGColor;
+
+ NSView child2 = new NSView () {
+ WantsLayer = true,
+ ToolTip = "Child 2"
+ };
+ child2.Layer.BackgroundColor = NSColor.Green.CGColor;
+
+ NSView child3 = new NSView () {
+ WantsLayer = true,
+ ToolTip = "Child 3"
+ };
+ child3.Layer.BackgroundColor = NSColor.Yellow.CGColor;
+
+ root.AddSubview (child1);
+ root.AddSubview (child2);
+ child2.AddSubview (child3);
+
+ return root;
+ }
+
+ static YogaNode CalculateLayout (CGRect rootFrame, CGSize imageSize)
+ {
+ var rootNode = new YogaNode () {
+ Width = (float)rootFrame.Width,
+ Height = (float)rootFrame.Height,
+ AlignItems = YogaAlign.Center,
+ JustifyContent = YogaJustify.Center
+ };
+
+ var child1Node = new YogaNode () {
+ Width = 100,
+ Height = 100
+ };
+
+ var child2Node = new YogaNode () {
+ Width = 200,
+ Height = 100
+ };
+
+ var child3Node = new YogaNode () {
+ Width = 100,
+ Height = 100
+ };
+
+ rootNode.Insert (0, child1Node);
+ rootNode.Insert (1, child2Node);
+ child2Node.Insert (0, child3Node);
+ rootNode.CalculateLayout ();
+
+ return rootNode;
+ }
+ }
+}
diff --git a/csharp/Mac/Facebook.Yoga.Mac.Test/ViewController.designer.cs b/csharp/Mac/Facebook.Yoga.Mac.Test/ViewController.designer.cs
new file mode 100644
index 00000000..1cf1e327
--- /dev/null
+++ b/csharp/Mac/Facebook.Yoga.Mac.Test/ViewController.designer.cs
@@ -0,0 +1,18 @@
+// WARNING
+//
+// This file has been generated automatically by Xamarin Studio to store outlets and
+// actions made in the UI designer. If it is removed, they will be lost.
+// Manual changes to this file may not be handled correctly.
+//
+using Foundation;
+
+namespace Facebook.Yoga.Mac.Test
+{
+ [Register("ViewController")]
+ partial class ViewController
+ {
+ void ReleaseDesignerOutlets()
+ {
+ }
+ }
+}
diff --git a/csharp/Mac/Facebook.Yoga.Mac.csproj b/csharp/Mac/Facebook.Yoga.Mac.csproj
new file mode 100644
index 00000000..63dcfe16
--- /dev/null
+++ b/csharp/Mac/Facebook.Yoga.Mac.csproj
@@ -0,0 +1,51 @@
+
+
+
+ Debug
+ AnyCPU
+ {19A1C7D7-C9CC-476A-B604-DF6A3DE1BA71}
+ {810C163F-4746-4721-8B8E-88A3673A62EA};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ Library
+ Facebook.Yoga.Mac
+ Facebook.Yoga.Mac
+ Resources
+
+
+ true
+ full
+ false
+ bin\Debug
+ __UNIFIED__;DEBUG;MONOMAC
+ prompt
+ 4
+ false
+
+
+ true
+ bin\Release
+ __UNIFIED__;MONOMAC
+ prompt
+ 4
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Dynamic
+ False
+
+
+
+
+
+
diff --git a/csharp/Mac/Facebook.Yoga.Mac.sln b/csharp/Mac/Facebook.Yoga.Mac.sln
new file mode 100644
index 00000000..c99766c6
--- /dev/null
+++ b/csharp/Mac/Facebook.Yoga.Mac.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2012
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Facebook.Yoga.Mac.Test", "Facebook.Yoga.Mac.Test\Facebook.Yoga.Mac.Test.csproj", "{64E0AB97-A904-4607-A535-EEA5A966C09E}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Facebook.Yoga.Mac", "Facebook.Yoga.Mac.csproj", "{19A1C7D7-C9CC-476A-B604-DF6A3DE1BA71}"
+EndProject
+Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Facebook.Yoga.Shared", "..\Facebook.Yoga\Facebook.Yoga.Shared.shproj", "{91C42D32-291D-4B72-90B4-551663D60B8B}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {64E0AB97-A904-4607-A535-EEA5A966C09E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {64E0AB97-A904-4607-A535-EEA5A966C09E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {64E0AB97-A904-4607-A535-EEA5A966C09E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {64E0AB97-A904-4607-A535-EEA5A966C09E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {19A1C7D7-C9CC-476A-B604-DF6A3DE1BA71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {19A1C7D7-C9CC-476A-B604-DF6A3DE1BA71}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {19A1C7D7-C9CC-476A-B604-DF6A3DE1BA71}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {19A1C7D7-C9CC-476A-B604-DF6A3DE1BA71}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+EndGlobal
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 9979f091..69aa0bf3 100644
--- a/csharp/tests/Facebook.Yoga/YogaNodeTest.cs
+++ b/csharp/tests/Facebook.Yoga/YogaNodeTest.cs
@@ -197,6 +197,54 @@ namespace Facebook.Yoga
});
}
+ [Test]
+ public void TestBaselineFunc()
+ {
+ YogaNode node = new YogaNode();
+ node.Height = 200;
+ node.FlexDirection = YogaFlexDirection.Row;
+ node.AlignItems = YogaAlign.Baseline;
+
+ YogaNode child0 = new YogaNode();
+ child0.Width = 100;
+ child0.Height = 110;
+ child0.SetBaselineFunction((_, width, height) => {
+ Assert.AreEqual(100, width);
+ Assert.AreEqual(110, height);
+ return 65;
+ });
+ node.Insert(0, child0);
+
+ YogaNode child1 = new YogaNode();
+ child1.Width = 100;
+ child1.Height = 110;
+ child1.SetBaselineFunction((_, width, height) => {
+ Assert.AreEqual(100, width);
+ Assert.AreEqual(110, height);
+ return 80;
+ });
+ node.Insert(1, child1);
+
+ YogaNode child2 = new YogaNode();
+ child2.Width = 100;
+ child2.Height = 110;
+ child2.SetBaselineFunction((_, width, height) => {
+ Assert.AreEqual(100, width);
+ Assert.AreEqual(110, height);
+ return 88;
+ });
+ node.Insert(2, child2);
+
+ node.CalculateLayout();
+
+ Assert.AreEqual(0, child0.LayoutX);
+ Assert.AreEqual(23, child0.LayoutY);
+ Assert.AreEqual(100, child1.LayoutX);
+ Assert.AreEqual(8, child1.LayoutY);
+ Assert.AreEqual(200, child2.LayoutX);
+ Assert.AreEqual(0, child2.LayoutY);
+ }
+
[Test]
public void TestPrint()
{
@@ -228,6 +276,36 @@ namespace Facebook.Yoga
Assert.AreEqual(100.Px(), node0.MaxHeight);
}
+ [Test]
+ public void TestCopyConstructor()
+ {
+ YogaNode node0 = new YogaNode();
+ node0.MaxWidth = 80;
+
+ YogaNode node1 = new YogaNode(node0);
+ Assert.AreEqual(80.Px(), node1.MaxWidth);
+
+ YogaNode node2 = new YogaNode(node1)
+ {
+ MaxHeight = 90,
+ };
+ Assert.AreEqual(80.Px(), node2.MaxWidth);
+ Assert.AreEqual(90.Px(), node2.MaxHeight);
+
+ YogaNode node3 = new YogaNode(node0)
+ {
+ MaxWidth = 100,
+ };
+ Assert.AreEqual(100.Px(), node3.MaxWidth);
+
+ YogaNode node4 = new YogaNode(node2)
+ {
+ MaxWidth = 100,
+ };
+ Assert.AreEqual(100.Px(), node4.MaxWidth);
+ Assert.AreEqual(90.Px(), node4.MaxHeight);
+ }
+
private void ForceGC()
{
GC.Collect(GC.MaxGeneration);
@@ -361,16 +439,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) {
diff --git a/yoga/YGMacros.h b/yoga/YGMacros.h
index d6724272..39e21b78 100644
--- a/yoga/YGMacros.h
+++ b/yoga/YGMacros.h
@@ -41,18 +41,12 @@
}
#endif
-#ifndef YG_ENUM_BEGIN
-#ifndef NS_ENUM
-#define YG_ENUM_BEGIN(name) enum name
-#else
-#define YG_ENUM_BEGIN(name) NS_ENUM(NSInteger, name)
-#endif
-#endif
-
-#ifndef YG_ENUM_END
-#ifndef NS_ENUM
-#define YG_ENUM_END(name) name
-#else
+#ifdef NS_ENUM
+// Cannot use NSInteger as NSInteger has a different size than int (which is the default type of a enum).
+// Therefor when linking the Yoga C library into obj-c the header is a missmatch for the Yoga ABI.
+#define YG_ENUM_BEGIN(name) NS_ENUM(int, name)
#define YG_ENUM_END(name)
-#endif
+#else
+#define YG_ENUM_BEGIN(name) enum name
+#define YG_ENUM_END(name) name
#endif