예제 #1
0
 public static void setMeasureFunction(this CSSNode node, MeasureFunction measureFunction)
 {
     node.MeasureFunction = measureFunction;
 }
예제 #2
0
        public void Test_rounding_flex_basis_flex_grow_row_prime_number_width()
        {
            CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true);

            CSSNode root = new CSSNode();

            root.FlexDirection = CSSFlexDirection.Row;
            root.StyleWidth    = 113f;
            root.StyleHeight   = 100f;

            CSSNode root_child0 = new CSSNode();

            root_child0.FlexGrow = 1f;
            root.Insert(0, root_child0);

            CSSNode root_child1 = new CSSNode();

            root_child1.FlexGrow = 1f;
            root.Insert(1, root_child1);

            CSSNode root_child2 = new CSSNode();

            root_child2.FlexGrow = 1f;
            root.Insert(2, root_child2);

            CSSNode root_child3 = new CSSNode();

            root_child3.FlexGrow = 1f;
            root.Insert(3, root_child3);

            CSSNode root_child4 = new CSSNode();

            root_child4.FlexGrow = 1f;
            root.Insert(4, root_child4);
            root.StyleDirection = CSSDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(113f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(23f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(23f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(22f, root_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child1.LayoutHeight);

            Assert.AreEqual(45f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(23f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);

            Assert.AreEqual(68f, root_child3.LayoutX);
            Assert.AreEqual(0f, root_child3.LayoutY);
            Assert.AreEqual(22f, root_child3.LayoutWidth);
            Assert.AreEqual(100f, root_child3.LayoutHeight);

            Assert.AreEqual(90f, root_child4.LayoutX);
            Assert.AreEqual(0f, root_child4.LayoutY);
            Assert.AreEqual(23f, root_child4.LayoutWidth);
            Assert.AreEqual(100f, root_child4.LayoutHeight);

            root.StyleDirection = CSSDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(113f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(90f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(23f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(68f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(22f, root_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child1.LayoutHeight);

            Assert.AreEqual(45f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(23f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);

            Assert.AreEqual(23f, root_child3.LayoutX);
            Assert.AreEqual(0f, root_child3.LayoutY);
            Assert.AreEqual(22f, root_child3.LayoutWidth);
            Assert.AreEqual(100f, root_child3.LayoutHeight);

            Assert.AreEqual(0f, root_child4.LayoutX);
            Assert.AreEqual(0f, root_child4.LayoutY);
            Assert.AreEqual(23f, root_child4.LayoutWidth);
            Assert.AreEqual(100f, root_child4.LayoutHeight);

            CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false);
        }
예제 #3
0
        public void TestAlreadyInitialize()
        {
            CSSNode node = new CSSNode();

            node.Reinitialize();
        }
예제 #4
0
        public void Test_rounding_flex_basis_flex_shrink_row()
        {
            CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true);

            CSSNode root = new CSSNode();

            root.FlexDirection = CSSFlexDirection.Row;
            root.StyleWidth    = 101f;
            root.StyleHeight   = 100f;

            CSSNode root_child0 = new CSSNode();

            root_child0.FlexShrink = 1f;
            root_child0.FlexBasis  = 100f;
            root.Insert(0, root_child0);

            CSSNode root_child1 = new CSSNode();

            root_child1.FlexBasis = 25f;
            root.Insert(1, root_child1);

            CSSNode root_child2 = new CSSNode();

            root_child2.FlexBasis = 25f;
            root.Insert(2, root_child2);
            root.StyleDirection = CSSDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(101f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(51f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(51f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(25f, root_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child1.LayoutHeight);

            Assert.AreEqual(76f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(25f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);

            root.StyleDirection = CSSDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(101f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(50f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(51f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(25f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(25f, root_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(25f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);

            CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false);
        }
예제 #5
0
        public void Test_rounding_total_fractial_nested()
        {
            CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true);

            CSSNode root = new CSSNode();

            root.StyleWidth  = 87.4f;
            root.StyleHeight = 113.4f;

            CSSNode root_child0 = new CSSNode();

            root_child0.FlexGrow    = 0.7f;
            root_child0.FlexBasis   = 50.3f;
            root_child0.StyleHeight = 20.3f;
            root.Insert(0, root_child0);

            CSSNode root_child0_child0 = new CSSNode();

            root_child0_child0.FlexGrow  = 1f;
            root_child0_child0.FlexBasis = 0.3f;
            root_child0_child0.SetPosition(CSSEdge.Bottom, 13.3f);
            root_child0_child0.StyleHeight = 9.9f;
            root_child0.Insert(0, root_child0_child0);

            CSSNode root_child0_child1 = new CSSNode();

            root_child0_child1.FlexGrow  = 4f;
            root_child0_child1.FlexBasis = 0.3f;
            root_child0_child1.SetPosition(CSSEdge.Top, 13.3f);
            root_child0_child1.StyleHeight = 1.1f;
            root_child0.Insert(1, root_child0_child1);

            CSSNode root_child1 = new CSSNode();

            root_child1.FlexGrow    = 1.6f;
            root_child1.StyleHeight = 10f;
            root.Insert(1, root_child1);

            CSSNode root_child2 = new CSSNode();

            root_child2.FlexGrow    = 1.1f;
            root_child2.StyleHeight = 10.7f;
            root.Insert(2, root_child2);
            root.StyleDirection = CSSDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(87f, root.LayoutWidth);
            Assert.AreEqual(113f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(87f, root_child0.LayoutWidth);
            Assert.AreEqual(59f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child0_child0.LayoutX);
            Assert.AreEqual(-13f, root_child0_child0.LayoutY);
            Assert.AreEqual(87f, root_child0_child0.LayoutWidth);
            Assert.AreEqual(12f, root_child0_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child0_child1.LayoutX);
            Assert.AreEqual(25f, root_child0_child1.LayoutY);
            Assert.AreEqual(87f, root_child0_child1.LayoutWidth);
            Assert.AreEqual(47f, root_child0_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(59f, root_child1.LayoutY);
            Assert.AreEqual(87f, root_child1.LayoutWidth);
            Assert.AreEqual(30f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(89f, root_child2.LayoutY);
            Assert.AreEqual(87f, root_child2.LayoutWidth);
            Assert.AreEqual(24f, root_child2.LayoutHeight);

            root.StyleDirection = CSSDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(87f, root.LayoutWidth);
            Assert.AreEqual(113f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(87f, root_child0.LayoutWidth);
            Assert.AreEqual(59f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child0_child0.LayoutX);
            Assert.AreEqual(-13f, root_child0_child0.LayoutY);
            Assert.AreEqual(87f, root_child0_child0.LayoutWidth);
            Assert.AreEqual(12f, root_child0_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child0_child1.LayoutX);
            Assert.AreEqual(25f, root_child0_child1.LayoutY);
            Assert.AreEqual(87f, root_child0_child1.LayoutWidth);
            Assert.AreEqual(47f, root_child0_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(59f, root_child1.LayoutY);
            Assert.AreEqual(87f, root_child1.LayoutWidth);
            Assert.AreEqual(30f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(89f, root_child2.LayoutY);
            Assert.AreEqual(87f, root_child2.LayoutWidth);
            Assert.AreEqual(24f, root_child2.LayoutHeight);

            CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false);
        }
예제 #6
0
        public void Test_justify_content_column_space_around()
        {
            CSSNode root = new CSSNode();

            root.JustifyContent = CSSJustify.SpaceAround;
            root.StyleWidth     = 102f;
            root.StyleHeight    = 102f;

            CSSNode root_child0 = new CSSNode();

            root_child0.StyleHeight = 10f;
            root.Insert(0, root_child0);

            CSSNode root_child1 = new CSSNode();

            root_child1.StyleHeight = 10f;
            root.Insert(1, root_child1);

            CSSNode root_child2 = new CSSNode();

            root_child2.StyleHeight = 10f;
            root.Insert(2, root_child2);
            root.StyleDirection = CSSDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(102f, root.LayoutWidth);
            Assert.AreEqual(102f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(12f, root_child0.LayoutY);
            Assert.AreEqual(102f, root_child0.LayoutWidth);
            Assert.AreEqual(10f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(46f, root_child1.LayoutY);
            Assert.AreEqual(102f, root_child1.LayoutWidth);
            Assert.AreEqual(10f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(80f, root_child2.LayoutY);
            Assert.AreEqual(102f, root_child2.LayoutWidth);
            Assert.AreEqual(10f, root_child2.LayoutHeight);

            root.StyleDirection = CSSDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(102f, root.LayoutWidth);
            Assert.AreEqual(102f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(12f, root_child0.LayoutY);
            Assert.AreEqual(102f, root_child0.LayoutWidth);
            Assert.AreEqual(10f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(46f, root_child1.LayoutY);
            Assert.AreEqual(102f, root_child1.LayoutWidth);
            Assert.AreEqual(10f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(80f, root_child2.LayoutY);
            Assert.AreEqual(102f, root_child2.LayoutWidth);
            Assert.AreEqual(10f, root_child2.LayoutHeight);
        }
        public void Test_absolute_layout_within_border()
        {
            CSSNode root = new CSSNode();

            root.SetMargin(CSSEdge.Left, 10f);
            root.SetMargin(CSSEdge.Top, 10f);
            root.SetMargin(CSSEdge.Right, 10f);
            root.SetMargin(CSSEdge.Bottom, 10f);
            root.SetPadding(CSSEdge.Left, 10f);
            root.SetPadding(CSSEdge.Top, 10f);
            root.SetPadding(CSSEdge.Right, 10f);
            root.SetPadding(CSSEdge.Bottom, 10f);
            root.SetBorder(CSSEdge.Left, 10f);
            root.SetBorder(CSSEdge.Top, 10f);
            root.SetBorder(CSSEdge.Right, 10f);
            root.SetBorder(CSSEdge.Bottom, 10f);
            root.StyleWidth  = 100f;
            root.StyleHeight = 100f;

            CSSNode root_child0 = new CSSNode();

            root_child0.PositionType = CSSPositionType.Absolute;
            root_child0.SetPosition(CSSEdge.Left, 0f);
            root_child0.SetPosition(CSSEdge.Top, 0f);
            root_child0.StyleWidth  = 50f;
            root_child0.StyleHeight = 50f;
            root.Insert(0, root_child0);

            CSSNode root_child1 = new CSSNode();

            root_child1.PositionType = CSSPositionType.Absolute;
            root_child1.SetPosition(CSSEdge.Right, 0f);
            root_child1.SetPosition(CSSEdge.Bottom, 0f);
            root_child1.StyleWidth  = 50f;
            root_child1.StyleHeight = 50f;
            root.Insert(1, root_child1);
            root.StyleDirection = CSSDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(10f, root.LayoutX);
            Assert.AreEqual(10f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(10f, root_child0.LayoutX);
            Assert.AreEqual(10f, root_child0.LayoutY);
            Assert.AreEqual(50f, root_child0.LayoutWidth);
            Assert.AreEqual(50f, root_child0.LayoutHeight);

            Assert.AreEqual(40f, root_child1.LayoutX);
            Assert.AreEqual(40f, root_child1.LayoutY);
            Assert.AreEqual(50f, root_child1.LayoutWidth);
            Assert.AreEqual(50f, root_child1.LayoutHeight);

            root.StyleDirection = CSSDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(10f, root.LayoutX);
            Assert.AreEqual(10f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(10f, root_child0.LayoutX);
            Assert.AreEqual(10f, root_child0.LayoutY);
            Assert.AreEqual(50f, root_child0.LayoutWidth);
            Assert.AreEqual(50f, root_child0.LayoutHeight);

            Assert.AreEqual(40f, root_child1.LayoutX);
            Assert.AreEqual(40f, root_child1.LayoutY);
            Assert.AreEqual(50f, root_child1.LayoutWidth);
            Assert.AreEqual(50f, root_child1.LayoutHeight);
        }
예제 #8
0
 public void AddChild(CSSNode child)
 {
     InsertChild(ChildCount, child);
 }
예제 #9
0
        public void Test_flex_shrink_to_zero()
        {
            CSSNode root = new CSSNode();

            root.StyleHeight = 75;

            CSSNode root_child0 = new CSSNode();

            root_child0.StyleWidth  = 50;
            root_child0.StyleHeight = 50;
            root.Insert(0, root_child0);

            CSSNode root_child1 = new CSSNode();

            root_child1.FlexShrink  = 1;
            root_child1.StyleWidth  = 50;
            root_child1.StyleHeight = 50;
            root.Insert(1, root_child1);

            CSSNode root_child2 = new CSSNode();

            root_child2.StyleWidth  = 50;
            root_child2.StyleHeight = 50;
            root.Insert(2, root_child2);
            root.StyleDirection = CSSDirection.LeftToRight;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(50, root.LayoutWidth);
            Assert.AreEqual(75, root.LayoutHeight);

            Assert.AreEqual(0, root_child0.LayoutX);
            Assert.AreEqual(0, root_child0.LayoutY);
            Assert.AreEqual(50, root_child0.LayoutWidth);
            Assert.AreEqual(50, root_child0.LayoutHeight);

            Assert.AreEqual(0, root_child1.LayoutX);
            Assert.AreEqual(50, root_child1.LayoutY);
            Assert.AreEqual(50, root_child1.LayoutWidth);
            Assert.AreEqual(0, root_child1.LayoutHeight);

            Assert.AreEqual(0, root_child2.LayoutX);
            Assert.AreEqual(50, root_child2.LayoutY);
            Assert.AreEqual(50, root_child2.LayoutWidth);
            Assert.AreEqual(50, root_child2.LayoutHeight);

            root.StyleDirection = CSSDirection.RightToLeft;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(50, root.LayoutWidth);
            Assert.AreEqual(75, root.LayoutHeight);

            Assert.AreEqual(0, root_child0.LayoutX);
            Assert.AreEqual(0, root_child0.LayoutY);
            Assert.AreEqual(50, root_child0.LayoutWidth);
            Assert.AreEqual(50, root_child0.LayoutHeight);

            Assert.AreEqual(0, root_child1.LayoutX);
            Assert.AreEqual(50, root_child1.LayoutY);
            Assert.AreEqual(50, root_child1.LayoutWidth);
            Assert.AreEqual(0, root_child1.LayoutHeight);

            Assert.AreEqual(0, root_child2.LayoutX);
            Assert.AreEqual(50, root_child2.LayoutY);
            Assert.AreEqual(50, root_child2.LayoutWidth);
            Assert.AreEqual(50, root_child2.LayoutHeight);
        }
예제 #10
0
 public static void setPadding(this CSSNode node, int spacingType, float padding)
 {
     node.SetPadding((CSSSpacingType)spacingType, padding);
 }
예제 #11
0
 public static void setBorder(this CSSNode node, int spacingType, float border)
 {
     node.SetBorder((CSSSpacingType)spacingType, border);
 }
예제 #12
0
 public static void setMargin(this CSSNode node, int spacingType, float margin)
 {
     node.SetMargin((CSSSpacingType)spacingType, margin);
 }
예제 #13
0
 public static bool isDirty(this CSSNode node)
 {
     return(node.IsDirty);
 }
예제 #14
0
 public static void calculateLayout(this CSSNode node)
 {
     node.CalculateLayout();
 }
        public void Test_align_content_stretch()
        {
            CSSNode root = new CSSNode();

            root.AlignContent = CSSAlign.Stretch;
            root.Wrap         = CSSWrap.Wrap;
            root.StyleWidth   = 100f;
            root.StyleHeight  = 100f;

            CSSNode root_child0 = new CSSNode();

            root_child0.StyleWidth = 50f;
            root.Insert(0, root_child0);

            CSSNode root_child1 = new CSSNode();

            root_child1.StyleWidth = 50f;
            root.Insert(1, root_child1);

            CSSNode root_child2 = new CSSNode();

            root_child2.StyleWidth = 50f;
            root.Insert(2, root_child2);

            CSSNode root_child3 = new CSSNode();

            root_child3.StyleWidth = 50f;
            root.Insert(3, root_child3);

            CSSNode root_child4 = new CSSNode();

            root_child4.StyleWidth = 50f;
            root.Insert(4, root_child4);
            root.StyleDirection = CSSDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(50f, root_child0.LayoutWidth);
            Assert.AreEqual(0f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(50f, root_child1.LayoutWidth);
            Assert.AreEqual(0f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(50f, root_child2.LayoutWidth);
            Assert.AreEqual(0f, root_child2.LayoutHeight);

            Assert.AreEqual(0f, root_child3.LayoutX);
            Assert.AreEqual(0f, root_child3.LayoutY);
            Assert.AreEqual(50f, root_child3.LayoutWidth);
            Assert.AreEqual(0f, root_child3.LayoutHeight);

            Assert.AreEqual(0f, root_child4.LayoutX);
            Assert.AreEqual(0f, root_child4.LayoutY);
            Assert.AreEqual(50f, root_child4.LayoutWidth);
            Assert.AreEqual(0f, root_child4.LayoutHeight);

            root.StyleDirection = CSSDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(50f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(50f, root_child0.LayoutWidth);
            Assert.AreEqual(0f, root_child0.LayoutHeight);

            Assert.AreEqual(50f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(50f, root_child1.LayoutWidth);
            Assert.AreEqual(0f, root_child1.LayoutHeight);

            Assert.AreEqual(50f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(50f, root_child2.LayoutWidth);
            Assert.AreEqual(0f, root_child2.LayoutHeight);

            Assert.AreEqual(50f, root_child3.LayoutX);
            Assert.AreEqual(0f, root_child3.LayoutY);
            Assert.AreEqual(50f, root_child3.LayoutWidth);
            Assert.AreEqual(0f, root_child3.LayoutHeight);

            Assert.AreEqual(50f, root_child4.LayoutX);
            Assert.AreEqual(0f, root_child4.LayoutY);
            Assert.AreEqual(50f, root_child4.LayoutWidth);
            Assert.AreEqual(0f, root_child4.LayoutHeight);
        }
예제 #16
0
        public void Test_flex_basis_overrides_main_size()
        {
            CSSNode root = new CSSNode();

            root.StyleWidth  = 100;
            root.StyleHeight = 100;

            CSSNode root_child0 = new CSSNode();

            root_child0.FlexGrow    = 1;
            root_child0.FlexBasis   = 50;
            root_child0.StyleHeight = 20;
            root.Insert(0, root_child0);

            CSSNode root_child1 = new CSSNode();

            root_child1.FlexGrow    = 1;
            root_child1.StyleHeight = 10;
            root.Insert(1, root_child1);

            CSSNode root_child2 = new CSSNode();

            root_child2.FlexGrow    = 1;
            root_child2.StyleHeight = 10;
            root.Insert(2, root_child2);
            root.StyleDirection = CSSDirection.LeftToRight;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(100, root.LayoutWidth);
            Assert.AreEqual(100, root.LayoutHeight);

            Assert.AreEqual(0, root_child0.LayoutX);
            Assert.AreEqual(0, root_child0.LayoutY);
            Assert.AreEqual(100, root_child0.LayoutWidth);
            Assert.AreEqual(60, root_child0.LayoutHeight);

            Assert.AreEqual(0, root_child1.LayoutX);
            Assert.AreEqual(60, root_child1.LayoutY);
            Assert.AreEqual(100, root_child1.LayoutWidth);
            Assert.AreEqual(20, root_child1.LayoutHeight);

            Assert.AreEqual(0, root_child2.LayoutX);
            Assert.AreEqual(80, root_child2.LayoutY);
            Assert.AreEqual(100, root_child2.LayoutWidth);
            Assert.AreEqual(20, root_child2.LayoutHeight);

            root.StyleDirection = CSSDirection.RightToLeft;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(100, root.LayoutWidth);
            Assert.AreEqual(100, root.LayoutHeight);

            Assert.AreEqual(0, root_child0.LayoutX);
            Assert.AreEqual(0, root_child0.LayoutY);
            Assert.AreEqual(100, root_child0.LayoutWidth);
            Assert.AreEqual(60, root_child0.LayoutHeight);

            Assert.AreEqual(0, root_child1.LayoutX);
            Assert.AreEqual(60, root_child1.LayoutY);
            Assert.AreEqual(100, root_child1.LayoutWidth);
            Assert.AreEqual(20, root_child1.LayoutHeight);

            Assert.AreEqual(0, root_child2.LayoutX);
            Assert.AreEqual(80, root_child2.LayoutY);
            Assert.AreEqual(100, root_child2.LayoutWidth);
            Assert.AreEqual(20, root_child2.LayoutHeight);
        }
예제 #17
0
        public void Test_justify_content_overflow_min_max()
        {
            CSSNode root = new CSSNode();

            root.JustifyContent = CSSJustify.Center;
            root.StyleMinHeight = 100;
            root.StyleMaxHeight = 110;

            CSSNode root_child0 = new CSSNode();

            root_child0.StyleWidth  = 50;
            root_child0.StyleHeight = 50;
            root.Insert(0, root_child0);

            CSSNode root_child1 = new CSSNode();

            root_child1.StyleWidth  = 50;
            root_child1.StyleHeight = 50;
            root.Insert(1, root_child1);

            CSSNode root_child2 = new CSSNode();

            root_child2.StyleWidth  = 50;
            root_child2.StyleHeight = 50;
            root.Insert(2, root_child2);
            root.StyleDirection = CSSDirection.LeftToRight;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(50, root.LayoutWidth);
            Assert.AreEqual(110, root.LayoutHeight);

            Assert.AreEqual(0, root_child0.LayoutX);
            Assert.AreEqual(-20, root_child0.LayoutY);
            Assert.AreEqual(50, root_child0.LayoutWidth);
            Assert.AreEqual(50, root_child0.LayoutHeight);

            Assert.AreEqual(0, root_child1.LayoutX);
            Assert.AreEqual(30, root_child1.LayoutY);
            Assert.AreEqual(50, root_child1.LayoutWidth);
            Assert.AreEqual(50, root_child1.LayoutHeight);

            Assert.AreEqual(0, root_child2.LayoutX);
            Assert.AreEqual(80, root_child2.LayoutY);
            Assert.AreEqual(50, root_child2.LayoutWidth);
            Assert.AreEqual(50, root_child2.LayoutHeight);

            root.StyleDirection = CSSDirection.RightToLeft;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(50, root.LayoutWidth);
            Assert.AreEqual(110, root.LayoutHeight);

            Assert.AreEqual(0, root_child0.LayoutX);
            Assert.AreEqual(-20, root_child0.LayoutY);
            Assert.AreEqual(50, root_child0.LayoutWidth);
            Assert.AreEqual(50, root_child0.LayoutHeight);

            Assert.AreEqual(0, root_child1.LayoutX);
            Assert.AreEqual(30, root_child1.LayoutY);
            Assert.AreEqual(50, root_child1.LayoutWidth);
            Assert.AreEqual(50, root_child1.LayoutHeight);

            Assert.AreEqual(0, root_child2.LayoutX);
            Assert.AreEqual(80, root_child2.LayoutY);
            Assert.AreEqual(50, root_child2.LayoutWidth);
            Assert.AreEqual(50, root_child2.LayoutHeight);
        }
예제 #18
0
        public static CSSNode Create(
            CSSDirection?styleDirection    = null,
            CSSFlexDirection?flexDirection = null,
            CSSJustify?justifyContent      = null,
            CSSAlign?alignContent          = null,
            CSSAlign?alignItems            = null,
            CSSAlign?alignSelf             = null,
            CSSPositionType?positionType   = null,
            CSSWrap?wrap         = null,
            CSSOverflow?overflow = null,
            float?flex           = null,
            float?flexGrow       = null,
            float?flexShrink     = null,
            float?flexBasis      = null,
            Spacing position     = null,
            Spacing margin       = null,
            Spacing padding      = null,
            Spacing border       = null,
            float?styleWidth     = null,
            float?styleHeight    = null,
            float?styleMaxWidth  = null,
            float?styleMaxHeight = null,
            float?styleMinWidth  = null,
            float?styleMinHeight = null)
        {
            CSSNode node = new CSSNode();

            if (styleDirection.HasValue)
            {
                node.StyleDirection = styleDirection.Value;
            }

            if (flexDirection.HasValue)
            {
                node.FlexDirection = flexDirection.Value;
            }

            if (justifyContent.HasValue)
            {
                node.JustifyContent = justifyContent.Value;
            }

            if (alignContent.HasValue)
            {
                node.AlignContent = alignContent.Value;
            }

            if (alignItems.HasValue)
            {
                node.AlignItems = alignItems.Value;
            }

            if (alignSelf.HasValue)
            {
                node.AlignSelf = alignSelf.Value;
            }

            if (positionType.HasValue)
            {
                node.PositionType = positionType.Value;
            }

            if (wrap.HasValue)
            {
                node.Wrap = wrap.Value;
            }

            if (overflow.HasValue)
            {
                node.Overflow = overflow.Value;
            }

            if (flex.HasValue)
            {
                node.Flex = flex.Value;
            }

            if (flexGrow.HasValue)
            {
                node.FlexGrow = flexGrow.Value;
            }

            if (flexShrink.HasValue)
            {
                node.FlexShrink = flexShrink.Value;
            }

            if (flexBasis.HasValue)
            {
                node.FlexBasis = flexBasis.Value;
            }

            if (position != null)
            {
                if (position.Top.HasValue)
                {
                    node.SetPosition(CSSEdge.Top, position.Top.Value);
                }

                if (position.Bottom.HasValue)
                {
                    node.SetPosition(CSSEdge.Bottom, position.Bottom.Value);
                }

                if (position.Left.HasValue)
                {
                    node.SetPosition(CSSEdge.Left, position.Left.Value);
                }

                if (position.Right.HasValue)
                {
                    node.SetPosition(CSSEdge.Right, position.Right.Value);
                }
            }

            if (margin != null)
            {
                if (margin.Top.HasValue)
                {
                    node.SetMargin(CSSEdge.Top, margin.Top.Value);
                }

                if (margin.Bottom.HasValue)
                {
                    node.SetMargin(CSSEdge.Bottom, margin.Bottom.Value);
                }

                if (margin.Left.HasValue)
                {
                    node.SetMargin(CSSEdge.Left, margin.Left.Value);
                }

                if (margin.Right.HasValue)
                {
                    node.SetMargin(CSSEdge.Right, margin.Right.Value);
                }
            }

            if (padding != null)
            {
                if (padding.Top.HasValue)
                {
                    node.SetPadding(CSSEdge.Top, padding.Top.Value);
                }

                if (padding.Bottom.HasValue)
                {
                    node.SetPadding(CSSEdge.Bottom, padding.Bottom.Value);
                }

                if (padding.Left.HasValue)
                {
                    node.SetPadding(CSSEdge.Left, padding.Left.Value);
                }

                if (padding.Right.HasValue)
                {
                    node.SetPadding(CSSEdge.Right, padding.Right.Value);
                }
            }

            if (border != null)
            {
                if (border.Top.HasValue)
                {
                    node.SetBorder(CSSEdge.Top, border.Top.Value);
                }

                if (border.Bottom.HasValue)
                {
                    node.SetBorder(CSSEdge.Bottom, border.Bottom.Value);
                }

                if (border.Left.HasValue)
                {
                    node.SetBorder(CSSEdge.Left, border.Left.Value);
                }

                if (border.Right.HasValue)
                {
                    node.SetBorder(CSSEdge.Right, border.Right.Value);
                }
            }

            if (styleWidth.HasValue)
            {
                node.StyleWidth = styleWidth.Value;
            }

            if (styleHeight.HasValue)
            {
                node.StyleHeight = styleHeight.Value;
            }

            if (styleMinWidth.HasValue)
            {
                node.StyleMinWidth = styleMinWidth.Value;
            }

            if (styleMinHeight.HasValue)
            {
                node.StyleMinHeight = styleMinHeight.Value;
            }

            if (styleMaxWidth.HasValue)
            {
                node.StyleMaxWidth = styleMaxWidth.Value;
            }

            if (styleMaxHeight.HasValue)
            {
                node.StyleMaxHeight = styleMaxHeight.Value;
            }

            return(node);
        }
예제 #19
0
        public void Test_justify_content_row_flex_end()
        {
            CSSNode root = new CSSNode();

            root.FlexDirection  = CSSFlexDirection.Row;
            root.JustifyContent = CSSJustify.FlexEnd;
            root.StyleWidth     = 102f;
            root.StyleHeight    = 102f;

            CSSNode root_child0 = new CSSNode();

            root_child0.StyleWidth = 10f;
            root.Insert(0, root_child0);

            CSSNode root_child1 = new CSSNode();

            root_child1.StyleWidth = 10f;
            root.Insert(1, root_child1);

            CSSNode root_child2 = new CSSNode();

            root_child2.StyleWidth = 10f;
            root.Insert(2, root_child2);
            root.StyleDirection = CSSDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(102f, root.LayoutWidth);
            Assert.AreEqual(102f, root.LayoutHeight);

            Assert.AreEqual(72f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(10f, root_child0.LayoutWidth);
            Assert.AreEqual(102f, root_child0.LayoutHeight);

            Assert.AreEqual(82f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(10f, root_child1.LayoutWidth);
            Assert.AreEqual(102f, root_child1.LayoutHeight);

            Assert.AreEqual(92f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(10f, root_child2.LayoutWidth);
            Assert.AreEqual(102f, root_child2.LayoutHeight);

            root.StyleDirection = CSSDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(102f, root.LayoutWidth);
            Assert.AreEqual(102f, root.LayoutHeight);

            Assert.AreEqual(20f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(10f, root_child0.LayoutWidth);
            Assert.AreEqual(102f, root_child0.LayoutHeight);

            Assert.AreEqual(10f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(10f, root_child1.LayoutWidth);
            Assert.AreEqual(102f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(10f, root_child2.LayoutWidth);
            Assert.AreEqual(102f, root_child2.LayoutHeight);
        }
예제 #20
0
        public void Test_flex_direction_column_no_height()
        {
            CSSNode root = new CSSNode();

            root.StyleWidth = 100;

            CSSNode root_child0 = new CSSNode();

            root_child0.StyleHeight = 10;
            root.Insert(0, root_child0);

            CSSNode root_child1 = new CSSNode();

            root_child1.StyleHeight = 10;
            root.Insert(1, root_child1);

            CSSNode root_child2 = new CSSNode();

            root_child2.StyleHeight = 10;
            root.Insert(2, root_child2);
            root.StyleDirection = CSSDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(100, root.LayoutWidth);
            Assert.AreEqual(30, root.LayoutHeight);

            Assert.AreEqual(0, root_child0.LayoutX);
            Assert.AreEqual(0, root_child0.LayoutY);
            Assert.AreEqual(100, root_child0.LayoutWidth);
            Assert.AreEqual(10, root_child0.LayoutHeight);

            Assert.AreEqual(0, root_child1.LayoutX);
            Assert.AreEqual(10, root_child1.LayoutY);
            Assert.AreEqual(100, root_child1.LayoutWidth);
            Assert.AreEqual(10, root_child1.LayoutHeight);

            Assert.AreEqual(0, root_child2.LayoutX);
            Assert.AreEqual(20, root_child2.LayoutY);
            Assert.AreEqual(100, root_child2.LayoutWidth);
            Assert.AreEqual(10, root_child2.LayoutHeight);

            root.StyleDirection = CSSDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(100, root.LayoutWidth);
            Assert.AreEqual(30, root.LayoutHeight);

            Assert.AreEqual(0, root_child0.LayoutX);
            Assert.AreEqual(0, root_child0.LayoutY);
            Assert.AreEqual(100, root_child0.LayoutWidth);
            Assert.AreEqual(10, root_child0.LayoutHeight);

            Assert.AreEqual(0, root_child1.LayoutX);
            Assert.AreEqual(10, root_child1.LayoutY);
            Assert.AreEqual(100, root_child1.LayoutWidth);
            Assert.AreEqual(10, root_child1.LayoutHeight);

            Assert.AreEqual(0, root_child2.LayoutX);
            Assert.AreEqual(20, root_child2.LayoutY);
            Assert.AreEqual(100, root_child2.LayoutWidth);
            Assert.AreEqual(10, root_child2.LayoutHeight);
        }
예제 #21
0
        public void TestRemoveAtFromEmpty()
        {
            CSSNode parent = new CSSNode();

            parent.RemoveAt(0);
        }
        public void Test_justify_content_column_space_between()
        {
            CSSNode root = new CSSNode();

            root.JustifyContent = CSSJustify.SpaceBetween;
            root.StyleWidth     = 102;
            root.StyleHeight    = 102;

            CSSNode root_child0 = new CSSNode();

            root_child0.StyleHeight = 10;
            root.Insert(0, root_child0);

            CSSNode root_child1 = new CSSNode();

            root_child1.StyleHeight = 10;
            root.Insert(1, root_child1);

            CSSNode root_child2 = new CSSNode();

            root_child2.StyleHeight = 10;
            root.Insert(2, root_child2);
            root.StyleDirection = CSSDirection.LeftToRight;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(102, root.LayoutWidth);
            Assert.AreEqual(102, root.LayoutHeight);

            Assert.AreEqual(0, root_child0.LayoutX);
            Assert.AreEqual(0, root_child0.LayoutY);
            Assert.AreEqual(102, root_child0.LayoutWidth);
            Assert.AreEqual(10, root_child0.LayoutHeight);

            Assert.AreEqual(0, root_child1.LayoutX);
            Assert.AreEqual(46, root_child1.LayoutY);
            Assert.AreEqual(102, root_child1.LayoutWidth);
            Assert.AreEqual(10, root_child1.LayoutHeight);

            Assert.AreEqual(0, root_child2.LayoutX);
            Assert.AreEqual(92, root_child2.LayoutY);
            Assert.AreEqual(102, root_child2.LayoutWidth);
            Assert.AreEqual(10, root_child2.LayoutHeight);

            root.StyleDirection = CSSDirection.RightToLeft;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(102, root.LayoutWidth);
            Assert.AreEqual(102, root.LayoutHeight);

            Assert.AreEqual(0, root_child0.LayoutX);
            Assert.AreEqual(0, root_child0.LayoutY);
            Assert.AreEqual(102, root_child0.LayoutWidth);
            Assert.AreEqual(10, root_child0.LayoutHeight);

            Assert.AreEqual(0, root_child1.LayoutX);
            Assert.AreEqual(46, root_child1.LayoutY);
            Assert.AreEqual(102, root_child1.LayoutWidth);
            Assert.AreEqual(10, root_child1.LayoutHeight);

            Assert.AreEqual(0, root_child2.LayoutX);
            Assert.AreEqual(92, root_child2.LayoutY);
            Assert.AreEqual(102, root_child2.LayoutWidth);
            Assert.AreEqual(10, root_child2.LayoutHeight);
        }
예제 #23
0
        public void Test_rounding_flex_basis_flex_grow_row_width_of_100()
        {
            CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true);

            CSSNode root = new CSSNode();

            root.FlexDirection = CSSFlexDirection.Row;
            root.StyleWidth    = 100f;
            root.StyleHeight   = 100f;

            CSSNode root_child0 = new CSSNode();

            root_child0.FlexGrow = 1f;
            root.Insert(0, root_child0);

            CSSNode root_child1 = new CSSNode();

            root_child1.FlexGrow = 1f;
            root.Insert(1, root_child1);

            CSSNode root_child2 = new CSSNode();

            root_child2.FlexGrow = 1f;
            root.Insert(2, root_child2);
            root.StyleDirection = CSSDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(33f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(33f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(34f, root_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child1.LayoutHeight);

            Assert.AreEqual(67f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(33f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);

            root.StyleDirection = CSSDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(67f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(33f, root_child0.LayoutWidth);
            Assert.AreEqual(100f, root_child0.LayoutHeight);

            Assert.AreEqual(33f, root_child1.LayoutX);
            Assert.AreEqual(0f, root_child1.LayoutY);
            Assert.AreEqual(34f, root_child1.LayoutWidth);
            Assert.AreEqual(100f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(0f, root_child2.LayoutY);
            Assert.AreEqual(33f, root_child2.LayoutWidth);
            Assert.AreEqual(100f, root_child2.LayoutHeight);

            CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false);
        }
        public void Test_justify_content_row_flex_start()
        {
            CSSNode root = new CSSNode();

            root.FlexDirection = CSSFlexDirection.Row;
            root.StyleWidth    = 102;
            root.StyleHeight   = 102;

            CSSNode root_child0 = new CSSNode();

            root_child0.StyleWidth = 10;
            root.Insert(0, root_child0);

            CSSNode root_child1 = new CSSNode();

            root_child1.StyleWidth = 10;
            root.Insert(1, root_child1);

            CSSNode root_child2 = new CSSNode();

            root_child2.StyleWidth = 10;
            root.Insert(2, root_child2);
            root.StyleDirection = CSSDirection.LeftToRight;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(102, root.LayoutWidth);
            Assert.AreEqual(102, root.LayoutHeight);

            Assert.AreEqual(0, root_child0.LayoutX);
            Assert.AreEqual(0, root_child0.LayoutY);
            Assert.AreEqual(10, root_child0.LayoutWidth);
            Assert.AreEqual(102, root_child0.LayoutHeight);

            Assert.AreEqual(10, root_child1.LayoutX);
            Assert.AreEqual(0, root_child1.LayoutY);
            Assert.AreEqual(10, root_child1.LayoutWidth);
            Assert.AreEqual(102, root_child1.LayoutHeight);

            Assert.AreEqual(20, root_child2.LayoutX);
            Assert.AreEqual(0, root_child2.LayoutY);
            Assert.AreEqual(10, root_child2.LayoutWidth);
            Assert.AreEqual(102, root_child2.LayoutHeight);

            root.StyleDirection = CSSDirection.RightToLeft;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(102, root.LayoutWidth);
            Assert.AreEqual(102, root.LayoutHeight);

            Assert.AreEqual(92, root_child0.LayoutX);
            Assert.AreEqual(0, root_child0.LayoutY);
            Assert.AreEqual(10, root_child0.LayoutWidth);
            Assert.AreEqual(102, root_child0.LayoutHeight);

            Assert.AreEqual(82, root_child1.LayoutX);
            Assert.AreEqual(0, root_child1.LayoutY);
            Assert.AreEqual(10, root_child1.LayoutWidth);
            Assert.AreEqual(102, root_child1.LayoutHeight);

            Assert.AreEqual(72, root_child2.LayoutX);
            Assert.AreEqual(0, root_child2.LayoutY);
            Assert.AreEqual(10, root_child2.LayoutWidth);
            Assert.AreEqual(102, root_child2.LayoutHeight);
        }
예제 #25
0
        public void Test_rounding_fractial_input_4()
        {
            CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true);

            CSSNode root = new CSSNode();

            root.SetPosition(CSSEdge.Top, 0.7f);
            root.StyleWidth  = 100f;
            root.StyleHeight = 113.4f;

            CSSNode root_child0 = new CSSNode();

            root_child0.FlexGrow    = 1f;
            root_child0.FlexBasis   = 50f;
            root_child0.StyleHeight = 20f;
            root.Insert(0, root_child0);

            CSSNode root_child1 = new CSSNode();

            root_child1.FlexGrow    = 1f;
            root_child1.StyleHeight = 10f;
            root.Insert(1, root_child1);

            CSSNode root_child2 = new CSSNode();

            root_child2.FlexGrow    = 1f;
            root_child2.StyleHeight = 10f;
            root.Insert(2, root_child2);
            root.StyleDirection = CSSDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(1f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(113f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(100f, root_child0.LayoutWidth);
            Assert.AreEqual(64f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(64f, root_child1.LayoutY);
            Assert.AreEqual(100f, root_child1.LayoutWidth);
            Assert.AreEqual(25f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(89f, root_child2.LayoutY);
            Assert.AreEqual(100f, root_child2.LayoutWidth);
            Assert.AreEqual(24f, root_child2.LayoutHeight);

            root.StyleDirection = CSSDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(1f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(113f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(0f, root_child0.LayoutY);
            Assert.AreEqual(100f, root_child0.LayoutWidth);
            Assert.AreEqual(64f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(64f, root_child1.LayoutY);
            Assert.AreEqual(100f, root_child1.LayoutWidth);
            Assert.AreEqual(25f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(89f, root_child2.LayoutY);
            Assert.AreEqual(100f, root_child2.LayoutWidth);
            Assert.AreEqual(24f, root_child2.LayoutHeight);

            CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false);
        }
예제 #26
0
        public void Test_wrap_row_align_items_center()
        {
            CSSNode root = new CSSNode();

            root.FlexDirection = CSSFlexDirection.Row;
            root.AlignItems    = CSSAlign.Center;
            root.Wrap          = CSSWrap.Wrap;
            root.StyleWidth    = 100;

            CSSNode root_child0 = new CSSNode();

            root_child0.StyleWidth  = 30;
            root_child0.StyleHeight = 10;
            root.Insert(0, root_child0);

            CSSNode root_child1 = new CSSNode();

            root_child1.StyleWidth  = 30;
            root_child1.StyleHeight = 20;
            root.Insert(1, root_child1);

            CSSNode root_child2 = new CSSNode();

            root_child2.StyleWidth  = 30;
            root_child2.StyleHeight = 30;
            root.Insert(2, root_child2);

            CSSNode root_child3 = new CSSNode();

            root_child3.StyleWidth  = 30;
            root_child3.StyleHeight = 30;
            root.Insert(3, root_child3);
            root.StyleDirection = CSSDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(100, root.LayoutWidth);
            Assert.AreEqual(60, root.LayoutHeight);

            Assert.AreEqual(0, root_child0.LayoutX);
            Assert.AreEqual(10, root_child0.LayoutY);
            Assert.AreEqual(30, root_child0.LayoutWidth);
            Assert.AreEqual(10, root_child0.LayoutHeight);

            Assert.AreEqual(30, root_child1.LayoutX);
            Assert.AreEqual(5, root_child1.LayoutY);
            Assert.AreEqual(30, root_child1.LayoutWidth);
            Assert.AreEqual(20, root_child1.LayoutHeight);

            Assert.AreEqual(60, root_child2.LayoutX);
            Assert.AreEqual(0, root_child2.LayoutY);
            Assert.AreEqual(30, root_child2.LayoutWidth);
            Assert.AreEqual(30, root_child2.LayoutHeight);

            Assert.AreEqual(0, root_child3.LayoutX);
            Assert.AreEqual(30, root_child3.LayoutY);
            Assert.AreEqual(30, root_child3.LayoutWidth);
            Assert.AreEqual(30, root_child3.LayoutHeight);

            root.StyleDirection = CSSDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(100, root.LayoutWidth);
            Assert.AreEqual(60, root.LayoutHeight);

            Assert.AreEqual(70, root_child0.LayoutX);
            Assert.AreEqual(10, root_child0.LayoutY);
            Assert.AreEqual(30, root_child0.LayoutWidth);
            Assert.AreEqual(10, root_child0.LayoutHeight);

            Assert.AreEqual(40, root_child1.LayoutX);
            Assert.AreEqual(5, root_child1.LayoutY);
            Assert.AreEqual(30, root_child1.LayoutWidth);
            Assert.AreEqual(20, root_child1.LayoutHeight);

            Assert.AreEqual(10, root_child2.LayoutX);
            Assert.AreEqual(0, root_child2.LayoutY);
            Assert.AreEqual(30, root_child2.LayoutWidth);
            Assert.AreEqual(30, root_child2.LayoutHeight);

            Assert.AreEqual(70, root_child3.LayoutX);
            Assert.AreEqual(30, root_child3.LayoutY);
            Assert.AreEqual(30, root_child3.LayoutWidth);
            Assert.AreEqual(30, root_child3.LayoutHeight);
        }
예제 #27
0
        public void TestFree()
        {
            CSSNode node = new CSSNode();

            node.Free();
        }
예제 #28
0
        public void Test_wrap_column()
        {
            CSSNode root = new CSSNode();

            root.Wrap        = CSSWrap.Wrap;
            root.StyleHeight = 100;

            CSSNode root_child0 = new CSSNode();

            root_child0.StyleWidth  = 30;
            root_child0.StyleHeight = 30;
            root.Insert(0, root_child0);

            CSSNode root_child1 = new CSSNode();

            root_child1.StyleWidth  = 30;
            root_child1.StyleHeight = 30;
            root.Insert(1, root_child1);

            CSSNode root_child2 = new CSSNode();

            root_child2.StyleWidth  = 30;
            root_child2.StyleHeight = 30;
            root.Insert(2, root_child2);

            CSSNode root_child3 = new CSSNode();

            root_child3.StyleWidth  = 30;
            root_child3.StyleHeight = 30;
            root.Insert(3, root_child3);
            root.StyleDirection = CSSDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(60, root.LayoutWidth);
            Assert.AreEqual(100, root.LayoutHeight);

            Assert.AreEqual(0, root_child0.LayoutX);
            Assert.AreEqual(0, root_child0.LayoutY);
            Assert.AreEqual(30, root_child0.LayoutWidth);
            Assert.AreEqual(30, root_child0.LayoutHeight);

            Assert.AreEqual(0, root_child1.LayoutX);
            Assert.AreEqual(30, root_child1.LayoutY);
            Assert.AreEqual(30, root_child1.LayoutWidth);
            Assert.AreEqual(30, root_child1.LayoutHeight);

            Assert.AreEqual(0, root_child2.LayoutX);
            Assert.AreEqual(60, root_child2.LayoutY);
            Assert.AreEqual(30, root_child2.LayoutWidth);
            Assert.AreEqual(30, root_child2.LayoutHeight);

            Assert.AreEqual(30, root_child3.LayoutX);
            Assert.AreEqual(0, root_child3.LayoutY);
            Assert.AreEqual(30, root_child3.LayoutWidth);
            Assert.AreEqual(30, root_child3.LayoutHeight);

            root.StyleDirection = CSSDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0, root.LayoutX);
            Assert.AreEqual(0, root.LayoutY);
            Assert.AreEqual(60, root.LayoutWidth);
            Assert.AreEqual(100, root.LayoutHeight);

            Assert.AreEqual(30, root_child0.LayoutX);
            Assert.AreEqual(0, root_child0.LayoutY);
            Assert.AreEqual(30, root_child0.LayoutWidth);
            Assert.AreEqual(30, root_child0.LayoutHeight);

            Assert.AreEqual(30, root_child1.LayoutX);
            Assert.AreEqual(30, root_child1.LayoutY);
            Assert.AreEqual(30, root_child1.LayoutWidth);
            Assert.AreEqual(30, root_child1.LayoutHeight);

            Assert.AreEqual(30, root_child2.LayoutX);
            Assert.AreEqual(60, root_child2.LayoutY);
            Assert.AreEqual(30, root_child2.LayoutWidth);
            Assert.AreEqual(30, root_child2.LayoutHeight);

            Assert.AreEqual(0, root_child3.LayoutX);
            Assert.AreEqual(0, root_child3.LayoutY);
            Assert.AreEqual(30, root_child3.LayoutWidth);
            Assert.AreEqual(30, root_child3.LayoutHeight);
        }
        public void Test_flex_direction_column_reverse()
        {
            CSSNode root = new CSSNode();

            root.FlexDirection = CSSFlexDirection.ColumnReverse;
            root.StyleWidth    = 100f;
            root.StyleHeight   = 100f;

            CSSNode root_child0 = new CSSNode();

            root_child0.StyleHeight = 10f;
            root.Insert(0, root_child0);

            CSSNode root_child1 = new CSSNode();

            root_child1.StyleHeight = 10f;
            root.Insert(1, root_child1);

            CSSNode root_child2 = new CSSNode();

            root_child2.StyleHeight = 10f;
            root.Insert(2, root_child2);
            root.StyleDirection = CSSDirection.LTR;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(90f, root_child0.LayoutY);
            Assert.AreEqual(100f, root_child0.LayoutWidth);
            Assert.AreEqual(10f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(80f, root_child1.LayoutY);
            Assert.AreEqual(100f, root_child1.LayoutWidth);
            Assert.AreEqual(10f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(70f, root_child2.LayoutY);
            Assert.AreEqual(100f, root_child2.LayoutWidth);
            Assert.AreEqual(10f, root_child2.LayoutHeight);

            root.StyleDirection = CSSDirection.RTL;
            root.CalculateLayout();

            Assert.AreEqual(0f, root.LayoutX);
            Assert.AreEqual(0f, root.LayoutY);
            Assert.AreEqual(100f, root.LayoutWidth);
            Assert.AreEqual(100f, root.LayoutHeight);

            Assert.AreEqual(0f, root_child0.LayoutX);
            Assert.AreEqual(90f, root_child0.LayoutY);
            Assert.AreEqual(100f, root_child0.LayoutWidth);
            Assert.AreEqual(10f, root_child0.LayoutHeight);

            Assert.AreEqual(0f, root_child1.LayoutX);
            Assert.AreEqual(80f, root_child1.LayoutY);
            Assert.AreEqual(100f, root_child1.LayoutWidth);
            Assert.AreEqual(10f, root_child1.LayoutHeight);

            Assert.AreEqual(0f, root_child2.LayoutX);
            Assert.AreEqual(70f, root_child2.LayoutY);
            Assert.AreEqual(100f, root_child2.LayoutWidth);
            Assert.AreEqual(10f, root_child2.LayoutHeight);
        }
예제 #30
0
 public static void removeChildAt(this CSSNode node, int i)
 {
     node.RemoveChildAt(i);
 }