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

Method GetScrolledRowFromWidget

src/widget.cpp:2453–2458  ·  view source on GitHub ↗

* Compute the row of a scrolled widget that a user clicked in. * @param clickpos Vertical position of the mouse click (without taking scrolling into account). * @param w The window the click was in. * @param widget Widget number of the widget clicked in. * @param padding Amount of empty space between the widget edge and the top of the first row. Default value is \c 0. *

Source from the content-addressed store, hash-verified

2451 * @return Row number clicked at. If clicked at a wrong position, #Scrollbar::npos is returned.
2452 */
2453Scrollbar::size_type Scrollbar::GetScrolledRowFromWidget(int clickpos, const Window * const w, WidgetID widget, int padding, int line_height) const
2454{
2455 int pos = w->GetRowFromWidget(clickpos, widget, padding, line_height);
2456 if (pos != INT_MAX) pos += this->GetPosition();
2457 return (pos < 0 || pos >= this->GetCount()) ? Scrollbar::npos : pos;
2458}
2459
2460/**
2461 * Update the given list position as if it were on this scroll bar when the given keycode was pressed.

Callers 15

OnClickMethod · 0.80
OnClickMethod · 0.80
OnClickMethod · 0.80
OnClickMethod · 0.80
OnDragDropMethod · 0.80
OnMouseDragMethod · 0.80
OnClickMethod · 0.80
GetOrderFromPtMethod · 0.80
OnClickMethod · 0.80
OnClickMethod · 0.80

Calls 3

GetPositionMethod · 0.95
GetCountMethod · 0.95
GetRowFromWidgetMethod · 0.80

Tested by

no test coverage detected