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

Function IsPtInWindowViewport

src/viewport.cpp:408–416  ·  view source on GitHub ↗

* Is a xy position inside the viewport of the window? * @param w Window to examine its viewport * @param x X coordinate of the xy position * @param y Y coordinate of the xy position * @return Pointer to the viewport if the xy position is in the viewport of the window, * otherwise \c nullptr is returned. */

Source from the content-addressed store, hash-verified

406 * otherwise \c nullptr is returned.
407 */
408Viewport *IsPtInWindowViewport(const Window *w, int x, int y)
409{
410 if (w->viewport == nullptr) return nullptr;
411
412 const Viewport &vp = *w->viewport;
413 if (IsInsideMM(x, vp.left, vp.left + vp.width) && IsInsideMM(y, vp.top, vp.top + vp.height)) return w->viewport.get();
414
415 return nullptr;
416}
417
418/**
419 * Translate screen coordinate in a viewport to underlying tile coordinate.

Callers 4

HandleAutoscrollFunction · 0.85
MouseLoopFunction · 0.85
OnMouseLoopMethod · 0.85
GetTileFromScreenXYFunction · 0.85

Calls 2

IsInsideMMFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected