Beispiel #1
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        private void UpdateLayoutWithFixedSize()
        {
            int itemCount = vChildItems.Count;

            if (itemCount == 0)
            {
                return;
            }

            bool  isRev             = (Arrangement == ArrangementType.OuterToInner);
            float relSumThickness   = 0;
            float paddedOuterRadius = OuterRadius - Padding.OuterRadius;
            float paddedInnerRadius = InnerRadius + Padding.InnerRadius;
            float availDeg          = ArcDegrees - Padding.StartDegree - Padding.EndDegree;
            float availThick        = paddedOuterRadius - paddedInnerRadius - Padding.Between * (itemCount - 1);
            float innerRadius       = paddedInnerRadius;
            float paddedStartDeg    = StartingDegree + (Padding.StartDegree - Padding.EndDegree) / 2;

            Vector2 anchorPos = RendererUtil.GetRelativeAnchorPosition(RectAnchor);

            anchorPos.x *= (vRectSize == null ? OuterRadius * 2 : ((Vector2)vRectSize).x);
            anchorPos.y *= (vRectSize == null ? OuterRadius * 2 : ((Vector2)vRectSize).y);

            for (int i = 0; i < itemCount; i++)
            {
                HoverLayoutArcGroupChild item = vChildItems[i];
                relSumThickness += item.RelativeThickness;
            }

            for (int i = 0; i < itemCount; i++)
            {
                int childI = (isRev ? itemCount - i - 1 : i);
                HoverLayoutArcGroupChild item = vChildItems[childI];
                ILayoutableArc           elem = item.Elem;
                float elemRelThick            = availThick * item.RelativeThickness / relSumThickness;
                float elemRelArcDeg           = availDeg * item.RelativeArcDegrees;
                float radiusOffset            = elemRelThick * item.RelativeRadiusOffset;
                float elemStartDeg            = paddedStartDeg + elemRelArcDeg * item.RelativeStartDegreeOffset;

                elem.SetArcLayout(
                    innerRadius + elemRelThick + radiusOffset,
                    innerRadius + radiusOffset,
                    elemRelArcDeg,
                    this
                    );

                elem.Controllers.Set(SettingsControllerMap.TransformLocalPosition + ".x", this);
                elem.Controllers.Set(SettingsControllerMap.TransformLocalPosition + ".y", this);
                elem.Controllers.Set(SettingsControllerMap.TransformLocalRotation, this);

                Vector3 localPos = elem.transform.localPosition;
                localPos.x = anchorPos.x;
                localPos.y = anchorPos.y;

                elem.transform.localPosition = localPos;
                elem.transform.localRotation = Quaternion.AngleAxis(elemStartDeg, Vector3.back);

                innerRadius += elemRelThick + Padding.Between;
            }
        }
