public override Rect GetBounds(DisplayObject targetSpace)
{
if (_clipRect != null)
return TransformRect((Rect)_clipRect, targetSpace);
int count = _children.Count;
Rect rect;
if (count == 0)
{
Vector2 v = TransformPoint(Vector2.zero, targetSpace);
rect = Rect.MinMaxRect(v.x, v.y, 0, 0);
}
else if (count == 1)
{
rect = _children[0].GetBounds(targetSpace);
}
else
{
float minX = float.MaxValue, maxX = float.MinValue;
float minY = float.MaxValue, maxY = float.MinValue;
for (int i = 0; i < count; ++i)
{
rect = _children[i].GetBounds(targetSpace);
minX = minX < rect.xMin ? minX : rect.xMin;
maxX = maxX > rect.xMax ? maxX : rect.xMax;
minY = minY < rect.yMin ? minY : rect.yMin;
maxY = maxY > rect.yMax ? maxY : rect.yMax;
}
rect = Rect.MinMaxRect(minX, minY, maxX, maxY);
}
return rect;
}