Ejemplo n.º 1
0
 public YogaStyle()
 {
     Direction      = YogaDirection.Inherit;
     FlexDirection  = YogaFlexDirection.Column;
     JustifyContent = YogaJustify.FlexStart;
     AlignContent   = YogaAlign.FlexStart;
     AlignItems     = YogaAlign.Stretch;
     AlignSelf      = YogaAlign.Auto;
     PositionType   = YogaPositionType.Relative;
     FlexWrap       = YogaWrap.NoWrap;
     Overflow       = YogaOverflow.Visible;
     Display        = YogaDisplay.Flex;
     Flex           = null;
     FlexGrow       = null;
     FlexShrink     = null;
     FlexBasis      = YogaValue.Auto;
     Margin         = YogaArray.From(DefaultEdgeValuesUnit);
     Position       = YogaArray.From(DefaultEdgeValuesUnit);
     Padding        = YogaArray.From(DefaultEdgeValuesUnit);
     Border         = YogaArray.From(DefaultEdgeValuesUnit);
     Dimensions     = YogaArray.From(DefaultDimensionValuesAutoUnit);
     MinDimensions  = YogaArray.From(DefaultDimensionValuesUnit);
     MaxDimensions  = YogaArray.From(DefaultDimensionValuesUnit);
     AspectRatio    = null;
 }
Ejemplo n.º 2
0
 public void CopyFrom(YogaStyle other)
 {
     Direction      = other.Direction;
     FlexDirection  = other.FlexDirection;
     JustifyContent = other.JustifyContent;
     AlignContent   = other.AlignContent;
     AlignItems     = other.AlignItems;
     AlignSelf      = other.AlignSelf;
     PositionType   = other.PositionType;
     FlexWrap       = other.FlexWrap;
     Overflow       = other.Overflow;
     Display        = other.Display;
     Flex           = other.Flex;
     FlexGrow       = other.FlexGrow;
     FlexShrink     = other.FlexShrink;
     FlexBasis      = other.FlexBasis;
     Margin.CopyFrom(other.Margin);
     Position.CopyFrom(other.Position);
     Padding.CopyFrom(other.Padding);
     Border.CopyFrom(other.Border);
     Dimensions.CopyFrom(other.Dimensions);
     MinDimensions.CopyFrom(other.MinDimensions);
     MaxDimensions.CopyFrom(other.MaxDimensions);
     AspectRatio = other.AspectRatio;
 }
Ejemplo n.º 3
0
        public YogaValue GetMarginLeadingValue(YogaFlexDirection axis)
        {
            if (axis.IsRow() && _style.Margin[YogaEdge.Start].Unit != YogaUnit.Undefined)
            {
                return(_style.Margin[YogaEdge.Start]);
            }

            return(_style.Margin[Leading[axis]]);
        }
Ejemplo n.º 4
0
        public YogaValue GetMarginTrailingValue(YogaFlexDirection axis)
        {
            if (axis.IsRow() && _style.Margin[YogaEdge.End].Unit != YogaUnit.Undefined)
            {
                return(_style.Margin[YogaEdge.End]);
            }

            return(_style.Margin[Trailing[axis]]);
        }
Ejemplo n.º 5
0
        public float?GetTrailingMargin(YogaFlexDirection axis, float?widthSize)
        {
            if (axis.IsRow() && _style.Margin[YogaEdge.End].Unit != YogaUnit.Undefined)
            {
                return(ResolveValueMargin(_style.Margin[YogaEdge.End], widthSize));
            }

            return(ResolveValueMargin(ComputedEdgeValue(_style.Margin, Trailing[axis], YogaValue.Zero), widthSize));
        }
Ejemplo n.º 6
0
        private YogaNode createYGNode(YogaConfig config, YogaFlexDirection flexDirection, int width, int height, bool alignBaseline)
        {
            YogaNode node = new YogaNode(config);

            node.FlexDirection = flexDirection;
            node.Width         = width;
            node.Height        = height;
            if (alignBaseline)
            {
                node.AlignItems = YogaAlign.Baseline;
            }
            return(node);
        }
Ejemplo n.º 7
0
        public float GetTrailingBorder(YogaFlexDirection flexDirection)
        {
            if (flexDirection.IsRow() &&
                _style.Border[YogaEdge.End].Unit != YogaUnit.Undefined &&
                _style.Border[YogaEdge.End].Value != null &&
                _style.Border[YogaEdge.End].Value >= 0.0f)
            {
                return(_style.Border[YogaEdge.End].Value.Value);
            }

            var computedEdgeValue = ComputedEdgeValue(_style.Border, Trailing[flexDirection], YogaValue.Zero).Value;

            return(YogaMath.Max(computedEdgeValue, 0.0f));
        }
Ejemplo n.º 8
0
        public float GetLeadingBorder(YogaFlexDirection axis)
        {
            if (axis.IsRow() &&
                _style.Border[YogaEdge.Start].Unit != YogaUnit.Undefined &&
                _style.Border[YogaEdge.Start].Value != null &&
                _style.Border[YogaEdge.Start].Value >= 0.0f)
            {
                return(_style.Border[YogaEdge.Start].Value.Value);
            }

            var computedEdgeValue = ComputedEdgeValue(_style.Border, Leading[axis], YogaValue.Zero).Value;

            return(YogaMath.Max(computedEdgeValue, 0.0F));
        }
