Add feature to use percentage as value unit

Summary:
Adds the feature to use percentage as a value unit.

You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.

I did some benchmarks:

```
Without Percentage Feature - Release x86:

Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms

Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms

With Percentage Feature - Release x86:

Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258

Reviewed By: dshahidehpour

Differential Revision: D4361945

Pulled By: emilsjolander

fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
This commit is contained in:
Lukas Woehrl
2017-01-02 05:20:37 -08:00
committed by Facebook Github Bot
parent 6f462a72bf
commit a85bd4ad2a
48 changed files with 4948 additions and 1209 deletions

6
.gitignore vendored
View File

@@ -9,6 +9,12 @@
# Visual studio code # Visual studio code
.vscode .vscode
*.pdb
*.tlog
*.obj
*.pch
*.log
*.orig
# Xcode # Xcode
## Build generated ## Build generated

View File

@@ -9,6 +9,12 @@
# Visual studio code # Visual studio code
.vscode .vscode
*.pdb
*.tlog
*.obj
*.pch
*.log
*.orig
# Xcode # Xcode
## Build generated ## Build generated

View File

@@ -0,0 +1,31 @@
/**
* 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 class Border
{
public float? Top;
public float? Bottom;
public float? Left;
public float? Right;
public Border(
float? top = null,
float? bottom = null,
float? left = null,
float? right = null)
{
Top = top;
Bottom = bottom;
Left = left;
Right = right;
}
}
}

View File

@@ -191,43 +191,64 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetFlexBasis(YGNodeHandle node, float flexBasis); public static extern void YGNodeStyleSetFlexBasis(YGNodeHandle node, float flexBasis);
[DllImport(DllName)] [DllImport(DllName)]
public static extern float YGNodeStyleGetFlexBasis(YGNodeHandle node); public static extern void YGNodeStyleSetFlexBasisPercent(YGNodeHandle node, float flexBasis);
[DllImport(DllName)]
public static extern YogaValue YGNodeStyleGetFlexBasis(YGNodeHandle node);
[DllImport(DllName)] [DllImport(DllName)]
public static extern void YGNodeStyleSetWidth(YGNodeHandle node, float width); public static extern void YGNodeStyleSetWidth(YGNodeHandle node, float width);
[DllImport(DllName)] [DllImport(DllName)]
public static extern float YGNodeStyleGetWidth(YGNodeHandle node); public static extern void YGNodeStyleSetWidthPercent(YGNodeHandle node, float width);
[DllImport(DllName)]
public static extern YogaValue YGNodeStyleGetWidth(YGNodeHandle node);
[DllImport(DllName)] [DllImport(DllName)]
public static extern void YGNodeStyleSetHeight(YGNodeHandle node, float height); public static extern void YGNodeStyleSetHeight(YGNodeHandle node, float height);
[DllImport(DllName)] [DllImport(DllName)]
public static extern float YGNodeStyleGetHeight(YGNodeHandle node); public static extern void YGNodeStyleSetHeightPercent(YGNodeHandle node, float height);
[DllImport(DllName)]
public static extern YogaValue YGNodeStyleGetHeight(YGNodeHandle node);
[DllImport(DllName)] [DllImport(DllName)]
public static extern void YGNodeStyleSetMinWidth(YGNodeHandle node, float minWidth); public static extern void YGNodeStyleSetMinWidth(YGNodeHandle node, float minWidth);
[DllImport(DllName)] [DllImport(DllName)]
public static extern float YGNodeStyleGetMinWidth(YGNodeHandle node); public static extern void YGNodeStyleSetMinWidthPercent(YGNodeHandle node, float minWidth);
[DllImport(DllName)]
public static extern YogaValue YGNodeStyleGetMinWidth(YGNodeHandle node);
[DllImport(DllName)] [DllImport(DllName)]
public static extern void YGNodeStyleSetMinHeight(YGNodeHandle node, float minHeight); public static extern void YGNodeStyleSetMinHeight(YGNodeHandle node, float minHeight);
[DllImport(DllName)] [DllImport(DllName)]
public static extern float YGNodeStyleGetMinHeight(YGNodeHandle node); public static extern void YGNodeStyleSetMinHeightPercent(YGNodeHandle node, float minHeight);
[DllImport(DllName)]
public static extern YogaValue YGNodeStyleGetMinHeight(YGNodeHandle node);
[DllImport(DllName)] [DllImport(DllName)]
public static extern void YGNodeStyleSetMaxWidth(YGNodeHandle node, float maxWidth); public static extern void YGNodeStyleSetMaxWidth(YGNodeHandle node, float maxWidth);
[DllImport(DllName)] [DllImport(DllName)]
public static extern float YGNodeStyleGetMaxWidth(YGNodeHandle node); public static extern void YGNodeStyleSetMaxWidthPercent(YGNodeHandle node, float maxWidth);
[DllImport(DllName)]
public static extern YogaValue YGNodeStyleGetMaxWidth(YGNodeHandle node);
[DllImport(DllName)] [DllImport(DllName)]
public static extern void YGNodeStyleSetMaxHeight(YGNodeHandle node, float maxHeight); public static extern void YGNodeStyleSetMaxHeight(YGNodeHandle node, float maxHeight);
[DllImport(DllName)] [DllImport(DllName)]
public static extern float YGNodeStyleGetMaxHeight(YGNodeHandle node); public static extern void YGNodeStyleSetMaxHeightPercent(YGNodeHandle node, float maxHeight);
[DllImport(DllName)]
public static extern YogaValue YGNodeStyleGetMaxHeight(YGNodeHandle node);
[DllImport(DllName)] [DllImport(DllName)]
public static extern void YGNodeStyleSetAspectRatio(YGNodeHandle node, float aspectRatio); public static extern void YGNodeStyleSetAspectRatio(YGNodeHandle node, float aspectRatio);
@@ -243,19 +264,28 @@ namespace Facebook.Yoga
public static extern void YGNodeStyleSetPosition(YGNodeHandle node, YogaEdge edge, float position); public static extern void YGNodeStyleSetPosition(YGNodeHandle node, YogaEdge edge, float position);
[DllImport(DllName)] [DllImport(DllName)]
public static extern float YGNodeStyleGetPosition(YGNodeHandle node, YogaEdge edge); public static extern void YGNodeStyleSetPositionPercent(YGNodeHandle node, YogaEdge edge, float position);
[DllImport(DllName)]
public static extern YogaValue YGNodeStyleGetPosition(YGNodeHandle node, YogaEdge edge);
[DllImport(DllName)] [DllImport(DllName)]
public static extern void YGNodeStyleSetMargin(YGNodeHandle node, YogaEdge edge, float margin); public static extern void YGNodeStyleSetMargin(YGNodeHandle node, YogaEdge edge, float margin);
[DllImport(DllName)] [DllImport(DllName)]
public static extern float YGNodeStyleGetMargin(YGNodeHandle node, YogaEdge edge); public static extern void YGNodeStyleSetMarginPercent(YGNodeHandle node, YogaEdge edge, float margin);
[DllImport(DllName)]
public static extern YogaValue YGNodeStyleGetMargin(YGNodeHandle node, YogaEdge edge);
[DllImport(DllName)] [DllImport(DllName)]
public static extern void YGNodeStyleSetPadding(YGNodeHandle node, YogaEdge edge, float padding); public static extern void YGNodeStyleSetPadding(YGNodeHandle node, YogaEdge edge, float padding);
[DllImport(DllName)] [DllImport(DllName)]
public static extern float YGNodeStyleGetPadding(YGNodeHandle node, YogaEdge edge); public static extern void YGNodeStyleSetPaddingPercent(YGNodeHandle node, YogaEdge edge, float padding);
[DllImport(DllName)]
public static extern YogaValue YGNodeStyleGetPadding(YGNodeHandle node, YogaEdge edge);
[DllImport(DllName)] [DllImport(DllName)]
public static extern void YGNodeStyleSetBorder(YGNodeHandle node, YogaEdge edge, float border); public static extern void YGNodeStyleSetBorder(YGNodeHandle node, YogaEdge edge, float border);

View File

@@ -11,16 +11,16 @@ namespace Facebook.Yoga
{ {
public class Spacing public class Spacing
{ {
public float? Top; public YogaValue? Top;
public float? Bottom; public YogaValue? Bottom;
public float? Left; public YogaValue? Left;
public float? Right; public YogaValue? Right;
public Spacing( public Spacing(
float? top = null, YogaValue? top = null,
float? bottom = null, YogaValue? bottom = null,
float? left = null, YogaValue? left = null,
float? right = null) YogaValue? right = null)
{ {
Top = top; Top = top;
Bottom = bottom; Bottom = bottom;

View File

@@ -17,5 +17,10 @@ namespace Facebook.Yoga
{ {
return float.IsNaN(value); return float.IsNaN(value);
} }
public static bool IsUndefined(YogaValue value)
{
return value.Unit == YogaUnit.Undefined;
}
} }
} }

View File

@@ -26,17 +26,17 @@ namespace Facebook.Yoga
float? flex = null, float? flex = null,
float? flexGrow = null, float? flexGrow = null,
float? flexShrink = null, float? flexShrink = null,
float? flexBasis = null, YogaValue? flexBasis = null,
Spacing position = null, Spacing position = null,
Spacing margin = null, Spacing margin = null,
Spacing padding = null, Spacing padding = null,
Spacing border = null, Border border = null,
float? width = null, YogaValue? width = null,
float? height = null, YogaValue? height = null,
float? maxWidth = null, YogaValue? maxWidth = null,
float? maxHeight = null, YogaValue? maxHeight = null,
float? minWidth = null, YogaValue? minWidth = null,
float? minHeight = null) YogaValue? minHeight = null)
{ {
YogaNode node = new YogaNode(); YogaNode node = new YogaNode();

View File

@@ -10,7 +10,6 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text; using System.Text;
namespace Facebook.Yoga namespace Facebook.Yoga
@@ -228,7 +227,7 @@ namespace Facebook.Yoga
} }
} }
public float FlexBasis public YogaValue FlexBasis
{ {
get get
{ {
@@ -237,28 +236,49 @@ namespace Facebook.Yoga
set set
{ {
Native.YGNodeStyleSetFlexBasis(_ygNode, value); if (value.Unit == YogaUnit.Percent)
{
Native.YGNodeStyleSetFlexBasisPercent(_ygNode, value.Value);
}
else
{
Native.YGNodeStyleSetFlexBasis(_ygNode, value.Value);
}
} }
} }
public float GetMargin(YogaEdge edge) public YogaValue GetMargin(YogaEdge edge)
{ {
return Native.YGNodeStyleGetMargin(_ygNode, edge); return Native.YGNodeStyleGetMargin(_ygNode, edge);
} }
public void SetMargin(YogaEdge edge, float value) public void SetMargin(YogaEdge edge, YogaValue value)
{ {
Native.YGNodeStyleSetMargin(_ygNode, edge, value); if (value.Unit == YogaUnit.Percent)
{
Native.YGNodeStyleSetMarginPercent(_ygNode, edge, value.Value);
}
else
{
Native.YGNodeStyleSetMargin(_ygNode, edge, value.Value);
}
} }
public float GetPadding(YogaEdge edge) public YogaValue GetPadding(YogaEdge edge)
{ {
return Native.YGNodeStyleGetPadding(_ygNode, edge); return Native.YGNodeStyleGetPadding(_ygNode, edge);
} }
public void SetPadding(YogaEdge edge, float padding) public void SetPadding(YogaEdge edge, YogaValue value)
{ {
Native.YGNodeStyleSetPadding(_ygNode, edge, padding); if (value.Unit == YogaUnit.Percent)
{
Native.YGNodeStyleSetPaddingPercent(_ygNode, edge, value.Value);
}
else
{
Native.YGNodeStyleSetPadding(_ygNode, edge, value.Value);
}
} }
public float GetBorder(YogaEdge edge) public float GetBorder(YogaEdge edge)
@@ -271,17 +291,24 @@ namespace Facebook.Yoga
Native.YGNodeStyleSetBorder(_ygNode, edge, border); Native.YGNodeStyleSetBorder(_ygNode, edge, border);
} }
public float GetPosition(YogaEdge edge) public YogaValue GetPosition(YogaEdge edge)
{ {
return Native.YGNodeStyleGetPosition(_ygNode, edge); return Native.YGNodeStyleGetPosition(_ygNode, edge);
} }
public void SetPosition(YogaEdge edge, float position) public void SetPosition(YogaEdge edge, YogaValue value)
{ {
Native.YGNodeStyleSetPosition(_ygNode, edge, position); if (value.Unit == YogaUnit.Percent)
{
Native.YGNodeStyleSetPositionPercent(_ygNode, edge, value.Value);
}
else
{
Native.YGNodeStyleSetPosition(_ygNode, edge, value.Value);
}
} }
public float Width public YogaValue Width
{ {
get get
{ {
@@ -290,11 +317,18 @@ namespace Facebook.Yoga
set set
{ {
Native.YGNodeStyleSetWidth(_ygNode, value); if (value.Unit == YogaUnit.Percent)
{
Native.YGNodeStyleSetWidthPercent(_ygNode, value.Value);
}
else
{
Native.YGNodeStyleSetWidth(_ygNode, value.Value);
}
} }
} }
public float Height public YogaValue Height
{ {
get get
{ {
@@ -303,11 +337,18 @@ namespace Facebook.Yoga
set set
{ {
Native.YGNodeStyleSetHeight(_ygNode, value); if (value.Unit == YogaUnit.Percent)
{
Native.YGNodeStyleSetHeightPercent(_ygNode, value.Value);
}
else
{
Native.YGNodeStyleSetHeight(_ygNode, value.Value);
}
} }
} }
public float MaxWidth public YogaValue MaxWidth
{ {
get get
{ {
@@ -316,11 +357,18 @@ namespace Facebook.Yoga
set set
{ {
Native.YGNodeStyleSetMaxWidth(_ygNode, value); if (value.Unit == YogaUnit.Percent)
{
Native.YGNodeStyleSetMaxWidthPercent(_ygNode, value.Value);
}
else
{
Native.YGNodeStyleSetMaxWidth(_ygNode, value.Value);
}
} }
} }
public float MaxHeight public YogaValue MaxHeight
{ {
get get
{ {
@@ -329,11 +377,18 @@ namespace Facebook.Yoga
set set
{ {
Native.YGNodeStyleSetMaxHeight(_ygNode, value); if (value.Unit == YogaUnit.Percent)
{
Native.YGNodeStyleSetMaxHeightPercent(_ygNode, value.Value);
}
else
{
Native.YGNodeStyleSetMaxHeight(_ygNode, value.Value);
}
} }
} }
public float MinWidth public YogaValue MinWidth
{ {
get get
{ {
@@ -342,11 +397,18 @@ namespace Facebook.Yoga
set set
{ {
Native.YGNodeStyleSetMinWidth(_ygNode, value); if (value.Unit == YogaUnit.Percent)
{
Native.YGNodeStyleSetMinWidthPercent(_ygNode, value.Value);
}
else
{
Native.YGNodeStyleSetMinWidth(_ygNode, value.Value);
}
} }
} }
public float MinHeight public YogaValue MinHeight
{ {
get get
{ {
@@ -355,7 +417,14 @@ namespace Facebook.Yoga
set set
{ {
Native.YGNodeStyleSetMinHeight(_ygNode, value); if (value.Unit == YogaUnit.Percent)
{
Native.YGNodeStyleSetMinHeightPercent(_ygNode, value.Value);
}
else
{
Native.YGNodeStyleSetMinHeight(_ygNode, value.Value);
}
} }
} }

View File

@@ -0,0 +1,18 @@
/**
* 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 enum YogaUnit
{
Undefined,
Pixel,
Percent,
}
}

View File

@@ -0,0 +1,74 @@
/**
* 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.Runtime.InteropServices;
namespace Facebook.Yoga
{
[StructLayout(LayoutKind.Sequential)]
public struct YogaValue
{
private float value;
private YogaUnit unit;
public YogaUnit Unit => unit;
public float Value => value;
public static YogaValue Pixel(float value)
{
return new YogaValue
{
value = value,
unit = YogaConstants.IsUndefined(value) ? YogaUnit.Undefined : YogaUnit.Pixel
};
}
public bool Equals(YogaValue other)
{
return Unit == other.Unit && (Value.Equals(other.Value) || Unit == YogaUnit.Undefined);
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
return obj is YogaValue && Equals((YogaValue) obj);
}
public override int GetHashCode()
{
unchecked
{
return (Value.GetHashCode() * 397) ^ (int) Unit;
}
}
public static YogaValue Undefined()
{
return new YogaValue
{
value = YogaConstants.Undefined,
unit = YogaUnit.Undefined
};
}
public static YogaValue Percent(float value)
{
return new YogaValue
{
value = value,
unit = YogaConstants.IsUndefined(value) ? YogaUnit.Undefined : YogaUnit.Percent
};
}
public static implicit operator YogaValue(float pixelValue)
{
return Pixel(pixelValue);
}
}
}

View File

@@ -0,0 +1,34 @@
/**
* 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 static class YogaValueExtensions
{
public static YogaValue Percent(this float value)
{
return YogaValue.Percent(value);
}
public static YogaValue Px(this float value)
{
return YogaValue.Pixel(value);
}
public static YogaValue Percent(this int value)
{
return YogaValue.Percent(value);
}
public static YogaValue Px(this int value)
{
return YogaValue.Pixel(value);
}
}
}

View File

@@ -21,15 +21,15 @@ namespace Facebook.Yoga
public void Test_absolute_layout_width_height_start_top() public void Test_absolute_layout_width_height_start_top()
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.PositionType = YogaPositionType.Absolute; root_child0.PositionType = YogaPositionType.Absolute;
root_child0.SetPosition(YogaEdge.Start, 10f); root_child0.SetPosition(YogaEdge.Start, 10);
root_child0.SetPosition(YogaEdge.Top, 10f); root_child0.SetPosition(YogaEdge.Top, 10);
root_child0.Width = 10f; root_child0.Width = 10;
root_child0.Height = 10f; root_child0.Height = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -62,15 +62,15 @@ namespace Facebook.Yoga
public void Test_absolute_layout_width_height_end_bottom() public void Test_absolute_layout_width_height_end_bottom()
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.PositionType = YogaPositionType.Absolute; root_child0.PositionType = YogaPositionType.Absolute;
root_child0.SetPosition(YogaEdge.End, 10f); root_child0.SetPosition(YogaEdge.End, 10);
root_child0.SetPosition(YogaEdge.Bottom, 10f); root_child0.SetPosition(YogaEdge.Bottom, 10);
root_child0.Width = 10f; root_child0.Width = 10;
root_child0.Height = 10f; root_child0.Height = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -103,15 +103,15 @@ namespace Facebook.Yoga
public void Test_absolute_layout_start_top_end_bottom() public void Test_absolute_layout_start_top_end_bottom()
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.PositionType = YogaPositionType.Absolute; root_child0.PositionType = YogaPositionType.Absolute;
root_child0.SetPosition(YogaEdge.Start, 10f); root_child0.SetPosition(YogaEdge.Start, 10);
root_child0.SetPosition(YogaEdge.Top, 10f); root_child0.SetPosition(YogaEdge.Top, 10);
root_child0.SetPosition(YogaEdge.End, 10f); root_child0.SetPosition(YogaEdge.End, 10);
root_child0.SetPosition(YogaEdge.Bottom, 10f); root_child0.SetPosition(YogaEdge.Bottom, 10);
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -144,17 +144,17 @@ namespace Facebook.Yoga
public void Test_absolute_layout_width_height_start_top_end_bottom() public void Test_absolute_layout_width_height_start_top_end_bottom()
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.PositionType = YogaPositionType.Absolute; root_child0.PositionType = YogaPositionType.Absolute;
root_child0.SetPosition(YogaEdge.Start, 10f); root_child0.SetPosition(YogaEdge.Start, 10);
root_child0.SetPosition(YogaEdge.Top, 10f); root_child0.SetPosition(YogaEdge.Top, 10);
root_child0.SetPosition(YogaEdge.End, 10f); root_child0.SetPosition(YogaEdge.End, 10);
root_child0.SetPosition(YogaEdge.Bottom, 10f); root_child0.SetPosition(YogaEdge.Bottom, 10);
root_child0.Width = 10f; root_child0.Width = 10;
root_child0.Height = 10f; root_child0.Height = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -189,18 +189,18 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row; root.FlexDirection = YogaFlexDirection.Row;
root.Overflow = YogaOverflow.Hidden; root.Overflow = YogaOverflow.Hidden;
root.Width = 50f; root.Width = 50;
root.Height = 50f; root.Height = 50;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.PositionType = YogaPositionType.Absolute; root_child0.PositionType = YogaPositionType.Absolute;
root_child0.SetPosition(YogaEdge.Start, 0f); root_child0.SetPosition(YogaEdge.Start, 0);
root_child0.SetPosition(YogaEdge.Top, 0f); root_child0.SetPosition(YogaEdge.Top, 0);
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode(); YogaNode root_child0_child0 = new YogaNode();
root_child0_child0.Width = 100f; root_child0_child0.Width = 100;
root_child0_child0.Height = 100f; root_child0_child0.Height = 100;
root_child0.Insert(0, root_child0_child0); root_child0.Insert(0, root_child0_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -243,35 +243,35 @@ namespace Facebook.Yoga
public void Test_absolute_layout_within_border() public void Test_absolute_layout_within_border()
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.SetMargin(YogaEdge.Left, 10f); root.SetMargin(YogaEdge.Left, 10);
root.SetMargin(YogaEdge.Top, 10f); root.SetMargin(YogaEdge.Top, 10);
root.SetMargin(YogaEdge.Right, 10f); root.SetMargin(YogaEdge.Right, 10);
root.SetMargin(YogaEdge.Bottom, 10f); root.SetMargin(YogaEdge.Bottom, 10);
root.SetPadding(YogaEdge.Left, 10f); root.SetPadding(YogaEdge.Left, 10);
root.SetPadding(YogaEdge.Top, 10f); root.SetPadding(YogaEdge.Top, 10);
root.SetPadding(YogaEdge.Right, 10f); root.SetPadding(YogaEdge.Right, 10);
root.SetPadding(YogaEdge.Bottom, 10f); root.SetPadding(YogaEdge.Bottom, 10);
root.SetBorder(YogaEdge.Left, 10f); root.SetBorder(YogaEdge.Left, 10);
root.SetBorder(YogaEdge.Top, 10f); root.SetBorder(YogaEdge.Top, 10);
root.SetBorder(YogaEdge.Right, 10f); root.SetBorder(YogaEdge.Right, 10);
root.SetBorder(YogaEdge.Bottom, 10f); root.SetBorder(YogaEdge.Bottom, 10);
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.PositionType = YogaPositionType.Absolute; root_child0.PositionType = YogaPositionType.Absolute;
root_child0.SetPosition(YogaEdge.Left, 0f); root_child0.SetPosition(YogaEdge.Left, 0);
root_child0.SetPosition(YogaEdge.Top, 0f); root_child0.SetPosition(YogaEdge.Top, 0);
root_child0.Width = 50f; root_child0.Width = 50;
root_child0.Height = 50f; root_child0.Height = 50;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.PositionType = YogaPositionType.Absolute; root_child1.PositionType = YogaPositionType.Absolute;
root_child1.SetPosition(YogaEdge.Right, 0f); root_child1.SetPosition(YogaEdge.Right, 0);
root_child1.SetPosition(YogaEdge.Bottom, 0f); root_child1.SetPosition(YogaEdge.Bottom, 0);
root_child1.Width = 50f; root_child1.Width = 50;
root_child1.Height = 50f; root_child1.Height = 50;
root.Insert(1, root_child1); root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();

View File

@@ -22,32 +22,32 @@ namespace Facebook.Yoga
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.Wrap = YogaWrap.Wrap; root.Wrap = YogaWrap.Wrap;
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Width = 50f; root_child0.Width = 50;
root_child0.Height = 10f; root_child0.Height = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.Width = 50f; root_child1.Width = 50;
root_child1.Height = 10f; root_child1.Height = 10;
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
root_child2.Width = 50f; root_child2.Width = 50;
root_child2.Height = 10f; root_child2.Height = 10;
root.Insert(2, root_child2); root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode(); YogaNode root_child3 = new YogaNode();
root_child3.Width = 50f; root_child3.Width = 50;
root_child3.Height = 10f; root_child3.Height = 10;
root.Insert(3, root_child3); root.Insert(3, root_child3);
YogaNode root_child4 = new YogaNode(); YogaNode root_child4 = new YogaNode();
root_child4.Width = 50f; root_child4.Width = 50;
root_child4.Height = 10f; root_child4.Height = 10;
root.Insert(4, root_child4); root.Insert(4, root_child4);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -122,32 +122,32 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.AlignContent = YogaAlign.FlexEnd; root.AlignContent = YogaAlign.FlexEnd;
root.Wrap = YogaWrap.Wrap; root.Wrap = YogaWrap.Wrap;
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Width = 50f; root_child0.Width = 50;
root_child0.Height = 10f; root_child0.Height = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.Width = 50f; root_child1.Width = 50;
root_child1.Height = 10f; root_child1.Height = 10;
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
root_child2.Width = 50f; root_child2.Width = 50;
root_child2.Height = 10f; root_child2.Height = 10;
root.Insert(2, root_child2); root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode(); YogaNode root_child3 = new YogaNode();
root_child3.Width = 50f; root_child3.Width = 50;
root_child3.Height = 10f; root_child3.Height = 10;
root.Insert(3, root_child3); root.Insert(3, root_child3);
YogaNode root_child4 = new YogaNode(); YogaNode root_child4 = new YogaNode();
root_child4.Width = 50f; root_child4.Width = 50;
root_child4.Height = 10f; root_child4.Height = 10;
root.Insert(4, root_child4); root.Insert(4, root_child4);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -222,32 +222,32 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.AlignContent = YogaAlign.Center; root.AlignContent = YogaAlign.Center;
root.Wrap = YogaWrap.Wrap; root.Wrap = YogaWrap.Wrap;
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Width = 50f; root_child0.Width = 50;
root_child0.Height = 10f; root_child0.Height = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.Width = 50f; root_child1.Width = 50;
root_child1.Height = 10f; root_child1.Height = 10;
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
root_child2.Width = 50f; root_child2.Width = 50;
root_child2.Height = 10f; root_child2.Height = 10;
root.Insert(2, root_child2); root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode(); YogaNode root_child3 = new YogaNode();
root_child3.Width = 50f; root_child3.Width = 50;
root_child3.Height = 10f; root_child3.Height = 10;
root.Insert(3, root_child3); root.Insert(3, root_child3);
YogaNode root_child4 = new YogaNode(); YogaNode root_child4 = new YogaNode();
root_child4.Width = 50f; root_child4.Width = 50;
root_child4.Height = 10f; root_child4.Height = 10;
root.Insert(4, root_child4); root.Insert(4, root_child4);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -322,27 +322,27 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.AlignContent = YogaAlign.Stretch; root.AlignContent = YogaAlign.Stretch;
root.Wrap = YogaWrap.Wrap; root.Wrap = YogaWrap.Wrap;
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Width = 50f; root_child0.Width = 50;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.Width = 50f; root_child1.Width = 50;
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
root_child2.Width = 50f; root_child2.Width = 50;
root.Insert(2, root_child2); root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode(); YogaNode root_child3 = new YogaNode();
root_child3.Width = 50f; root_child3.Width = 50;
root.Insert(3, root_child3); root.Insert(3, root_child3);
YogaNode root_child4 = new YogaNode(); YogaNode root_child4 = new YogaNode();
root_child4.Width = 50f; root_child4.Width = 50;
root.Insert(4, root_child4); root.Insert(4, root_child4);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();

View File

@@ -21,11 +21,11 @@ namespace Facebook.Yoga
public void Test_align_items_stretch() public void Test_align_items_stretch()
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Height = 10f; root_child0.Height = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -59,12 +59,12 @@ namespace Facebook.Yoga
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.AlignItems = YogaAlign.Center; root.AlignItems = YogaAlign.Center;
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Width = 10f; root_child0.Width = 10;
root_child0.Height = 10f; root_child0.Height = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -98,12 +98,12 @@ namespace Facebook.Yoga
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.AlignItems = YogaAlign.FlexStart; root.AlignItems = YogaAlign.FlexStart;
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Width = 10f; root_child0.Width = 10;
root_child0.Height = 10f; root_child0.Height = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -137,12 +137,12 @@ namespace Facebook.Yoga
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.AlignItems = YogaAlign.FlexEnd; root.AlignItems = YogaAlign.FlexEnd;
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Width = 10f; root_child0.Width = 10;
root_child0.Height = 10f; root_child0.Height = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();

View File

@@ -21,13 +21,13 @@ namespace Facebook.Yoga
public void Test_align_self_center() public void Test_align_self_center()
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.AlignSelf = YogaAlign.Center; root_child0.AlignSelf = YogaAlign.Center;
root_child0.Width = 10f; root_child0.Width = 10;
root_child0.Height = 10f; root_child0.Height = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -60,13 +60,13 @@ namespace Facebook.Yoga
public void Test_align_self_flex_end() public void Test_align_self_flex_end()
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.AlignSelf = YogaAlign.FlexEnd; root_child0.AlignSelf = YogaAlign.FlexEnd;
root_child0.Width = 10f; root_child0.Width = 10;
root_child0.Height = 10f; root_child0.Height = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -99,13 +99,13 @@ namespace Facebook.Yoga
public void Test_align_self_flex_start() public void Test_align_self_flex_start()
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.AlignSelf = YogaAlign.FlexStart; root_child0.AlignSelf = YogaAlign.FlexStart;
root_child0.Width = 10f; root_child0.Width = 10;
root_child0.Height = 10f; root_child0.Height = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -139,13 +139,13 @@ namespace Facebook.Yoga
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.AlignItems = YogaAlign.FlexStart; root.AlignItems = YogaAlign.FlexStart;
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.AlignSelf = YogaAlign.FlexEnd; root_child0.AlignSelf = YogaAlign.FlexEnd;
root_child0.Width = 10f; root_child0.Width = 10;
root_child0.Height = 10f; root_child0.Height = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();

View File

@@ -21,10 +21,10 @@ namespace Facebook.Yoga
public void Test_border_no_size() public void Test_border_no_size()
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.SetBorder(YogaEdge.Left, 10f); root.SetBorder(YogaEdge.Left, 10);
root.SetBorder(YogaEdge.Top, 10f); root.SetBorder(YogaEdge.Top, 10);
root.SetBorder(YogaEdge.Right, 10f); root.SetBorder(YogaEdge.Right, 10);
root.SetBorder(YogaEdge.Bottom, 10f); root.SetBorder(YogaEdge.Bottom, 10);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -46,14 +46,14 @@ namespace Facebook.Yoga
public void Test_border_container_match_child() public void Test_border_container_match_child()
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.SetBorder(YogaEdge.Left, 10f); root.SetBorder(YogaEdge.Left, 10);
root.SetBorder(YogaEdge.Top, 10f); root.SetBorder(YogaEdge.Top, 10);
root.SetBorder(YogaEdge.Right, 10f); root.SetBorder(YogaEdge.Right, 10);
root.SetBorder(YogaEdge.Bottom, 10f); root.SetBorder(YogaEdge.Bottom, 10);
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Width = 10f; root_child0.Width = 10;
root_child0.Height = 10f; root_child0.Height = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -86,16 +86,16 @@ namespace Facebook.Yoga
public void Test_border_flex_child() public void Test_border_flex_child()
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.SetBorder(YogaEdge.Left, 10f); root.SetBorder(YogaEdge.Left, 10);
root.SetBorder(YogaEdge.Top, 10f); root.SetBorder(YogaEdge.Top, 10);
root.SetBorder(YogaEdge.Right, 10f); root.SetBorder(YogaEdge.Right, 10);
root.SetBorder(YogaEdge.Bottom, 10f); root.SetBorder(YogaEdge.Bottom, 10);
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f; root_child0.FlexGrow = 1;
root_child0.Width = 10f; root_child0.Width = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -128,15 +128,15 @@ namespace Facebook.Yoga
public void Test_border_stretch_child() public void Test_border_stretch_child()
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.SetBorder(YogaEdge.Left, 10f); root.SetBorder(YogaEdge.Left, 10);
root.SetBorder(YogaEdge.Top, 10f); root.SetBorder(YogaEdge.Top, 10);
root.SetBorder(YogaEdge.Right, 10f); root.SetBorder(YogaEdge.Right, 10);
root.SetBorder(YogaEdge.Bottom, 10f); root.SetBorder(YogaEdge.Bottom, 10);
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Height = 10f; root_child0.Height = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -171,15 +171,15 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.JustifyContent = YogaJustify.Center; root.JustifyContent = YogaJustify.Center;
root.AlignItems = YogaAlign.Center; root.AlignItems = YogaAlign.Center;
root.SetBorder(YogaEdge.Start, 10f); root.SetBorder(YogaEdge.Start, 10);
root.SetBorder(YogaEdge.End, 20f); root.SetBorder(YogaEdge.End, 20);
root.SetBorder(YogaEdge.Bottom, 20f); root.SetBorder(YogaEdge.Bottom, 20);
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Width = 10f; root_child0.Width = 10;
root_child0.Height = 10f; root_child0.Height = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();

View File

@@ -21,18 +21,18 @@ namespace Facebook.Yoga
public void Test_flex_direction_column_no_height() public void Test_flex_direction_column_no_height()
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.Width = 100f; root.Width = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Height = 10f; root_child0.Height = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.Height = 10f; root_child1.Height = 10;
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
root_child2.Height = 10f; root_child2.Height = 10;
root.Insert(2, root_child2); root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -86,18 +86,18 @@ namespace Facebook.Yoga
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row; root.FlexDirection = YogaFlexDirection.Row;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Width = 10f; root_child0.Width = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.Width = 10f; root_child1.Width = 10;
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
root_child2.Width = 10f; root_child2.Width = 10;
root.Insert(2, root_child2); root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -150,19 +150,19 @@ namespace Facebook.Yoga
public void Test_flex_direction_column() public void Test_flex_direction_column()
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Height = 10f; root_child0.Height = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.Height = 10f; root_child1.Height = 10;
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
root_child2.Height = 10f; root_child2.Height = 10;
root.Insert(2, root_child2); root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -216,19 +216,19 @@ namespace Facebook.Yoga
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row; root.FlexDirection = YogaFlexDirection.Row;
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Width = 10f; root_child0.Width = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.Width = 10f; root_child1.Width = 10;
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
root_child2.Width = 10f; root_child2.Width = 10;
root.Insert(2, root_child2); root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -282,19 +282,19 @@ namespace Facebook.Yoga
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.ColumnReverse; root.FlexDirection = YogaFlexDirection.ColumnReverse;
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Height = 10f; root_child0.Height = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.Height = 10f; root_child1.Height = 10;
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
root_child2.Height = 10f; root_child2.Height = 10;
root.Insert(2, root_child2); root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -348,19 +348,19 @@ namespace Facebook.Yoga
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.RowReverse; root.FlexDirection = YogaFlexDirection.RowReverse;
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Width = 10f; root_child0.Width = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.Width = 10f; root_child1.Width = 10;
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
root_child2.Width = 10f; root_child2.Width = 10;
root.Insert(2, root_child2); root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();

View File

@@ -21,16 +21,16 @@ namespace Facebook.Yoga
public void Test_flex_basis_flex_grow_column() public void Test_flex_basis_flex_grow_column()
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f; root_child0.FlexGrow = 1;
root_child0.FlexBasis = 50f; root_child0.FlexBasis = 50;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 1f; root_child1.FlexGrow = 1;
root.Insert(1, root_child1); root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -74,16 +74,16 @@ namespace Facebook.Yoga
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row; root.FlexDirection = YogaFlexDirection.Row;
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f; root_child0.FlexGrow = 1;
root_child0.FlexBasis = 50f; root_child0.FlexBasis = 50;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 1f; root_child1.FlexGrow = 1;
root.Insert(1, root_child1); root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -126,16 +126,16 @@ namespace Facebook.Yoga
public void Test_flex_basis_flex_shrink_column() public void Test_flex_basis_flex_shrink_column()
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.FlexShrink = 1f; root_child0.FlexShrink = 1;
root_child0.FlexBasis = 100f; root_child0.FlexBasis = 100;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.FlexBasis = 50f; root_child1.FlexBasis = 50;
root.Insert(1, root_child1); root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -179,16 +179,16 @@ namespace Facebook.Yoga
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row; root.FlexDirection = YogaFlexDirection.Row;
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.FlexShrink = 1f; root_child0.FlexShrink = 1;
root_child0.FlexBasis = 100f; root_child0.FlexBasis = 100;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.FlexBasis = 50f; root_child1.FlexBasis = 50;
root.Insert(1, root_child1); root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -231,22 +231,22 @@ namespace Facebook.Yoga
public void Test_flex_shrink_to_zero() public void Test_flex_shrink_to_zero()
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.Height = 75f; root.Height = 75;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Width = 50f; root_child0.Width = 50;
root_child0.Height = 50f; root_child0.Height = 50;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.FlexShrink = 1f; root_child1.FlexShrink = 1;
root_child1.Width = 50f; root_child1.Width = 50;
root_child1.Height = 50f; root_child1.Height = 50;
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
root_child2.Width = 50f; root_child2.Width = 50;
root_child2.Height = 50f; root_child2.Height = 50;
root.Insert(2, root_child2); root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -299,23 +299,23 @@ namespace Facebook.Yoga
public void Test_flex_basis_overrides_main_size() public void Test_flex_basis_overrides_main_size()
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f; root_child0.FlexGrow = 1;
root_child0.FlexBasis = 50f; root_child0.FlexBasis = 50;
root_child0.Height = 20f; root_child0.Height = 20;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 1f; root_child1.FlexGrow = 1;
root_child1.Height = 10f; root_child1.Height = 10;
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
root_child2.FlexGrow = 1f; root_child2.FlexGrow = 1;
root_child2.Height = 10f; root_child2.Height = 10;
root.Insert(2, root_child2); root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -368,15 +368,15 @@ namespace Facebook.Yoga
public void Test_flex_grow_shrink_at_most() public void Test_flex_grow_shrink_at_most()
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode(); YogaNode root_child0_child0 = new YogaNode();
root_child0_child0.FlexGrow = 1f; root_child0_child0.FlexGrow = 1;
root_child0_child0.FlexShrink = 1f; root_child0_child0.FlexShrink = 1;
root_child0.Insert(0, root_child0_child0); root_child0.Insert(0, root_child0_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();

View File

@@ -22,26 +22,26 @@ namespace Facebook.Yoga
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.Wrap = YogaWrap.Wrap; root.Wrap = YogaWrap.Wrap;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Width = 30f; root_child0.Width = 30;
root_child0.Height = 30f; root_child0.Height = 30;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.Width = 30f; root_child1.Width = 30;
root_child1.Height = 30f; root_child1.Height = 30;
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
root_child2.Width = 30f; root_child2.Width = 30;
root_child2.Height = 30f; root_child2.Height = 30;
root.Insert(2, root_child2); root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode(); YogaNode root_child3 = new YogaNode();
root_child3.Width = 30f; root_child3.Width = 30;
root_child3.Height = 30f; root_child3.Height = 30;
root.Insert(3, root_child3); root.Insert(3, root_child3);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -106,26 +106,26 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row; root.FlexDirection = YogaFlexDirection.Row;
root.Wrap = YogaWrap.Wrap; root.Wrap = YogaWrap.Wrap;
root.Width = 100f; root.Width = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Width = 30f; root_child0.Width = 30;
root_child0.Height = 30f; root_child0.Height = 30;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.Width = 30f; root_child1.Width = 30;
root_child1.Height = 30f; root_child1.Height = 30;
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
root_child2.Width = 30f; root_child2.Width = 30;
root_child2.Height = 30f; root_child2.Height = 30;
root.Insert(2, root_child2); root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode(); YogaNode root_child3 = new YogaNode();
root_child3.Width = 30f; root_child3.Width = 30;
root_child3.Height = 30f; root_child3.Height = 30;
root.Insert(3, root_child3); root.Insert(3, root_child3);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -191,26 +191,26 @@ namespace Facebook.Yoga
root.FlexDirection = YogaFlexDirection.Row; root.FlexDirection = YogaFlexDirection.Row;
root.AlignItems = YogaAlign.FlexEnd; root.AlignItems = YogaAlign.FlexEnd;
root.Wrap = YogaWrap.Wrap; root.Wrap = YogaWrap.Wrap;
root.Width = 100f; root.Width = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Width = 30f; root_child0.Width = 30;
root_child0.Height = 10f; root_child0.Height = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.Width = 30f; root_child1.Width = 30;
root_child1.Height = 20f; root_child1.Height = 20;
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
root_child2.Width = 30f; root_child2.Width = 30;
root_child2.Height = 30f; root_child2.Height = 30;
root.Insert(2, root_child2); root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode(); YogaNode root_child3 = new YogaNode();
root_child3.Width = 30f; root_child3.Width = 30;
root_child3.Height = 30f; root_child3.Height = 30;
root.Insert(3, root_child3); root.Insert(3, root_child3);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -276,26 +276,26 @@ namespace Facebook.Yoga
root.FlexDirection = YogaFlexDirection.Row; root.FlexDirection = YogaFlexDirection.Row;
root.AlignItems = YogaAlign.Center; root.AlignItems = YogaAlign.Center;
root.Wrap = YogaWrap.Wrap; root.Wrap = YogaWrap.Wrap;
root.Width = 100f; root.Width = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Width = 30f; root_child0.Width = 30;
root_child0.Height = 10f; root_child0.Height = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.Width = 30f; root_child1.Width = 30;
root_child1.Height = 20f; root_child1.Height = 20;
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
root_child2.Width = 30f; root_child2.Width = 30;
root_child2.Height = 30f; root_child2.Height = 30;
root.Insert(2, root_child2); root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode(); YogaNode root_child3 = new YogaNode();
root_child3.Width = 30f; root_child3.Width = 30;
root_child3.Height = 30f; root_child3.Height = 30;
root.Insert(3, root_child3); root.Insert(3, root_child3);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();

View File

@@ -22,19 +22,19 @@ namespace Facebook.Yoga
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row; root.FlexDirection = YogaFlexDirection.Row;
root.Width = 102f; root.Width = 102;
root.Height = 102f; root.Height = 102;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Width = 10f; root_child0.Width = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.Width = 10f; root_child1.Width = 10;
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
root_child2.Width = 10f; root_child2.Width = 10;
root.Insert(2, root_child2); root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -89,19 +89,19 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row; root.FlexDirection = YogaFlexDirection.Row;
root.JustifyContent = YogaJustify.FlexEnd; root.JustifyContent = YogaJustify.FlexEnd;
root.Width = 102f; root.Width = 102;
root.Height = 102f; root.Height = 102;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Width = 10f; root_child0.Width = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.Width = 10f; root_child1.Width = 10;
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
root_child2.Width = 10f; root_child2.Width = 10;
root.Insert(2, root_child2); root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -156,19 +156,19 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row; root.FlexDirection = YogaFlexDirection.Row;
root.JustifyContent = YogaJustify.Center; root.JustifyContent = YogaJustify.Center;
root.Width = 102f; root.Width = 102;
root.Height = 102f; root.Height = 102;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Width = 10f; root_child0.Width = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.Width = 10f; root_child1.Width = 10;
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
root_child2.Width = 10f; root_child2.Width = 10;
root.Insert(2, root_child2); root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -223,19 +223,19 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row; root.FlexDirection = YogaFlexDirection.Row;
root.JustifyContent = YogaJustify.SpaceBetween; root.JustifyContent = YogaJustify.SpaceBetween;
root.Width = 102f; root.Width = 102;
root.Height = 102f; root.Height = 102;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Width = 10f; root_child0.Width = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.Width = 10f; root_child1.Width = 10;
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
root_child2.Width = 10f; root_child2.Width = 10;
root.Insert(2, root_child2); root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -290,19 +290,19 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row; root.FlexDirection = YogaFlexDirection.Row;
root.JustifyContent = YogaJustify.SpaceAround; root.JustifyContent = YogaJustify.SpaceAround;
root.Width = 102f; root.Width = 102;
root.Height = 102f; root.Height = 102;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Width = 10f; root_child0.Width = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.Width = 10f; root_child1.Width = 10;
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
root_child2.Width = 10f; root_child2.Width = 10;
root.Insert(2, root_child2); root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -355,18 +355,18 @@ namespace Facebook.Yoga
public void Test_justify_content_column_flex_start() public void Test_justify_content_column_flex_start()
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.Width = 102f; root.Width = 102;
root.Height = 102f; root.Height = 102;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Height = 10f; root_child0.Height = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
root_child2.Height = 10f; root_child2.Height = 10;
root.Insert(2, root_child2); root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -420,19 +420,19 @@ namespace Facebook.Yoga
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.JustifyContent = YogaJustify.FlexEnd; root.JustifyContent = YogaJustify.FlexEnd;
root.Width = 102f; root.Width = 102;
root.Height = 102f; root.Height = 102;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Height = 10f; root_child0.Height = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.Height = 10f; root_child1.Height = 10;
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
root_child2.Height = 10f; root_child2.Height = 10;
root.Insert(2, root_child2); root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -486,19 +486,19 @@ namespace Facebook.Yoga
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.JustifyContent = YogaJustify.Center; root.JustifyContent = YogaJustify.Center;
root.Width = 102f; root.Width = 102;
root.Height = 102f; root.Height = 102;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Height = 10f; root_child0.Height = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.Height = 10f; root_child1.Height = 10;
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
root_child2.Height = 10f; root_child2.Height = 10;
root.Insert(2, root_child2); root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -552,19 +552,19 @@ namespace Facebook.Yoga
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.JustifyContent = YogaJustify.SpaceBetween; root.JustifyContent = YogaJustify.SpaceBetween;
root.Width = 102f; root.Width = 102;
root.Height = 102f; root.Height = 102;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Height = 10f; root_child0.Height = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.Height = 10f; root_child1.Height = 10;
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
root_child2.Height = 10f; root_child2.Height = 10;
root.Insert(2, root_child2); root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -618,19 +618,19 @@ namespace Facebook.Yoga
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.JustifyContent = YogaJustify.SpaceAround; root.JustifyContent = YogaJustify.SpaceAround;
root.Width = 102f; root.Width = 102;
root.Height = 102f; root.Height = 102;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Height = 10f; root_child0.Height = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.Height = 10f; root_child1.Height = 10;
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
root_child2.Height = 10f; root_child2.Height = 10;
root.Insert(2, root_child2); root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();

View File

@@ -22,12 +22,12 @@ namespace Facebook.Yoga
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row; root.FlexDirection = YogaFlexDirection.Row;
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.SetMargin(YogaEdge.Start, 10f); root_child0.SetMargin(YogaEdge.Start, 10);
root_child0.Width = 10f; root_child0.Width = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -60,12 +60,12 @@ namespace Facebook.Yoga
public void Test_margin_top() public void Test_margin_top()
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.SetMargin(YogaEdge.Top, 10f); root_child0.SetMargin(YogaEdge.Top, 10);
root_child0.Height = 10f; root_child0.Height = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -100,12 +100,12 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row; root.FlexDirection = YogaFlexDirection.Row;
root.JustifyContent = YogaJustify.FlexEnd; root.JustifyContent = YogaJustify.FlexEnd;
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.SetMargin(YogaEdge.End, 10f); root_child0.SetMargin(YogaEdge.End, 10);
root_child0.Width = 10f; root_child0.Width = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -139,12 +139,12 @@ namespace Facebook.Yoga
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.JustifyContent = YogaJustify.FlexEnd; root.JustifyContent = YogaJustify.FlexEnd;
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.SetMargin(YogaEdge.Bottom, 10f); root_child0.SetMargin(YogaEdge.Bottom, 10);
root_child0.Height = 10f; root_child0.Height = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -178,12 +178,12 @@ namespace Facebook.Yoga
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row; root.FlexDirection = YogaFlexDirection.Row;
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f; root_child0.FlexGrow = 1;
root_child0.SetMargin(YogaEdge.Start, 10f); root_child0.SetMargin(YogaEdge.Start, 10);
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -216,12 +216,12 @@ namespace Facebook.Yoga
public void Test_margin_and_flex_column() public void Test_margin_and_flex_column()
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f; root_child0.FlexGrow = 1;
root_child0.SetMargin(YogaEdge.Top, 10f); root_child0.SetMargin(YogaEdge.Top, 10);
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -255,12 +255,12 @@ namespace Facebook.Yoga
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row; root.FlexDirection = YogaFlexDirection.Row;
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f; root_child0.FlexGrow = 1;
root_child0.SetMargin(YogaEdge.Top, 10f); root_child0.SetMargin(YogaEdge.Top, 10);
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -293,12 +293,12 @@ namespace Facebook.Yoga
public void Test_margin_and_stretch_column() public void Test_margin_and_stretch_column()
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f; root_child0.FlexGrow = 1;
root_child0.SetMargin(YogaEdge.Start, 10f); root_child0.SetMargin(YogaEdge.Start, 10);
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -332,15 +332,15 @@ namespace Facebook.Yoga
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row; root.FlexDirection = YogaFlexDirection.Row;
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f; root_child0.FlexGrow = 1;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 1f; root_child1.FlexGrow = 1;
root.Insert(1, root_child1); root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -383,15 +383,15 @@ namespace Facebook.Yoga
public void Test_margin_with_sibling_column() public void Test_margin_with_sibling_column()
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f; root_child0.FlexGrow = 1;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 1f; root_child1.FlexGrow = 1;
root.Insert(1, root_child1); root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();

View File

@@ -21,12 +21,12 @@ namespace Facebook.Yoga
public void Test_max_width() public void Test_max_width()
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.MaxWidth = 50f; root_child0.MaxWidth = 50;
root_child0.Height = 10f; root_child0.Height = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -60,12 +60,12 @@ namespace Facebook.Yoga
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row; root.FlexDirection = YogaFlexDirection.Row;
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Width = 10f; root_child0.Width = 10;
root_child0.MaxHeight = 50f; root_child0.MaxHeight = 50;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -98,16 +98,16 @@ namespace Facebook.Yoga
public void Test_min_height() public void Test_min_height()
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f; root_child0.FlexGrow = 1;
root_child0.MinHeight = 60f; root_child0.MinHeight = 60;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 1f; root_child1.FlexGrow = 1;
root.Insert(1, root_child1); root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -151,16 +151,16 @@ namespace Facebook.Yoga
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row; root.FlexDirection = YogaFlexDirection.Row;
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f; root_child0.FlexGrow = 1;
root_child0.MinWidth = 60f; root_child0.MinWidth = 60;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 1f; root_child1.FlexGrow = 1;
root.Insert(1, root_child1); root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -204,13 +204,13 @@ namespace Facebook.Yoga
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.JustifyContent = YogaJustify.Center; root.JustifyContent = YogaJustify.Center;
root.Width = 100f; root.Width = 100;
root.MinHeight = 100f; root.MinHeight = 100;
root.MaxHeight = 200f; root.MaxHeight = 200;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Width = 60f; root_child0.Width = 60;
root_child0.Height = 60f; root_child0.Height = 60;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -244,13 +244,13 @@ namespace Facebook.Yoga
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.AlignItems = YogaAlign.Center; root.AlignItems = YogaAlign.Center;
root.MinWidth = 100f; root.MinWidth = 100;
root.MaxWidth = 200f; root.MaxWidth = 200;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Width = 60f; root_child0.Width = 60;
root_child0.Height = 60f; root_child0.Height = 60;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -284,22 +284,22 @@ namespace Facebook.Yoga
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.JustifyContent = YogaJustify.Center; root.JustifyContent = YogaJustify.Center;
root.MinHeight = 100f; root.MinHeight = 100;
root.MaxHeight = 110f; root.MaxHeight = 110;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Width = 50f; root_child0.Width = 50;
root_child0.Height = 50f; root_child0.Height = 50;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.Width = 50f; root_child1.Width = 50;
root_child1.Height = 50f; root_child1.Height = 50;
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
root_child2.Width = 50f; root_child2.Width = 50;
root_child2.Height = 50f; root_child2.Height = 50;
root.Insert(2, root_child2); root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -352,17 +352,17 @@ namespace Facebook.Yoga
public void Test_flex_grow_within_max_width() public void Test_flex_grow_within_max_width()
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.Width = 200f; root.Width = 200;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.FlexDirection = YogaFlexDirection.Row; root_child0.FlexDirection = YogaFlexDirection.Row;
root_child0.MaxWidth = 100f; root_child0.MaxWidth = 100;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode(); YogaNode root_child0_child0 = new YogaNode();
root_child0_child0.FlexGrow = 1f; root_child0_child0.FlexGrow = 1;
root_child0_child0.Height = 20f; root_child0_child0.Height = 20;
root_child0.Insert(0, root_child0_child0); root_child0.Insert(0, root_child0_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -405,17 +405,17 @@ namespace Facebook.Yoga
public void Test_flex_grow_within_constrained_max_width() public void Test_flex_grow_within_constrained_max_width()
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.Width = 200f; root.Width = 200;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.FlexDirection = YogaFlexDirection.Row; root_child0.FlexDirection = YogaFlexDirection.Row;
root_child0.MaxWidth = 300f; root_child0.MaxWidth = 300;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode(); YogaNode root_child0_child0 = new YogaNode();
root_child0_child0.FlexGrow = 1f; root_child0_child0.FlexGrow = 1;
root_child0_child0.Height = 20f; root_child0_child0.Height = 20;
root_child0.Insert(0, root_child0_child0); root_child0.Insert(0, root_child0_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -459,15 +459,15 @@ namespace Facebook.Yoga
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row; root.FlexDirection = YogaFlexDirection.Row;
root.MinWidth = 100f; root.MinWidth = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f; root_child0.FlexGrow = 1;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.Width = 50f; root_child1.Width = 50;
root.Insert(1, root_child1); root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -510,14 +510,14 @@ namespace Facebook.Yoga
public void Test_flex_grow_within_constrained_min_column() public void Test_flex_grow_within_constrained_min_column()
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.MinHeight = 100f; root.MinHeight = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f; root_child0.FlexGrow = 1;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.Height = 50f; root_child1.Height = 50;
root.Insert(1, root_child1); root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -560,21 +560,21 @@ namespace Facebook.Yoga
public void Test_flex_grow_within_constrained_max_row() public void Test_flex_grow_within_constrained_max_row()
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.Width = 200f; root.Width = 200;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.FlexDirection = YogaFlexDirection.Row; root_child0.FlexDirection = YogaFlexDirection.Row;
root_child0.MaxWidth = 100f; root_child0.MaxWidth = 100;
root_child0.Height = 100f; root_child0.Height = 100;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode(); YogaNode root_child0_child0 = new YogaNode();
root_child0_child0.FlexShrink = 1f; root_child0_child0.FlexShrink = 1;
root_child0_child0.FlexBasis = 100f; root_child0_child0.FlexBasis = 100;
root_child0.Insert(0, root_child0_child0); root_child0.Insert(0, root_child0_child0);
YogaNode root_child0_child1 = new YogaNode(); YogaNode root_child0_child1 = new YogaNode();
root_child0_child1.Width = 50f; root_child0_child1.Width = 50;
root_child0.Insert(1, root_child0_child1); root_child0.Insert(1, root_child0_child1);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -627,16 +627,16 @@ namespace Facebook.Yoga
public void Test_flex_grow_within_constrained_max_column() public void Test_flex_grow_within_constrained_max_column()
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.Width = 100f; root.Width = 100;
root.MaxHeight = 100f; root.MaxHeight = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.FlexShrink = 1f; root_child0.FlexShrink = 1;
root_child0.FlexBasis = 100f; root_child0.FlexBasis = 100;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.Height = 50f; root_child1.Height = 50;
root.Insert(1, root_child1); root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();

View File

@@ -21,10 +21,10 @@ namespace Facebook.Yoga
public void Test_padding_no_size() public void Test_padding_no_size()
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.SetPadding(YogaEdge.Left, 10f); root.SetPadding(YogaEdge.Left, 10);
root.SetPadding(YogaEdge.Top, 10f); root.SetPadding(YogaEdge.Top, 10);
root.SetPadding(YogaEdge.Right, 10f); root.SetPadding(YogaEdge.Right, 10);
root.SetPadding(YogaEdge.Bottom, 10f); root.SetPadding(YogaEdge.Bottom, 10);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -46,14 +46,14 @@ namespace Facebook.Yoga
public void Test_padding_container_match_child() public void Test_padding_container_match_child()
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.SetPadding(YogaEdge.Left, 10f); root.SetPadding(YogaEdge.Left, 10);
root.SetPadding(YogaEdge.Top, 10f); root.SetPadding(YogaEdge.Top, 10);
root.SetPadding(YogaEdge.Right, 10f); root.SetPadding(YogaEdge.Right, 10);
root.SetPadding(YogaEdge.Bottom, 10f); root.SetPadding(YogaEdge.Bottom, 10);
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Width = 10f; root_child0.Width = 10;
root_child0.Height = 10f; root_child0.Height = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -86,16 +86,16 @@ namespace Facebook.Yoga
public void Test_padding_flex_child() public void Test_padding_flex_child()
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.SetPadding(YogaEdge.Left, 10f); root.SetPadding(YogaEdge.Left, 10);
root.SetPadding(YogaEdge.Top, 10f); root.SetPadding(YogaEdge.Top, 10);
root.SetPadding(YogaEdge.Right, 10f); root.SetPadding(YogaEdge.Right, 10);
root.SetPadding(YogaEdge.Bottom, 10f); root.SetPadding(YogaEdge.Bottom, 10);
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f; root_child0.FlexGrow = 1;
root_child0.Width = 10f; root_child0.Width = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -128,15 +128,15 @@ namespace Facebook.Yoga
public void Test_padding_stretch_child() public void Test_padding_stretch_child()
{ {
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.SetPadding(YogaEdge.Left, 10f); root.SetPadding(YogaEdge.Left, 10);
root.SetPadding(YogaEdge.Top, 10f); root.SetPadding(YogaEdge.Top, 10);
root.SetPadding(YogaEdge.Right, 10f); root.SetPadding(YogaEdge.Right, 10);
root.SetPadding(YogaEdge.Bottom, 10f); root.SetPadding(YogaEdge.Bottom, 10);
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Height = 10f; root_child0.Height = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -171,15 +171,15 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.JustifyContent = YogaJustify.Center; root.JustifyContent = YogaJustify.Center;
root.AlignItems = YogaAlign.Center; root.AlignItems = YogaAlign.Center;
root.SetPadding(YogaEdge.Start, 10f); root.SetPadding(YogaEdge.Start, 10);
root.SetPadding(YogaEdge.End, 20f); root.SetPadding(YogaEdge.End, 20);
root.SetPadding(YogaEdge.Bottom, 20f); root.SetPadding(YogaEdge.Bottom, 20);
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.Width = 10f; root_child0.Width = 10;
root_child0.Height = 10f; root_child0.Height = 10;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -214,16 +214,16 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.JustifyContent = YogaJustify.FlexEnd; root.JustifyContent = YogaJustify.FlexEnd;
root.AlignItems = YogaAlign.FlexEnd; root.AlignItems = YogaAlign.FlexEnd;
root.Width = 200f; root.Width = 200;
root.Height = 200f; root.Height = 200;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.SetPadding(YogaEdge.Left, 20f); root_child0.SetPadding(YogaEdge.Left, 20);
root_child0.SetPadding(YogaEdge.Top, 20f); root_child0.SetPadding(YogaEdge.Top, 20);
root_child0.SetPadding(YogaEdge.Right, 20f); root_child0.SetPadding(YogaEdge.Right, 20);
root_child0.SetPadding(YogaEdge.Bottom, 20f); root_child0.SetPadding(YogaEdge.Bottom, 20);
root_child0.Width = 100f; root_child0.Width = 100;
root_child0.Height = 100f; root_child0.Height = 100;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();

View File

@@ -0,0 +1,959 @@
/**
* 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.
*/
// @Generated by gentest/gentest.rb from gentest/fixtures/YGPercentageTest.html
using System;
using NUnit.Framework;
namespace Facebook.Yoga
{
[TestFixture]
public class YGPercentageTest
{
[Test]
public void Test_percentage_width_height()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
root_child0.Width = 30.Percent();
root_child0.Height = 30.Percent();
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(60f, root_child0.LayoutWidth);
Assert.AreEqual(60f, root_child0.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(140f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(60f, root_child0.LayoutWidth);
Assert.AreEqual(60f, root_child0.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_position_left_top()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 400;
root.Height = 400;
YogaNode root_child0 = new YogaNode();
root_child0.SetPosition(YogaEdge.Left, 10.Percent());
root_child0.SetPosition(YogaEdge.Top, 20.Percent());
root_child0.Width = 45.Percent();
root_child0.Height = 55.Percent();
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(400f, root.LayoutWidth);
Assert.AreEqual(400f, root.LayoutHeight);
Assert.AreEqual(40f, root_child0.LayoutX);
Assert.AreEqual(80f, root_child0.LayoutY);
Assert.AreEqual(180f, root_child0.LayoutWidth);
Assert.AreEqual(220f, root_child0.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(400f, root.LayoutWidth);
Assert.AreEqual(400f, root.LayoutHeight);
Assert.AreEqual(260f, root_child0.LayoutX);
Assert.AreEqual(80f, root_child0.LayoutY);
Assert.AreEqual(180f, root_child0.LayoutWidth);
Assert.AreEqual(220f, root_child0.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_position_bottom_right()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 500;
root.Height = 500;
YogaNode root_child0 = new YogaNode();
root_child0.SetPosition(YogaEdge.Right, 20.Percent());
root_child0.SetPosition(YogaEdge.Bottom, 10.Percent());
root_child0.Width = 55.Percent();
root_child0.Height = 15.Percent();
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(500f, root.LayoutWidth);
Assert.AreEqual(500f, root.LayoutHeight);
Assert.AreEqual(-100f, root_child0.LayoutX);
Assert.AreEqual(-50f, root_child0.LayoutY);
Assert.AreEqual(275f, root_child0.LayoutWidth);
Assert.AreEqual(75f, root_child0.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(500f, root.LayoutWidth);
Assert.AreEqual(500f, root.LayoutHeight);
Assert.AreEqual(125f, root_child0.LayoutX);
Assert.AreEqual(-50f, root_child0.LayoutY);
Assert.AreEqual(275f, root_child0.LayoutWidth);
Assert.AreEqual(75f, root_child0.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_flex_basis()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 50.Percent();
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 1;
root_child1.FlexBasis = 25.Percent();
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(125f, root_child0.LayoutWidth);
Assert.AreEqual(200f, root_child0.LayoutHeight);
Assert.AreEqual(125f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(75f, root_child1.LayoutWidth);
Assert.AreEqual(200f, root_child1.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(75f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(125f, root_child0.LayoutWidth);
Assert.AreEqual(200f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(75f, root_child1.LayoutWidth);
Assert.AreEqual(200f, root_child1.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_flex_basis_cross()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 50.Percent();
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 1;
root_child1.FlexBasis = 25.Percent();
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(200f, root_child0.LayoutWidth);
Assert.AreEqual(125f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(125f, root_child1.LayoutY);
Assert.AreEqual(200f, root_child1.LayoutWidth);
Assert.AreEqual(75f, root_child1.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(200f, root_child0.LayoutWidth);
Assert.AreEqual(125f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(125f, root_child1.LayoutY);
Assert.AreEqual(200f, root_child1.LayoutWidth);
Assert.AreEqual(75f, root_child1.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_flex_basis_cross_min_height()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1;
root_child0.MinHeight = 60.Percent();
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 2;
root_child1.MinHeight = 10.Percent();
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(200f, root_child0.LayoutWidth);
Assert.AreEqual(140f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(140f, root_child1.LayoutY);
Assert.AreEqual(200f, root_child1.LayoutWidth);
Assert.AreEqual(60f, root_child1.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(200f, root_child0.LayoutWidth);
Assert.AreEqual(140f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(140f, root_child1.LayoutY);
Assert.AreEqual(200f, root_child1.LayoutWidth);
Assert.AreEqual(60f, root_child1.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_flex_basis_main_max_height()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 10.Percent();
root_child0.MaxHeight = 60.Percent();
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 4;
root_child1.FlexBasis = 10.Percent();
root_child1.MaxHeight = 20.Percent();
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(52f, root_child0.LayoutWidth);
Assert.AreEqual(120f, root_child0.LayoutHeight);
Assert.AreEqual(52f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(148f, root_child1.LayoutWidth);
Assert.AreEqual(40f, root_child1.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(148f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(52f, root_child0.LayoutWidth);
Assert.AreEqual(120f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(148f, root_child1.LayoutWidth);
Assert.AreEqual(40f, root_child1.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_flex_basis_cross_max_height()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 10.Percent();
root_child0.MaxHeight = 60.Percent();
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 4;
root_child1.FlexBasis = 10.Percent();
root_child1.MaxHeight = 20.Percent();
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(200f, root_child0.LayoutWidth);
Assert.AreEqual(120f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(120f, root_child1.LayoutY);
Assert.AreEqual(200f, root_child1.LayoutWidth);
Assert.AreEqual(40f, root_child1.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(200f, root_child0.LayoutWidth);
Assert.AreEqual(120f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(120f, root_child1.LayoutY);
Assert.AreEqual(200f, root_child1.LayoutWidth);
Assert.AreEqual(40f, root_child1.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_flex_basis_main_max_width()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 15.Percent();
root_child0.MaxWidth = 60.Percent();
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 4;
root_child1.FlexBasis = 10.Percent();
root_child1.MaxWidth = 20.Percent();
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(120f, root_child0.LayoutWidth);
Assert.AreEqual(200f, root_child0.LayoutHeight);
Assert.AreEqual(120f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(40f, root_child1.LayoutWidth);
Assert.AreEqual(200f, root_child1.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(80f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(120f, root_child0.LayoutWidth);
Assert.AreEqual(200f, root_child0.LayoutHeight);
Assert.AreEqual(40f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(40f, root_child1.LayoutWidth);
Assert.AreEqual(200f, root_child1.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_flex_basis_cross_max_width()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 10.Percent();
root_child0.MaxWidth = 60.Percent();
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 4;
root_child1.FlexBasis = 15.Percent();
root_child1.MaxWidth = 20.Percent();
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(120f, root_child0.LayoutWidth);
Assert.AreEqual(50f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(50f, root_child1.LayoutY);
Assert.AreEqual(40f, root_child1.LayoutWidth);
Assert.AreEqual(150f, root_child1.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(80f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(120f, root_child0.LayoutWidth);
Assert.AreEqual(50f, root_child0.LayoutHeight);
Assert.AreEqual(160f, root_child1.LayoutX);
Assert.AreEqual(50f, root_child1.LayoutY);
Assert.AreEqual(40f, root_child1.LayoutWidth);
Assert.AreEqual(150f, root_child1.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_flex_basis_main_min_width()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 15.Percent();
root_child0.MinWidth = 60.Percent();
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 4;
root_child1.FlexBasis = 10.Percent();
root_child1.MinWidth = 20.Percent();
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(120f, root_child0.LayoutWidth);
Assert.AreEqual(200f, root_child0.LayoutHeight);
Assert.AreEqual(120f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(80f, root_child1.LayoutWidth);
Assert.AreEqual(200f, root_child1.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(80f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(120f, root_child0.LayoutWidth);
Assert.AreEqual(200f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(80f, root_child1.LayoutWidth);
Assert.AreEqual(200f, root_child1.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_flex_basis_cross_min_width()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.Width = 200;
root.Height = 200;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1;
root_child0.FlexBasis = 10.Percent();
root_child0.MinWidth = 60.Percent();
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 4;
root_child1.FlexBasis = 15.Percent();
root_child1.MinWidth = 20.Percent();
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(200f, root_child0.LayoutWidth);
Assert.AreEqual(50f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(50f, root_child1.LayoutY);
Assert.AreEqual(200f, root_child1.LayoutWidth);
Assert.AreEqual(150f, root_child1.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(200f, root_child0.LayoutWidth);
Assert.AreEqual(50f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(50f, root_child1.LayoutY);
Assert.AreEqual(200f, root_child1.LayoutWidth);
Assert.AreEqual(150f, root_child1.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_multiple_nested_with_padding_margin_and_percentage_values()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.Width = 200;
root.Height = 200;
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.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.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.Width = 45.Percent();
root_child0_child0.Insert(0, root_child0_child0_child0);
YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 4;
root_child1.FlexBasis = 15.Percent();
root_child1.MinWidth = 20.Percent();
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(5f, root_child0.LayoutX);
Assert.AreEqual(5f, root_child0.LayoutY);
Assert.AreEqual(190f, root_child0.LayoutWidth);
Assert.AreEqual(48f, root_child0.LayoutHeight);
Assert.AreEqual(8f, root_child0_child0.LayoutX);
Assert.AreEqual(8f, root_child0_child0.LayoutY);
Assert.AreEqual(92f, root_child0_child0.LayoutWidth);
Assert.AreEqual(25f, root_child0_child0.LayoutHeight);
Assert.AreEqual(10f, root_child0_child0_child0.LayoutX);
Assert.AreEqual(10f, root_child0_child0_child0.LayoutY);
Assert.AreEqual(36f, root_child0_child0_child0.LayoutWidth);
Assert.AreEqual(6f, root_child0_child0_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(58f, root_child1.LayoutY);
Assert.AreEqual(200f, root_child1.LayoutWidth);
Assert.AreEqual(142f, root_child1.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(200f, root.LayoutHeight);
Assert.AreEqual(5f, root_child0.LayoutX);
Assert.AreEqual(5f, root_child0.LayoutY);
Assert.AreEqual(190f, root_child0.LayoutWidth);
Assert.AreEqual(48f, root_child0.LayoutHeight);
Assert.AreEqual(90f, root_child0_child0.LayoutX);
Assert.AreEqual(8f, root_child0_child0.LayoutY);
Assert.AreEqual(92f, root_child0_child0.LayoutWidth);
Assert.AreEqual(25f, root_child0_child0.LayoutHeight);
Assert.AreEqual(46f, root_child0_child0_child0.LayoutX);
Assert.AreEqual(10f, root_child0_child0_child0.LayoutY);
Assert.AreEqual(36f, root_child0_child0_child0.LayoutWidth);
Assert.AreEqual(6f, root_child0_child0_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(58f, root_child1.LayoutY);
Assert.AreEqual(200f, root_child1.LayoutWidth);
Assert.AreEqual(142f, root_child1.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_margin_should_calculate_based_only_on_width()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.Width = 200;
root.Height = 100;
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.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
root_child0_child0.Width = 10;
root_child0_child0.Height = 10;
root_child0.Insert(0, root_child0_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(20f, root_child0.LayoutX);
Assert.AreEqual(20f, root_child0.LayoutY);
Assert.AreEqual(160f, root_child0.LayoutWidth);
Assert.AreEqual(60f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(10f, root_child0_child0.LayoutWidth);
Assert.AreEqual(10f, root_child0_child0.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(20f, root_child0.LayoutX);
Assert.AreEqual(20f, root_child0.LayoutY);
Assert.AreEqual(160f, root_child0.LayoutWidth);
Assert.AreEqual(60f, root_child0.LayoutHeight);
Assert.AreEqual(150f, root_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(10f, root_child0_child0.LayoutWidth);
Assert.AreEqual(10f, root_child0_child0.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_padding_should_calculate_based_only_on_width()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.Width = 200;
root.Height = 100;
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.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
root_child0_child0.Width = 10;
root_child0_child0.Height = 10;
root_child0.Insert(0, root_child0_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(200f, root_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(20f, root_child0_child0.LayoutX);
Assert.AreEqual(20f, root_child0_child0.LayoutY);
Assert.AreEqual(10f, root_child0_child0.LayoutWidth);
Assert.AreEqual(10f, root_child0_child0.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(200f, root_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(170f, root_child0_child0.LayoutX);
Assert.AreEqual(20f, root_child0_child0.LayoutY);
Assert.AreEqual(10f, root_child0_child0.LayoutWidth);
Assert.AreEqual(10f, root_child0_child0.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
[Test]
public void Test_percentage_absolute_position()
{
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode();
root.Width = 200;
root.Height = 100;
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.Width = 10;
root_child0.Height = 10;
root.Insert(0, root_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(60f, root_child0.LayoutX);
Assert.AreEqual(10f, root_child0.LayoutY);
Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(10f, root_child0.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(60f, root_child0.LayoutX);
Assert.AreEqual(10f, root_child0.LayoutY);
Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(10f, root_child0.LayoutHeight);
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
}
}

View File

@@ -24,19 +24,19 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row; root.FlexDirection = YogaFlexDirection.Row;
root.Width = 100f; root.Width = 100;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f; root_child0.FlexGrow = 1;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 1f; root_child1.FlexGrow = 1;
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
root_child2.FlexGrow = 1f; root_child2.FlexGrow = 1;
root.Insert(2, root_child2); root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -94,27 +94,27 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row; root.FlexDirection = YogaFlexDirection.Row;
root.Width = 113f; root.Width = 113;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f; root_child0.FlexGrow = 1;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 1f; root_child1.FlexGrow = 1;
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
root_child2.FlexGrow = 1f; root_child2.FlexGrow = 1;
root.Insert(2, root_child2); root.Insert(2, root_child2);
YogaNode root_child3 = new YogaNode(); YogaNode root_child3 = new YogaNode();
root_child3.FlexGrow = 1f; root_child3.FlexGrow = 1;
root.Insert(3, root_child3); root.Insert(3, root_child3);
YogaNode root_child4 = new YogaNode(); YogaNode root_child4 = new YogaNode();
root_child4.FlexGrow = 1f; root_child4.FlexGrow = 1;
root.Insert(4, root_child4); root.Insert(4, root_child4);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -192,20 +192,20 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row; root.FlexDirection = YogaFlexDirection.Row;
root.Width = 101f; root.Width = 101;
root.Height = 100f; root.Height = 100;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.FlexShrink = 1f; root_child0.FlexShrink = 1;
root_child0.FlexBasis = 100f; root_child0.FlexBasis = 100;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.FlexBasis = 25f; root_child1.FlexBasis = 25;
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
root_child2.FlexBasis = 25f; root_child2.FlexBasis = 25;
root.Insert(2, root_child2); root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -262,23 +262,23 @@ namespace Facebook.Yoga
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.Width = 100f; root.Width = 100;
root.Height = 113f; root.Height = 113;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f; root_child0.FlexGrow = 1;
root_child0.FlexBasis = 50f; root_child0.FlexBasis = 50;
root_child0.Height = 20f; root_child0.Height = 20;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 1f; root_child1.FlexGrow = 1;
root_child1.Height = 10f; root_child1.Height = 10;
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
root_child2.FlexGrow = 1f; root_child2.FlexGrow = 1;
root_child2.Height = 10f; root_child2.Height = 10;
root.Insert(2, root_child2); root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -346,7 +346,7 @@ namespace Facebook.Yoga
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 1.6f; root_child1.FlexGrow = 1.6f;
root_child1.Height = 10f; root_child1.Height = 10;
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
@@ -418,14 +418,14 @@ namespace Facebook.Yoga
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode(); YogaNode root_child0_child0 = new YogaNode();
root_child0_child0.FlexGrow = 1f; root_child0_child0.FlexGrow = 1;
root_child0_child0.FlexBasis = 0.3f; root_child0_child0.FlexBasis = 0.3f;
root_child0_child0.SetPosition(YogaEdge.Bottom, 13.3f); root_child0_child0.SetPosition(YogaEdge.Bottom, 13.3f);
root_child0_child0.Height = 9.9f; root_child0_child0.Height = 9.9f;
root_child0.Insert(0, root_child0_child0); root_child0.Insert(0, root_child0_child0);
YogaNode root_child0_child1 = new YogaNode(); YogaNode root_child0_child1 = new YogaNode();
root_child0_child1.FlexGrow = 4f; root_child0_child1.FlexGrow = 4;
root_child0_child1.FlexBasis = 0.3f; root_child0_child1.FlexBasis = 0.3f;
root_child0_child1.SetPosition(YogaEdge.Top, 13.3f); root_child0_child1.SetPosition(YogaEdge.Top, 13.3f);
root_child0_child1.Height = 1.1f; root_child0_child1.Height = 1.1f;
@@ -433,7 +433,7 @@ namespace Facebook.Yoga
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 1.6f; root_child1.FlexGrow = 1.6f;
root_child1.Height = 10f; root_child1.Height = 10;
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
@@ -515,23 +515,23 @@ namespace Facebook.Yoga
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.Width = 100f; root.Width = 100;
root.Height = 113.4f; root.Height = 113.4f;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f; root_child0.FlexGrow = 1;
root_child0.FlexBasis = 50f; root_child0.FlexBasis = 50;
root_child0.Height = 20f; root_child0.Height = 20;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 1f; root_child1.FlexGrow = 1;
root_child1.Height = 10f; root_child1.Height = 10;
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
root_child2.FlexGrow = 1f; root_child2.FlexGrow = 1;
root_child2.Height = 10f; root_child2.Height = 10;
root.Insert(2, root_child2); root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -588,23 +588,23 @@ namespace Facebook.Yoga
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true); YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.Width = 100f; root.Width = 100;
root.Height = 113.6f; root.Height = 113.6f;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f; root_child0.FlexGrow = 1;
root_child0.FlexBasis = 50f; root_child0.FlexBasis = 50;
root_child0.Height = 20f; root_child0.Height = 20;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 1f; root_child1.FlexGrow = 1;
root_child1.Height = 10f; root_child1.Height = 10;
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
root_child2.FlexGrow = 1f; root_child2.FlexGrow = 1;
root_child2.Height = 10f; root_child2.Height = 10;
root.Insert(2, root_child2); root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -662,23 +662,23 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.SetPosition(YogaEdge.Top, 0.3f); root.SetPosition(YogaEdge.Top, 0.3f);
root.Width = 100f; root.Width = 100;
root.Height = 113.4f; root.Height = 113.4f;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f; root_child0.FlexGrow = 1;
root_child0.FlexBasis = 50f; root_child0.FlexBasis = 50;
root_child0.Height = 20f; root_child0.Height = 20;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 1f; root_child1.FlexGrow = 1;
root_child1.Height = 10f; root_child1.Height = 10;
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
root_child2.FlexGrow = 1f; root_child2.FlexGrow = 1;
root_child2.Height = 10f; root_child2.Height = 10;
root.Insert(2, root_child2); root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
@@ -736,23 +736,23 @@ namespace Facebook.Yoga
YogaNode root = new YogaNode(); YogaNode root = new YogaNode();
root.SetPosition(YogaEdge.Top, 0.7f); root.SetPosition(YogaEdge.Top, 0.7f);
root.Width = 100f; root.Width = 100;
root.Height = 113.4f; root.Height = 113.4f;
YogaNode root_child0 = new YogaNode(); YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f; root_child0.FlexGrow = 1;
root_child0.FlexBasis = 50f; root_child0.FlexBasis = 50;
root_child0.Height = 20f; root_child0.Height = 20;
root.Insert(0, root_child0); root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode(); YogaNode root_child1 = new YogaNode();
root_child1.FlexGrow = 1f; root_child1.FlexGrow = 1;
root_child1.Height = 10f; root_child1.Height = 10;
root.Insert(1, root_child1); root.Insert(1, root_child1);
YogaNode root_child2 = new YogaNode(); YogaNode root_child2 = new YogaNode();
root_child2.FlexGrow = 1f; root_child2.FlexGrow = 1;
root_child2.Height = 10f; root_child2.Height = 10;
root.Insert(2, root_child2); root.Insert(2, root_child2);
root.StyleDirection = YogaDirection.LTR; root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();

View File

@@ -51,14 +51,14 @@ namespace Facebook.Yoga
Assert.AreEqual(YogaFlexDirection.Column, node.FlexDirection); Assert.AreEqual(YogaFlexDirection.Column, node.FlexDirection);
Assert.AreEqual(YogaPositionType.Absolute, node.PositionType); Assert.AreEqual(YogaPositionType.Absolute, node.PositionType);
Assert.AreEqual(YogaWrap.Wrap, node.Wrap); Assert.AreEqual(YogaWrap.Wrap, node.Wrap);
Assert.AreEqual(6, node.GetPosition(YogaEdge.Top)); Assert.AreEqual(6.Px(), node.GetPosition(YogaEdge.Top));
Assert.IsTrue(YogaConstants.IsUndefined(node.GetPosition(YogaEdge.Bottom))); Assert.IsTrue(YogaConstants.IsUndefined(node.GetPosition(YogaEdge.Bottom)));
Assert.AreEqual(4, node.GetPosition(YogaEdge.Right)); Assert.AreEqual(4.Px(), node.GetPosition(YogaEdge.Right));
Assert.IsTrue(YogaConstants.IsUndefined(node.GetPosition(YogaEdge.Left))); Assert.IsTrue(YogaConstants.IsUndefined(node.GetPosition(YogaEdge.Left)));
Assert.AreEqual(0, node.GetMargin(YogaEdge.Top)); Assert.AreEqual(0.Px(), node.GetMargin(YogaEdge.Top));
Assert.AreEqual(5, node.GetMargin(YogaEdge.Bottom)); Assert.AreEqual(5.Px(), node.GetMargin(YogaEdge.Bottom));
Assert.AreEqual(3, node.GetMargin(YogaEdge.Left)); Assert.AreEqual(3.Px(), node.GetMargin(YogaEdge.Left));
Assert.AreEqual(0, node.GetMargin(YogaEdge.Right)); Assert.AreEqual(0.Px(), node.GetMargin(YogaEdge.Right));
} }
[Test] [Test]
@@ -85,7 +85,7 @@ namespace Facebook.Yoga
position: new Spacing(top: 5, bottom: 6, left: 7, right: 8), position: new Spacing(top: 5, bottom: 6, left: 7, right: 8),
margin: new Spacing(top: 9, bottom: 10, left: 11, right: 12), margin: new Spacing(top: 9, bottom: 10, left: 11, right: 12),
padding: new Spacing(top: 13, bottom: 14, left: 15, right: 16), padding: new Spacing(top: 13, bottom: 14, left: 15, right: 16),
border: new Spacing(top: 17, bottom: 18, left: 19, right: 20), border: new Border(top: 17, bottom: 18, left: 19, right: 20),
width: 21, width: 21,
height: 22, height: 22,
@@ -108,36 +108,36 @@ namespace Facebook.Yoga
Assert.AreEqual(2, node.FlexGrow); Assert.AreEqual(2, node.FlexGrow);
Assert.AreEqual(3, node.FlexShrink); Assert.AreEqual(3, node.FlexShrink);
Assert.AreEqual(4, node.FlexBasis); Assert.AreEqual(4.Px(), node.FlexBasis);
node.FlexGrow = YogaConstants.Undefined; node.FlexGrow = YogaConstants.Undefined;
Assert.AreEqual(1, node.FlexGrow); Assert.AreEqual(1, node.FlexGrow);
Assert.AreEqual(5, node.GetPosition(YogaEdge.Top)); Assert.AreEqual(5.Px(), node.GetPosition(YogaEdge.Top));
Assert.AreEqual(6, node.GetPosition(YogaEdge.Bottom)); Assert.AreEqual(6.Px(), node.GetPosition(YogaEdge.Bottom));
Assert.AreEqual(7, node.GetPosition(YogaEdge.Left)); Assert.AreEqual(7.Px(), node.GetPosition(YogaEdge.Left));
Assert.AreEqual(8, node.GetPosition(YogaEdge.Right)); Assert.AreEqual(8.Px(), node.GetPosition(YogaEdge.Right));
Assert.AreEqual(9, node.GetMargin(YogaEdge.Top)); Assert.AreEqual(9.Px(), node.GetMargin(YogaEdge.Top));
Assert.AreEqual(10, node.GetMargin(YogaEdge.Bottom)); Assert.AreEqual(10.Px(), node.GetMargin(YogaEdge.Bottom));
Assert.AreEqual(11, node.GetMargin(YogaEdge.Left)); Assert.AreEqual(11.Px(), node.GetMargin(YogaEdge.Left));
Assert.AreEqual(12, node.GetMargin(YogaEdge.Right)); Assert.AreEqual(12.Px(), node.GetMargin(YogaEdge.Right));
Assert.AreEqual(13, node.GetPadding(YogaEdge.Top)); Assert.AreEqual(13.Px(), node.GetPadding(YogaEdge.Top));
Assert.AreEqual(14, node.GetPadding(YogaEdge.Bottom)); Assert.AreEqual(14.Px(), node.GetPadding(YogaEdge.Bottom));
Assert.AreEqual(15, node.GetPadding(YogaEdge.Left)); Assert.AreEqual(15.Px(), node.GetPadding(YogaEdge.Left));
Assert.AreEqual(16, node.GetPadding(YogaEdge.Right)); Assert.AreEqual(16.Px(), node.GetPadding(YogaEdge.Right));
Assert.AreEqual(17, node.GetBorder(YogaEdge.Top)); Assert.AreEqual(17, node.GetBorder(YogaEdge.Top));
Assert.AreEqual(18, node.GetBorder(YogaEdge.Bottom)); Assert.AreEqual(18, node.GetBorder(YogaEdge.Bottom));
Assert.AreEqual(19, node.GetBorder(YogaEdge.Left)); Assert.AreEqual(19, node.GetBorder(YogaEdge.Left));
Assert.AreEqual(20, node.GetBorder(YogaEdge.Right)); Assert.AreEqual(20, node.GetBorder(YogaEdge.Right));
Assert.AreEqual(21, node.Width); Assert.AreEqual(21.Px(), node.Width);
Assert.AreEqual(22, node.Height); Assert.AreEqual(22.Px(), node.Height);
Assert.AreEqual(23, node.MinWidth); Assert.AreEqual(23.Px(), node.MinWidth);
Assert.AreEqual(24, node.MinHeight); Assert.AreEqual(24.Px(), node.MinHeight);
Assert.AreEqual(25, node.MaxWidth); Assert.AreEqual(25.Px(), node.MaxWidth);
Assert.AreEqual(26, node.MaxHeight); Assert.AreEqual(26.Px(), node.MaxHeight);
} }
} }
} }

View File

@@ -212,7 +212,7 @@ namespace Facebook.Yoga
parent.Insert(0, child0); parent.Insert(0, child0);
parent.Insert(0, child1); parent.Insert(0, child1);
parent.CalculateLayout(); parent.CalculateLayout();
Assert.AreEqual(parent.Print(), "{layout: {width: 100, height: 120, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 100, height: 120, children: [\n {layout: {width: 35, height: 45, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 35, height: 45, },\n {layout: {width: 30, height: 40, top: 45, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 30, height: 40, },\n]},\n"); Assert.AreEqual("{layout: {width: 100, height: 120, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 100px, height: 120px, children: [\n {layout: {width: 35, height: 45, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 35px, height: 45px, },\n {layout: {width: 30, height: 40, top: 45, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 30px, height: 40px, },\n]},\n", parent.Print());
} }
[Test] [Test]
@@ -225,7 +225,7 @@ namespace Facebook.Yoga
node1.MaxHeight = 100; node1.MaxHeight = 100;
node0.CopyStyle(node1); node0.CopyStyle(node1);
Assert.AreEqual(100, node0.MaxHeight); Assert.AreEqual(100.Px(), node0.MaxHeight);
} }
private void ForceGC() private void ForceGC()

View File

@@ -17,6 +17,11 @@ ENUMS = {
'LTR', 'LTR',
'RTL', 'RTL',
], ],
'Unit': [
'Undefined',
'Pixel',
'Percent',
],
'FlexDirection': [ 'FlexDirection': [
'Column', 'Column',
'ColumnReverse', 'ColumnReverse',

View File

@@ -0,0 +1,82 @@
<div id="percentage_width_height" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: row;">
<div style="width: 30%; height: 30%;"></div>
</div>
<div id="percentage_position_left_top" experiments="Rounding" style="width: 400px; height: 400px; flex-direction: row;">
<div style="width: 45%; height: 55%; left: 10%; top: 20%"></div>
</div>
<div id="percentage_position_bottom_right" experiments="Rounding" style="width: 500px; height: 500px; flex-direction: row;">
<div style="width: 55%; height: 15%; bottom: 10%; right: 20%"></div>
</div>
<div id="percentage_flex_basis" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: row;">
<div style="flex-grow: 1; flex-basis: 50%;"></div>
<div style="flex-grow: 1; flex-basis: 25%;"></div>
</div>
<div id="percentage_flex_basis_cross" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: column;">
<div style="flex-grow: 1; flex-basis: 50%;"></div>
<div style="flex-grow: 1; flex-basis: 25%;"></div>
</div>
<div id="percentage_flex_basis_cross_min_height" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: column;">
<div style="flex-grow: 1; min-height: 60%;"></div>
<div style="flex-grow: 2; min-height: 10%;"></div>
</div>
<div id="percentage_flex_basis_main_max_height" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: row;">
<div style="flex-grow: 1; flex-basis: 10%; max-height: 60%;"></div>
<div style="flex-grow: 4; flex-basis: 10%; max-height: 20%;"></div>
</div>
<div id="percentage_flex_basis_cross_max_height" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: column;">
<div style="flex-grow: 1; flex-basis: 10%; max-height: 60%;"></div>
<div style="flex-grow: 4; flex-basis: 10%; max-height: 20%;"></div>
</div>
<div id="percentage_flex_basis_main_max_width" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: row;">
<div style="flex-grow: 1; flex-basis: 15%; max-width: 60%;"></div>
<div style="flex-grow: 4; flex-basis: 10%; max-width: 20%;"></div>
</div>
<div id="percentage_flex_basis_cross_max_width" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: column;">
<div style="flex-grow: 1; flex-basis: 10%; max-width: 60%;"></div>
<div style="flex-grow: 4; flex-basis: 15%; max-width: 20%;"></div>
</div>
<div id="percentage_flex_basis_main_min_width" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: row;">
<div style="flex-grow: 1; flex-basis: 15%; min-width: 60%;"></div>
<div style="flex-grow: 4; flex-basis: 10%; min-width: 20%;"></div>
</div>
<div id="percentage_flex_basis_cross_min_width" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: column;">
<div style="flex-grow: 1; flex-basis: 10%; min-width: 60%;"></div>
<div style="flex-grow: 4; flex-basis: 15%; min-width: 20%;"></div>
</div>
<div id="percentage_multiple_nested_with_padding_margin_and_percentage_values" experiments="Rounding" style="width: 200px; height: 200px; flex-direction: column;">
<div style="flex-grow: 1; flex-basis: 10%; min-width: 60%; margin: 5px; padding: 3px;">
<div style="width: 50%; margin: 5px; padding: 3%;">
<div style="width: 45%; margin: 5%; padding: 3px;"></div>
</div>
</div>
<div style="flex-grow: 4; flex-basis: 15%; min-width: 20%;"></div>
</div>
<div id="percentage_margin_should_calculate_based_only_on_width" experiments="Rounding" style="width: 200px; height: 100px;">
<div style="flex-grow: 1; margin: 10%;">
<div style="width: 10px; height: 10px;"></div>
</div>
</div>
<div id="percentage_padding_should_calculate_based_only_on_width" experiments="Rounding" style="width: 200px; height: 100px;">
<div style="flex-grow: 1; padding: 10%;">
<div style="width: 10px; height: 10px;"></div>
</div>
</div>
<div id="percentage_absolute_position" experiments="Rounding" style="width: 200px; height: 100px;">
<div style="position: absolute; top: 10%; left: 30%; width: 10px; height: 10px;"></div>
</div>

View File

@@ -7,10 +7,18 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
function toFloatString(n) { function toValueCpp(value) {
var n = value.toString().replace('px','').replace('%','');
return n + (Number(n) == n && n % 1 !== 0 ? 'f' : ''); return n + (Number(n) == n && n % 1 !== 0 ? 'f' : '');
} }
function toFunctionName(value) {
if (value.indexOf('%') >= 0){
return 'Percent';
}
return '';
}
var CPPEmitter = function() { var CPPEmitter = function() {
Emitter.call(this, 'cpp', ' '); Emitter.call(this, 'cpp', ' ');
}; };
@@ -66,7 +74,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
}}, }},
AssertEQ:{value:function(v0, v1) { AssertEQ:{value:function(v0, v1) {
this.push('ASSERT_FLOAT_EQ(' + toFloatString(v0) + ', ' + v1 + ');'); this.push('ASSERT_FLOAT_EQ(' + toValueCpp(v0) + ', ' + v1 + ');');
}}, }},
YGAlignAuto:{value:'YGAlignAuto'}, YGAlignAuto:{value:'YGAlignAuto'},
@@ -133,90 +141,90 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
}}, }},
YGNodeStyleSetAlignContent:{value:function(nodeName, value) { YGNodeStyleSetAlignContent:{value:function(nodeName, value) {
this.push('YGNodeStyleSetAlignContent(' + nodeName + ', ' + value + ');'); this.push('YGNodeStyleSetAlignContent(' + nodeName + ', ' + toValueCpp(value) + ');');
}}, }},
YGNodeStyleSetAlignItems:{value:function(nodeName, value) { YGNodeStyleSetAlignItems:{value:function(nodeName, value) {
this.push('YGNodeStyleSetAlignItems(' + nodeName + ', ' + value + ');'); this.push('YGNodeStyleSetAlignItems(' + nodeName + ', ' + toValueCpp(value) + ');');
}}, }},
YGNodeStyleSetAlignSelf:{value:function(nodeName, value) { YGNodeStyleSetAlignSelf:{value:function(nodeName, value) {
this.push('YGNodeStyleSetAlignSelf(' + nodeName + ', ' + value + ');'); this.push('YGNodeStyleSetAlignSelf(' + nodeName + ', ' + toValueCpp(value) + ');');
}}, }},
YGNodeStyleSetBorder:{value:function(nodeName, edge, value) { YGNodeStyleSetBorder:{value:function(nodeName, edge, value) {
this.push('YGNodeStyleSetBorder(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');'); this.push('YGNodeStyleSetBorder(' + nodeName + ', ' + edge + ', ' + toValueCpp(value) + ');');
}}, }},
YGNodeStyleSetDirection:{value:function(nodeName, value) { YGNodeStyleSetDirection:{value:function(nodeName, value) {
this.push('YGNodeStyleSetDirection(' + nodeName + ', ' + value + ');'); this.push('YGNodeStyleSetDirection(' + nodeName + ', ' + toValueCpp(value) + ');');
}}, }},
YGNodeStyleSetFlexBasis:{value:function(nodeName, value) { YGNodeStyleSetFlexBasis:{value:function(nodeName, value) {
this.push('YGNodeStyleSetFlexBasis(' + nodeName + ', ' + toFloatString(value) + ');'); this.push('YGNodeStyleSetFlexBasis' + toFunctionName(value) + '(' + nodeName + ', ' + toValueCpp(value) + ');');
}}, }},
YGNodeStyleSetFlexDirection:{value:function(nodeName, value) { YGNodeStyleSetFlexDirection:{value:function(nodeName, value) {
this.push('YGNodeStyleSetFlexDirection(' + nodeName + ', ' + value + ');'); this.push('YGNodeStyleSetFlexDirection(' + nodeName + ', ' + toValueCpp(value) + ');');
}}, }},
YGNodeStyleSetFlexGrow:{value:function(nodeName, value) { YGNodeStyleSetFlexGrow:{value:function(nodeName, value) {
this.push('YGNodeStyleSetFlexGrow(' + nodeName + ', ' + toFloatString(value) + ');'); this.push('YGNodeStyleSetFlexGrow(' + nodeName + ', ' + toValueCpp(value) + ');');
}}, }},
YGNodeStyleSetFlexShrink:{value:function(nodeName, value) { YGNodeStyleSetFlexShrink:{value:function(nodeName, value) {
this.push('YGNodeStyleSetFlexShrink(' + nodeName + ', ' + toFloatString(value) + ');'); this.push('YGNodeStyleSetFlexShrink(' + nodeName + ', ' + toValueCpp(value) + ');');
}}, }},
YGNodeStyleSetFlexWrap:{value:function(nodeName, value) { YGNodeStyleSetFlexWrap:{value:function(nodeName, value) {
this.push('YGNodeStyleSetFlexWrap(' + nodeName + ', ' + value + ');'); this.push('YGNodeStyleSetFlexWrap(' + nodeName + ', ' + toValueCpp(value) + ');');
}}, }},
YGNodeStyleSetHeight:{value:function(nodeName, value) { YGNodeStyleSetHeight:{value:function(nodeName, value) {
this.push('YGNodeStyleSetHeight(' + nodeName + ', ' + toFloatString(value) + ');'); this.push('YGNodeStyleSetHeight' + toFunctionName(value) + '(' + nodeName + ', ' + toValueCpp(value) + ');');
}}, }},
YGNodeStyleSetJustifyContent:{value:function(nodeName, value) { YGNodeStyleSetJustifyContent:{value:function(nodeName, value) {
this.push('YGNodeStyleSetJustifyContent(' + nodeName + ', ' + value + ');'); this.push('YGNodeStyleSetJustifyContent(' + nodeName + ', ' + toValueCpp(value) + ');');
}}, }},
YGNodeStyleSetMargin:{value:function(nodeName, edge, value) { YGNodeStyleSetMargin:{value:function(nodeName, edge, value) {
this.push('YGNodeStyleSetMargin(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');'); this.push('YGNodeStyleSetMargin' + toFunctionName(value) + '(' + nodeName + ', ' + edge + ', ' + toValueCpp(value) + ');');
}}, }},
YGNodeStyleSetMaxHeight:{value:function(nodeName, value) { YGNodeStyleSetMaxHeight:{value:function(nodeName, value) {
this.push('YGNodeStyleSetMaxHeight(' + nodeName + ', ' + toFloatString(value) + ');'); this.push('YGNodeStyleSetMaxHeight' + toFunctionName(value) + '(' + nodeName + ', ' + toValueCpp(value) + ');');
}}, }},
YGNodeStyleSetMaxWidth:{value:function(nodeName, value) { YGNodeStyleSetMaxWidth:{value:function(nodeName, value) {
this.push('YGNodeStyleSetMaxWidth(' + nodeName + ', ' + toFloatString(value) + ');'); this.push('YGNodeStyleSetMaxWidth' + toFunctionName(value) + '(' + nodeName + ', ' + toValueCpp(value) + ');');
}}, }},
YGNodeStyleSetMinHeight:{value:function(nodeName, value) { YGNodeStyleSetMinHeight:{value:function(nodeName, value) {
this.push('YGNodeStyleSetMinHeight(' + nodeName + ', ' + toFloatString(value) + ');'); this.push('YGNodeStyleSetMinHeight' + toFunctionName(value) + '(' + nodeName + ', ' + toValueCpp(value) + ');');
}}, }},
YGNodeStyleSetMinWidth:{value:function(nodeName, value) { YGNodeStyleSetMinWidth:{value:function(nodeName, value) {
this.push('YGNodeStyleSetMinWidth(' + nodeName + ', ' + toFloatString(value) + ');'); this.push('YGNodeStyleSetMinWidth' + toFunctionName(value) + '(' + nodeName + ', ' + toValueCpp(value) + ');');
}}, }},
YGNodeStyleSetOverflow:{value:function(nodeName, value) { YGNodeStyleSetOverflow:{value:function(nodeName, value) {
this.push('YGNodeStyleSetOverflow(' + nodeName + ', ' + value + ');'); this.push('YGNodeStyleSetOverflow(' + nodeName + ', ' + toValueCpp(value) + ');');
}}, }},
YGNodeStyleSetPadding:{value:function(nodeName, edge, value) { YGNodeStyleSetPadding:{value:function(nodeName, edge, value) {
this.push('YGNodeStyleSetPadding(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');'); this.push('YGNodeStyleSetPadding' + toFunctionName(value) + '(' + nodeName + ', ' + edge + ', ' + toValueCpp(value) + ');');
}}, }},
YGNodeStyleSetPosition:{value:function(nodeName, edge, value) { YGNodeStyleSetPosition:{value:function(nodeName, edge, value) {
this.push('YGNodeStyleSetPosition(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');'); this.push('YGNodeStyleSetPosition' + toFunctionName(value) + '(' + nodeName + ', ' + edge + ', ' + toValueCpp(value) + ');');
}}, }},
YGNodeStyleSetPositionType:{value:function(nodeName, value) { YGNodeStyleSetPositionType:{value:function(nodeName, value) {
this.push('YGNodeStyleSetPositionType(' + nodeName + ', ' + value + ');'); this.push('YGNodeStyleSetPositionType(' + nodeName + ', ' + toValueCpp(value) + ');');
}}, }},
YGNodeStyleSetWidth:{value:function(nodeName, value) { YGNodeStyleSetWidth:{value:function(nodeName, value) {
this.push('YGNodeStyleSetWidth(' + nodeName + ', ' + toFloatString(value) + ');'); this.push('YGNodeStyleSetWidth' + toFunctionName(value) + '(' + nodeName + ', ' + toValueCpp(value) + ');');
}}, }},
}); });

View File

@@ -7,6 +7,19 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
function toValueCs(value) {
var n = value.toString().replace('px','').replace('%','');
return n + (Number(n) == n && n % 1 !== 0 ? 'f' : '');
}
function toCsUnitValue(value) {
var methodName = '';
if (value.indexOf('%') >= 0){
methodName = '.Percent()';
}
return toValueCs(value) + methodName;
}
var CSEmitter = function() { var CSEmitter = function() {
Emitter.call(this, 'cs', ' '); Emitter.call(this, 'cs', ' ');
}; };
@@ -143,90 +156,90 @@ CSEmitter.prototype = Object.create(Emitter.prototype, {
}}, }},
YGNodeStyleSetAlignContent:{value:function(nodeName, value) { YGNodeStyleSetAlignContent:{value:function(nodeName, value) {
this.push(nodeName + '.AlignContent = ' + value + ';'); this.push(nodeName + '.AlignContent = ' + toValueCs(value) + ';');
}}, }},
YGNodeStyleSetAlignItems:{value:function(nodeName, value) { YGNodeStyleSetAlignItems:{value:function(nodeName, value) {
this.push(nodeName + '.AlignItems = ' + value + ';'); this.push(nodeName + '.AlignItems = ' + toValueCs(value) + ';');
}}, }},
YGNodeStyleSetAlignSelf:{value:function(nodeName, value) { YGNodeStyleSetAlignSelf:{value:function(nodeName, value) {
this.push(nodeName + '.AlignSelf = ' + value + ';'); this.push(nodeName + '.AlignSelf = ' + toValueCs(value) + ';');
}}, }},
YGNodeStyleSetBorder:{value:function(nodeName, edge, value) { YGNodeStyleSetBorder:{value:function(nodeName, edge, value) {
this.push(nodeName + '.SetBorder(' + edge + ', ' + value + 'f);'); this.push(nodeName + '.SetBorder(' + edge + ', ' + toValueCs(value) + ');');
}}, }},
YGNodeStyleSetDirection:{value:function(nodeName, value) { YGNodeStyleSetDirection:{value:function(nodeName, value) {
this.push(nodeName + '.StyleDirection = ' + value + ';'); this.push(nodeName + '.StyleDirection = ' + toValueCs(value) + ';');
}}, }},
YGNodeStyleSetFlexBasis:{value:function(nodeName, value) { YGNodeStyleSetFlexBasis:{value:function(nodeName, value) {
this.push(nodeName + '.FlexBasis = ' + value + 'f;'); this.push(nodeName + '.FlexBasis = ' + toCsUnitValue(value) + ';');
}}, }},
YGNodeStyleSetFlexDirection:{value:function(nodeName, value) { YGNodeStyleSetFlexDirection:{value:function(nodeName, value) {
this.push(nodeName + '.FlexDirection = ' + value + ';'); this.push(nodeName + '.FlexDirection = ' + toValueCs(value) + ';');
}}, }},
YGNodeStyleSetFlexGrow:{value:function(nodeName, value) { YGNodeStyleSetFlexGrow:{value:function(nodeName, value) {
this.push(nodeName + '.FlexGrow = ' + value + 'f;'); this.push(nodeName + '.FlexGrow = ' + toValueCs(value) + ';');
}}, }},
YGNodeStyleSetFlexShrink:{value:function(nodeName, value) { YGNodeStyleSetFlexShrink:{value:function(nodeName, value) {
this.push(nodeName + '.FlexShrink = ' + value + 'f;'); this.push(nodeName + '.FlexShrink = ' + toValueCs(value) + ';');
}}, }},
YGNodeStyleSetFlexWrap:{value:function(nodeName, value) { YGNodeStyleSetFlexWrap:{value:function(nodeName, value) {
this.push(nodeName + '.Wrap = ' + value + ';'); this.push(nodeName + '.Wrap = ' + toValueCs(value) + ';');
}}, }},
YGNodeStyleSetHeight:{value:function(nodeName, value) { YGNodeStyleSetHeight:{value:function(nodeName, value) {
this.push(nodeName + '.Height = ' + value + 'f;'); this.push(nodeName + '.Height = ' + toCsUnitValue(value) + ';');
}}, }},
YGNodeStyleSetJustifyContent:{value:function(nodeName, value) { YGNodeStyleSetJustifyContent:{value:function(nodeName, value) {
this.push(nodeName + '.JustifyContent = ' + value + ';'); this.push(nodeName + '.JustifyContent = ' + toValueCs(value) + ';');
}}, }},
YGNodeStyleSetMargin:{value:function(nodeName, edge, value) { YGNodeStyleSetMargin:{value:function(nodeName, edge, value) {
this.push(nodeName + '.SetMargin(' + edge + ', ' + value + 'f);'); this.push(nodeName + '.SetMargin(' + edge + ', ' + toCsUnitValue(value) + ');');
}}, }},
YGNodeStyleSetMaxHeight:{value:function(nodeName, value) { YGNodeStyleSetMaxHeight:{value:function(nodeName, value) {
this.push(nodeName + '.MaxHeight = ' + value + 'f;'); this.push(nodeName + '.MaxHeight = ' + toCsUnitValue(value) + ';');
}}, }},
YGNodeStyleSetMaxWidth:{value:function(nodeName, value) { YGNodeStyleSetMaxWidth:{value:function(nodeName, value) {
this.push(nodeName + '.MaxWidth = ' + value + 'f;'); this.push(nodeName + '.MaxWidth = ' + toCsUnitValue(value) + ';');
}}, }},
YGNodeStyleSetMinHeight:{value:function(nodeName, value) { YGNodeStyleSetMinHeight:{value:function(nodeName, value) {
this.push(nodeName + '.MinHeight = ' + value + 'f;'); this.push(nodeName + '.MinHeight = ' + toCsUnitValue(value) + ';');
}}, }},
YGNodeStyleSetMinWidth:{value:function(nodeName, value) { YGNodeStyleSetMinWidth:{value:function(nodeName, value) {
this.push(nodeName + '.MinWidth = ' + value + 'f;'); this.push(nodeName + '.MinWidth = ' + toCsUnitValue(value) + ';');
}}, }},
YGNodeStyleSetOverflow:{value:function(nodeName, value) { YGNodeStyleSetOverflow:{value:function(nodeName, value) {
this.push(nodeName + '.Overflow = ' + value + ';'); this.push(nodeName + '.Overflow = ' + toValueCs(value) + ';');
}}, }},
YGNodeStyleSetPadding:{value:function(nodeName, edge, value) { YGNodeStyleSetPadding:{value:function(nodeName, edge, value) {
this.push(nodeName + '.SetPadding(' + edge + ', ' + value + 'f);'); this.push(nodeName + '.SetPadding(' + edge + ', ' + toCsUnitValue(value) + ');');
}}, }},
YGNodeStyleSetPosition:{value:function(nodeName, edge, value) { YGNodeStyleSetPosition:{value:function(nodeName, edge, value) {
this.push(nodeName + '.SetPosition(' + edge + ', ' + value + 'f);'); this.push(nodeName + '.SetPosition(' + edge + ', ' + toCsUnitValue(value) + ');');
}}, }},
YGNodeStyleSetPositionType:{value:function(nodeName, value) { YGNodeStyleSetPositionType:{value:function(nodeName, value) {
this.push(nodeName + '.PositionType = ' + value + ';'); this.push(nodeName + '.PositionType = ' + toValueCs(value) + ';');
}}, }},
YGNodeStyleSetWidth:{value:function(nodeName, value) { YGNodeStyleSetWidth:{value:function(nodeName, value) {
this.push(nodeName + '.Width = ' + value + 'f;'); this.push(nodeName + '.Width = ' + toCsUnitValue(value) + ';');
}}, }},
}); });

View File

@@ -7,6 +7,18 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
function toValueJava(value) {
var n = value.toString().replace('px','').replace('%','');
return n + (Number(n) == n && n % 1 !== 0 ? '' : '');
}
function toMethodName(value) {
if (value.indexOf('%') >= 0){
return 'Percent';
}
return '';
}
var JavaEmitter = function() { var JavaEmitter = function() {
Emitter.call(this, 'java', ' '); Emitter.call(this, 'java', ' ');
}; };
@@ -148,90 +160,90 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
}}, }},
YGNodeStyleSetAlignContent:{value:function(nodeName, value) { YGNodeStyleSetAlignContent:{value:function(nodeName, value) {
this.push(nodeName + '.setAlignContent(' + value + ');'); this.push(nodeName + '.setAlignContent(' + toValueJava(value) + ');');
}}, }},
YGNodeStyleSetAlignItems:{value:function(nodeName, value) { YGNodeStyleSetAlignItems:{value:function(nodeName, value) {
this.push(nodeName + '.setAlignItems(' + value + ');'); this.push(nodeName + '.setAlignItems(' + toValueJava(value) + ');');
}}, }},
YGNodeStyleSetAlignSelf:{value:function(nodeName, value) { YGNodeStyleSetAlignSelf:{value:function(nodeName, value) {
this.push(nodeName + '.setAlignSelf(' + value + ');'); this.push(nodeName + '.setAlignSelf(' + toValueJava(value) + ');');
}}, }},
YGNodeStyleSetBorder:{value:function(nodeName, edge, value) { YGNodeStyleSetBorder:{value:function(nodeName, edge, value) {
this.push(nodeName + '.setBorder(' + edge + ', ' + value + 'f);'); this.push(nodeName + '.setBorder(' + edge + ', ' + toValueJava(value) + 'f);');
}}, }},
YGNodeStyleSetDirection:{value:function(nodeName, value) { YGNodeStyleSetDirection:{value:function(nodeName, value) {
this.push(nodeName + '.setDirection(' + value + ');'); this.push(nodeName + '.setDirection(' + toValueJava(value) + ');');
}}, }},
YGNodeStyleSetFlexBasis:{value:function(nodeName, value) { YGNodeStyleSetFlexBasis:{value:function(nodeName, value) {
this.push(nodeName + '.setFlexBasis(' + value + 'f);'); this.push(nodeName + '.setFlexBasis' + toMethodName(value) + '(' + toValueJava(value) + 'f);');
}}, }},
YGNodeStyleSetFlexDirection:{value:function(nodeName, value) { YGNodeStyleSetFlexDirection:{value:function(nodeName, value) {
this.push(nodeName + '.setFlexDirection(' + value + ');'); this.push(nodeName + '.setFlexDirection(' + toValueJava(value) + ');');
}}, }},
YGNodeStyleSetFlexGrow:{value:function(nodeName, value) { YGNodeStyleSetFlexGrow:{value:function(nodeName, value) {
this.push(nodeName + '.setFlexGrow(' + value + 'f);'); this.push(nodeName + '.setFlexGrow(' + toValueJava(value) + 'f);');
}}, }},
YGNodeStyleSetFlexShrink:{value:function(nodeName, value) { YGNodeStyleSetFlexShrink:{value:function(nodeName, value) {
this.push(nodeName + '.setFlexShrink(' + value + 'f);'); this.push(nodeName + '.setFlexShrink(' + toValueJava(value) + 'f);');
}}, }},
YGNodeStyleSetFlexWrap:{value:function(nodeName, value) { YGNodeStyleSetFlexWrap:{value:function(nodeName, value) {
this.push(nodeName + '.setWrap(' + value + ');'); this.push(nodeName + '.setWrap(' + toValueJava(value) + ');');
}}, }},
YGNodeStyleSetHeight:{value:function(nodeName, value) { YGNodeStyleSetHeight:{value:function(nodeName, value) {
this.push(nodeName + '.setHeight(' + value + 'f);'); this.push(nodeName + '.setHeight' + toMethodName(value) + '(' + toValueJava(value) + 'f);');
}}, }},
YGNodeStyleSetJustifyContent:{value:function(nodeName, value) { YGNodeStyleSetJustifyContent:{value:function(nodeName, value) {
this.push(nodeName + '.setJustifyContent(' + value + ');'); this.push(nodeName + '.setJustifyContent(' + toValueJava(value) + ');');
}}, }},
YGNodeStyleSetMargin:{value:function(nodeName, edge, value) { YGNodeStyleSetMargin:{value:function(nodeName, edge, value) {
this.push(nodeName + '.setMargin(' + edge + ', ' + value + 'f);'); this.push(nodeName + '.setMargin' + toMethodName(value) + '(' + edge + ', ' + toValueJava(value) + 'f);');
}}, }},
YGNodeStyleSetMaxHeight:{value:function(nodeName, value) { YGNodeStyleSetMaxHeight:{value:function(nodeName, value) {
this.push(nodeName + '.setMaxHeight(' + value + 'f);'); this.push(nodeName + '.setMaxHeight' + toMethodName(value) + '(' + toValueJava(value) + 'f);');
}}, }},
YGNodeStyleSetMaxWidth:{value:function(nodeName, value) { YGNodeStyleSetMaxWidth:{value:function(nodeName, value) {
this.push(nodeName + '.setMaxWidth(' + value + 'f);'); this.push(nodeName + '.setMaxWidth' + toMethodName(value) + '(' + toValueJava(value) + 'f);');
}}, }},
YGNodeStyleSetMinHeight:{value:function(nodeName, value) { YGNodeStyleSetMinHeight:{value:function(nodeName, value) {
this.push(nodeName + '.setMinHeight(' + value + 'f);'); this.push(nodeName + '.setMinHeight' + toMethodName(value) + '(' + toValueJava(value) + 'f);');
}}, }},
YGNodeStyleSetMinWidth:{value:function(nodeName, value) { YGNodeStyleSetMinWidth:{value:function(nodeName, value) {
this.push(nodeName + '.setMinWidth(' + value + 'f);'); this.push(nodeName + '.setMinWidth' + toMethodName(value) + '(' + toValueJava(value) + 'f);');
}}, }},
YGNodeStyleSetOverflow:{value:function(nodeName, value) { YGNodeStyleSetOverflow:{value:function(nodeName, value) {
this.push(nodeName + '.setOverflow(' + value + ');'); this.push(nodeName + '.setOverflow(' + toValueJava(value) + ');');
}}, }},
YGNodeStyleSetPadding:{value:function(nodeName, edge, value) { YGNodeStyleSetPadding:{value:function(nodeName, edge, value) {
this.push(nodeName + '.setPadding(' + edge + ', ' + value + ');'); this.push(nodeName + '.setPadding' + toMethodName(value) + '(' + edge + ', ' + toValueJava(value) + ');');
}}, }},
YGNodeStyleSetPosition:{value:function(nodeName, edge, value) { YGNodeStyleSetPosition:{value:function(nodeName, edge, value) {
this.push(nodeName + '.setPosition(' + edge + ', ' + value + 'f);'); this.push(nodeName + '.setPosition' + toMethodName(value) + '(' + edge + ', ' + toValueJava(value) + 'f);');
}}, }},
YGNodeStyleSetPositionType:{value:function(nodeName, value) { YGNodeStyleSetPositionType:{value:function(nodeName, value) {
this.push(nodeName + '.setPositionType(' + value + ');'); this.push(nodeName + '.setPositionType(' + toValueJava(value) + ');');
}}, }},
YGNodeStyleSetWidth:{value:function(nodeName, value) { YGNodeStyleSetWidth:{value:function(nodeName, value) {
this.push(nodeName + '.setWidth(' + value + 'f);'); this.push(nodeName + '.setWidth' + toMethodName(value) + '(' + toValueJava(value) + 'f);');
}}, }},
}); });

View File

@@ -384,7 +384,7 @@ function pixelValue(e, value) {
switch (value) { switch (value) {
case 'auto': return e.YGUndefined; case 'auto': return e.YGUndefined;
case 'undefined': return e.YGUndefined; case 'undefined': return e.YGUndefined;
default: return value.replace('px', ''); default: return value;
} }
} }

View File

@@ -16,4 +16,8 @@ public class YogaConstants {
public static boolean isUndefined(float value) { public static boolean isUndefined(float value) {
return Float.compare(value, UNDEFINED) == 0; return Float.compare(value, UNDEFINED) == 0;
} }
public static boolean isUndefined(YogaValue value) {
return value.unit == YogaUnit.UNDEFINED;
}
} }

View File

@@ -323,10 +323,10 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
jni_YGNodeStyleSetFlexShrink(mNativePointer, flexShrink); jni_YGNodeStyleSetFlexShrink(mNativePointer, flexShrink);
} }
private native float jni_YGNodeStyleGetFlexBasis(long nativePointer); private native Object jni_YGNodeStyleGetFlexBasis(long nativePointer);
@Override @Override
public float getFlexBasis() { public YogaValue getFlexBasis() {
return jni_YGNodeStyleGetFlexBasis(mNativePointer); return (YogaValue) jni_YGNodeStyleGetFlexBasis(mNativePointer);
} }
private native void jni_YGNodeStyleSetFlexBasis(long nativePointer, float flexBasis); private native void jni_YGNodeStyleSetFlexBasis(long nativePointer, float flexBasis);
@@ -335,13 +335,19 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
jni_YGNodeStyleSetFlexBasis(mNativePointer, flexBasis); jni_YGNodeStyleSetFlexBasis(mNativePointer, flexBasis);
} }
private native float jni_YGNodeStyleGetMargin(long nativePointer, int edge); private native void jni_YGNodeStyleSetFlexBasisPercent(long nativePointer, float percent);
@Override @Override
public float getMargin(YogaEdge edge) { public void setFlexBasisPercent(float percent) {
jni_YGNodeStyleSetFlexBasisPercent(mNativePointer, percent);
}
private native Object jni_YGNodeStyleGetMargin(long nativePointer, int edge);
@Override
public YogaValue getMargin(YogaEdge edge) {
if (!mHasSetMargin) { if (!mHasSetMargin) {
return edge.intValue() < YogaEdge.START.intValue() ? 0 : YogaConstants.UNDEFINED; return edge.intValue() < YogaEdge.START.intValue() ? YogaValue.ZERO : YogaValue.UNDEFINED;
} }
return jni_YGNodeStyleGetMargin(mNativePointer, edge.intValue()); return (YogaValue) jni_YGNodeStyleGetMargin(mNativePointer, edge.intValue());
} }
private native void jni_YGNodeStyleSetMargin(long nativePointer, int edge, float margin); private native void jni_YGNodeStyleSetMargin(long nativePointer, int edge, float margin);
@@ -351,13 +357,20 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
jni_YGNodeStyleSetMargin(mNativePointer, edge.intValue(), margin); jni_YGNodeStyleSetMargin(mNativePointer, edge.intValue(), margin);
} }
private native float jni_YGNodeStyleGetPadding(long nativePointer, int edge); private native void jni_YGNodeStyleSetMarginPercent(long nativePointer, int edge, float percent);
@Override @Override
public float getPadding(YogaEdge edge) { public void setMarginPercent(YogaEdge edge, float percent) {
mHasSetMargin = true;
jni_YGNodeStyleSetMarginPercent(mNativePointer, edge.intValue(), percent);
}
private native Object jni_YGNodeStyleGetPadding(long nativePointer, int edge);
@Override
public YogaValue getPadding(YogaEdge edge) {
if (!mHasSetPadding) { if (!mHasSetPadding) {
return edge.intValue() < YogaEdge.START.intValue() ? 0 : YogaConstants.UNDEFINED; return edge.intValue() < YogaEdge.START.intValue() ? YogaValue.ZERO : YogaValue.UNDEFINED;
} }
return jni_YGNodeStyleGetPadding(mNativePointer, edge.intValue()); return (YogaValue) jni_YGNodeStyleGetPadding(mNativePointer, edge.intValue());
} }
private native void jni_YGNodeStyleSetPadding(long nativePointer, int edge, float padding); private native void jni_YGNodeStyleSetPadding(long nativePointer, int edge, float padding);
@@ -367,6 +380,13 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
jni_YGNodeStyleSetPadding(mNativePointer, edge.intValue(), padding); jni_YGNodeStyleSetPadding(mNativePointer, edge.intValue(), padding);
} }
private native void jni_YGNodeStyleSetPaddingPercent(long nativePointer, int edge, float percent);
@Override
public void setPaddingPercent(YogaEdge edge, float percent) {
mHasSetPadding = true;
jni_YGNodeStyleSetPaddingPercent(mNativePointer, edge.intValue(), percent);
}
private native float jni_YGNodeStyleGetBorder(long nativePointer, int edge); private native float jni_YGNodeStyleGetBorder(long nativePointer, int edge);
@Override @Override
public float getBorder(YogaEdge edge) { public float getBorder(YogaEdge edge) {
@@ -383,13 +403,13 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
jni_YGNodeStyleSetBorder(mNativePointer, edge.intValue(), border); jni_YGNodeStyleSetBorder(mNativePointer, edge.intValue(), border);
} }
private native float jni_YGNodeStyleGetPosition(long nativePointer, int edge); private native Object jni_YGNodeStyleGetPosition(long nativePointer, int edge);
@Override @Override
public float getPosition(YogaEdge edge) { public YogaValue getPosition(YogaEdge edge) {
if (!mHasSetPosition) { if (!mHasSetPosition) {
return YogaConstants.UNDEFINED; return YogaValue.UNDEFINED;
} }
return jni_YGNodeStyleGetPosition(mNativePointer, edge.intValue()); return (YogaValue) jni_YGNodeStyleGetPosition(mNativePointer, edge.intValue());
} }
private native void jni_YGNodeStyleSetPosition(long nativePointer, int edge, float position); private native void jni_YGNodeStyleSetPosition(long nativePointer, int edge, float position);
@@ -399,10 +419,17 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
jni_YGNodeStyleSetPosition(mNativePointer, edge.intValue(), position); jni_YGNodeStyleSetPosition(mNativePointer, edge.intValue(), position);
} }
private native float jni_YGNodeStyleGetWidth(long nativePointer); private native void jni_YGNodeStyleSetPositionPercent(long nativePointer, int edge, float percent);
@Override @Override
public float getWidth() { public void setPositionPercent(YogaEdge edge, float percent) {
return jni_YGNodeStyleGetWidth(mNativePointer); mHasSetPosition = true;
jni_YGNodeStyleSetPositionPercent(mNativePointer, edge.intValue(), percent);
}
private native Object jni_YGNodeStyleGetWidth(long nativePointer);
@Override
public YogaValue getWidth() {
return (YogaValue) jni_YGNodeStyleGetWidth(mNativePointer);
} }
private native void jni_YGNodeStyleSetWidth(long nativePointer, float width); private native void jni_YGNodeStyleSetWidth(long nativePointer, float width);
@@ -411,10 +438,16 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
jni_YGNodeStyleSetWidth(mNativePointer, width); jni_YGNodeStyleSetWidth(mNativePointer, width);
} }
private native float jni_YGNodeStyleGetHeight(long nativePointer); private native void jni_YGNodeStyleSetWidthPercent(long nativePointer, float percent);
@Override @Override
public float getHeight() { public void setWidthPercent(float percent) {
return jni_YGNodeStyleGetHeight(mNativePointer); jni_YGNodeStyleSetWidthPercent(mNativePointer, percent);
}
private native Object jni_YGNodeStyleGetHeight(long nativePointer);
@Override
public YogaValue getHeight() {
return (YogaValue) jni_YGNodeStyleGetHeight(mNativePointer);
} }
private native void jni_YGNodeStyleSetHeight(long nativePointer, float height); private native void jni_YGNodeStyleSetHeight(long nativePointer, float height);
@@ -423,10 +456,16 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
jni_YGNodeStyleSetHeight(mNativePointer, height); jni_YGNodeStyleSetHeight(mNativePointer, height);
} }
private native float jni_YGNodeStyleGetMinWidth(long nativePointer); private native void jni_YGNodeStyleSetHeightPercent(long nativePointer, float percent);
@Override @Override
public float getMinWidth() { public void setHeightPercent(float percent) {
return jni_YGNodeStyleGetMinWidth(mNativePointer); jni_YGNodeStyleSetHeightPercent(mNativePointer, percent);
}
private native Object jni_YGNodeStyleGetMinWidth(long nativePointer);
@Override
public YogaValue getMinWidth() {
return (YogaValue) jni_YGNodeStyleGetMinWidth(mNativePointer);
} }
private native void jni_YGNodeStyleSetMinWidth(long nativePointer, float minWidth); private native void jni_YGNodeStyleSetMinWidth(long nativePointer, float minWidth);
@@ -435,10 +474,16 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
jni_YGNodeStyleSetMinWidth(mNativePointer, minWidth); jni_YGNodeStyleSetMinWidth(mNativePointer, minWidth);
} }
private native float jni_YGNodeStyleGetMinHeight(long nativePointer); private native void jni_YGNodeStyleSetMinWidthPercent(long nativePointer, float percent);
@Override @Override
public float getMinHeight() { public void setMinWidthPercent(float percent) {
return jni_YGNodeStyleGetMinHeight(mNativePointer); jni_YGNodeStyleSetMinWidthPercent(mNativePointer, percent);
}
private native Object jni_YGNodeStyleGetMinHeight(long nativePointer);
@Override
public YogaValue getMinHeight() {
return (YogaValue) jni_YGNodeStyleGetMinHeight(mNativePointer);
} }
private native void jni_YGNodeStyleSetMinHeight(long nativePointer, float minHeight); private native void jni_YGNodeStyleSetMinHeight(long nativePointer, float minHeight);
@@ -447,10 +492,16 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
jni_YGNodeStyleSetMinHeight(mNativePointer, minHeight); jni_YGNodeStyleSetMinHeight(mNativePointer, minHeight);
} }
private native float jni_YGNodeStyleGetMaxWidth(long nativePointer); private native void jni_YGNodeStyleSetMinHeightPercent(long nativePointer, float percent);
@Override @Override
public float getMaxWidth() { public void setMinHeightPercent(float percent) {
return jni_YGNodeStyleGetMaxWidth(mNativePointer); jni_YGNodeStyleSetMinHeightPercent(mNativePointer, percent);
}
private native Object jni_YGNodeStyleGetMaxWidth(long nativePointer);
@Override
public YogaValue getMaxWidth() {
return (YogaValue) jni_YGNodeStyleGetMaxWidth(mNativePointer);
} }
private native void jni_YGNodeStyleSetMaxWidth(long nativePointer, float maxWidth); private native void jni_YGNodeStyleSetMaxWidth(long nativePointer, float maxWidth);
@@ -459,10 +510,16 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
jni_YGNodeStyleSetMaxWidth(mNativePointer, maxWidth); jni_YGNodeStyleSetMaxWidth(mNativePointer, maxWidth);
} }
private native float jni_YGNodeStyleGetMaxHeight(long nativePointer); private native void jni_YGNodeStyleSetMaxWidthPercent(long nativePointer, float percent);
@Override @Override
public float getMaxHeight() { public void setMaxWidthPercent(float percent) {
return jni_YGNodeStyleGetMaxHeight(mNativePointer); jni_YGNodeStyleSetMaxWidthPercent(mNativePointer, percent);
}
private native Object jni_YGNodeStyleGetMaxHeight(long nativePointer);
@Override
public YogaValue getMaxHeight() {
return (YogaValue) jni_YGNodeStyleGetMaxHeight(mNativePointer);
} }
private native void jni_YGNodeStyleSetMaxHeight(long nativePointer, float maxheight); private native void jni_YGNodeStyleSetMaxHeight(long nativePointer, float maxheight);
@@ -471,6 +528,12 @@ public class YogaNode implements YogaNodeAPI<YogaNode> {
jni_YGNodeStyleSetMaxHeight(mNativePointer, maxheight); jni_YGNodeStyleSetMaxHeight(mNativePointer, maxheight);
} }
private native void jni_YGNodeStyleSetMaxHeightPercent(long nativePointer, float percent);
@Override
public void setMaxHeightPercent(float percent) {
jni_YGNodeStyleSetMaxHeightPercent(mNativePointer, percent);
}
private native float jni_YGNodeStyleGetAspectRatio(long nativePointer); private native float jni_YGNodeStyleGetAspectRatio(long nativePointer);
public float getAspectRatio() { public float getAspectRatio() {
return jni_YGNodeStyleGetAspectRatio(mNativePointer); return jni_YGNodeStyleGetAspectRatio(mNativePointer);

View File

@@ -45,28 +45,38 @@ public interface YogaNodeAPI<YogaNodeType extends YogaNodeAPI> {
void setFlexGrow(float flexGrow); void setFlexGrow(float flexGrow);
float getFlexShrink(); float getFlexShrink();
void setFlexShrink(float flexShrink); void setFlexShrink(float flexShrink);
float getFlexBasis(); YogaValue getFlexBasis();
void setFlexBasis(float flexBasis); void setFlexBasis(float flexBasis);
float getMargin(YogaEdge edge); void setFlexBasisPercent(float percent);
YogaValue getMargin(YogaEdge edge);
void setMargin(YogaEdge edge, float margin); void setMargin(YogaEdge edge, float margin);
float getPadding(YogaEdge edge); void setMarginPercent(YogaEdge edge, float percent);
YogaValue getPadding(YogaEdge edge);
void setPadding(YogaEdge edge, float padding); void setPadding(YogaEdge edge, float padding);
void setPaddingPercent(YogaEdge edge, float percent);
float getBorder(YogaEdge edge); float getBorder(YogaEdge edge);
void setBorder(YogaEdge edge, float border); void setBorder(YogaEdge edge, float border);
float getPosition(YogaEdge edge); YogaValue getPosition(YogaEdge edge);
void setPosition(YogaEdge edge, float position); void setPosition(YogaEdge edge, float position);
float getWidth(); void setPositionPercent(YogaEdge edge, float percent);
YogaValue getWidth();
void setWidth(float width); void setWidth(float width);
float getHeight(); void setWidthPercent(float percent);
YogaValue getHeight();
void setHeight(float height); void setHeight(float height);
float getMaxWidth(); void setHeightPercent(float percent);
YogaValue getMaxWidth();
void setMaxWidth(float maxWidth); void setMaxWidth(float maxWidth);
float getMinWidth(); void setMaxWidthPercent(float percent);
YogaValue getMinWidth();
void setMinWidth(float minWidth); void setMinWidth(float minWidth);
float getMaxHeight(); void setMinWidthPercent(float percent);
YogaValue getMaxHeight();
void setMaxHeight(float maxHeight); void setMaxHeight(float maxHeight);
float getMinHeight(); void setMaxHeightPercent(float percent);
YogaValue getMinHeight();
void setMinHeight(float minHeight); void setMinHeight(float minHeight);
void setMinHeightPercent(float percent);
float getLayoutX(); float getLayoutX();
float getLayoutY(); float getLayoutY();
float getLayoutWidth(); float getLayoutWidth();

View File

@@ -0,0 +1,38 @@
/**
* 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.
*/
package com.facebook.yoga;
import com.facebook.proguard.annotations.DoNotStrip;
@DoNotStrip
public enum YogaUnit {
UNDEFINED(0),
PIXEL(1),
PERCENT(2);
private int mIntValue;
YogaUnit(int intValue) {
mIntValue = intValue;
}
public int intValue() {
return mIntValue;
}
public static YogaUnit fromInt(int value) {
switch (value) {
case 0: return UNDEFINED;
case 1: return PIXEL;
case 2: return PERCENT;
default: throw new IllegalArgumentException("Unkown enum value: " + value);
}
}
}

View File

@@ -0,0 +1,45 @@
/**
* 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.
*/
package com.facebook.yoga;
import com.facebook.proguard.annotations.DoNotStrip;
@DoNotStrip
public class YogaValue {
static final YogaValue UNDEFINED = new YogaValue(YogaConstants.UNDEFINED, YogaUnit.UNDEFINED);
static final YogaValue ZERO = new YogaValue(0, YogaUnit.PIXEL);
public final float value;
public final YogaUnit unit;
YogaValue(float value, YogaUnit unit) {
this.value = value;
this.unit = unit;
}
@DoNotStrip
YogaValue(float value, int unit) {
this(value, YogaUnit.fromInt(unit));
}
@Override
public boolean equals(Object other) {
if (other instanceof YogaValue) {
final YogaValue otherValue = (YogaValue) other;
return value == otherValue.value && unit == otherValue.unit;
}
return false;
}
@Override
public int hashCode() {
return Float.floatToIntBits(value) + unit.intValue();
}
}

View File

@@ -7,9 +7,9 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
#include <yoga/Yoga.h>
#include <fb/fbjni.h> #include <fb/fbjni.h>
#include <iostream> #include <iostream>
#include <yoga/Yoga.h>
using namespace facebook::jni; using namespace facebook::jni;
using namespace std; using namespace std;
@@ -70,8 +70,8 @@ static YGSize YGJNIMeasureFunc(YGNodeRef node,
int32_t wBits = 0xFFFFFFFF & (measureResult >> 32); int32_t wBits = 0xFFFFFFFF & (measureResult >> 32);
int32_t hBits = 0xFFFFFFFF & measureResult; int32_t hBits = 0xFFFFFFFF & measureResult;
const float *measuredWidth = reinterpret_cast<float*>(&wBits); const float *measuredWidth = reinterpret_cast<float *>(&wBits);
const float *measuredHeight = reinterpret_cast<float*>(&hBits); const float *measuredHeight = reinterpret_cast<float *>(&hBits);
return YGSize{*measuredWidth, *measuredHeight}; return YGSize{*measuredWidth, *measuredHeight};
} else { } else {
@@ -204,6 +204,14 @@ void jni_YGNodeCopyStyle(alias_ref<jobject>, jlong dstNativePointer, jlong srcNa
YGNodeCopyStyle(_jlong2YGNodeRef(dstNativePointer), _jlong2YGNodeRef(srcNativePointer)); YGNodeCopyStyle(_jlong2YGNodeRef(dstNativePointer), _jlong2YGNodeRef(srcNativePointer));
} }
struct JYogaValue : public JavaClass<JYogaValue> {
constexpr static auto kJavaDescriptor = "Lcom/facebook/yoga/YogaValue;";
static local_ref<javaobject> create(YGValue value) {
return newInstance(value.value, static_cast<int>(value.unit));
}
};
#define YG_NODE_JNI_STYLE_PROP(javatype, type, name) \ #define YG_NODE_JNI_STYLE_PROP(javatype, type, name) \
javatype jni_YGNodeStyleGet##name(alias_ref<jobject>, jlong nativePointer) { \ javatype jni_YGNodeStyleGet##name(alias_ref<jobject>, jlong nativePointer) { \
return (javatype) YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer)); \ return (javatype) YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer)); \
@@ -213,6 +221,19 @@ void jni_YGNodeCopyStyle(alias_ref<jobject>, jlong dstNativePointer, jlong srcNa
YGNodeStyleSet##name(_jlong2YGNodeRef(nativePointer), static_cast<type>(value)); \ YGNodeStyleSet##name(_jlong2YGNodeRef(nativePointer), static_cast<type>(value)); \
} }
#define YG_NODE_JNI_STYLE_UNIT_PROP(name) \
local_ref<jobject> jni_YGNodeStyleGet##name(alias_ref<jobject>, jlong nativePointer) { \
return JYogaValue::create(YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer))); \
} \
\
void jni_YGNodeStyleSet##name(alias_ref<jobject>, jlong nativePointer, jfloat value) { \
YGNodeStyleSet##name(_jlong2YGNodeRef(nativePointer), static_cast<float>(value)); \
} \
\
void jni_YGNodeStyleSet##name##Percent(alias_ref<jobject>, jlong nativePointer, jfloat value) { \
YGNodeStyleSet##name##Percent(_jlong2YGNodeRef(nativePointer), static_cast<float>(value)); \
}
#define YG_NODE_JNI_STYLE_EDGE_PROP(javatype, type, name) \ #define YG_NODE_JNI_STYLE_EDGE_PROP(javatype, type, name) \
javatype jni_YGNodeStyleGet##name(alias_ref<jobject>, jlong nativePointer, jint edge) { \ javatype jni_YGNodeStyleGet##name(alias_ref<jobject>, jlong nativePointer, jint edge) { \
return (javatype) YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer), \ return (javatype) YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer), \
@@ -228,6 +249,29 @@ void jni_YGNodeCopyStyle(alias_ref<jobject>, jlong dstNativePointer, jlong srcNa
static_cast<type>(value)); \ static_cast<type>(value)); \
} }
#define YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(name) \
local_ref<jobject> jni_YGNodeStyleGet##name(alias_ref<jobject>, \
jlong nativePointer, \
jint edge) { \
return JYogaValue::create( \
YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer), static_cast<YGEdge>(edge))); \
} \
\
void jni_YGNodeStyleSet##name(alias_ref<jobject>, jlong nativePointer, jint edge, jfloat value) { \
YGNodeStyleSet##name(_jlong2YGNodeRef(nativePointer), \
static_cast<YGEdge>(edge), \
static_cast<float>(value)); \
} \
\
void jni_YGNodeStyleSet##name##Percent(alias_ref<jobject>, \
jlong nativePointer, \
jint edge, \
jfloat value) { \
YGNodeStyleSet##name##Percent(_jlong2YGNodeRef(nativePointer), \
static_cast<YGEdge>(edge), \
static_cast<float>(value)); \
}
YG_NODE_JNI_STYLE_PROP(jint, YGDirection, Direction); YG_NODE_JNI_STYLE_PROP(jint, YGDirection, Direction);
YG_NODE_JNI_STYLE_PROP(jint, YGFlexDirection, FlexDirection); YG_NODE_JNI_STYLE_PROP(jint, YGFlexDirection, FlexDirection);
YG_NODE_JNI_STYLE_PROP(jint, YGJustify, JustifyContent); YG_NODE_JNI_STYLE_PROP(jint, YGJustify, JustifyContent);
@@ -243,19 +287,19 @@ void jni_YGNodeStyleSetFlex(alias_ref<jobject>, jlong nativePointer, jfloat valu
} }
YG_NODE_JNI_STYLE_PROP(jfloat, float, FlexGrow); YG_NODE_JNI_STYLE_PROP(jfloat, float, FlexGrow);
YG_NODE_JNI_STYLE_PROP(jfloat, float, FlexShrink); YG_NODE_JNI_STYLE_PROP(jfloat, float, FlexShrink);
YG_NODE_JNI_STYLE_PROP(jfloat, float, FlexBasis); YG_NODE_JNI_STYLE_UNIT_PROP(FlexBasis);
YG_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Position); YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(Position);
YG_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Margin); YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(Margin);
YG_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Padding); YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(Padding);
YG_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Border); YG_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Border);
YG_NODE_JNI_STYLE_PROP(jfloat, float, Width); YG_NODE_JNI_STYLE_UNIT_PROP(Width);
YG_NODE_JNI_STYLE_PROP(jfloat, float, MinWidth); YG_NODE_JNI_STYLE_UNIT_PROP(MinWidth);
YG_NODE_JNI_STYLE_PROP(jfloat, float, MaxWidth); YG_NODE_JNI_STYLE_UNIT_PROP(MaxWidth);
YG_NODE_JNI_STYLE_PROP(jfloat, float, Height); YG_NODE_JNI_STYLE_UNIT_PROP(Height);
YG_NODE_JNI_STYLE_PROP(jfloat, float, MinHeight); YG_NODE_JNI_STYLE_UNIT_PROP(MinHeight);
YG_NODE_JNI_STYLE_PROP(jfloat, float, MaxHeight); YG_NODE_JNI_STYLE_UNIT_PROP(MaxHeight);
// Yoga specific properties, not compatible with flexbox specification // Yoga specific properties, not compatible with flexbox specification
YG_NODE_JNI_STYLE_PROP(jfloat, float, AspectRatio); YG_NODE_JNI_STYLE_PROP(jfloat, float, AspectRatio);
@@ -278,7 +322,6 @@ jint JNI_OnLoad(JavaVM *vm, void *) {
YGMakeNativeMethod(jni_YGNodeMarkLayoutSeen), YGMakeNativeMethod(jni_YGNodeMarkLayoutSeen),
YGMakeNativeMethod(jni_YGNodeSetHasMeasureFunc), YGMakeNativeMethod(jni_YGNodeSetHasMeasureFunc),
YGMakeNativeMethod(jni_YGNodeCopyStyle), YGMakeNativeMethod(jni_YGNodeCopyStyle),
YGMakeNativeMethod(jni_YGNodeStyleGetDirection), YGMakeNativeMethod(jni_YGNodeStyleGetDirection),
YGMakeNativeMethod(jni_YGNodeStyleSetDirection), YGMakeNativeMethod(jni_YGNodeStyleSetDirection),
YGMakeNativeMethod(jni_YGNodeStyleGetFlexDirection), YGMakeNativeMethod(jni_YGNodeStyleGetFlexDirection),
@@ -303,29 +346,38 @@ jint JNI_OnLoad(JavaVM *vm, void *) {
YGMakeNativeMethod(jni_YGNodeStyleSetFlexShrink), YGMakeNativeMethod(jni_YGNodeStyleSetFlexShrink),
YGMakeNativeMethod(jni_YGNodeStyleGetFlexBasis), YGMakeNativeMethod(jni_YGNodeStyleGetFlexBasis),
YGMakeNativeMethod(jni_YGNodeStyleSetFlexBasis), YGMakeNativeMethod(jni_YGNodeStyleSetFlexBasis),
YGMakeNativeMethod(jni_YGNodeStyleSetFlexBasisPercent),
YGMakeNativeMethod(jni_YGNodeStyleGetMargin), YGMakeNativeMethod(jni_YGNodeStyleGetMargin),
YGMakeNativeMethod(jni_YGNodeStyleSetMargin), YGMakeNativeMethod(jni_YGNodeStyleSetMargin),
YGMakeNativeMethod(jni_YGNodeStyleSetMarginPercent),
YGMakeNativeMethod(jni_YGNodeStyleGetPadding), YGMakeNativeMethod(jni_YGNodeStyleGetPadding),
YGMakeNativeMethod(jni_YGNodeStyleSetPadding), YGMakeNativeMethod(jni_YGNodeStyleSetPadding),
YGMakeNativeMethod(jni_YGNodeStyleSetPaddingPercent),
YGMakeNativeMethod(jni_YGNodeStyleGetBorder), YGMakeNativeMethod(jni_YGNodeStyleGetBorder),
YGMakeNativeMethod(jni_YGNodeStyleSetBorder), YGMakeNativeMethod(jni_YGNodeStyleSetBorder),
YGMakeNativeMethod(jni_YGNodeStyleGetPosition), YGMakeNativeMethod(jni_YGNodeStyleGetPosition),
YGMakeNativeMethod(jni_YGNodeStyleSetPosition), YGMakeNativeMethod(jni_YGNodeStyleSetPosition),
YGMakeNativeMethod(jni_YGNodeStyleSetPositionPercent),
YGMakeNativeMethod(jni_YGNodeStyleGetWidth), YGMakeNativeMethod(jni_YGNodeStyleGetWidth),
YGMakeNativeMethod(jni_YGNodeStyleSetWidth), YGMakeNativeMethod(jni_YGNodeStyleSetWidth),
YGMakeNativeMethod(jni_YGNodeStyleSetWidthPercent),
YGMakeNativeMethod(jni_YGNodeStyleGetHeight), YGMakeNativeMethod(jni_YGNodeStyleGetHeight),
YGMakeNativeMethod(jni_YGNodeStyleSetHeight), YGMakeNativeMethod(jni_YGNodeStyleSetHeight),
YGMakeNativeMethod(jni_YGNodeStyleSetHeightPercent),
YGMakeNativeMethod(jni_YGNodeStyleGetMinWidth), YGMakeNativeMethod(jni_YGNodeStyleGetMinWidth),
YGMakeNativeMethod(jni_YGNodeStyleSetMinWidth), YGMakeNativeMethod(jni_YGNodeStyleSetMinWidth),
YGMakeNativeMethod(jni_YGNodeStyleSetMinWidthPercent),
YGMakeNativeMethod(jni_YGNodeStyleGetMinHeight), YGMakeNativeMethod(jni_YGNodeStyleGetMinHeight),
YGMakeNativeMethod(jni_YGNodeStyleSetMinHeight), YGMakeNativeMethod(jni_YGNodeStyleSetMinHeight),
YGMakeNativeMethod(jni_YGNodeStyleSetMinHeightPercent),
YGMakeNativeMethod(jni_YGNodeStyleGetMaxWidth), YGMakeNativeMethod(jni_YGNodeStyleGetMaxWidth),
YGMakeNativeMethod(jni_YGNodeStyleSetMaxWidth), YGMakeNativeMethod(jni_YGNodeStyleSetMaxWidth),
YGMakeNativeMethod(jni_YGNodeStyleSetMaxWidthPercent),
YGMakeNativeMethod(jni_YGNodeStyleGetMaxHeight), YGMakeNativeMethod(jni_YGNodeStyleGetMaxHeight),
YGMakeNativeMethod(jni_YGNodeStyleSetMaxHeight), YGMakeNativeMethod(jni_YGNodeStyleSetMaxHeight),
YGMakeNativeMethod(jni_YGNodeStyleSetMaxHeightPercent),
YGMakeNativeMethod(jni_YGNodeStyleGetAspectRatio), YGMakeNativeMethod(jni_YGNodeStyleGetAspectRatio),
YGMakeNativeMethod(jni_YGNodeStyleSetAspectRatio), YGMakeNativeMethod(jni_YGNodeStyleSetAspectRatio),
YGMakeNativeMethod(jni_YGNodeGetInstanceCount), YGMakeNativeMethod(jni_YGNodeGetInstanceCount),
YGMakeNativeMethod(jni_YGSetLogger), YGMakeNativeMethod(jni_YGSetLogger),
YGMakeNativeMethod(jni_YGLog), YGMakeNativeMethod(jni_YGLog),

View File

@@ -0,0 +1,941 @@
/**
* 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.
*/
// @Generated by gentest/gentest.rb from gentest/fixtures/YGPercentageTest.html
package com.facebook.yoga;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class YGPercentageTest {
@Test
public void test_percentage_width_height() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
root_child0.setWidthPercent(30f);
root_child0.setHeightPercent(30f);
root.addChildAt(root_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(60f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(140f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(60f, root_child0.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_position_left_top() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(400f);
root.setHeight(400f);
final YogaNode root_child0 = new YogaNode();
root_child0.setPositionPercent(YogaEdge.LEFT, 10f);
root_child0.setPositionPercent(YogaEdge.TOP, 20f);
root_child0.setWidthPercent(45f);
root_child0.setHeightPercent(55f);
root.addChildAt(root_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(400f, root.getLayoutWidth(), 0.0f);
assertEquals(400f, root.getLayoutHeight(), 0.0f);
assertEquals(40f, root_child0.getLayoutX(), 0.0f);
assertEquals(80f, root_child0.getLayoutY(), 0.0f);
assertEquals(180f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(220f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(400f, root.getLayoutWidth(), 0.0f);
assertEquals(400f, root.getLayoutHeight(), 0.0f);
assertEquals(260f, root_child0.getLayoutX(), 0.0f);
assertEquals(80f, root_child0.getLayoutY(), 0.0f);
assertEquals(180f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(220f, root_child0.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_position_bottom_right() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(500f);
root.setHeight(500f);
final YogaNode root_child0 = new YogaNode();
root_child0.setPositionPercent(YogaEdge.RIGHT, 20f);
root_child0.setPositionPercent(YogaEdge.BOTTOM, 10f);
root_child0.setWidthPercent(55f);
root_child0.setHeightPercent(15f);
root.addChildAt(root_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(500f, root.getLayoutWidth(), 0.0f);
assertEquals(500f, root.getLayoutHeight(), 0.0f);
assertEquals(-100f, root_child0.getLayoutX(), 0.0f);
assertEquals(-50f, root_child0.getLayoutY(), 0.0f);
assertEquals(275f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(75f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(500f, root.getLayoutWidth(), 0.0f);
assertEquals(500f, root.getLayoutHeight(), 0.0f);
assertEquals(125f, root_child0.getLayoutX(), 0.0f);
assertEquals(-50f, root_child0.getLayoutY(), 0.0f);
assertEquals(275f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(75f, root_child0.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_flex_basis() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
root_child0.setFlexGrow(1f);
root_child0.setFlexBasisPercent(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
root_child1.setFlexGrow(1f);
root_child1.setFlexBasisPercent(25f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(125f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(125f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(75f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(75f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(125f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(75f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child1.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_flex_basis_cross() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
root_child0.setFlexGrow(1f);
root_child0.setFlexBasisPercent(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
root_child1.setFlexGrow(1f);
root_child1.setFlexBasisPercent(25f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(125f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(125f, root_child1.getLayoutY(), 0.0f);
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(75f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(125f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(125f, root_child1.getLayoutY(), 0.0f);
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(75f, root_child1.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_flex_basis_cross_min_height() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
root_child0.setFlexGrow(1f);
root_child0.setMinHeightPercent(60f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
root_child1.setFlexGrow(2f);
root_child1.setMinHeightPercent(10f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(140f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(140f, root_child1.getLayoutY(), 0.0f);
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(60f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(140f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(140f, root_child1.getLayoutY(), 0.0f);
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(60f, root_child1.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_flex_basis_main_max_height() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
root_child0.setFlexGrow(1f);
root_child0.setFlexBasisPercent(10f);
root_child0.setMaxHeightPercent(60f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
root_child1.setFlexGrow(4f);
root_child1.setFlexBasisPercent(10f);
root_child1.setMaxHeightPercent(20f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(52f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(120f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(52f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(148f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(40f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(148f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(52f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(120f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(148f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(40f, root_child1.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_flex_basis_cross_max_height() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
root_child0.setFlexGrow(1f);
root_child0.setFlexBasisPercent(10f);
root_child0.setMaxHeightPercent(60f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
root_child1.setFlexGrow(4f);
root_child1.setFlexBasisPercent(10f);
root_child1.setMaxHeightPercent(20f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(120f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(120f, root_child1.getLayoutY(), 0.0f);
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(40f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(120f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(120f, root_child1.getLayoutY(), 0.0f);
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(40f, root_child1.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_flex_basis_main_max_width() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
root_child0.setFlexGrow(1f);
root_child0.setFlexBasisPercent(15f);
root_child0.setMaxWidthPercent(60f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
root_child1.setFlexGrow(4f);
root_child1.setFlexBasisPercent(10f);
root_child1.setMaxWidthPercent(20f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(120f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(120f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(80f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(120f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(40f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child1.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_flex_basis_cross_max_width() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
root_child0.setFlexGrow(1f);
root_child0.setFlexBasisPercent(10f);
root_child0.setMaxWidthPercent(60f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
root_child1.setFlexGrow(4f);
root_child1.setFlexBasisPercent(15f);
root_child1.setMaxWidthPercent(20f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(120f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(50f, root_child1.getLayoutY(), 0.0f);
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(150f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(80f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(120f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(160f, root_child1.getLayoutX(), 0.0f);
assertEquals(50f, root_child1.getLayoutY(), 0.0f);
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(150f, root_child1.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_flex_basis_main_min_width() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
root.setFlexDirection(YogaFlexDirection.ROW);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
root_child0.setFlexGrow(1f);
root_child0.setFlexBasisPercent(15f);
root_child0.setMinWidthPercent(60f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
root_child1.setFlexGrow(4f);
root_child1.setFlexBasisPercent(10f);
root_child1.setMinWidthPercent(20f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(120f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(120f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(80f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(80f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(120f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(80f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child1.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_flex_basis_cross_min_width() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
root_child0.setFlexGrow(1f);
root_child0.setFlexBasisPercent(10f);
root_child0.setMinWidthPercent(60f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = new YogaNode();
root_child1.setFlexGrow(4f);
root_child1.setFlexBasisPercent(15f);
root_child1.setMinWidthPercent(20f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(50f, root_child1.getLayoutY(), 0.0f);
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(150f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(50f, root_child1.getLayoutY(), 0.0f);
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(150f, root_child1.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_multiple_nested_with_padding_margin_and_percentage_values() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = new YogaNode();
root_child0.setFlexGrow(1f);
root_child0.setFlexBasisPercent(10f);
root_child0.setMargin(YogaEdge.LEFT, 5f);
root_child0.setMargin(YogaEdge.TOP, 5f);
root_child0.setMargin(YogaEdge.RIGHT, 5f);
root_child0.setMargin(YogaEdge.BOTTOM, 5f);
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.setMinWidthPercent(60f);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = new YogaNode();
root_child0_child0.setMargin(YogaEdge.LEFT, 5f);
root_child0_child0.setMargin(YogaEdge.TOP, 5f);
root_child0_child0.setMargin(YogaEdge.RIGHT, 5f);
root_child0_child0.setMargin(YogaEdge.BOTTOM, 5f);
root_child0_child0.setPaddingPercent(YogaEdge.LEFT, 3);
root_child0_child0.setPaddingPercent(YogaEdge.TOP, 3);
root_child0_child0.setPaddingPercent(YogaEdge.RIGHT, 3);
root_child0_child0.setPaddingPercent(YogaEdge.BOTTOM, 3);
root_child0_child0.setWidthPercent(50f);
root_child0.addChildAt(root_child0_child0, 0);
final YogaNode root_child0_child0_child0 = new YogaNode();
root_child0_child0_child0.setMarginPercent(YogaEdge.LEFT, 5f);
root_child0_child0_child0.setMarginPercent(YogaEdge.TOP, 5f);
root_child0_child0_child0.setMarginPercent(YogaEdge.RIGHT, 5f);
root_child0_child0_child0.setMarginPercent(YogaEdge.BOTTOM, 5f);
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.setWidthPercent(45f);
root_child0_child0.addChildAt(root_child0_child0_child0, 0);
final YogaNode root_child1 = new YogaNode();
root_child1.setFlexGrow(4f);
root_child1.setFlexBasisPercent(15f);
root_child1.setMinWidthPercent(20f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(5f, root_child0.getLayoutX(), 0.0f);
assertEquals(5f, root_child0.getLayoutY(), 0.0f);
assertEquals(190f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(48f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(8f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(8f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(92f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(25f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(10f, root_child0_child0_child0.getLayoutX(), 0.0f);
assertEquals(10f, root_child0_child0_child0.getLayoutY(), 0.0f);
assertEquals(36f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(6f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(58f, root_child1.getLayoutY(), 0.0f);
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(142f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(5f, root_child0.getLayoutX(), 0.0f);
assertEquals(5f, root_child0.getLayoutY(), 0.0f);
assertEquals(190f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(48f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(90f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(8f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(92f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(25f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(46f, root_child0_child0_child0.getLayoutX(), 0.0f);
assertEquals(10f, root_child0_child0_child0.getLayoutY(), 0.0f);
assertEquals(36f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(6f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(58f, root_child1.getLayoutY(), 0.0f);
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(142f, root_child1.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_margin_should_calculate_based_only_on_width() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
root.setWidth(200f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
root_child0.setFlexGrow(1f);
root_child0.setMarginPercent(YogaEdge.LEFT, 10f);
root_child0.setMarginPercent(YogaEdge.TOP, 10f);
root_child0.setMarginPercent(YogaEdge.RIGHT, 10f);
root_child0.setMarginPercent(YogaEdge.BOTTOM, 10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = new YogaNode();
root_child0_child0.setWidth(10f);
root_child0_child0.setHeight(10f);
root_child0.addChildAt(root_child0_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0.getLayoutX(), 0.0f);
assertEquals(20f, root_child0.getLayoutY(), 0.0f);
assertEquals(160f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(60f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0.getLayoutX(), 0.0f);
assertEquals(20f, root_child0.getLayoutY(), 0.0f);
assertEquals(160f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(60f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(150f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_padding_should_calculate_based_only_on_width() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
root.setWidth(200f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
root_child0.setFlexGrow(1f);
root_child0.setPaddingPercent(YogaEdge.LEFT, 10);
root_child0.setPaddingPercent(YogaEdge.TOP, 10);
root_child0.setPaddingPercent(YogaEdge.RIGHT, 10);
root_child0.setPaddingPercent(YogaEdge.BOTTOM, 10);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = new YogaNode();
root_child0_child0.setWidth(10f);
root_child0_child0.setHeight(10f);
root_child0.addChildAt(root_child0_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(20f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(170f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(20f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
@Test
public void test_percentage_absolute_position() {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
final YogaNode root = new YogaNode();
root.setWidth(200f);
root.setHeight(100f);
final YogaNode root_child0 = new YogaNode();
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0.setPositionPercent(YogaEdge.LEFT, 30f);
root_child0.setPositionPercent(YogaEdge.TOP, 10f);
root_child0.setWidth(10f);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(60f, root_child0.getLayoutX(), 0.0f);
assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(60f, root_child0.getLayoutX(), 0.0f);
assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
}

View File

@@ -136,6 +136,6 @@ public class YogaNodeTest {
node1.setMaxHeight(100); node1.setMaxHeight(100);
node0.copyStyle(node1); node0.copyStyle(node1);
assertEquals(100, (int) node0.getMaxHeight()); assertEquals(100, (int) node0.getMaxHeight().value);
} }
} }

View File

@@ -27,49 +27,49 @@ TEST(YogaTest, assert_default_values) {
ASSERT_EQ(YGOverflowVisible, YGNodeStyleGetOverflow(root)); ASSERT_EQ(YGOverflowVisible, YGNodeStyleGetOverflow(root));
ASSERT_FLOAT_EQ(0, YGNodeStyleGetFlexGrow(root)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetFlexGrow(root));
ASSERT_FLOAT_EQ(0, YGNodeStyleGetFlexShrink(root)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetFlexShrink(root));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetFlexBasis(root))); ASSERT_FALSE(YGNodeStyleGetFlexBasis(root).unit != YGUnitUndefined);
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetPosition(root, YGEdgeLeft))); ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeLeft).unit != YGUnitUndefined);
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetPosition(root, YGEdgeTop))); ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeTop).unit != YGUnitUndefined);
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetPosition(root, YGEdgeRight))); ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeRight).unit != YGUnitUndefined);
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetPosition(root, YGEdgeBottom))); ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeBottom).unit != YGUnitUndefined);
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetPosition(root, YGEdgeStart))); ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeStart).unit != YGUnitUndefined);
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetPosition(root, YGEdgeEnd))); ASSERT_FALSE(YGNodeStyleGetPosition(root, YGEdgeEnd).unit != YGUnitUndefined);
ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeLeft)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeLeft).value);
ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeTop)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeTop).value);
ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeRight)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeRight).value);
ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeBottom)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeBottom).value);
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetMargin(root, YGEdgeStart))); ASSERT_FALSE(YGNodeStyleGetMargin(root, YGEdgeStart).unit != YGUnitUndefined);
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetMargin(root, YGEdgeEnd))); ASSERT_FALSE(YGNodeStyleGetMargin(root, YGEdgeEnd).unit != YGUnitUndefined);
ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeLeft)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeLeft).value);
ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeTop)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeTop).value);
ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeRight)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeRight).value);
ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeBottom)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeBottom).value);
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetPadding(root, YGEdgeStart))); ASSERT_FALSE(YGNodeStyleGetPadding(root, YGEdgeStart).unit != YGUnitUndefined);
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetPadding(root, YGEdgeEnd))); ASSERT_FALSE(YGNodeStyleGetPadding(root, YGEdgeEnd).unit != YGUnitUndefined);
ASSERT_FLOAT_EQ(0, YGNodeStyleGetBorder(root, YGEdgeLeft)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetBorder(root, YGEdgeLeft));
ASSERT_FLOAT_EQ(0, YGNodeStyleGetBorder(root, YGEdgeTop)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetBorder(root, YGEdgeTop));
ASSERT_FLOAT_EQ(0, YGNodeStyleGetBorder(root, YGEdgeRight)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetBorder(root, YGEdgeRight));
ASSERT_FLOAT_EQ(0, YGNodeStyleGetBorder(root, YGEdgeBottom)); ASSERT_FLOAT_EQ(0, YGNodeStyleGetBorder(root, YGEdgeBottom));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetBorder(root, YGEdgeStart))); ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetBorder(root, YGEdgeStart)));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetBorder(root, YGEdgeEnd))); ASSERT_TRUE(YGFloatIsUndefined(YGNodeStyleGetBorder(root, YGEdgeEnd)));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetWidth(root))); ASSERT_FALSE(YGNodeStyleGetWidth(root).unit != YGUnitUndefined);
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetHeight(root))); ASSERT_FALSE(YGNodeStyleGetHeight(root).unit != YGUnitUndefined);
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetMinWidth(root))); ASSERT_FALSE(YGNodeStyleGetMinWidth(root).unit != YGUnitUndefined);
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetMinHeight(root))); ASSERT_FALSE(YGNodeStyleGetMinHeight(root).unit != YGUnitUndefined);
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetMaxWidth(root))); ASSERT_FALSE(YGNodeStyleGetMaxWidth(root).unit != YGUnitUndefined);
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetMaxHeight(root))); ASSERT_FALSE(YGNodeStyleGetMaxHeight(root).unit != YGUnitUndefined);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetRight(root)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetRight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetBottom(root)); ASSERT_FLOAT_EQ(0, YGNodeLayoutGetBottom(root));
ASSERT_TRUE(YGValueIsUndefined(YGNodeLayoutGetWidth(root))); ASSERT_TRUE(YGFloatIsUndefined(YGNodeLayoutGetWidth(root)));
ASSERT_TRUE(YGValueIsUndefined(YGNodeLayoutGetHeight(root))); ASSERT_TRUE(YGFloatIsUndefined(YGNodeLayoutGetHeight(root)));
ASSERT_EQ(YGDirectionInherit, YGNodeLayoutGetDirection(root)); ASSERT_EQ(YGDirectionInherit, YGNodeLayoutGetDirection(root));
YGNodeFreeRecursive(root); YGNodeFreeRecursive(root);

View File

@@ -283,7 +283,7 @@ TEST(YogaTest, overflow_scroll_column) {
ASSERT_FLOAT_EQ(100, constraintList.constraints[0].width); ASSERT_FLOAT_EQ(100, constraintList.constraints[0].width);
ASSERT_EQ(YGMeasureModeAtMost, constraintList.constraints[0].widthMode); ASSERT_EQ(YGMeasureModeAtMost, constraintList.constraints[0].widthMode);
ASSERT_TRUE(YGValueIsUndefined(constraintList.constraints[0].height)); ASSERT_TRUE(YGFloatIsUndefined(constraintList.constraints[0].height));
ASSERT_EQ(YGMeasureModeUndefined, constraintList.constraints[0].heightMode); ASSERT_EQ(YGMeasureModeUndefined, constraintList.constraints[0].heightMode);
free(constraintList.constraints); free(constraintList.constraints);
@@ -312,7 +312,7 @@ TEST(YogaTest, overflow_scroll_row) {
ASSERT_EQ(1, constraintList.length); ASSERT_EQ(1, constraintList.length);
ASSERT_TRUE(YGValueIsUndefined(constraintList.constraints[0].width)); ASSERT_TRUE(YGFloatIsUndefined(constraintList.constraints[0].width));
ASSERT_EQ(YGMeasureModeUndefined, constraintList.constraints[0].widthMode); ASSERT_EQ(YGMeasureModeUndefined, constraintList.constraints[0].widthMode);
ASSERT_FLOAT_EQ(100, constraintList.constraints[0].height); ASSERT_FLOAT_EQ(100, constraintList.constraints[0].height);

919
tests/YGPercentageTest.cpp Normal file
View File

@@ -0,0 +1,919 @@
/**
* 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.
*/
// @Generated by gentest/gentest.rb from gentest/fixtures/YGPercentageTest.html
#include <yoga/Yoga.h>
#include <gtest/gtest.h>
TEST(YogaTest, percentage_width_height) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetWidthPercent(root_child0, 30);
YGNodeStyleSetHeightPercent(root_child0, 30);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(140, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
}
TEST(YogaTest, percentage_position_left_top) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 400);
YGNodeStyleSetHeight(root, 400);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetPositionPercent(root_child0, YGEdgeLeft, 10);
YGNodeStyleSetPositionPercent(root_child0, YGEdgeTop, 20);
YGNodeStyleSetWidthPercent(root_child0, 45);
YGNodeStyleSetHeightPercent(root_child0, 55);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(220, YGNodeLayoutGetHeight(root_child0));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(260, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(220, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
}
TEST(YogaTest, percentage_position_bottom_right) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 500);
YGNodeStyleSetHeight(root, 500);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetPositionPercent(root_child0, YGEdgeRight, 20);
YGNodeStyleSetPositionPercent(root_child0, YGEdgeBottom, 10);
YGNodeStyleSetWidthPercent(root_child0, 55);
YGNodeStyleSetHeightPercent(root_child0, 15);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(-100, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(-50, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(275, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(75, YGNodeLayoutGetHeight(root_child0));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(125, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(-50, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(275, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(75, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
}
TEST(YogaTest, percentage_flex_basis) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasisPercent(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeStyleSetFlexBasisPercent(root_child1, 25);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(125, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(125, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(75, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(75, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(125, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(75, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
}
TEST(YogaTest, percentage_flex_basis_cross) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasisPercent(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeStyleSetFlexBasisPercent(root_child1, 25);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(125, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(125, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(75, YGNodeLayoutGetHeight(root_child1));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(125, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(125, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(75, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
}
TEST(YogaTest, percentage_flex_basis_cross_min_height) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetMinHeightPercent(root_child0, 60);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child1, 2);
YGNodeStyleSetMinHeightPercent(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(140, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(140, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(140, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(140, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
}
TEST(YogaTest, percentage_flex_basis_main_max_height) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasisPercent(root_child0, 10);
YGNodeStyleSetMaxHeightPercent(root_child0, 60);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child1, 4);
YGNodeStyleSetFlexBasisPercent(root_child1, 10);
YGNodeStyleSetMaxHeightPercent(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(52, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(52, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(148, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(148, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(52, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(148, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
}
TEST(YogaTest, percentage_flex_basis_cross_max_height) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasisPercent(root_child0, 10);
YGNodeStyleSetMaxHeightPercent(root_child0, 60);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child1, 4);
YGNodeStyleSetFlexBasisPercent(root_child1, 10);
YGNodeStyleSetMaxHeightPercent(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
}
TEST(YogaTest, percentage_flex_basis_main_max_width) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasisPercent(root_child0, 15);
YGNodeStyleSetMaxWidthPercent(root_child0, 60);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child1, 4);
YGNodeStyleSetFlexBasisPercent(root_child1, 10);
YGNodeStyleSetMaxWidthPercent(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
}
TEST(YogaTest, percentage_flex_basis_cross_max_width) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasisPercent(root_child0, 10);
YGNodeStyleSetMaxWidthPercent(root_child0, 60);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child1, 4);
YGNodeStyleSetFlexBasisPercent(root_child1, 15);
YGNodeStyleSetMaxWidthPercent(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child1));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
}
TEST(YogaTest, percentage_flex_basis_main_min_width) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasisPercent(root_child0, 15);
YGNodeStyleSetMinWidthPercent(root_child0, 60);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child1, 4);
YGNodeStyleSetFlexBasisPercent(root_child1, 10);
YGNodeStyleSetMinWidthPercent(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
}
TEST(YogaTest, percentage_flex_basis_cross_min_width) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasisPercent(root_child0, 10);
YGNodeStyleSetMinWidthPercent(root_child0, 60);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child1, 4);
YGNodeStyleSetFlexBasisPercent(root_child1, 15);
YGNodeStyleSetMinWidthPercent(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child1));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
}
TEST(YogaTest, percentage_multiple_nested_with_padding_margin_and_percentage_values) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasisPercent(root_child0, 10);
YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 5);
YGNodeStyleSetMargin(root_child0, YGEdgeTop, 5);
YGNodeStyleSetMargin(root_child0, YGEdgeRight, 5);
YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 5);
YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 3);
YGNodeStyleSetPadding(root_child0, YGEdgeTop, 3);
YGNodeStyleSetPadding(root_child0, YGEdgeRight, 3);
YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 3);
YGNodeStyleSetMinWidthPercent(root_child0, 60);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNew();
YGNodeStyleSetMargin(root_child0_child0, YGEdgeLeft, 5);
YGNodeStyleSetMargin(root_child0_child0, YGEdgeTop, 5);
YGNodeStyleSetMargin(root_child0_child0, YGEdgeRight, 5);
YGNodeStyleSetMargin(root_child0_child0, YGEdgeBottom, 5);
YGNodeStyleSetPaddingPercent(root_child0_child0, YGEdgeLeft, 3);
YGNodeStyleSetPaddingPercent(root_child0_child0, YGEdgeTop, 3);
YGNodeStyleSetPaddingPercent(root_child0_child0, YGEdgeRight, 3);
YGNodeStyleSetPaddingPercent(root_child0_child0, YGEdgeBottom, 3);
YGNodeStyleSetWidthPercent(root_child0_child0, 50);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
const YGNodeRef root_child0_child0_child0 = YGNodeNew();
YGNodeStyleSetMarginPercent(root_child0_child0_child0, YGEdgeLeft, 5);
YGNodeStyleSetMarginPercent(root_child0_child0_child0, YGEdgeTop, 5);
YGNodeStyleSetMarginPercent(root_child0_child0_child0, YGEdgeRight, 5);
YGNodeStyleSetMarginPercent(root_child0_child0_child0, YGEdgeBottom, 5);
YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeLeft, 3);
YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeTop, 3);
YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeRight, 3);
YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeBottom, 3);
YGNodeStyleSetWidthPercent(root_child0_child0_child0, 45);
YGNodeInsertChild(root_child0_child0, root_child0_child0_child0, 0);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child1, 4);
YGNodeStyleSetFlexBasisPercent(root_child1, 15);
YGNodeStyleSetMinWidthPercent(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(5, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(5, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(190, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(48, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(8, YGNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(8, YGNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(92, YGNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child0_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0_child0_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0_child0_child0));
ASSERT_FLOAT_EQ(36, YGNodeLayoutGetWidth(root_child0_child0_child0));
ASSERT_FLOAT_EQ(6, YGNodeLayoutGetHeight(root_child0_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(58, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(142, YGNodeLayoutGetHeight(root_child1));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(5, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(5, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(190, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(48, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(8, YGNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(92, YGNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child0_child0));
ASSERT_FLOAT_EQ(46, YGNodeLayoutGetLeft(root_child0_child0_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0_child0_child0));
ASSERT_FLOAT_EQ(36, YGNodeLayoutGetWidth(root_child0_child0_child0));
ASSERT_FLOAT_EQ(6, YGNodeLayoutGetHeight(root_child0_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(58, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(142, YGNodeLayoutGetHeight(root_child1));
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
}
TEST(YogaTest, percentage_margin_should_calculate_based_only_on_width) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetMarginPercent(root_child0, YGEdgeLeft, 10);
YGNodeStyleSetMarginPercent(root_child0, YGEdgeTop, 10);
YGNodeStyleSetMarginPercent(root_child0, YGEdgeRight, 10);
YGNodeStyleSetMarginPercent(root_child0, YGEdgeBottom, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNew();
YGNodeStyleSetWidth(root_child0_child0, 10);
YGNodeStyleSetHeight(root_child0_child0, 10);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(160, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(160, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(150, YGNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0));
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
}
TEST(YogaTest, percentage_padding_should_calculate_based_only_on_width) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetPaddingPercent(root_child0, YGEdgeLeft, 10);
YGNodeStyleSetPaddingPercent(root_child0, YGEdgeTop, 10);
YGNodeStyleSetPaddingPercent(root_child0, YGEdgeRight, 10);
YGNodeStyleSetPaddingPercent(root_child0, YGEdgeBottom, 10);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNew();
YGNodeStyleSetWidth(root_child0_child0, 10);
YGNodeStyleSetHeight(root_child0_child0, 10);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(170, YGNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0));
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
}
TEST(YogaTest, percentage_absolute_position) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 100);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
YGNodeStyleSetPositionPercent(root_child0, YGEdgeLeft, 30);
YGNodeStyleSetPositionPercent(root_child0, YGEdgeTop, 10);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
}

View File

@@ -26,7 +26,7 @@ TEST(YogaTest, copy_style_modified) {
const YGNodeRef node0 = YGNodeNew(); const YGNodeRef node0 = YGNodeNew();
ASSERT_FALSE(YGNodeIsDirty(node0)); ASSERT_FALSE(YGNodeIsDirty(node0));
ASSERT_EQ(YGFlexDirectionColumn, YGNodeStyleGetFlexDirection(node0)); ASSERT_EQ(YGFlexDirectionColumn, YGNodeStyleGetFlexDirection(node0));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetMaxHeight(node0))); ASSERT_FALSE(YGNodeStyleGetMaxHeight(node0).unit != YGUnitUndefined);
const YGNodeRef node1 = YGNodeNew(); const YGNodeRef node1 = YGNodeNew();
YGNodeStyleSetFlexDirection(node1, YGFlexDirectionRow); YGNodeStyleSetFlexDirection(node1, YGFlexDirectionRow);
@@ -35,7 +35,7 @@ TEST(YogaTest, copy_style_modified) {
YGNodeCopyStyle(node0, node1); YGNodeCopyStyle(node0, node1);
ASSERT_TRUE(YGNodeIsDirty(node0)); ASSERT_TRUE(YGNodeIsDirty(node0));
ASSERT_EQ(YGFlexDirectionRow, YGNodeStyleGetFlexDirection(node0)); ASSERT_EQ(YGFlexDirectionRow, YGNodeStyleGetFlexDirection(node0));
ASSERT_FLOAT_EQ(10, YGNodeStyleGetMaxHeight(node0)); ASSERT_FLOAT_EQ(10, YGNodeStyleGetMaxHeight(node0).value);
YGNodeFree(node0); YGNodeFree(node0);
YGNodeFree(node1); YGNodeFree(node1);

View File

@@ -113,4 +113,11 @@ typedef enum YGAlign {
YGAlignStretch, YGAlignStretch,
} YGAlign; } YGAlign;
#define YGUnitCount 3
typedef enum YGUnit {
YGUnitUndefined,
YGUnitPixel,
YGUnitPercent,
} YGUnit;
YG_EXTERN_C_END YG_EXTERN_C_END

File diff suppressed because it is too large Load Diff

View File

@@ -38,6 +38,11 @@ typedef struct YGSize {
float height; float height;
} YGSize; } YGSize;
typedef struct YGValue {
float value;
YGUnit unit;
} YGValue;
typedef struct YGNode *YGNodeRef; typedef struct YGNode *YGNodeRef;
typedef YGSize (*YGMeasureFunc)(YGNodeRef node, typedef YGSize (*YGMeasureFunc)(YGNodeRef node,
float width, float width,
@@ -83,7 +88,7 @@ WIN_EXPORT bool YGNodeIsDirty(const YGNodeRef node);
WIN_EXPORT void YGNodePrint(const YGNodeRef node, const YGPrintOptions options); WIN_EXPORT void YGNodePrint(const YGNodeRef node, const YGPrintOptions options);
WIN_EXPORT bool YGValueIsUndefined(const float value); WIN_EXPORT bool YGFloatIsUndefined(const float value);
WIN_EXPORT bool YGNodeCanUseCachedMeasurement(const YGMeasureMode widthMode, WIN_EXPORT bool YGNodeCanUseCachedMeasurement(const YGMeasureMode widthMode,
const float width, const float width,
@@ -108,12 +113,26 @@ WIN_EXPORT void YGNodeCopyStyle(const YGNodeRef dstNode, const YGNodeRef srcNode
WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, const type paramName); \ WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, const type paramName); \
WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node); WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node);
#define YG_NODE_STYLE_PROPERTY_UNIT(type, name, paramName) \
WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, const float paramName); \
WIN_EXPORT void YGNodeStyleSet##name##Percent(const YGNodeRef node, const float paramName); \
WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node);
#define YG_NODE_STYLE_EDGE_PROPERTY(type, name, paramName) \ #define YG_NODE_STYLE_EDGE_PROPERTY(type, name, paramName) \
WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, \ WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, \
const YGEdge edge, \ const YGEdge edge, \
const type paramName); \ const type paramName); \
WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge); WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge);
#define YG_NODE_STYLE_EDGE_PROPERTY_UNIT(type, name, paramName) \
WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, \
const YGEdge edge, \
const float paramName); \
WIN_EXPORT void YGNodeStyleSet##name##Percent(const YGNodeRef node, \
const YGEdge edge, \
const float paramName); \
WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge);
#define YG_NODE_LAYOUT_PROPERTY(type, name) \ #define YG_NODE_LAYOUT_PROPERTY(type, name) \
WIN_EXPORT type YGNodeLayoutGet##name(const YGNodeRef node); WIN_EXPORT type YGNodeLayoutGet##name(const YGNodeRef node);
@@ -135,19 +154,19 @@ YG_NODE_STYLE_PROPERTY(YGOverflow, Overflow, overflow);
WIN_EXPORT void YGNodeStyleSetFlex(const YGNodeRef node, const float flex); WIN_EXPORT void YGNodeStyleSetFlex(const YGNodeRef node, const float flex);
YG_NODE_STYLE_PROPERTY(float, FlexGrow, flexGrow); YG_NODE_STYLE_PROPERTY(float, FlexGrow, flexGrow);
YG_NODE_STYLE_PROPERTY(float, FlexShrink, flexShrink); YG_NODE_STYLE_PROPERTY(float, FlexShrink, flexShrink);
YG_NODE_STYLE_PROPERTY(float, FlexBasis, flexBasis); YG_NODE_STYLE_PROPERTY_UNIT(YGValue, FlexBasis, flexBasis);
YG_NODE_STYLE_EDGE_PROPERTY(float, Position, position); YG_NODE_STYLE_EDGE_PROPERTY_UNIT(YGValue, Position, position);
YG_NODE_STYLE_EDGE_PROPERTY(float, Margin, margin); YG_NODE_STYLE_EDGE_PROPERTY_UNIT(YGValue, Margin, margin);
YG_NODE_STYLE_EDGE_PROPERTY(float, Padding, padding); YG_NODE_STYLE_EDGE_PROPERTY_UNIT(YGValue, Padding, padding);
YG_NODE_STYLE_EDGE_PROPERTY(float, Border, border); YG_NODE_STYLE_EDGE_PROPERTY(float, Border, border);
YG_NODE_STYLE_PROPERTY(float, Width, width); YG_NODE_STYLE_PROPERTY_UNIT(YGValue, Width, width);
YG_NODE_STYLE_PROPERTY(float, Height, height); YG_NODE_STYLE_PROPERTY_UNIT(YGValue, Height, height);
YG_NODE_STYLE_PROPERTY(float, MinWidth, minWidth); YG_NODE_STYLE_PROPERTY_UNIT(YGValue, MinWidth, minWidth);
YG_NODE_STYLE_PROPERTY(float, MinHeight, minHeight); YG_NODE_STYLE_PROPERTY_UNIT(YGValue, MinHeight, minHeight);
YG_NODE_STYLE_PROPERTY(float, MaxWidth, maxWidth); YG_NODE_STYLE_PROPERTY_UNIT(YGValue, MaxWidth, maxWidth);
YG_NODE_STYLE_PROPERTY(float, MaxHeight, maxHeight); YG_NODE_STYLE_PROPERTY_UNIT(YGValue, MaxHeight, maxHeight);
// Yoga specific properties, not compatible with flexbox specification // Yoga specific properties, not compatible with flexbox specification
// Aspect ratio control the size of the undefined dimension of a node. // Aspect ratio control the size of the undefined dimension of a node.