Esempio n. 1
0
    /// <summary>
    /// 得到某一行的大小数据,根据行号
    /// </summary>
    /// <param name="deltaY"></param>
    /// <param name="i"></param>
    /// <param name="originHeight"></param>
    /// <returns></returns>
    private LineData GetLine(float deltaY, int i, float originHeight)
    {
        //生成一行
        LineData ld;

        if (lineDataList.Count == 0)
        {
            ld = LineData.NewLine(deltaY, i, originHeight);
            lineDataList.Add(ld);
        }
        else
        {
            ld = lineDataList[lineDataList.Count - 1];
        }
        return(ld);
    }
Esempio n. 2
0
    /// <summary>
    /// 计算显示cell需要的数据,按行存储
    /// </summary>
    /// <param name="beginIndex">开始计算的cell索引</param>
    /// <param name="source">数据源</param>
    public void fillData(int beginIndex, List <GridDataSource> source)
    {
        float tempPosY = padding.top;

        for (int i = beginIndex; i < source.Count; i++)
        {
            GridDataSource data = source[i];
            WllTemplate    wllt = itemTemplate.GetWllItemTemplate(data.templateId);

            LineData ld          = GetLine(tempPosY, i, wllt.height);
            float    heightDelta = 0;
            bool     addSucess   = ld.AddCell(data, i, wllt, this, ref heightDelta);
            if (!addSucess)
            {
                //滑动位置
                tempPosY = tempPosY + ld.lineHeight + padding.spacey;
                //新增一行
                ld = LineData.NewLine(tempPosY, i, wllt.height);

                addSucess = ld.AddCell(data, i, wllt, this, ref heightDelta);
                if (!addSucess)
                {
                    Debug.LogError("Item的大小不合适窗口的大小");
                    break;
                }
                else
                {
                    lineDataList.Add(ld);
                }
            }
        }
        //控制content的长度
        LineData last = lineDataList[lineDataList.Count - 1];

        ContentHeight = last.childLineY + last.lineHeight + padding.bottom;
    }