void printNumberIfNotZero(Node node, string str, Value number)
 {
     if (!Flex.FloatsEqual(number.value, 0))
     {
         printNumberIfNotUndefined(node, str, number);
     }
 }
 // StyleSetFlex sets flex
 public void StyleSetFlex(float flex)
 {
     if (this.nodeStyle.Flex != flex)
     {
         this.nodeStyle.Flex = flex;
         Flex.nodeMarkDirtyInternal(this);
     }
 }
 // StyleSetPositionType sets position type
 public void StyleSetPositionType(PositionType positionType)
 {
     if (this.nodeStyle.PositionType != positionType)
     {
         this.nodeStyle.PositionType = positionType;
         Flex.nodeMarkDirtyInternal(this);
     }
 }
 // StyleSetDirection sets direction
 public void StyleSetDirection(Direction direction)
 {
     if (this.nodeStyle.Direction != direction)
     {
         this.nodeStyle.Direction = direction;
         Flex.nodeMarkDirtyInternal(this);
     }
 }
 // StyleSetFlexShrink sets flex shrink
 public void StyleSetFlexShrink(float flexShrink)
 {
     if (this.nodeStyle.FlexShrink != flexShrink)
     {
         this.nodeStyle.FlexShrink = flexShrink;
         Flex.nodeMarkDirtyInternal(this);
     }
 }
 // StyleSetDisplay sets display
 public void StyleSetDisplay(Display display)
 {
     if (this.nodeStyle.Display != display)
     {
         this.nodeStyle.Display = display;
         Flex.nodeMarkDirtyInternal(this);
     }
 }
 // StyleSetAspectRatio sets axpect ratio
 public void StyleSetAspectRatio(float aspectRatio)
 {
     if (this.nodeStyle.AspectRatio != aspectRatio)
     {
         this.nodeStyle.AspectRatio = aspectRatio;
         Flex.nodeMarkDirtyInternal(this);
     }
 }
 // StyleSetFlexWrap sets flex wrap
 public void StyleSetFlexWrap(Wrap flexWrap)
 {
     if (this.nodeStyle.FlexWrap != flexWrap)
     {
         this.nodeStyle.FlexWrap = flexWrap;
         Flex.nodeMarkDirtyInternal(this);
     }
 }
 // StyleSetOverflow sets overflow
 public void StyleSetOverflow(Overflow overflow)
 {
     if (this.nodeStyle.Overflow != overflow)
     {
         this.nodeStyle.Overflow = overflow;
         Flex.nodeMarkDirtyInternal(this);
     }
 }
 // StyleSetAlignItems sets align content
 public void StyleSetAlignItems(Align alignItems)
 {
     if (this.nodeStyle.AlignItems != alignItems)
     {
         this.nodeStyle.AlignItems = alignItems;
         Flex.nodeMarkDirtyInternal(this);
     }
 }
 // StyleSetAlignSelf sets align self
 public void StyleSetAlignSelf(Align alignSelf)
 {
     if (this.nodeStyle.AlignSelf != alignSelf)
     {
         this.nodeStyle.AlignSelf = alignSelf;
         Flex.nodeMarkDirtyInternal(this);
     }
 }
 // StyleSetAlignContent sets align content
 public void StyleSetAlignContent(Align alignContent)
 {
     if (this.nodeStyle.AlignContent != alignContent)
     {
         this.nodeStyle.AlignContent = alignContent;
         Flex.nodeMarkDirtyInternal(this);
     }
 }
 // StyleSetJustifyContent sets justify content
 public void StyleSetJustifyContent(Justify justifyContent)
 {
     if (this.nodeStyle.JustifyContent != justifyContent)
     {
         this.nodeStyle.JustifyContent = justifyContent;
         Flex.nodeMarkDirtyInternal(this);
     }
 }
 // StyleSetFlexDirection sets flex directions
 public void StyleSetFlexDirection(FlexDirection flexDirection)
 {
     if (this.nodeStyle.FlexDirection != flexDirection)
     {
         this.nodeStyle.FlexDirection = flexDirection;
         Flex.nodeMarkDirtyInternal(this);
     }
 }
 // StyleSetFlexGrow sets flex grow
 public void StyleSetFlexGrow(float flexGrow)
 {
     if (this.nodeStyle.FlexGrow != flexGrow)
     {
         this.nodeStyle.FlexGrow = flexGrow;
         Flex.nodeMarkDirtyInternal(this);
     }
 }
 // NodeStyleSetFlexBasisAuto sets flex basis auto
 public void NodeStyleSetFlexBasisAuto()
 {
     if (this.nodeStyle.FlexBasis.unit != Unit.Auto)
     {
         this.nodeStyle.FlexBasis.value = float.NaN;
         this.nodeStyle.FlexBasis.unit  = Unit.Auto;
         Flex.nodeMarkDirtyInternal(this);
     }
 }
        public void AddChild(Node child)
        {
            if (child == null || child.Parent == this)
            {
                return;
            }

            Flex.InsertChild(this, child, ChildrenCount);
        }
        public void InsertChild(Node child, int idx)
        {
            if (child == null)
            {
                return;
            }

            Flex.InsertChild(this, child, idx);
        }
 // StyleSetMarginAuto sets margin auto
 public void StyleSetMarginAuto(Edge edge)
 {
     if (this.nodeStyle.Margin[(int)edge].unit != Unit.Auto)
     {
         this.nodeStyle.Margin[(int)edge].value = float.NaN;
         this.nodeStyle.Margin[(int)edge].unit  = Unit.Auto;
         Flex.nodeMarkDirtyInternal(this);
     }
 }
        // StyleSetWidthAuto sets width auto
        public void StyleSetWidthAuto()
        {
            var dim = this.nodeStyle.Dimensions[(int)Dimension.Width];

            if (dim.unit != Unit.Auto)
            {
                dim.value = float.NaN;
                dim.unit  = Unit.Auto;
                Flex.nodeMarkDirtyInternal(this);
            }
        }
 // StyleSetMaxHeightPercent sets max height percent
 public void StyleSetMaxHeightPercent(float maxHeight)
 {
     if (this.nodeStyle.MaxDimensions[(int)Dimension.Height].value != maxHeight ||
         this.nodeStyle.MaxDimensions[(int)Dimension.Height].unit != Unit.Percent)
     {
         this.nodeStyle.MaxDimensions[(int)Dimension.Height].value = maxHeight;
         this.nodeStyle.MaxDimensions[(int)Dimension.Height].unit  = Unit.Percent;
         if (Flex.FloatIsUndefined(maxHeight))
         {
             this.nodeStyle.MaxDimensions[(int)Dimension.Height].unit = Unit.Auto;
         }
         Flex.nodeMarkDirtyInternal(this);
     }
 }
 // StyleSetMaxWidth sets max width
 public void StyleSetMaxWidth(float maxWidth)
 {
     if (this.nodeStyle.MaxDimensions[(int)Dimension.Width].value != maxWidth ||
         this.nodeStyle.MaxDimensions[(int)Dimension.Width].unit != Unit.Point)
     {
         this.nodeStyle.MaxDimensions[(int)Dimension.Width].value = maxWidth;
         this.nodeStyle.MaxDimensions[(int)Dimension.Width].unit  = Unit.Point;
         if (Flex.FloatIsUndefined(maxWidth))
         {
             this.nodeStyle.MaxDimensions[(int)Dimension.Width].unit = Unit.Auto;
         }
         Flex.nodeMarkDirtyInternal(this);
     }
 }
 // StyleSetBorder sets border
 public void StyleSetBorder(Edge edge, float border)
 {
     if (this.nodeStyle.Border[(int)edge].value != border ||
         this.nodeStyle.Border[(int)edge].unit != Unit.Point)
     {
         this.nodeStyle.Border[(int)edge].value = border;
         this.nodeStyle.Border[(int)edge].unit  = Unit.Point;
         if (Flex.FloatIsUndefined(border))
         {
             this.nodeStyle.Border[(int)edge].unit = Unit.Undefined;
         }
         Flex.nodeMarkDirtyInternal(this);
     }
 }
 // StyleSetPaddingPercent sets padding percent
 public void StyleSetPaddingPercent(Edge edge, float padding)
 {
     if (this.nodeStyle.Padding[(int)edge].value != padding ||
         this.nodeStyle.Padding[(int)edge].unit != Unit.Percent)
     {
         this.nodeStyle.Padding[(int)edge].value = padding;
         this.nodeStyle.Padding[(int)edge].unit  = Unit.Percent;
         if (Flex.FloatIsUndefined(padding))
         {
             this.nodeStyle.Padding[(int)edge].unit = Unit.Undefined;
         }
         Flex.nodeMarkDirtyInternal(this);
     }
 }
 // StyleSetMarginPercent sets margin percent
 public void StyleSetMarginPercent(Edge edge, float margin)
 {
     if (this.nodeStyle.Margin[(int)edge].value != margin ||
         this.nodeStyle.Margin[(int)edge].unit != Unit.Percent)
     {
         this.nodeStyle.Margin[(int)edge].value = margin;
         this.nodeStyle.Margin[(int)edge].unit  = Unit.Percent;
         if (Flex.FloatIsUndefined(margin))
         {
             this.nodeStyle.Margin[(int)edge].unit = Unit.Undefined;
         }
         Flex.nodeMarkDirtyInternal(this);
     }
 }
 // StyleSetFlexBasisPercent sets flex basis percent
 public void StyleSetFlexBasisPercent(float flexBasis)
 {
     if (this.nodeStyle.FlexBasis.value != flexBasis ||
         this.nodeStyle.FlexBasis.unit != Unit.Percent)
     {
         this.nodeStyle.FlexBasis.value = flexBasis;
         this.nodeStyle.FlexBasis.unit  = Unit.Percent;
         if (Flex.FloatIsUndefined(flexBasis))
         {
             this.nodeStyle.FlexBasis.unit = Unit.Auto;
         }
         Flex.nodeMarkDirtyInternal(this);
     }
 }
        // StyleSetPositionPercent sets position percent
        public void StyleSetPositionPercent(Edge edge, float position)
        {
            var pos = this.nodeStyle.Position[(int)edge];

            if (pos.value != position || pos.unit != Unit.Percent)
            {
                pos.value = position;
                pos.unit  = Unit.Percent;
                if (Flex.FloatIsUndefined(position))
                {
                    pos.unit = Unit.Undefined;
                }
                Flex.nodeMarkDirtyInternal(this);
            }
        }
        // StyleSetHeightPercent sets height percent
        public void StyleSetHeightPercent(float height)
        {
            var dim = this.nodeStyle.Dimensions[(int)Dimension.Height];

            if (dim.value != height || dim.unit != Unit.Percent)
            {
                dim.value = height;
                dim.unit  = Unit.Percent;
                if (Flex.FloatIsUndefined(height))
                {
                    dim.unit = Unit.Auto;
                }
                Flex.nodeMarkDirtyInternal(this);
            }
        }
        // StyleSetWidthPercent sets width percent
        public void StyleSetWidthPercent(float width)
        {
            var dim = this.nodeStyle.Dimensions[(int)Dimension.Width];

            if (dim.value != width || dim.unit != Unit.Percent)
            {
                dim.value = width;
                dim.unit  = Unit.Percent;
                if (Flex.FloatIsUndefined(width))
                {
                    dim.unit = Unit.Auto;
                }
                Flex.nodeMarkDirtyInternal(this);
            }
        }
Example #30
0
        // // Reset resets a node
        public static void Reset(ref Node node)
        {
            Flex.assertWithNode(node, node.Children.Count == 0, "Cannot reset a node which still has children attached");
            Flex.assertWithNode(node, node.Parent == null, "Cannot reset a node still attached to a parent");
            node.Children.Clear();

            var config = node.config;

            node = CreateDefaultNode();
            if (config.UseWebDefaults)
            {
                node.nodeStyle.FlexDirection = FlexDirection.Row;
                node.nodeStyle.AlignContent  = Align.Stretch;
            }
            node.config = config;
        }