public override unsafe byte PreInit(SizeConfig *value, ulong mask, ref UIPropertyWriterContext context)
 {
     value->minWidth  = 0f.Px();
     value->maxWidth  = float.PositiveInfinity.Px();
     value->width     = float.NaN.Px();
     value->height    = float.NaN.Px();
     value->minHeight = 0f.Px();
     value->maxHeight = float.PositiveInfinity.Px();
     return(0);
 }
Пример #2
0
        public static void Render(IntPtr configPtr, NodeInfo *nodeInfo, UIPassState *statePtr, UIVertexData *vertexDataPtr, UIContextData *context)
        {
            IntPtr            configSource           = configPtr + nodeInfo->configOffset;
            BoxModelConfig *  boxConfig              = (BoxModelConfig *)UIConfigUtility.GetConfig(nodeInfo->configurationMask, UIConfigLayoutTable.BoxModelConfig, configSource).ToPointer();
            BackgroundConfig *backgroundConfig       = (BackgroundConfig *)UIConfigUtility.GetConfig(nodeInfo->configurationMask, UIConfigLayoutTable.BackgroundConfig, configSource).ToPointer();
            BorderConfig *    borderConfig           = (BorderConfig *)UIConfigUtility.GetConfig(nodeInfo->configurationMask, UIConfigLayoutTable.BorderConfig, configSource).ToPointer();
            SizeConfig *      sizeConfig             = (SizeConfig *)UIConfigUtility.GetConfig(nodeInfo->configurationMask, UIConfigLayoutTable.SizeConfig, configSource).ToPointer();
            BoxLayoutConfig * sequentialLayoutConfig = (BoxLayoutConfig *)UIConfigUtility.GetConfig(nodeInfo->configurationMask, UIConfigLayoutTable.BoxLayoutConfig, configSource).ToPointer();
            HeaderConfig *    headerConfig           = (HeaderConfig *)(configPtr + nodeInfo->nodeOffset);

            UIRenderBoxWriters.WriteRenderBox(statePtr, backgroundConfig, borderConfig, vertexDataPtr, context);
        }
 public override unsafe byte PostInit(SizeConfig *value, IntPtr config, ulong mask, MemoryBinaryWriter extraBytesStream, long extraByteStreamOffset, UIPropertyWriterContext context)
 {
     return(0);
 }
Пример #4
0
        public static void Layout(int childIndex, IntPtr configPtr, NodeInfo *nodeInfo, IntPtr statePtr, UIContextData *context)
        {
            if (childIndex < 0)
            {
                UIPassState *     selfPtr          = (UIPassState *)(((IntPtr)statePtr) + (UnsafeUtility.SizeOf <UIPassState>() * nodeInfo->index)).ToPointer();
                IntPtr            configSource     = configPtr + nodeInfo->configOffset;
                BoxModelConfig *  boxConfig        = (BoxModelConfig *)UIConfigUtility.GetConfig(nodeInfo->configurationMask, UIConfigLayoutTable.BoxModelConfig, configSource).ToPointer();
                BackgroundConfig *backgroundConfig = (BackgroundConfig *)UIConfigUtility.GetConfig(nodeInfo->configurationMask, UIConfigLayoutTable.BackgroundConfig, configSource).ToPointer();
                BorderConfig *    borderConfig     = (BorderConfig *)UIConfigUtility.GetConfig(nodeInfo->configurationMask, UIConfigLayoutTable.BorderConfig, configSource).ToPointer();
                SizeConfig *      sizeConfig       = (SizeConfig *)UIConfigUtility.GetConfig(nodeInfo->configurationMask, UIConfigLayoutTable.SizeConfig, configSource).ToPointer();

                BoxLayoutConfig *boxLayoutConfig = (BoxLayoutConfig *)UIConfigUtility.GetConfig(nodeInfo->configurationMask, UIConfigLayoutTable.BoxLayoutConfig, configSource).ToPointer();
                HeaderConfig *   headerConfig    = (HeaderConfig *)(configPtr + nodeInfo->nodeOffset);
                float            height          = 0f;
                float            width           = 0f;
                float2           childrenSize    = default;
                int4             multiplier      = default;
                //float4 padding = boxConfig->padding.Normalize(*context);
                float4 constraints = new float4(
                    sizeConfig->minWidth.Normalize(*context), sizeConfig->maxWidth.Normalize(*context),
                    sizeConfig->minHeight.Normalize(*context), sizeConfig->maxHeight.Normalize(*context)
                    );
                var spacing = boxLayoutConfig->spacing.Normalize(*context);
                switch (boxLayoutConfig->direction)
                {
                case Direction.Left:
                    for (int i = 0; i < headerConfig->childCount; i++)
                    {
                        var childState = (UIPassState *)(((IntPtr)statePtr) + (UnsafeUtility.SizeOf <UIPassState>() * UnsafeUtility.ReadArrayElement <int>((configPtr + nodeInfo->childrenOffset).ToPointer(), headerConfig->childCount - 1 - i))).ToPointer();
                        LayoutHorizontal(childState, ref width, ref height);
                        if (i + 1 < headerConfig->childCount)
                        {
                            width += spacing;
                        }
                    }
                    multiplier = new int4(1, 0, 0, 1);
                    break;

                case Direction.Right:
                    for (int i = 0; i < headerConfig->childCount; i++)
                    {
                        var childState = (UIPassState *)(statePtr + (UnsafeUtility.SizeOf <UIPassState>() * (UnsafeUtility.ReadArrayElement <int>((configPtr + nodeInfo->childrenOffset).ToPointer(), i)))).ToPointer();
                        LayoutHorizontal(childState, ref width, ref height);
                        if (i + 1 < headerConfig->childCount)
                        {
                            width += spacing;
                        }
                    }
                    multiplier = new int4(1, 0, 0, 1);
                    break;

                case Direction.Up:
                    for (int i = 0; i < headerConfig->childCount; i++)
                    {
                        var childState = (UIPassState *)(((IntPtr)statePtr) + (UnsafeUtility.SizeOf <UIPassState>() * UnsafeUtility.ReadArrayElement <int>((configPtr + nodeInfo->childrenOffset).ToPointer(), i))).ToPointer();
                        LayoutVertical(childState, ref height, ref width);
                        if (i + 1 < headerConfig->childCount)
                        {
                            height += spacing;
                        }
                    }
                    multiplier = new int4(0, 1, 1, 0);
                    break;

                case Direction.Down:
                    for (int i = 0; i < headerConfig->childCount; i++)
                    {
                        var childState = (UIPassState *)(((IntPtr)statePtr) + (UnsafeUtility.SizeOf <UIPassState>() * UnsafeUtility.ReadArrayElement <int>((configPtr + nodeInfo->childrenOffset).ToPointer(), headerConfig->childCount - 1 - i))).ToPointer();
                        LayoutVertical(childState, ref height, ref width);
                        if (i + 1 < headerConfig->childCount)
                        {
                            height += spacing;
                        }
                    }
                    multiplier = new int4(0, 1, 1, 0);
                    break;
                }
                childrenSize  = new float2(width, height);
                selfPtr->size = new float2(
                    math.clamp(childrenSize.x, constraints.x, constraints.y),
                    math.clamp(childrenSize.y, constraints.z, constraints.w)
                    );;
                UIJobUtility.AdjustPosition(childrenSize, constraints, boxLayoutConfig, selfPtr, statePtr, headerConfig->childCount, (configPtr + nodeInfo->childrenOffset).ToPointer(), multiplier);

                //Debug.Log(selfPtr->size);
            }
        }