* 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. */
| 2542 | * @returns Scrolled rect. |
| 2543 | */ |
| 2544 | Rect 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. |
no test coverage detected