コード例 #1
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;
 }
コード例 #2
0
        public YogaLayout()
        {
            var cached = new YogaCachedMeasurement[MaxCachedResultCount];

            for (var i = 0; i < cached.Length; i++)
            {
                cached[i] = new YogaCachedMeasurement();
            }

            Position   = new YogaArray <float?>(4);
            Dimensions = YogaArray.From(DefaultDimensionValues);
            Margin     = new YogaArray <float?>(6);
            Border     = new YogaArray <float>(6);
            Padding    = new YogaArray <float>(6);
            Direction  = YogaDirection.Inherit;
            ComputedFlexBasisGeneration = 0;
            ComputedFlexBasis           = null;
            HadOverflow                        = false;
            GenerationCount                    = 0;
            LastOwnerDirection                 = (YogaDirection)(-1);
            NextCachedMeasurementsIndex        = 0;
            CachedMeasurements                 = cached;
            MeasuredDimensions                 = YogaArray.From(DefaultDimensionValues);
            CachedLayout                       = new YogaCachedMeasurement();
            DidUseLegacyFlag                   = false;
            DoesLegacyStretchFlagAffectsLayout = false;
        }
コード例 #3
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;
 }
コード例 #4
0
        public YogaDirection ResolveDirection(YogaDirection ownerDirection)
        {
            if (_style.Direction == YogaDirection.Inherit)
            {
                return(ownerDirection > YogaDirection.Inherit ? ownerDirection : YogaDirection.LeftToRight);
            }

            return(_style.Direction);
        }
コード例 #5
0
        public void SetPosition(YogaDirection direction, float?mainSize, float?crossSize, float?ownerWidth)
        {
            /* Root nodes should be always layouted as LTR, so we don't return negative
             * values. */
            var directionRespectingRoot = _owner != null ? direction : YogaDirection.LeftToRight;
            var mainAxis  = _style.FlexDirection.ResolveFlexDirection(directionRespectingRoot);
            var crossAxis = mainAxis.FlexDirectionCross(directionRespectingRoot);

            var relativePositionMain  = GetRelativePosition(mainAxis, mainSize);
            var relativePositionCross = GetRelativePosition(crossAxis, crossSize);

            SetLayoutPosition((GetLeadingMargin(mainAxis, ownerWidth) + relativePositionMain), Leading[mainAxis]);
            SetLayoutPosition((GetTrailingMargin(mainAxis, ownerWidth) + relativePositionMain), Trailing[mainAxis]);
            SetLayoutPosition((GetLeadingMargin(crossAxis, ownerWidth) + relativePositionCross), Leading[crossAxis]);
            SetLayoutPosition((GetTrailingMargin(crossAxis, ownerWidth) + relativePositionCross), Trailing[crossAxis]);
        }
コード例 #6
0
 public void CopyFrom(YogaLayout other)
 {
     Position.CopyFrom(other.Position);
     Dimensions.CopyFrom(other.Dimensions);
     Margin.CopyFrom(other.Margin);
     Border.CopyFrom(other.Border);
     Padding.CopyFrom(other.Padding);
     Direction = other.Direction;
     ComputedFlexBasisGeneration = other.ComputedFlexBasisGeneration;
     ComputedFlexBasis           = other.ComputedFlexBasis;
     HadOverflow                 = other.HadOverflow;
     GenerationCount             = other.GenerationCount;
     LastOwnerDirection          = other.LastOwnerDirection;
     NextCachedMeasurementsIndex = other.NextCachedMeasurementsIndex;
     Array.Copy(other.CachedMeasurements, CachedMeasurements, CachedMeasurements.Length);
     MeasuredDimensions.CopyFrom(other.MeasuredDimensions);
     CachedLayout.CopyFrom(other.CachedLayout);
     DidUseLegacyFlag = other.DidUseLegacyFlag;
     DoesLegacyStretchFlagAffectsLayout = other.DoesLegacyStretchFlagAffectsLayout;
 }
コード例 #7
0
        public void Clear()
        {
            Position.Clear();
            Dimensions.Clear();
            Margin.Clear();
            Border.Clear();
            Padding.Clear();
            Direction = YogaDirection.Inherit;
            ComputedFlexBasisGeneration = 0;
            ComputedFlexBasis           = 0F;
            HadOverflow                 = false;
            GenerationCount             = 0;
            LastOwnerDirection          = YogaDirection.Inherit;
            NextCachedMeasurementsIndex = 0;
            MeasuredDimensions.Clear();
            CachedLayout.Clear();
            DidUseLegacyFlag = false;
            DoesLegacyStretchFlagAffectsLayout = false;

            foreach (var item in CachedMeasurements)
            {
                item.Clear();
            }
        }
コード例 #8
0
ファイル: Native.cs プロジェクト: zmjios/yoga
 public static extern void YGNodeStyleSetDirection(YGNodeHandle node, YogaDirection direction);
コード例 #9
0
ファイル: Native.cs プロジェクト: zmjios/yoga
 public static extern void YGNodeCalculateLayout(
     YGNodeHandle node,
     float availableWidth,
     float availableHeight,
     YogaDirection parentDirection);
コード例 #10
0
ファイル: YogaExtensions.cs プロジェクト: brezza92/PixelFarm
 public static YogaFlexDirection FlexDirectionCross(this YogaFlexDirection flexDirection, YogaDirection direction)
 {
     return(flexDirection.IsColumn()
         ? YogaFlexDirection.Row.ResolveFlexDirection(direction)
         : YogaFlexDirection.Column);
 }
コード例 #11
0
ファイル: YogaExtensions.cs プロジェクト: brezza92/PixelFarm
        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);
        }
コード例 #12
0
 public static extern void YGNodeStyleSetDirection(IntPtr node, YogaDirection direction);