Beispiel #2
0
        /*--------------------------------------------------------------------------------------------*/
        private void UpdateLayoutWithFixedSize()
        {
            int itemCount = vChildItems.Count;

            if (itemCount == 0)
            {
                return;
            }

            bool    isHoriz       = IsHorizontal;
            bool    isRev         = IsReversed;
            Vector2 anchorPos     = RendererUtil.GetRelativeAnchorPosition(Anchor);
            float   anchorStartX  = anchorPos.x * SizeX;
            float   anchorStartY  = anchorPos.y * SizeY;
            float   horizOuterPad = Padding.Left + Padding.Right;
            float   vertOuterPad  = Padding.Top + Padding.Bottom;
            float   betweenSumPad = Padding.Between * (itemCount - 1);
            float   relSumX       = 0;
            float   relSumY       = 0;
            float   elemAvailSizeX;
            float   elemAvailSizeY;
            float   cellAvailSizeX;
            float   cellAvailSizeY;

            if (isHoriz)
            {
                elemAvailSizeX = SizeX - horizOuterPad - betweenSumPad;
                elemAvailSizeY = SizeY - vertOuterPad;
                cellAvailSizeX = SizeX - horizOuterPad;
                cellAvailSizeY = elemAvailSizeY;
            }
            else
            {
                elemAvailSizeX = SizeX - horizOuterPad;
                elemAvailSizeY = SizeY - vertOuterPad - betweenSumPad;
                cellAvailSizeX = elemAvailSizeX;
                cellAvailSizeY = SizeY - vertOuterPad;
            }

            for (int i = 0; i < itemCount; i++)
            {
                HoverLayoutRectGroupChild item = vChildItems[i];
                relSumX += item.RelativeSizeX;
                relSumY += item.RelativeSizeY;
            }

            float posX = anchorStartX - (Padding.Right - Padding.Left) / 2 -
                         (isHoriz ? cellAvailSizeX / 2 : 0);
            float posY = anchorStartY - (Padding.Top - Padding.Bottom) / 2 -
                         (isHoriz ? 0 : cellAvailSizeY / 2);

            for (int i = 0; i < itemCount; i++)
            {
                int childI = (isRev ? itemCount - i - 1 : i);
                HoverLayoutRectGroupChild item = vChildItems[childI];
                ILayoutableRect           elem = item.Elem;

                Vector3 localPos     = elem.transform.localPosition;
                float   elemRelSizeX = elemAvailSizeX * item.RelativeSizeX / (isHoriz ? relSumX : 1);
                float   elemRelSizeY = elemAvailSizeY * item.RelativeSizeY / (isHoriz ? 1 : relSumY);

                localPos.x = posX + (isHoriz ? elemRelSizeX / 2 : 0) +
                             elemRelSizeX * item.RelativePositionOffsetX;
                localPos.y = posY + (isHoriz ? 0 : elemRelSizeY / 2) +
                             elemRelSizeY * item.RelativePositionOffsetY;

                posX += (isHoriz ? elemRelSizeX + Padding.Between : 0);
                posY += (isHoriz ? 0 : elemRelSizeY + Padding.Between);

                elem.Controllers.Set(
                    SettingsControllerMap.SpecialPrefix + "Transform.localPosition.x", this);
                elem.Controllers.Set(
                    SettingsControllerMap.SpecialPrefix + "Transform.localPosition.y", this);

                elem.SetRectLayout(elemRelSizeX, elemRelSizeY, this);
                elem.transform.localPosition = localPos;
            }
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        private void UpdateLayoutWithFixedSize()
        {
            int itemCount = vChildItems.Count;

            if (itemCount == 0)
            {
                return;
            }

            bool  isRev             = (Arrangement == ArrangementType.Reverse);
            float degSumPad         = DegreePadding * (itemCount - 1);// + RadiusPadding*2;
            float relSumArcDeg      = 0;
            float paddedOuterRadius = OuterRadius - RadiusPadding;
            float paddedInnerRadius = InnerRadius + RadiusPadding;
            float availDeg          = ArcDegrees - degSumPad;
            float deg = StartingDegree - ArcDegrees / 2;

            Vector2 anchorPos = RendererUtil.GetRelativeAnchorPosition(RectAnchor);

            anchorPos.x *= (vRectSize == null ? OuterRadius * 2 : ((Vector2)vRectSize).x);
            anchorPos.y *= (vRectSize == null ? OuterRadius * 2 : ((Vector2)vRectSize).y);

            for (int i = 0; i < itemCount; i++)
            {
                HoverLayoutArcGroupChild item = vChildItems[i];
                relSumArcDeg += item.RelativeArcDegrees;
            }

            for (int i = 0; i < itemCount; i++)
            {
                int childI = (isRev ? itemCount - i - 1 : i);
                HoverLayoutArcGroupChild item = vChildItems[childI];
                ILayoutableArc           elem = item.Elem;
                float elemRelDeg    = availDeg * item.RelativeArcDegrees / relSumArcDeg;
                float relInset      = (paddedOuterRadius - paddedInnerRadius) * (1 - item.RelativeThickness) / 2;
                float elemThick     = paddedOuterRadius - paddedInnerRadius - relInset * 2;
                float elemRelArcDeg = availDeg * item.RelativeArcDegrees;
                float radiusOffset  = elemThick * item.RelativeRadiusOffset;
                float elemStartDeg  = deg + elemRelDeg / 2 +
                                      elemRelArcDeg * item.RelativeStartDegreeOffset;

                elem.SetArcLayout(
                    paddedOuterRadius - relInset + radiusOffset,
                    paddedInnerRadius + relInset + radiusOffset,
                    elemRelDeg,
                    this
                    );

                elem.Controllers.Set(SettingsControllerMap.TransformLocalPosition + ".x", this);
                elem.Controllers.Set(SettingsControllerMap.TransformLocalPosition + ".y", this);
                elem.Controllers.Set(SettingsControllerMap.TransformLocalRotation, this);

                Vector3 localPos = elem.transform.localPosition;
                localPos.x = anchorPos.x;
                localPos.y = anchorPos.y;

                elem.transform.localPosition = localPos;
                elem.transform.localRotation = Quaternion.AngleAxis(elemStartDeg, Vector3.back);

                deg += elemRelDeg + DegreePadding;
            }
        }