* 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
| 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 | */ |
| 212 | int 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. |
no test coverage detected