* * rct2: 0x006EBD96 */
| 693 | * rct2: 0x006EBD96 |
| 694 | */ |
| 695 | static void WidgetScrollDraw(RenderTarget& rt, WindowBase& w, WidgetIndex widgetIndex) |
| 696 | { |
| 697 | // Get the widget |
| 698 | int32_t scrollIndex = WindowGetScrollDataIndex(w, widgetIndex); |
| 699 | const auto& widget = w.widgets[widgetIndex]; |
| 700 | const auto& scroll = w.scrolls[scrollIndex]; |
| 701 | |
| 702 | // Resolve the absolute ltrb |
| 703 | ScreenCoordsXY topLeft = w.windowPos + ScreenCoordsXY{ widget.left, widget.top }; |
| 704 | ScreenCoordsXY bottomRight = w.windowPos + ScreenCoordsXY{ widget.right, widget.bottom }; |
| 705 | |
| 706 | auto colour = w.colours[widget.colour]; |
| 707 | |
| 708 | // Draw the border |
| 709 | Rectangle::fillInset( |
| 710 | rt, { topLeft, bottomRight }, colour, Rectangle::BorderStyle::inset, Rectangle::FillBrightness::light, |
| 711 | Rectangle::FillMode::dontLightenWhenInset); |
| 712 | |
| 713 | // Inflate by -1 |
| 714 | topLeft.x++; |
| 715 | topLeft.y++; |
| 716 | bottomRight.x--; |
| 717 | bottomRight.y--; |
| 718 | |
| 719 | bool hScrollNeeded = scroll.contentWidth > (widget.width() - 1) && (scroll.flags & HSCROLLBAR_VISIBLE); |
| 720 | bool vScrollNeeded = scroll.contentHeight > widget.height() - 1 && (scroll.flags & VSCROLLBAR_VISIBLE); |
| 721 | |
| 722 | // Horizontal scrollbar |
| 723 | if (hScrollNeeded) |
| 724 | { |
| 725 | WidgetHScrollbarDraw( |
| 726 | rt, scroll, topLeft.x, bottomRight.y - kScrollBarWidth, |
| 727 | ((scroll.flags & VSCROLLBAR_VISIBLE) ? bottomRight.x - (kScrollBarWidth + 1) : bottomRight.x), bottomRight.y, |
| 728 | colour); |
| 729 | } |
| 730 | |
| 731 | // Vertical scrollbar |
| 732 | if (vScrollNeeded) |
| 733 | { |
| 734 | WidgetVScrollbarDraw( |
| 735 | rt, scroll, bottomRight.x - kScrollBarWidth, topLeft.y, bottomRight.x, |
| 736 | ((scroll.flags & HSCROLLBAR_VISIBLE) ? bottomRight.y - (kScrollBarWidth + 1) : bottomRight.y), colour); |
| 737 | } |
| 738 | |
| 739 | // Contents |
| 740 | if (hScrollNeeded) |
| 741 | bottomRight.y -= (kScrollBarWidth + 1); |
| 742 | if (vScrollNeeded) |
| 743 | bottomRight.x -= (kScrollBarWidth + 1); |
| 744 | |
| 745 | bottomRight.y++; |
| 746 | bottomRight.x++; |
| 747 | |
| 748 | // Create a new inner scroll render target |
| 749 | RenderTarget scrollRT = rt; |
| 750 | |
| 751 | // Clip the scroll RT against the outer RT |
| 752 | int32_t cl = std::max<int32_t>(rt.x, topLeft.x); |
no test coverage detected