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; }
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; }
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]]); }
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]]); }
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)); }
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); }
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)); }
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)); }
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); }
// 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)); }
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)); }
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)); }
public static extern void YGNodeStyleSetFlexDirection(YGNodeHandle node, YogaFlexDirection flexDirection);
public static YogaFlexDirection FlexDirectionCross(this YogaFlexDirection flexDirection, YogaDirection direction) { return(flexDirection.IsColumn() ? YogaFlexDirection.Row.ResolveFlexDirection(direction) : YogaFlexDirection.Column); }
public static bool IsColumn(this YogaFlexDirection flexDirection) { return(flexDirection == YogaFlexDirection.Column || flexDirection == YogaFlexDirection.ColumnReverse); }
public static bool IsRow(this YogaFlexDirection flexDirection) { return(flexDirection == YogaFlexDirection.Row || flexDirection == YogaFlexDirection.RowReverse); }
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]); }
public float GetTrailingPaddingAndBorder(YogaFlexDirection axis, float?widthSize) { return(GetTrailingPadding(axis, widthSize) + GetTrailingBorder(axis)); }
public static extern void YGNodeStyleSetFlexDirection(IntPtr node, YogaFlexDirection flexDirection);
public float?GetRelativePosition(YogaFlexDirection axis, float?axisSize) { return(IsLeadingPositionDefined(axis) ? GetLeadingPosition(axis, axisSize) : -GetTrailingPosition(axis, axisSize)); }
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); }
public float?GetMarginForAxis(YogaFlexDirection axis, float?widthSize) { return(GetLeadingMargin(axis, widthSize) + GetTrailingMargin(axis, widthSize)); }