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

Method GetRowFromWidget

src/window.cpp:212–218  ·  view source on GitHub ↗

* Compute the row of a widget that a user clicked in. * @param clickpos Vertical position of the mouse click. * @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. * @param line_height Height of a single row. A negative value means using the vertical resize step of the widget. * @return

Source from the content-addressed store, hash-verified

210 * @note The widget does not know where a list printed at the widget ends, so below a list is not a wrong position.
211 */
212int Window::GetRowFromWidget(int clickpos, WidgetID widget, int padding, int line_height) const
213{
214 const NWidgetBase *wid = this->GetWidget<NWidgetBase>(widget);
215 if (line_height < 0) line_height = wid->resize_y;
216 if (clickpos < wid->pos_y + padding) return INT_MAX;
217 return (clickpos - wid->pos_y - padding) / line_height;
218}
219
220/**
221 * Disable the highlighted status of all widgets.

Callers 6

OnClickMethod · 0.80
SettingsPanelClickMethod · 0.80
GetHyperlinkMethod · 0.80
OnClickMethod · 0.80
OnMouseOverMethod · 0.80

Calls 1

Tested by

no test coverage detected