示例#1
0
        public void AddDataCSOnStart(List <T> datas, List <Vector2> rects)
        {
            ColumnCount = 1;
            mRectTransformContainer.anchoredPosition = mRectTransformContainer.anchoredPosition.RAddY(-nowStartPos);
            int startTemp = MinStart;

            MinStart -= rects.Count;
            float size = 0;

            mDataProviders.AddRange(datas);
            nowStartPos = mDict_dRect[startTemp].mRect.position.y;
            for (int i = startTemp - 1, j = rects.Count - 1, k = 0; j >= 0; i--, j--, k++)
            {
                nowStartPos += mDict_dRect[i + 1].mRect.height;
                // nowStartPos += rects[j].y;
                size += rects[j].y;
                YuoLoopListRect dRect = new YuoLoopListRect(GetBlockSizeX(), nowStartPos, rects[j].x, rects[j].y, mDataProviders.Count - 1 - k);
                mDict_dRect[i] = dRect;
            }
            nowStartPos += mDict_dRect[MinStart].mRect.height;
            mRectTransformContainer.sizeDelta        = new Vector2(mRectTransformContainer.sizeDelta.x, mRectTransformContainer.sizeDelta.y + size);
            mRectTransformContainer.anchoredPosition = mRectTransformContainer.anchoredPosition.RAddY(nowStartPos);
            mScrollRect.verticalNormalizedPosition   = 1 - mRectTransformContainer.anchoredPosition.y / (mRectTransformContainer.sizeDelta.y - (mScrollRect.transform as RectTransform).sizeDelta.y);
            foreach (var item in mList_items)
            {
                if (item.gameObject.activeSelf)
                {
                    var r = item.transform as RectTransform;
                    r.anchoredPosition = r.anchoredPosition.RSetY(item.DRect.mRect.position.y - nowStartPos);
                }
            }
            UpdateRender();
        }
示例#2
0
 /// <summary>
 /// 更新动态渲染格
 /// </summary>
 /// <param name="count"></param>
 private void CreatRects(int count)
 {
     mDict_dRect = new Dictionary <int, YuoLoopListRect>();
     for (int i = 0; i < count; ++i)
     {
         int             row    = i / ColumnCount;
         int             column = i % ColumnCount;
         YuoLoopListRect dRect  = new YuoLoopListRect(column * GetBlockSizeX(), -row * GetBlockSizeY() - CellSize.y * CellSizeScale.y, CellSize.x * CellSizeScale.x, CellSize.y * CellSizeScale.y, i);
         mDict_dRect[i] = dRect;
     }
 }
示例#3
0
 private void CreatRectsCustomSize(List <Vector2> rects)
 {
     mDict_dRect = new Dictionary <int, YuoLoopListRect>();
     nowEndPos   = 0;
     for (int i = 0; i < rects.Count; i++)
     {
         int column = i % ColumnCount;
         nowEndPos -= rects[i].y;
         YuoLoopListRect dRect = new YuoLoopListRect(column * GetBlockSizeX(), nowEndPos, rects[i].x, rects[i].y, i);
         mDict_dRect[i] = dRect;
     }
 }
示例#4
0
        public void AddDataOnEnd(T data, Vector2 rect)
        {
            ColumnCount = 1;
            int endTemp = mDict_dRect.Count + MinStart;

            mDataProviders.Add(data);
            nowEndPos  = mDict_dRect.Count != 0 ? mDict_dRect[endTemp - 1].mRect.position.y : 0;
            nowEndPos -= rect.y;
            YuoLoopListRect dRect = new YuoLoopListRect(GetBlockSizeX(), nowEndPos, rect.x, rect.y, endTemp);

            mDict_dRect[endTemp] = dRect;
            mRectTransformContainer.sizeDelta = new Vector2(mRectTransformContainer.sizeDelta.x, mRectTransformContainer.sizeDelta.y + rect.y);
            UpdateRender();
        }
示例#5
0
        /// <summary>
        /// 通过动态格子获得动态渲染器
        /// </summary>
        /// <param name="rect"></param>
        /// <returns></returns>
        private YuoLoopListItem <T> GetDynmicItem(YuoLoopListRect rect)
        {
            int len = mList_items.Count;

            for (int i = 0; i < len; ++i)
            {
                YuoLoopListItem <T> item = mList_items[i];
                if (item.DRect == null)
                {
                    continue;
                }
                if (rect.Index == item.DRect.Index)
                {
                    return(item);
                }
            }
            return(null);
        }
示例#6
0
        public void AddDataCSOnEnd(List <T> datas, List <Vector2> rects)
        {
            ColumnCount = 1;
            int   endTemp = mDict_dRect.Count + MinStart - 1;
            float size    = 0;

            mDataProviders.AddRange(datas);
            nowEndPos = mDict_dRect[endTemp].mRect.position.y;
            //for (int i = startTemp - 1, j = rects.Count - 1, k = 0; j >= 0; i--, j--, k++)
            for (int i = endTemp + 1, k = 0; i <= endTemp + rects.Count; i++, k++)
            {
                nowEndPos -= rects[k].y;
                size      += rects[k].y;
                YuoLoopListRect dRect = new YuoLoopListRect(GetBlockSizeX(), nowEndPos, rects[k].x, rects[k].y, i);
                mDict_dRect[i] = dRect;
            }
            //nowEndPos += mDict_dRect[MinStart].mRect.height;
            mRectTransformContainer.sizeDelta = new Vector2(mRectTransformContainer.sizeDelta.x, mRectTransformContainer.sizeDelta.y + size);
            UpdateRender();
        }
示例#7
0
 /// <summary>
 /// 是否相交
 /// </summary>
 /// <param name="otherRect"></param>
 /// <returns></returns>
 public bool Overlaps(YuoLoopListRect otherRect)
 {
     return(mRect.Overlaps(otherRect.mRect));
 }