protected override void UpdateBounds()
{
if (_virtual)
return;
int cnt = _children.Count;
int i;
GObject child;
float curX = 0;
float curY = 0;
float cw, ch;
float maxWidth = 0;
float maxHeight = 0;
float sw;
float sh;
if (_layout == ListLayoutType.SingleColumn)
{
for (i = 0; i < cnt; i++)
{
child = GetChildAt(i);
if (foldInvisibleItems && !child.visible)
continue;
sw = Mathf.CeilToInt(child.width);
sh = Mathf.CeilToInt(child.height);
if (curY != 0)
curY += _lineGap;
child.y = curY;
curY += sh;
if (sw > maxWidth)
maxWidth = sw;
}
cw = curX + maxWidth;
ch = curY;
}
else if (_layout == ListLayoutType.SingleRow)
{
for (i = 0; i < cnt; i++)
{
child = GetChildAt(i);
if (foldInvisibleItems && !child.visible)
continue;
sw = Mathf.CeilToInt(child.width);
sh = Mathf.CeilToInt(child.height);
if (curX != 0)
curX += _columnGap;
child.x = curX;
curX += sw;
if (sh > maxHeight)
maxHeight = sh;
}
cw = curX;
ch = curY + maxHeight;
}
else if (_layout == ListLayoutType.FlowHorizontal)
{
int j = 0;
float viewWidth = this.viewWidth;
for (i = 0; i < cnt; i++)
{
child = GetChildAt(i);
if (foldInvisibleItems && !child.visible)
continue;
sw = Mathf.CeilToInt(child.width);
sh = Mathf.CeilToInt(child.height);
if (curX != 0)
curX += _columnGap;
if (_lineItemCount != 0 && j >= _lineItemCount
|| _lineItemCount == 0 && curX + sw > viewWidth && maxHeight != 0)
{
//new line
curX -= _columnGap;
if (curX > maxWidth)
maxWidth = curX;
curX = 0;
curY += maxHeight + _lineGap;
maxHeight = 0;
j = 0;
}
child.SetXY(curX, curY);
curX += sw;
if (sh > maxHeight)
maxHeight = sh;
j++;
}
ch = curY + maxHeight;
cw = maxWidth;
}
else if (_layout == ListLayoutType.FlowVertical)
{
int j = 0;
float viewHeight = this.viewHeight;
for (i = 0; i < cnt; i++)
{
child = GetChildAt(i);
if (foldInvisibleItems && !child.visible)
continue;
sw = Mathf.CeilToInt(child.width);
sh = Mathf.CeilToInt(child.height);
if (curY != 0)
curY += _lineGap;
if (_lineItemCount != 0 && j >= _lineItemCount
|| _lineItemCount == 0 && curY + sh > viewHeight && maxWidth != 0)
{
curY -= _lineGap;
if (curY > maxHeight)
maxHeight = curY;
curY = 0;
curX += maxWidth + _columnGap;
maxWidth = 0;
j = 0;
}
child.SetXY(curX, curY);
curY += sh;
if (sw > maxWidth)
maxWidth = sw;
j++;
}
cw = curX + maxWidth;
ch = maxHeight;
}
else //pagination
{
int j = 0;
int p = 0;
float viewWidth = this.viewWidth;
float viewHeight = this.viewHeight;
for (i = 0; i < cnt; i++)
{
child = GetChildAt(i);
if (foldInvisibleItems && !child.visible)
continue;
sw = Mathf.CeilToInt(child.width);
sh = Mathf.CeilToInt(child.height);
if (curX != 0)
curX += _columnGap;
if (_lineItemCount != 0 && j >= _lineItemCount
|| _lineItemCount == 0 && curX + sw > viewWidth && maxHeight != 0)
{
//new line
curX -= _columnGap;
if (curX > maxWidth)
maxWidth = curX;
curX = 0;
curY += maxHeight + _lineGap;
maxHeight = 0;
j = 0;
if (curY + sh > viewHeight && maxWidth != 0)//new page
{
p++;
curY = 0;
}
}
child.SetXY(p * viewWidth + curX, curY);
curX += sw;
if (sh > maxHeight)
maxHeight = sh;
j++;
}
ch = curY + maxHeight;
cw = (p + 1) * viewWidth;
}
HandleAlign(cw, ch);
SetBounds(0, 0, cw, ch);
this.InvalidateBatchingState();
}