Ejemplo n.º 9
0
        public static YogaFlexDirection ResolveFlexDirection(this YogaFlexDirection flexDirection, YogaDirection direction)
        {
            if (direction == YogaDirection.RightToLeft)
            {
                if (flexDirection == YogaFlexDirection.Row)
                {
                    return(YogaFlexDirection.RowReverse);
                }
                else if (flexDirection == YogaFlexDirection.RowReverse)
                {
                    return(YogaFlexDirection.Row);
                }
            }

            return(flexDirection);
        }
Ejemplo n.º 10
0
        // Methods related to positions, margin, padding and border
        public float?GetLeadingPosition(YogaFlexDirection axis, float?axisSize)
        {
            var leadingPosition = default(YogaValue);

            if (axis.IsRow())
            {
                leadingPosition = ComputedEdgeValue(_style.Position, YogaEdge.Start, YogaValue.Undefined);
                if (leadingPosition.Unit != YogaUnit.Undefined)
                {
                    return(leadingPosition.Resolve(axisSize));
                }
            }

            leadingPosition = ComputedEdgeValue(_style.Position, Leading[axis], YogaValue.Undefined);
            return(leadingPosition.Unit == YogaUnit.Undefined ? 0.0f : leadingPosition.Resolve(axisSize));
        }
Ejemplo n.º 11
0
        public float?GetTrailingPosition(YogaFlexDirection axis, float?axisSize)
        {
            var trailingPosition = default(YogaValue);

            if (axis.IsRow())
            {
                trailingPosition = ComputedEdgeValue(_style.Position, YogaEdge.End, YogaValue.Undefined);
                if (trailingPosition.Unit != YogaUnit.Undefined)
                {
                    return(trailingPosition.Resolve(axisSize));
                }
            }

            trailingPosition = ComputedEdgeValue(_style.Position, Trailing[axis], YogaValue.Undefined);
            return(trailingPosition.Unit == YogaUnit.Undefined ? 0.0f : trailingPosition.Resolve(axisSize));
        }
Ejemplo n.º 12
0
        public float GetTrailingPadding(YogaFlexDirection axis, float?widthSize)
        {
            var paddingEdgeEnd = _style.Padding[YogaEdge.End].Resolve(widthSize);

            if (axis.IsRow() &&
                _style.Padding[YogaEdge.End].Unit != YogaUnit.Undefined &&
                paddingEdgeEnd != null &&
                paddingEdgeEnd >= 0.0f)
            {
                return(paddingEdgeEnd.Value);
            }

            var resolvedValue = ComputedEdgeValue(_style.Padding, Trailing[axis], YogaValue.Zero).Resolve(widthSize);

            return(YogaMath.Max(resolvedValue, 0.0f));
        }
Ejemplo n.º 13
0
 public static extern void YGNodeStyleSetFlexDirection(YGNodeHandle node, YogaFlexDirection flexDirection);
Ejemplo n.º 14
0
 public static YogaFlexDirection FlexDirectionCross(this YogaFlexDirection flexDirection, YogaDirection direction)
 {
     return(flexDirection.IsColumn()
         ? YogaFlexDirection.Row.ResolveFlexDirection(direction)
         : YogaFlexDirection.Column);
 }
Ejemplo n.º 15
0
 public static bool IsColumn(this YogaFlexDirection flexDirection)
 {
     return(flexDirection == YogaFlexDirection.Column || flexDirection == YogaFlexDirection.ColumnReverse);
 }
Ejemplo n.º 16
0
 public static bool IsRow(this YogaFlexDirection flexDirection)
 {
     return(flexDirection == YogaFlexDirection.Row || flexDirection == YogaFlexDirection.RowReverse);
 }
Ejemplo n.º 17
0
        private void SetChildTrailingPosition(YogaNode child, YogaFlexDirection axis)
        {
            var size = child.Layout.MeasuredDimensions[Dimension[axis]];

            child.SetLayoutPosition(Layout.MeasuredDimensions[Dimension[axis]] - size - child.Layout.Position[Position[axis]], Trailing[axis]);
        }
Ejemplo n.º 18
0
 public float GetTrailingPaddingAndBorder(YogaFlexDirection axis, float?widthSize)
 {
     return(GetTrailingPadding(axis, widthSize) + GetTrailingBorder(axis));
 }
Ejemplo n.º 19
0
 public static extern void YGNodeStyleSetFlexDirection(IntPtr node, YogaFlexDirection flexDirection);
Ejemplo n.º 20
0
 public float?GetRelativePosition(YogaFlexDirection axis, float?axisSize)
 {
     return(IsLeadingPositionDefined(axis) ? GetLeadingPosition(axis, axisSize) : -GetTrailingPosition(axis, axisSize));
 }
Ejemplo n.º 21
0
 public bool IsTrailingPositionDefined(YogaFlexDirection axis)
 {
     return((axis.IsRow() && ComputedEdgeValue(_style.Position, YogaEdge.End, YogaValue.Undefined).Unit != YogaUnit.Undefined) ||
            ComputedEdgeValue(_style.Position, Trailing[axis], YogaValue.Undefined).Unit != YogaUnit.Undefined);
 }
Ejemplo n.º 22
0
 public float?GetMarginForAxis(YogaFlexDirection axis, float?widthSize)
 {
     return(GetLeadingMargin(axis, widthSize) + GetTrailingMargin(axis, widthSize));
 }