* Splits a drawing of a window into regions that can be seen and are not hidden * by other opaque overlapping windows. */
| 493 | * by other opaque overlapping windows. |
| 494 | */ |
| 495 | void WindowDraw(Drawing::RenderTarget& rt, WindowBase& w, int32_t left, int32_t top, int32_t right, int32_t bottom) |
| 496 | { |
| 497 | if (!w.isVisible) |
| 498 | return; |
| 499 | |
| 500 | // Divide the draws up for only the visible regions of the window recursively |
| 501 | auto itPos = WindowGetIterator(&w); |
| 502 | for (auto it = std::next(itPos); it != gWindowList.end(); it++) |
| 503 | { |
| 504 | // Check if this window overlaps w |
| 505 | auto topwindow = it->get(); |
| 506 | if (topwindow->flags.has(WindowFlag::transparent)) |
| 507 | continue; |
| 508 | if (topwindow->flags.has(WindowFlag::dead)) |
| 509 | continue; |
| 510 | if (topwindow->windowPos.x >= right || topwindow->windowPos.y >= bottom) |
| 511 | continue; |
| 512 | if (topwindow->windowPos.x + topwindow->width <= left || topwindow->windowPos.y + topwindow->height <= top) |
| 513 | continue; |
| 514 | |
| 515 | // A window overlaps w, split up the draw into two regions where the window starts to overlap |
| 516 | if (topwindow->windowPos.x > left) |
| 517 | { |
| 518 | // Split draw at topwindow.left |
| 519 | WindowDrawCore(rt, w, left, top, topwindow->windowPos.x, bottom); |
| 520 | WindowDrawCore(rt, w, topwindow->windowPos.x, top, right, bottom); |
| 521 | } |
| 522 | else if (topwindow->windowPos.x + topwindow->width < right) |
| 523 | { |
| 524 | // Split draw at topwindow.right |
| 525 | WindowDrawCore(rt, w, left, top, topwindow->windowPos.x + topwindow->width, bottom); |
| 526 | WindowDrawCore(rt, w, topwindow->windowPos.x + topwindow->width, top, right, bottom); |
| 527 | } |
| 528 | else if (topwindow->windowPos.y > top) |
| 529 | { |
| 530 | // Split draw at topwindow.top |
| 531 | WindowDrawCore(rt, w, left, top, right, topwindow->windowPos.y); |
| 532 | WindowDrawCore(rt, w, left, topwindow->windowPos.y, right, bottom); |
| 533 | } |
| 534 | else if (topwindow->windowPos.y + topwindow->height < bottom) |
| 535 | { |
| 536 | // Split draw at topwindow.bottom |
| 537 | WindowDrawCore(rt, w, left, top, right, topwindow->windowPos.y + topwindow->height); |
| 538 | WindowDrawCore(rt, w, left, topwindow->windowPos.y + topwindow->height, right, bottom); |
| 539 | } |
| 540 | |
| 541 | // Drawing for this region should be done now, exit |
| 542 | return; |
| 543 | } |
| 544 | |
| 545 | // No windows overlap |
| 546 | WindowDrawCore(rt, w, left, top, right, bottom); |
| 547 | } |
| 548 | |
| 549 | /** |
| 550 | * Draws the given window and any other overlapping transparent windows. |
no test coverage detected