Esempio n. 1
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();
            }
        }