예제 #1
0
        internal ShapeLayer(LottieDrawable lottieDrawable, Layer layerModel) : base(lottieDrawable, layerModel)
        {
            var shapeGroup = new ShapeGroup(layerModel.Name, layerModel.Shapes);

            _contentGroup = new ContentGroup(lottieDrawable, this, shapeGroup);
            _contentGroup.SetContents(new List <IContent>(), new List <IContent>());
        }
예제 #2
0
        public void AbsorbContent(List <IContent> contentsIter)
        {
            // This check prevents a repeater from getting added twice.
            // This can happen in the following situation:
            //    RECTANGLE
            //    REPEATER 1
            //    FILL
            //    REPEATER 2
            // In this case, the expected structure would be:
            //     REPEATER 2
            //        REPEATER 1
            //            RECTANGLE
            //        FILL
            // Without this check, REPEATER 1 will try and absorb contents once it is already inside of
            // REPEATER 2.
            if (_contentGroup != null)
            {
                return;
            }
            // Fast forward the iterator until after this content.
            int index = contentsIter.Count;

            while (index > 0)
            {
                index--;
                if (contentsIter[index] == this)
                {
                    break;
                }
            }
            var contents = new List <IContent>();

            while (index > 0)
            {
                index--;
                contents.Add(contentsIter[index]);
                contentsIter.RemoveAt(index);
            }
            contents.Reverse();
            _contentGroup = new ContentGroup(_lottieDrawable, _layer, "Repeater", contents, null);
        }