Exemplo n.º 1
0
 /// <summary>
 /// Instantiates a <see cref="EdgeSpacing"/>.
 /// </summary>
 /// <param name="defaultValue">The default spacing value.</param>
 public EdgeSpacing(YogaValue defaultValue)
 {
     _defaultValue = defaultValue;
 }
Exemplo n.º 2
0
 public static YogaValue Percent(this float value)
 {
     return(YogaValue.Percent(value));
 }
Exemplo n.º 3
0
 public static YogaValue Pt(this int value)
 {
     return(YogaValue.Point(value));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Instantiates a <see cref="EdgeSpacing"/>
 /// </summary>
 public EdgeSpacing()
     : this(YogaValue.Point(0))
 {
 }
Exemplo n.º 5
0
 /// <summary>
 /// Sets the padding for the node.
 /// </summary>
 /// <param name="spacingType">The spacing type.</param>
 /// <param name="padding">The padding.</param>
 public void SetPadding(int spacingType, YogaValue padding)
 {
     _padding.Set(spacingType, padding);
     UpdatePadding();
 }
Exemplo n.º 6
0
 public static bool IsUndefined(YogaValue value)
 {
     return(value.Unit == YogaUnit.Undefined);
 }
Exemplo n.º 7
0
        public static YogaBuild Node(
            YogaConfig config           = null,
            Direction direction         = Direction.Inherit,
            FlexDirection flexDirection = FlexDirection.Column,
            Justify justifyContent      = Justify.FlexStart,
            YogaAlign alignContent      = YogaAlign.FlexStart,
            YogaAlign alignItems        = YogaAlign.Stretch,
            YogaAlign alignSelf         = YogaAlign.Auto,
            float aspectRatio           = Net.YogaValue.YGUndefined,
            PositionType positionType   = PositionType.Relative,
            Wrap flexWrap           = Wrap.NoWrap,
            Overflow overflow       = Overflow.Visible,
            Display display         = Display.Flex,
            float flex              = float.NaN,
            float flexGrow          = float.NaN,
            float flexShrink        = float.NaN,
            YogaValue flexBasis     = null, // YogaValue.Auto,
            YogaValue width         = null, // YogaValue.Auto,
            YogaValue height        = null, // YogaValue.Auto,
            YogaValue minWidth      = null, // YogaValue.Undefined,
            YogaValue minHeight     = null, // YogaValue.Undefined,
            YogaValue maxWidth      = null, // YogaValue.Undefined,
            YogaValue maxHeight     = null, // YogaValue.Undefined,
            YogaValue left          = null,
            YogaValue top           = null,
            YogaValue right         = null,
            YogaValue bottom        = null,
            YogaValue start         = null,
            YogaValue end           = null,
            Edges margin            = null,
            Edges position          = null,
            Edges padding           = null,
            Edges border            = null,
            MeasureFunc measureFunc = null
            )
        {
            var node = new YogaNode(config)
            {
                Style = new YogaStyle
                {
                    Direction      = direction,
                    FlexDirection  = flexDirection,
                    JustifyContent = justifyContent,
                    AlignContent   = alignContent,
                    AlignItems     = alignItems,
                    AlignSelf      = alignSelf,
                    AspectRatio    = aspectRatio,
                    PositionType   = positionType,
                    FlexWrap       = flexWrap,
                    Overflow       = overflow,
                    Display        = display,
                    Flex           = flex,
                    FlexGrow       = flexGrow,
                    FlexShrink     = flexShrink,
                    FlexBasis      = flexBasis ?? YogaValue.Auto,
                    Width          = width ?? YogaValue.Auto,
                    Height         = height ?? YogaValue.Auto,
                    MinWidth       = minWidth ?? YogaValue.Undefined,
                    MinHeight      = minHeight ?? YogaValue.Undefined,
                    MaxWidth       = maxWidth ?? YogaValue.Undefined,
                    MaxHeight      = maxHeight ?? YogaValue.Undefined
                }
            };

            if (margin != null)
            {
                node.Style.Margin = margin;
            }
            if (position != null)
            {
                node.Style.Position = position;
            }
            if (padding != null)
            {
                node.Style.Padding = padding;
            }
            if (border != null)
            {
                node.Style.Border = border;
            }
            if (start != null)
            {
                node.Style.Position.Start = start;
            }
            if (end != null)
            {
                node.Style.Position.End = end;
            }
            if (left != null)
            {
                node.Style.Left = left;
            }
            if (top != null)
            {
                node.Style.Top = top;
            }
            if (right != null)
            {
                node.Style.Right = right;
            }
            if (bottom != null)
            {
                node.Style.Bottom = bottom;
            }

            if (measureFunc != null)
            {
                node.MeasureFunc = measureFunc;
            }

            return(new YogaBuild(node));
        }
Exemplo n.º 8
0
        public void SyncWithLayout(YogaNode targetNode)
        {
            targetNode.Flex = float.NaN;

            float fb = FlexBasisToFloat().GetSpecifiedValueOrDefault(float.NaN);

            if (fb == -1f)
            {
                targetNode.FlexBasis = YogaValue.Auto();
            }
            else
            {
                targetNode.FlexBasis = fb;
            }

            targetNode.FlexGrow          = flexGrow.GetSpecifiedValueOrDefault(float.NaN);
            targetNode.FlexShrink        = flexShrink.GetSpecifiedValueOrDefault(float.NaN);
            targetNode.Left              = positionLeft.GetSpecifiedValueOrDefault(float.NaN);
            targetNode.Top               = positionTop.GetSpecifiedValueOrDefault(float.NaN);
            targetNode.Right             = positionRight.GetSpecifiedValueOrDefault(float.NaN);
            targetNode.Bottom            = positionBottom.GetSpecifiedValueOrDefault(float.NaN);
            targetNode.MarginLeft        = marginLeft.GetSpecifiedValueOrDefault(float.NaN);
            targetNode.MarginTop         = marginTop.GetSpecifiedValueOrDefault(float.NaN);
            targetNode.MarginRight       = marginRight.GetSpecifiedValueOrDefault(float.NaN);
            targetNode.MarginBottom      = marginBottom.GetSpecifiedValueOrDefault(float.NaN);
            targetNode.PaddingLeft       = paddingLeft.GetSpecifiedValueOrDefault(float.NaN);
            targetNode.PaddingTop        = paddingTop.GetSpecifiedValueOrDefault(float.NaN);
            targetNode.PaddingRight      = paddingRight.GetSpecifiedValueOrDefault(float.NaN);
            targetNode.PaddingBottom     = paddingBottom.GetSpecifiedValueOrDefault(float.NaN);
            targetNode.BorderLeftWidth   = borderLeftWidth.GetSpecifiedValueOrDefault(float.NaN);
            targetNode.BorderTopWidth    = borderTopWidth.GetSpecifiedValueOrDefault(float.NaN);
            targetNode.BorderRightWidth  = borderRightWidth.GetSpecifiedValueOrDefault(float.NaN);
            targetNode.BorderBottomWidth = borderBottomWidth.GetSpecifiedValueOrDefault(float.NaN);
            targetNode.Width             = width.GetSpecifiedValueOrDefault(float.NaN);
            targetNode.Height            = height.GetSpecifiedValueOrDefault(float.NaN);

            PositionType posType = (PositionType)positionType.value;

            switch (posType)
            {
            case PositionType.Absolute:
            case PositionType.Manual:
                targetNode.PositionType = YogaPositionType.Absolute;
                break;

            case PositionType.Relative:
                targetNode.PositionType = YogaPositionType.Relative;
                break;
            }

            targetNode.Overflow  = (YogaOverflow)(overflow.value);
            targetNode.AlignSelf = (YogaAlign)(alignSelf.value);
            targetNode.MaxWidth  = maxWidth.GetSpecifiedValueOrDefault(float.NaN);
            targetNode.MaxHeight = maxHeight.GetSpecifiedValueOrDefault(float.NaN);
            targetNode.MinWidth  = minWidth.GetSpecifiedValueOrDefault(float.NaN);
            targetNode.MinHeight = minHeight.GetSpecifiedValueOrDefault(float.NaN);

            // Note: the following applies to VisualContainer only
            // but it won't cause any trouble and we avoid making this method virtual
            targetNode.FlexDirection  = (YogaFlexDirection)flexDirection.value;
            targetNode.AlignContent   = (YogaAlign)alignContent.GetSpecifiedValueOrDefault((int)DefaultAlignContent);
            targetNode.AlignItems     = (YogaAlign)alignItems.GetSpecifiedValueOrDefault((int)DefaultAlignItems);
            targetNode.JustifyContent = (YogaJustify)justifyContent.value;
            targetNode.Wrap           = (YogaWrap)flexWrap.value;
        }
Exemplo n.º 9
0
 public YogaValue2(YogaValue x, YogaValue y)
 {
     X = x;
     Y = y;
 }