MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / ScrollRect

Function ScrollRect

src/widget.cpp:2544–2564  ·  view source on GitHub ↗

* Apply 'scroll' to a rect to be drawn in. * @param r Rect to be 'scrolled'. * @param sb The scrollbar affecting the scroll. * @param resize_step Resize step of the widget/scrollbar (1 if the scrollbar is pixel-based.) * @returns Scrolled rect. */

Source from the content-addressed store, hash-verified

2542 * @returns Scrolled rect.
2543 */
2544Rect ScrollRect(Rect r, const Scrollbar &sb, int resize_step)
2545{
2546 const int count = sb.GetCount() * resize_step;
2547 const int position = sb.GetPosition() * resize_step;
2548
2549 if (sb.IsVertical()) {
2550 r.top -= position;
2551 r.bottom = r.top + count;
2552 } else {
2553 bool rtl = _current_text_dir == TD_RTL;
2554 if (rtl) {
2555 r.right += position;
2556 r.left = r.right - count;
2557 } else {
2558 r.left -= position;
2559 r.right = r.left + count;
2560 }
2561 }
2562
2563 return r;
2564}
2565
2566/**
2567 * Scrollbar widget.

Callers 3

DrawWidgetMethod · 0.85
DrawWidgetMethod · 0.85
DrawWidgetLogMethod · 0.85

Calls 3

GetPositionMethod · 0.80
IsVerticalMethod · 0.80
GetCountMethod · 0.45

Tested by

no test coverage detected