예제 #1
0
파일: BmLabel.cs 프로젝트: DotLab/Futilef
        public void CacheTextTransform()
        {
            textTransformDirty = false;

            float fontScaling = fontSize / file.fontSize;

            if (truncate)
            {
                float meshL = cachedMeshBox.l;
//				Console.Log((cachedMeshBox.r - cachedMeshBox.l) * fontScaling, cachedSize.x);
                for (int i = 1; i < cachedCharInfoCount; i++)
                {
                    if ((cachedCharInfos[i].right - meshL) * fontScaling > cachedSize.x)
                    {
                        cachedDisplayCharInfoCount = i;
                        cachedLineRect.Set(cachedLineBox.l, cachedLineBox.b, cachedCharInfos[i - 1].nextX - cachedLineBox.l, cachedLineBox.t - cachedLineBox.b);
                        cachedMeshRect.Set(cachedMeshBox.l, cachedMeshBox.b, cachedCharInfos[i - 1].right - cachedMeshBox.l, cachedMeshBox.t - cachedMeshBox.b);
                        break;
                    }
                }
            }

            var textPivot = Align.Calc(textAlign);

            if (textAlign != Align.None)
            {
                if (verticalAlign == VerticalAlign.Base)
                {
                    cachedTextPivotPos.Set(
                        (cachedLineRect.w + cachedLineRect.x) * textPivot.x,
                        (cachedLineRect.h + cachedLineRect.y) * textPivot.y);
                }
                else if (verticalAlign == VerticalAlign.Line)
                {
                    cachedTextPivotPos.Set(
                        cachedLineRect.w * textPivot.x + cachedLineRect.x,
                        cachedLineRect.h * textPivot.y + cachedLineRect.y);
                }
                else
                {
                    cachedTextPivotPos.Set(
                        cachedMeshRect.w * textPivot.x + cachedMeshRect.x,
                        cachedMeshRect.h * textPivot.y + cachedMeshRect.y);
                }
                cachedTextPivotPos.Mult(fontScaling);
            }
            else
            {
                cachedTextPivotPos.Set(0);
            }

            if (useLayout)
            {
                cachedTextPivotPos.Sub(textPivot * cachedSize);
            }
        }
예제 #2
0
        public virtual void CacheTransform()
        {
            transformDirty = false;

            bool useParentSize = parent != null && parent.useLayout;

            if (useParentSize)
            {
                cachedPos  = Axes.Calc(relativePosAxes, pos, parent.cachedSize);
                cachedSize = Axes.Calc(relativeSizeAxes, size, parent.cachedSize);
            }
            else
            {
                cachedPos  = Axes.Calc(relativePosAxes, pos);
                cachedSize = Axes.Calc(relativeSizeAxes, size);
            }

            if (useLayout)
            {
                cachedPivot   = cachedSize * Align.Calc(pivotAlign, customPivotAlign);
                cachedPos.x  += margin.l;
                cachedPos.y  += margin.b;
                cachedSize.x -= margin.l + margin.r;
                cachedSize.y -= margin.b + margin.t;
                cachedMat.FromTranslation(-cachedPivot);
                cachedMat.ScaleRotateTranslate(scl, rot, cachedPos);
            }
            else
            {
                cachedMat.FromScalingRotationTranslation(scl, rot, cachedPos);
            }

            if (useParentSize)
            {
                cachedAnchor = parent.cachedSize * Align.Calc(anchorAlign, customAnchorAlign);
                cachedMat.Translate(cachedAnchor);
            }

            cachedMatConcat = parent == null ? cachedMat : parent.cachedMatConcat * cachedMat;

            if (needMatConcatInverse)
            {
                cachedMatConcatInverse.FromInverse(cachedMatConcat);
            }
            if (needScreenAabb)
            {
                cachedScreenAabb = (cachedMatConcat * new Quad(0, 0, cachedSize.x, cachedSize.y)).GetAabb();
            }
        }