* * rct2: 0x006EA594 * returns widget_index if found, -1 otherwise */
| 1196 | * returns widget_index if found, -1 otherwise |
| 1197 | */ |
| 1198 | WidgetIndex FindWidgetFromPoint(WindowBase& w, const ScreenCoordsXY& screenCoords) override |
| 1199 | { |
| 1200 | // Invalidate the window |
| 1201 | w.onPrepareDraw(); |
| 1202 | |
| 1203 | // Find the widget at point x, y |
| 1204 | WidgetIndex widget_index = kWidgetIndexNull; |
| 1205 | for (auto i = 0u; i < w.widgets.size(); i++) |
| 1206 | { |
| 1207 | const auto& widget = w.widgets[i]; |
| 1208 | |
| 1209 | if (widget.type != WidgetType::empty && widget.isVisible()) |
| 1210 | { |
| 1211 | if (screenCoords.x >= w.windowPos.x + widget.left && screenCoords.x <= w.windowPos.x + widget.right |
| 1212 | && screenCoords.y >= w.windowPos.y + widget.top && screenCoords.y <= w.windowPos.y + widget.bottom) |
| 1213 | { |
| 1214 | widget_index = i; |
| 1215 | } |
| 1216 | } |
| 1217 | } |
| 1218 | |
| 1219 | // Return next widget if a dropdown |
| 1220 | if (widget_index != kWidgetIndexNull) |
| 1221 | { |
| 1222 | const auto& widget = w.widgets[widget_index]; |
| 1223 | if (widget.type == WidgetType::dropdownMenu) |
| 1224 | widget_index++; |
| 1225 | } |
| 1226 | |
| 1227 | // Return the widget index |
| 1228 | return widget_index; |
| 1229 | } |
| 1230 | |
| 1231 | /** |
| 1232 | * Invalidates the specified window. |
no test coverage detected