getAbsoluteRect function

Rect getAbsoluteRect(
  1. Buffer buffer,
  2. Rect localRect
)

Helper function to traverse the parent chain of a Buffer to find its absolute Rect boundaries.

Implementation

Rect getAbsoluteRect(Buffer buffer, Rect localRect) {
  int x = localRect.x;
  int y = localRect.y;
  Buffer current = buffer;
  while (current is Viewport) {
    x += current.bounds.x;
    y += current.bounds.y;
    current = current.parent;
  }
  return Rect(x, y, localRect.width, localRect.height);
}